| 40 | } |
| 41 | |
| 42 | GrB_Info GB_selector |
| 43 | ( |
| 44 | GrB_Matrix C, // output matrix, NULL or existing header |
| 45 | GB_Opcode opcode, // selector opcode |
| 46 | const GB_Operator op, // user operator, NULL for resize/nonzombie |
| 47 | const bool flipij, // if true, flip i and j for user operator |
| 48 | GrB_Matrix A, // input matrix |
| 49 | int64_t ithunk, // (int64_t) Thunk, if Thunk is NULL |
| 50 | const GrB_Scalar Thunk, // optional input for select operator |
| 51 | GB_Context Context |
| 52 | ) |
| 53 | { |
| 54 | |
| 55 | //-------------------------------------------------------------------------- |
| 56 | // check inputs |
| 57 | //-------------------------------------------------------------------------- |
| 58 | |
| 59 | GrB_Info info ; |
| 60 | ASSERT_OP_OK_OR_NULL (op, "selectop/idxunop for GB_selector", GB0) ; |
| 61 | ASSERT_SCALAR_OK_OR_NULL (Thunk, "Thunk for GB_selector", GB0) ; |
| 62 | ASSERT (GB_IS_SELECTOP_CODE (opcode) || GB_IS_INDEXUNARYOP_CODE (opcode)) ; |
| 63 | ASSERT_MATRIX_OK (A, "A input for GB_selector", GB_FLIP (GB0)) ; |
| 64 | // positional selector (tril, triu, diag, offdiag, resize, rowindex, ...): |
| 65 | // can't be jumbled. nonzombie, entry-valued op, user op: jumbled OK |
| 66 | ASSERT (GB_IMPLIES (GB_OPCODE_IS_POSITIONAL (opcode), !GB_JUMBLED (A))) ; |
| 67 | ASSERT (C == NULL || (C != NULL && (C->static_header || GBNSTATIC))) ; |
| 68 | |
| 69 | //-------------------------------------------------------------------------- |
| 70 | // declare workspace |
| 71 | //-------------------------------------------------------------------------- |
| 72 | |
| 73 | bool in_place_A = (C == NULL) ; // GrB_wait and GB_resize only |
| 74 | int64_t *restrict Zp = NULL ; size_t Zp_size = 0 ; |
| 75 | GB_WERK_DECLARE (Work, int64_t) ; |
| 76 | int64_t *restrict Wfirst = NULL ; |
| 77 | int64_t *restrict Wlast = NULL ; |
| 78 | int64_t *restrict Cp_kfirst = NULL ; |
| 79 | GB_WERK_DECLARE (A_ek_slicing, int64_t) ; |
| 80 | |
| 81 | int64_t avlen = A->vlen ; |
| 82 | int64_t avdim = A->vdim ; |
| 83 | const bool A_iso = A->iso ; |
| 84 | |
| 85 | int64_t *restrict Cp = NULL ; size_t Cp_size = 0 ; |
| 86 | int64_t *restrict Ch = NULL ; size_t Ch_size = 0 ; |
| 87 | int64_t *restrict Ci = NULL ; size_t Ci_size = 0 ; |
| 88 | GB_void *restrict Cx = NULL ; size_t Cx_size = 0 ; |
| 89 | |
| 90 | //-------------------------------------------------------------------------- |
| 91 | // get Thunk |
| 92 | //-------------------------------------------------------------------------- |
| 93 | |
| 94 | // The scalar value of Thunk has already been typecasted to an integer |
| 95 | // (int64_t ithunk). |
| 96 | |
| 97 | // It is also now typecast to the same type as A (to the scalar athunk) |
| 98 | // which is required for GxB_SelectOps, and to the op->ytype (the scalar |
| 99 | // ythunk) for GrB_IndexUnaryOps. |
no test coverage detected