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

Function GB_bix_alloc

deps/GraphBLAS/Source/GB_bix_alloc.c:19–88  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17#include "GB.h"
18
19GB_PUBLIC
20GrB_Info GB_bix_alloc // allocate A->b, A->i, and A->x space in a matrix
21(
22 GrB_Matrix A, // matrix to allocate space for
23 const GrB_Index nzmax, // number of entries the matrix can hold;
24 // ignored if A is iso and full
25 const int sparsity, // sparse (=hyper/auto) / bitmap / full
26 const bool bitmap_calloc, // if true, calloc A->b, otherwise use malloc
27 const bool numeric, // if true, allocate A->x, otherwise A->x is NULL
28 const bool A_iso, // if true, allocate A as iso
29 GB_Context Context
30)
31{
32
33 //--------------------------------------------------------------------------
34 // check inputs
35 //--------------------------------------------------------------------------
36
37 ASSERT (A != NULL) ;
38
39 //--------------------------------------------------------------------------
40 // allocate the A->b, A->x, and A->i content of the matrix
41 //--------------------------------------------------------------------------
42
43 // Free the existing A->b, A->x, and A->i content, if any.
44 // Leave A->p and A->h unchanged.
45 GB_bix_free (A) ;
46 A->iso = A_iso ; // OK: see caller for iso burble
47
48 bool ok = true ;
49 if (sparsity == GxB_BITMAP)
50 {
51 if (bitmap_calloc)
52 {
53 // content is fully defined
54 A->b = GB_CALLOC (nzmax, int8_t, &(A->b_size)) ;
55 A->magic = GB_MAGIC ;
56 }
57 else
58 {
59 // bitmap is not defined and will be computed by the caller
60 A->b = GB_MALLOC (nzmax, int8_t, &(A->b_size)) ;
61 }
62 ok = (A->b != NULL) ;
63 }
64 else if (sparsity != GxB_FULL)
65 {
66 // sparsity: sparse / hyper / auto
67 A->i = GB_MALLOC (nzmax, int64_t, &(A->i_size)) ;
68 ok = (A->i != NULL) ;
69 if (ok) A->i [0] = 0 ;
70 }
71
72 if (numeric)
73 {
74 // calloc the space if A is bitmap
75 A->x = GB_XALLOC (sparsity == GxB_BITMAP, A_iso, // x:OK
76 nzmax, A->type->size, &(A->x_size)) ;

Callers 9

GB_concat_fullFunction · 0.85
GB_emult_04Function · 0.85
GB_emult_02Function · 0.85
GB_new_bixFunction · 0.85
GB_concat_bitmapFunction · 0.85
GB_split_sparseFunction · 0.85
GB_mx_mxArray_to_MatrixFunction · 0.85
mexFunctionFunction · 0.85

Calls 2

GB_bix_freeFunction · 0.85
GB_phybix_freeFunction · 0.85

Tested by

no test coverage detected