1 //------------------------------------------------------------------------------
2 // GB_scalar.h: definitions for 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 #ifndef GB_SCALAR_H
11 #define GB_SCALAR_H
12 
13 GxB_Scalar GB_Scalar_wrap   // create a new GxB_Scalar with one entry
14 (
15     GxB_Scalar s,           // GxB_Scalar to create
16     GrB_Type type,          // type of GxB_Scalar to create
17     void *Sx                // becomes S->x, an array of size 1 * type->size
18 ) ;
19 
20 // stype can be NULL if op is positional
21 
22 // wrap a bare scalar inside a statically-allocated GxB_Scalar
23 #define GB_SCALAR_WRAP(scalar,T,ampersand,bare,stype)                       \
24     struct GB_Scalar_opaque scalar ## _header ;                             \
25     size_t ssize = (stype == NULL) ? 1 : (stype->size) ;                    \
26     GB_void Sx [GB_VLA (ssize)] ;                                           \
27     GxB_Scalar scalar = GB_Scalar_wrap (& scalar ## _header, stype, Sx) ;   \
28     memcpy (Sx, ampersand bare, ssize) ;
29 
30 #endif
31 
32