| 89 | #include "GB_subref.h" |
| 90 | |
| 91 | GB_PUBLIC |
| 92 | GrB_Info GB_subref // C = A(I,J): either symbolic or numeric |
| 93 | ( |
| 94 | // output |
| 95 | GrB_Matrix C, // output matrix, static header |
| 96 | // input, not modified |
| 97 | bool C_iso, // if true, return C as iso, regardless of A |
| 98 | const bool C_is_csc, // requested format of C |
| 99 | const GrB_Matrix A, |
| 100 | const GrB_Index *I, // index list for C = A(I,J), or GrB_ALL, etc. |
| 101 | const int64_t ni, // length of I, or special |
| 102 | const GrB_Index *J, // index list for C = A(I,J), or GrB_ALL, etc. |
| 103 | const int64_t nj, // length of J, or special |
| 104 | const bool symbolic, // if true, construct C as symbolic |
| 105 | GB_Context Context |
| 106 | ) |
| 107 | { |
| 108 | |
| 109 | //-------------------------------------------------------------------------- |
| 110 | // check inputs |
| 111 | //-------------------------------------------------------------------------- |
| 112 | |
| 113 | GrB_Info info ; |
| 114 | ASSERT (C != NULL && (C->static_header || GBNSTATIC)) ; |
| 115 | ASSERT_MATRIX_OK (A, "A for C=A(I,J) subref", GB0) ; |
| 116 | ASSERT (GB_ZOMBIES_OK (A)) ; |
| 117 | ASSERT (GB_JUMBLED_OK (A)) ; // A is sorted, below, if jumbled on input |
| 118 | ASSERT (GB_PENDING_OK (A)) ; |
| 119 | |
| 120 | //-------------------------------------------------------------------------- |
| 121 | // check if C is iso and get its iso value |
| 122 | //-------------------------------------------------------------------------- |
| 123 | |
| 124 | GrB_Type ctype = (symbolic) ? GrB_INT64 : A->type ; |
| 125 | size_t csize = ctype->size ; |
| 126 | GB_void cscalar [GB_VLA(csize)] ; |
| 127 | memset (cscalar, 0, csize) ; |
| 128 | if (symbolic) |
| 129 | { |
| 130 | // symbolic extraction never results in an iso matrix |
| 131 | C_iso = false ; |
| 132 | } |
| 133 | else |
| 134 | { |
| 135 | // determine if C is iso and get the iso scalar |
| 136 | if (A->iso) |
| 137 | { |
| 138 | memcpy (cscalar, A->x, csize) ; |
| 139 | C_iso = true ; |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | if (C_iso) |
| 144 | { |
| 145 | GBURBLE ("(iso subref) ") ; |
| 146 | } |
| 147 | |
| 148 | //-------------------------------------------------------------------------- |
no test coverage detected