1 //------------------------------------------------------------------------------ 2 // GxB_Matrix_subassign_[SCALAR]: assign to submatrix, 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 submatrix: 11 12 // C(Rows,Cols)<M> = accum(C(Rows,Cols),x) 13 14 // The scalar x is implicitly expanded into a matrix A of size nRows-by-nCols, 15 // with each entry in A equal to x. 16 17 // Compare with GrB_Matrix_assign_scalar, 18 // which uses M and C_Replace differently. 19 20 #include "GB_subassign.h" 21 22 #define GB_ASSIGN_SCALAR(type,T,ampersand) \ 23 GrB_Info GB_EVAL2 (GXB (Matrix_subassign_), T) /* C(Rows,Cols)<M> += x */ \ 24 ( \ 25 GrB_Matrix C, /* input/output matrix for results */ \ 26 const GrB_Matrix M, /* optional mask for C(Rows,Cols) */ \ 27 const GrB_BinaryOp accum, /* accum for Z=accum(C(Rows,Cols),x) */ \ 28 type x, /* scalar to assign to C(Rows,Cols) */ \ 29 const GrB_Index *Rows, /* row indices */ \ 30 GrB_Index nRows, /* number of row indices */ \ 31 const GrB_Index *Cols, /* column indices */ \ 32 GrB_Index nCols, /* number of column indices */ \ 33 const GrB_Descriptor desc /* descriptor for C(Rows,Cols) and M */ \ 34 ) \ 35 { \ 36 GB_WHERE (C, "GxB_Matrix_subassign_" GB_STR(T) \ 37 " (C, M, accum, x, Rows, nRows, Cols, nCols, desc)") ; \ 38 GB_BURBLE_START ("GxB_Matrix_subassign " GB_STR(T)) ; \ 39 GB_RETURN_IF_NULL_OR_FAULTY (C) ; \ 40 GB_RETURN_IF_FAULTY (M) ; \ 41 GrB_Info info = GB_subassign_scalar (C, M, accum, ampersand x, \ 42 GB_## T ## _code, Rows, nRows, Cols, nCols, desc, Context) ; \ 43 GB_BURBLE_END ; \ 44 return (info) ; \ 45 } 46 47 GB_ASSIGN_SCALAR (bool , BOOL , &) 48 GB_ASSIGN_SCALAR (int8_t , INT8 , &) 49 GB_ASSIGN_SCALAR (uint8_t , UINT8 , &) 50 GB_ASSIGN_SCALAR (int16_t , INT16 , &) 51 GB_ASSIGN_SCALAR (uint16_t , UINT16 , &) 52 GB_ASSIGN_SCALAR (int32_t , INT32 , &) 53 GB_ASSIGN_SCALAR (uint32_t , UINT32 , &) 54 GB_ASSIGN_SCALAR (int64_t , INT64 , &) 55 GB_ASSIGN_SCALAR (uint64_t , UINT64 , &) 56 GB_ASSIGN_SCALAR (float , FP32 , &) 57 GB_ASSIGN_SCALAR (double , FP64 , &) 58 GB_ASSIGN_SCALAR (GxB_FC32_t, FC32 , &) 59 GB_ASSIGN_SCALAR (GxB_FC64_t, FC64 , &) 60 GB_ASSIGN_SCALAR (void * , UDT , ) 61 62