MCPcopy Create free account
hub / github.com/RedisGraph/RedisGraph / GB_setElement

Function GB_setElement

deps/GraphBLAS/Source/GB_setElement.c:36–463  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34#define GB_FREE_ALL ;
35
36GrB_Info GB_setElement // set a single entry, C(row,col) = scalar
37(
38 GrB_Matrix C, // matrix to modify
39 const GrB_BinaryOp accum, // if NULL: C(row,col) = scalar
40 // else: C(row,col) += scalar
41 const void *scalar, // scalar to set
42 const GrB_Index row, // row index
43 const GrB_Index col, // column index
44 const GB_Type_code scalar_code, // type of the scalar
45 GB_Context Context
46)
47{
48
49 //--------------------------------------------------------------------------
50 // check inputs
51 //--------------------------------------------------------------------------
52
53 GrB_Info info ;
54 ASSERT (C != NULL) ;
55 GB_RETURN_IF_NULL (scalar) ;
56
57 if (row >= GB_NROWS (C))
58 {
59 GB_ERROR (GrB_INVALID_INDEX,
60 "Row index " GBu " out of range; must be < " GBd,
61 row, GB_NROWS (C)) ;
62 }
63 if (col >= GB_NCOLS (C))
64 {
65 GB_ERROR (GrB_INVALID_INDEX,
66 "Column index " GBu " out of range; must be < " GBd,
67 col, GB_NCOLS (C)) ;
68 }
69
70 ASSERT (scalar_code <= GB_UDT_code) ;
71
72 GrB_Type ctype = C->type ;
73 GB_Type_code ccode = ctype->code ;
74
75 // scalar_code and C must be compatible
76 if (!GB_code_compatible (scalar_code, ccode))
77 {
78 GB_ERROR (GrB_DOMAIN_MISMATCH,
79 "Input scalar of type [%s]\n"
80 "cannot be typecast to entry of type [%s]",
81 GB_code_string (scalar_code), ctype->name) ;
82 }
83
84 if (accum != NULL)
85 {
86 // C and scalar must be compatible with the accum operator
87 GB_RETURN_IF_FAULTY_OR_POSITIONAL (accum) ;
88 GB_OK (GB_BinaryOp_compatible (accum, ctype, ctype, NULL, scalar_code,
89 Context)) ;
90 }
91
92 // pending tuples and zombies are expected, and C might be jumbled too
93 ASSERT (GB_JUMBLED_OK (C)) ;

Calls 15

GB_code_compatibleFunction · 0.85
GB_code_stringFunction · 0.85
GB_BinaryOp_compatibleFunction · 0.85
GB_code_typeFunction · 0.85
GB_cast_scalarFunction · 0.85
GB_convert_any_to_isoFunction · 0.85
GB_lookupFunction · 0.85
GB_cast_factoryFunction · 0.85
GB_op_is_secondFunction · 0.85
GB_Pending_addFunction · 0.85
GB_phybix_freeFunction · 0.85

Tested by

no test coverage detected