1 //------------------------------------------------------------------------------
2 // GxB_Matrix_subassign: C(Rows,Cols)<M> = accum (C(Rows,Cols),A) or A'
3 //------------------------------------------------------------------------------
4 
5 // SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved.
6 // SPDX-License-Identifier: Apache-2.0
7 
8 //------------------------------------------------------------------------------
9 
10 // Compare with GrB_Matrix_assign, which uses M and C_replace differently
11 
12 #include "GB_subassign.h"
13 
GxB_Matrix_subassign(GrB_Matrix C,const GrB_Matrix M,const GrB_BinaryOp accum,const GrB_Matrix A,const GrB_Index * Rows,GrB_Index nRows,const GrB_Index * Cols,GrB_Index nCols,const GrB_Descriptor desc)14 GrB_Info GxB_Matrix_subassign       // C(Rows,Cols)<M> += A or A'
15 (
16     GrB_Matrix C,                   // input/output matrix for results
17     const GrB_Matrix M,             // mask for C(Rows,Cols), unused if NULL
18     const GrB_BinaryOp accum,       // accum for Z=accum(C(Rows,Cols),T)
19     const GrB_Matrix A,             // first input:  matrix A
20     const GrB_Index *Rows,          // row indices
21     GrB_Index nRows,                // number of row indices
22     const GrB_Index *Cols,          // column indices
23     GrB_Index nCols,                // number of column indices
24     const GrB_Descriptor desc       // descriptor for C(Rows,Cols), M, and A
25 )
26 {
27 
28     //--------------------------------------------------------------------------
29     // check inputs
30     //--------------------------------------------------------------------------
31 
32     GB_WHERE (C, "GxB_Matrix_subassign"
33         " (C, M, accum, A, Rows, nRows, Cols, nCols, desc)") ;
34     GB_BURBLE_START ("GxB_subassign") ;
35     GB_RETURN_IF_NULL_OR_FAULTY (C) ;
36     GB_RETURN_IF_FAULTY (M) ;
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     //--------------------------------------------------------------------------
44     // C(Rows,Cols)<M> = accum (C(Rows,Cols), A) and variations
45     //--------------------------------------------------------------------------
46 
47     info = GB_subassign (
48         C,          C_replace,      // C matrix and its descriptor
49         M, Mask_comp, Mask_struct,  // mask matrix and its descriptor
50         false,                      // do not transpose the mask
51         accum,                      // for accum (C(Rows,Cols),A)
52         A,          A_transpose,    // A and its descriptor (T=A or A')
53         Rows, nRows,                // row indices
54         Cols, nCols,                // column indices
55         false, NULL, GB_ignore_code,// no scalar expansion
56         Context) ;
57 
58     GB_BURBLE_END ;
59     return (info) ;
60 }
61 
62