1 //------------------------------------------------------------------------------ 2 // GxB_Vector_subassign_[SCALAR]: assign scalar to vector, via scalar expansion 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 // Assigns a single scalar to a subvector, w(Rows)<M> = accum(w(Rows),x) 11 // The scalar x is implicitly expanded into a vector u of size nRows-by-1, 12 // with each entry in u equal to x. 13 14 // The actual work is done in GB_subassign_scalar.c. 15 16 #include "GB_subassign.h" 17 18 #define GB_ASSIGN_SCALAR(type,T,ampersand) \ 19 GrB_Info GB_EVAL2 (GXB (Vector_subassign_), T) /* w(I)<M> = accum (w(I),x) */ \ 20 ( \ 21 GrB_Vector w, /* input/output vector for results */ \ 22 const GrB_Vector M, /* optional mask for w(Rows) */ \ 23 const GrB_BinaryOp accum, /* optional accum for Z=accum(w(Rows),x)*/ \ 24 type x, /* scalar to assign to w(Rows) */ \ 25 const GrB_Index *Rows, /* row indices */ \ 26 GrB_Index nRows, /* number of row indices */ \ 27 const GrB_Descriptor desc /* descriptor for w(Rows) and M */ \ 28 ) \ 29 { \ 30 GB_WHERE (w, "GxB_Vector_subassign_" GB_STR(T) \ 31 " (w, M, accum, x, Rows, nRows, desc)") ; \ 32 GB_BURBLE_START ("GxB_subassign") ; \ 33 GB_RETURN_IF_NULL_OR_FAULTY (w) ; \ 34 GB_RETURN_IF_FAULTY (M) ; \ 35 ASSERT (GB_VECTOR_OK (w)) ; \ 36 ASSERT (GB_IMPLIES (M != NULL, GB_VECTOR_OK (M))) ; \ 37 GrB_Info info = (GB_subassign_scalar ((GrB_Matrix) w, (GrB_Matrix) M, \ 38 accum, ampersand x, GB_## T ## _code, Rows, nRows, GrB_ALL, 1, desc, \ 39 Context)) ; \ 40 GB_BURBLE_END ; \ 41 return (info) ; \ 42 } 43 44 GB_ASSIGN_SCALAR (bool , BOOL , &) 45 GB_ASSIGN_SCALAR (int8_t , INT8 , &) 46 GB_ASSIGN_SCALAR (uint8_t , UINT8 , &) 47 GB_ASSIGN_SCALAR (int16_t , INT16 , &) 48 GB_ASSIGN_SCALAR (uint16_t , UINT16 , &) 49 GB_ASSIGN_SCALAR (int32_t , INT32 , &) 50 GB_ASSIGN_SCALAR (uint32_t , UINT32 , &) 51 GB_ASSIGN_SCALAR (int64_t , INT64 , &) 52 GB_ASSIGN_SCALAR (uint64_t , UINT64 , &) 53 GB_ASSIGN_SCALAR (float , FP32 , &) 54 GB_ASSIGN_SCALAR (double , FP64 , &) 55 GB_ASSIGN_SCALAR (GxB_FC32_t, FC32 , &) 56 GB_ASSIGN_SCALAR (GxB_FC64_t, FC64 , &) 57 GB_ASSIGN_SCALAR (void * , UDT , ) 58 59