| 16 | //------------------------------------------------------------------------------ |
| 17 | |
| 18 | GrB_Info GrB_Matrix_apply // C<M> = accum (C, op(A)) or op(A') |
| 19 | ( |
| 20 | GrB_Matrix C, // input/output matrix for results |
| 21 | const GrB_Matrix M_in, // optional mask for C, unused if NULL |
| 22 | const GrB_BinaryOp accum, // optional accum for Z=accum(C,T) |
| 23 | const GrB_UnaryOp op, // operator to apply to the entries |
| 24 | const GrB_Matrix A, // first input: matrix A |
| 25 | const GrB_Descriptor desc // descriptor for C, M, and A |
| 26 | ) |
| 27 | { |
| 28 | |
| 29 | //-------------------------------------------------------------------------- |
| 30 | // check inputs |
| 31 | //-------------------------------------------------------------------------- |
| 32 | |
| 33 | GB_WHERE (C, "GrB_Matrix_apply (C, M, accum, op, A, desc)") ; |
| 34 | GB_BURBLE_START ("GrB_apply (unary op)") ; |
| 35 | GB_RETURN_IF_NULL_OR_FAULTY (C) ; |
| 36 | GB_RETURN_IF_FAULTY (M_in) ; |
| 37 | GB_RETURN_IF_NULL_OR_FAULTY (A) ; |
| 38 | |
| 39 | // get the descriptor |
| 40 | GB_GET_DESCRIPTOR (info, desc, C_replace, Mask_comp, Mask_struct, |
| 41 | A_transpose, xx1, xx2, xx7) ; |
| 42 | |
| 43 | // get the mask |
| 44 | GrB_Matrix M = GB_get_mask (M_in, &Mask_comp, &Mask_struct) ; |
| 45 | |
| 46 | //-------------------------------------------------------------------------- |
| 47 | // apply the operator and optionally transpose |
| 48 | //-------------------------------------------------------------------------- |
| 49 | |
| 50 | info = GB_apply ( |
| 51 | C, C_replace, // C and its descriptor |
| 52 | M, Mask_comp, Mask_struct, // mask and its descriptor |
| 53 | accum, // optional accum for Z=accum(C,T) |
| 54 | (GB_Operator) op, NULL, false, // operator op(.) to apply to the entries |
| 55 | A, A_transpose, // A and its descriptor |
| 56 | Context) ; |
| 57 | |
| 58 | GB_BURBLE_END ; |
| 59 | return (info) ; |
| 60 | } |
| 61 | |
| 62 | //------------------------------------------------------------------------------ |
| 63 | // GB_1st: apply a binary operator: op(x,A) |