| 24 | #include "GB_accum_mask.h" |
| 25 | |
| 26 | GrB_Info GB_extract // C<M> = accum (C, A(I,J)) |
| 27 | ( |
| 28 | GrB_Matrix C, // input/output matrix for results |
| 29 | const bool C_replace, // C matrix descriptor |
| 30 | const GrB_Matrix M, // optional mask for C, unused if NULL |
| 31 | const bool Mask_comp, // mask descriptor |
| 32 | const bool Mask_struct, // if true, use the only structure of M |
| 33 | const GrB_BinaryOp accum, // optional accum for Z=accum(C,T) |
| 34 | const GrB_Matrix A, // input matrix |
| 35 | const bool A_transpose, // A matrix descriptor |
| 36 | const GrB_Index *Rows, // row indices |
| 37 | const GrB_Index nRows_in, // number of row indices |
| 38 | const GrB_Index *Cols, // column indices |
| 39 | const GrB_Index nCols_in, // number of column indices |
| 40 | GB_Context Context |
| 41 | ) |
| 42 | { |
| 43 | |
| 44 | //-------------------------------------------------------------------------- |
| 45 | // check inputs |
| 46 | //-------------------------------------------------------------------------- |
| 47 | |
| 48 | // C may be aliased with M and/or A |
| 49 | |
| 50 | GrB_Info info ; |
| 51 | struct GB_Matrix_opaque T_header ; |
| 52 | GrB_Matrix T = NULL ; |
| 53 | GB_RETURN_IF_NULL (Rows) ; |
| 54 | GB_RETURN_IF_NULL (Cols) ; |
| 55 | GB_RETURN_IF_FAULTY_OR_POSITIONAL (accum) ; |
| 56 | |
| 57 | ASSERT_MATRIX_OK (C, "C input for GB_Matrix_extract", GB0) ; |
| 58 | ASSERT_MATRIX_OK_OR_NULL (M, "M for GB_Matrix_extract", GB0) ; |
| 59 | ASSERT_BINARYOP_OK_OR_NULL (accum, "accum for GB_Matrix_extract", GB0) ; |
| 60 | ASSERT_MATRIX_OK (A, "A input for GB_Matrix_extract", GB0) ; |
| 61 | |
| 62 | // check domains and dimensions for C<M> = accum (C,T) |
| 63 | GB_OK (GB_compatible (C->type, C, M, Mask_struct, accum, A->type, |
| 64 | Context)) ; |
| 65 | |
| 66 | // check the dimensions of C |
| 67 | int64_t cnrows = GB_NROWS (C) ; |
| 68 | int64_t cncols = GB_NCOLS (C) ; |
| 69 | |
| 70 | int64_t nRows, nCols, RowColon [3], ColColon [3] ; |
| 71 | int rkind, ckind ; |
| 72 | |
| 73 | if (!A_transpose) |
| 74 | { |
| 75 | // T = A(Rows,Cols) |
| 76 | GB_ijlength (Rows, nRows_in, GB_NROWS (A), &nRows, &rkind, RowColon) ; |
| 77 | GB_ijlength (Cols, nCols_in, GB_NCOLS (A), &nCols, &ckind, ColColon) ; |
| 78 | } |
| 79 | else |
| 80 | { |
| 81 | // T = A(Cols,Rows) |
| 82 | GB_ijlength (Rows, nRows_in, GB_NCOLS (A), &nRows, &rkind, RowColon) ; |
| 83 | GB_ijlength (Cols, nCols_in, GB_NROWS (A), &nCols, &ckind, ColColon) ; |
no test coverage detected