1 //------------------------------------------------------------------------------
2 // GxB_Scalar_setElement: set an entry in a GxB_Scalar
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 scalar, s = x, typecasting from the type of x to
11 // the type of s as needed.
12 
13 #include "GB.h"
14 
15 #define GB_SET(type,T,ampersand)                                            \
16 GrB_Info GB_EVAL2 (GXB (Scalar_setElement_), T)    /* s = x */              \
17 (                                                                           \
18     GxB_Scalar s,                       /* GxB_Scalar to modify       */    \
19     type x                              /* user scalar to assign to s */    \
20 )                                                                           \
21 {                                                                           \
22     GB_WHERE (s, "GxB_Scalar_setElement_" GB_STR(T) " (w, x)") ;            \
23     GB_RETURN_IF_NULL_OR_FAULTY (s) ;                                       \
24     ASSERT (GB_SCALAR_OK (s)) ;                                             \
25     return (GB_setElement ((GrB_Matrix) s, ampersand x, 0, 0,               \
26         GB_ ## T ## _code, Context)) ;                                      \
27 }
28 
29 GB_SET (bool      , BOOL   , &)
30 GB_SET (int8_t    , INT8   , &)
31 GB_SET (int16_t   , INT16  , &)
32 GB_SET (int32_t   , INT32  , &)
33 GB_SET (int64_t   , INT64  , &)
34 GB_SET (uint8_t   , UINT8  , &)
35 GB_SET (uint16_t  , UINT16 , &)
36 GB_SET (uint32_t  , UINT32 , &)
37 GB_SET (uint64_t  , UINT64 , &)
38 GB_SET (float     , FP32   , &)
39 GB_SET (double    , FP64   , &)
40 GB_SET (GxB_FC32_t, FC32   , &)
41 GB_SET (GxB_FC64_t, FC64   , &)
42 GB_SET (void *    , UDT    ,  )
43 
44