1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
|
//------------------------------------------------------------------------------
// GB_Scalar_wrap: wrap a C scalar inside a GraphBLAS scalar
//------------------------------------------------------------------------------
// SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2022, All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
//------------------------------------------------------------------------------
// This method construct a shallow statically-defined scalar, with no memory
// allocations. The scalar is iso full, with a single entry.
// Note that since the header is statically allocated, it cannot be transfered
// automatically to the GPU when using CUDA.
#include "GB.h"
#include "GB_scalar.h"
GrB_Scalar GB_Scalar_wrap // create a new GrB_Scalar with one entry
(
GrB_Scalar s, // GrB_Scalar to create
GrB_Type type, // type of GrB_Scalar to create
void *Sx // becomes S->x, an array of size 1 * type->size
)
{
//--------------------------------------------------------------------------
// check inputs
//--------------------------------------------------------------------------
ASSERT (s != NULL) ;
//--------------------------------------------------------------------------
// create the GrB_Scalar
//--------------------------------------------------------------------------
s->magic = GB_MAGIC ;
s->header_size = 0 ;
s->type = (type == NULL) ? GrB_BOOL : type ;
s->logger = NULL ;
s->logger_size = 0 ;
s->plen = -1 ;
s->vlen = 1 ;
s->vdim = 1 ;
s->nvec = 1 ;
s->nvec_nonempty = 1 ;
s->p = NULL ; s->p_size = 0 ; s->p_shallow = false ;
s->h = NULL ; s->h_size = 0 ; s->h_shallow = false ;
s->b = NULL ; s->b_size = 0 ; s->b_shallow = false ;
s->i = NULL ; s->i_size = 0 ; s->i_shallow = false ;
s->x = Sx ; s->x_size = type->size ; s->x_shallow = true ;
s->Y = NULL ;
s->Y_shallow = false ;
s->nvals = 0 ;
s->Pending = NULL ;
s->nzombies = 0 ;
s->hyper_switch = GxB_NEVER_HYPER ;
s->bitmap_switch = 0.5 ;
s->sparsity_control = GxB_FULL ;
s->static_header = true ;
s->is_csc = true ;
s->jumbled = false ;
s->iso = true ; // OK: scalar wrap with a single entry
//--------------------------------------------------------------------------
// return result
//--------------------------------------------------------------------------
return (s) ;
}
|