1 //------------------------------------------------------------------------------
2 // GrB_Col_assign: C<M>(Rows,col) = accum (C(Rows,col),u)
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 GxB_Col_subassign, which uses the M and C_replace differently
11 
12 #include "GB_assign.h"
13 #include "GB_bitmap_assign.h"
14 
GrB_Col_assign(GrB_Matrix C,const GrB_Vector M,const GrB_BinaryOp accum,const GrB_Vector u,const GrB_Index * Rows,GrB_Index nRows,GrB_Index col,const GrB_Descriptor desc)15 GrB_Info GrB_Col_assign             // C<M>(Rows,col) = accum (C(Rows,col),u)
16 (
17     GrB_Matrix C,                   // input/output matrix for results
18     const GrB_Vector M,             // mask for C(:,col), unused if NULL
19     const GrB_BinaryOp accum,       // optional accum for z=accum(C(Rows,col),t)
20     const GrB_Vector u,             // input vector
21     const GrB_Index *Rows,          // row indices
22     GrB_Index nRows,                // number of row indices
23     GrB_Index col,                  // column index
24     const GrB_Descriptor desc       // descriptor for C(:,col) and M
25 )
26 {
27 
28     //--------------------------------------------------------------------------
29     // check inputs
30     //--------------------------------------------------------------------------
31 
32     GB_WHERE (C, "GrB_Col_assign (C, M, accum, u, Rows, nRows, col, desc)") ;
33     GB_BURBLE_START ("GrB_assign") ;
34     GB_RETURN_IF_NULL_OR_FAULTY (C) ;
35     GB_RETURN_IF_FAULTY (M) ;
36     GB_RETURN_IF_NULL_OR_FAULTY (u) ;
37     ASSERT (M == NULL || GB_VECTOR_OK (M)) ;
38     ASSERT (GB_VECTOR_OK (u)) ;
39 
40     // get the descriptor
41     GB_GET_DESCRIPTOR (info, desc, C_replace, Mask_comp, Mask_struct,
42         xx1, xx2, xx3, xx7) ;
43 
44     //--------------------------------------------------------------------------
45     // C(Rows,col)<M> = accum (C(Rows,col), u)
46     //--------------------------------------------------------------------------
47 
48     // construct the column index list Cols = [ col ] of length nCols = 1
49     GrB_Index Cols [1] ;
50     Cols [0] = col ;
51 
52     info = GB_assign (
53         C,                  C_replace,      // C matrix and its descriptor
54         (GrB_Matrix) M, Mask_comp, Mask_struct, // mask and its descriptor
55         false,                              // do not transpose the mask
56         accum,                              // for accum (C(Rows,col),u)
57         (GrB_Matrix) u,     false,          // u as a matrix; never transposed
58         Rows, nRows,                        // row indices
59         Cols, 1,                            // a single column index
60         false, NULL, GB_ignore_code,        // no scalar expansion
61         GB_COL_ASSIGN,
62         Context) ;
63 
64     GB_BURBLE_END ;
65     return (info) ;
66 }
67