1 //------------------------------------------------------------------------------
2 // GrB_Vector_assign: w<M>(Rows) = accum (w(Rows),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_Vector_subassign, which uses M and C_replace differently
11 
12 #include "GB_assign.h"
13 #include "GB_bitmap_assign.h"
14 
GrB_Vector_assign(GrB_Vector w,const GrB_Vector M,const GrB_BinaryOp accum,const GrB_Vector u,const GrB_Index * Rows,GrB_Index nRows,const GrB_Descriptor desc)15 GrB_Info GrB_Vector_assign          // w<M>(Rows) = accum (w(Rows),u)
16 (
17     GrB_Vector w,                   // input/output matrix for results
18     const GrB_Vector M,             // optional mask for w, unused if NULL
19     const GrB_BinaryOp accum,       // optional accum for z=accum(w(Rows),t)
20     const GrB_Vector u,             // first input:  vector u
21     const GrB_Index *Rows,          // row indices
22     GrB_Index nRows,                // number of row indices
23     const GrB_Descriptor desc       // descriptor for w and M
24 )
25 {
26 
27     //--------------------------------------------------------------------------
28     // check inputs
29     //--------------------------------------------------------------------------
30 
31     GB_WHERE (w, "GrB_Vector_assign (w, M, accum, u, Rows, nRows, desc)") ;
32     GB_BURBLE_START ("GrB_assign") ;
33     GB_RETURN_IF_NULL_OR_FAULTY (w) ;
34     GB_RETURN_IF_FAULTY (M) ;
35     GB_RETURN_IF_NULL_OR_FAULTY (u) ;
36     ASSERT (GB_VECTOR_OK (w)) ;
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     // w(Rows)<M> = accum (w(Rows), u) and variations
46     //--------------------------------------------------------------------------
47 
48     info = GB_assign (
49         (GrB_Matrix) w,     C_replace,  // w vector and its descriptor
50         (GrB_Matrix) M, Mask_comp, Mask_struct,  // mask and its descriptor
51         false,                          // do not transpose the mask
52         accum,                          // for accum (C(Rows,:),A)
53         (GrB_Matrix) u,     false,      // u as a matrix; never transposed
54         Rows, nRows,                    // row indices
55         GrB_ALL, 1,                     // all column indices
56         false, NULL, GB_ignore_code,    // no scalar expansion
57         GB_ASSIGN,
58         Context) ;
59 
60     GB_BURBLE_END ;
61     return (info) ;
62 }
63 
64