1 //------------------------------------------------------------------------------ 2 // GrB_Matrix_setElement: set an entry in a matrix, C(row,col) = x 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 // Set a single entry in a matrix, C(row,col) = x in MATLAB notation, 11 // typecasting from the type of x to the type of C, as needed. 12 13 #include "GB.h" 14 15 #define GB_SET(prefix,type,T,ampersand) \ 16 GrB_Info GB_EVAL3 (prefix, _Matrix_setElement_, T) /* C (row,col) = x */ \ 17 ( \ 18 GrB_Matrix C, /* matrix to modify */\ 19 type x, /* scalar to assign to C(row,col) */\ 20 GrB_Index row, /* row index */\ 21 GrB_Index col /* column index */\ 22 ) \ 23 { \ 24 GB_WHERE (C, GB_STR(prefix) "_Matrix_setElement_" GB_STR(T) \ 25 " (C, row, col, x)") ; \ 26 GB_RETURN_IF_NULL_OR_FAULTY (C) ; \ 27 return (GB_setElement (C, ampersand x, row, col, GB_ ## T ## _code, \ 28 Context)) ; \ 29 } 30 31 GB_SET (GrB, bool , BOOL , &) 32 GB_SET (GrB, int8_t , INT8 , &) 33 GB_SET (GrB, int16_t , INT16 , &) 34 GB_SET (GrB, int32_t , INT32 , &) 35 GB_SET (GrB, int64_t , INT64 , &) 36 GB_SET (GrB, uint8_t , UINT8 , &) 37 GB_SET (GrB, uint16_t , UINT16 , &) 38 GB_SET (GrB, uint32_t , UINT32 , &) 39 GB_SET (GrB, uint64_t , UINT64 , &) 40 GB_SET (GrB, float , FP32 , &) 41 GB_SET (GrB, double , FP64 , &) 42 GB_SET (GxB, GxB_FC32_t, FC32 , &) 43 GB_SET (GxB, GxB_FC64_t, FC64 , &) 44 GB_SET (GrB, void * , UDT , ) 45 46