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

Function GB_hypermatrix_prune

deps/GraphBLAS/Source/GB_hypermatrix_prune.c:16–87  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14#include "GB.h"
15
16GrB_Info GB_hypermatrix_prune
17(
18 GrB_Matrix A, // matrix to prune
19 GB_Context Context
20)
21{
22
23 //--------------------------------------------------------------------------
24 // check inputs
25 //--------------------------------------------------------------------------
26
27 ASSERT (A != NULL) ;
28 ASSERT (GB_ZOMBIES_OK (A)) ; // pattern not accessed
29 ASSERT (GB_JUMBLED_OK (A)) ;
30 ASSERT_MATRIX_OK (A, "A before hypermatrix_prune", GB0) ;
31
32 if (!GB_IS_HYPERSPARSE (A))
33 {
34 // nothing to do
35 return (GrB_SUCCESS) ;
36 }
37
38 //--------------------------------------------------------------------------
39 // count # of empty vectors
40 //--------------------------------------------------------------------------
41
42 if (A->nvec_nonempty < 0)
43 {
44 // A->nvec_nonempty is needed to prune the hyperlist
45 A->nvec_nonempty = GB_nvec_nonempty (A, Context) ;
46 }
47
48 //--------------------------------------------------------------------------
49 // prune empty vectors
50 //--------------------------------------------------------------------------
51
52 if (A->nvec_nonempty < A->nvec) // A->nvec_nonempty used here
53 {
54 // create new Ap_new and Ah_new arrays, with no empty vectors
55 int64_t *restrict Ap_new = NULL ; size_t Ap_new_size = 0 ;
56 int64_t *restrict Ah_new = NULL ; size_t Ah_new_size = 0 ;
57 int64_t nvec_new, plen_new ;
58 int64_t anz = A->nvals ;
59 ASSERT (anz == A->p [A->nvec]) ;
60 GrB_Info info = GB_hyper_prune (&Ap_new, &Ap_new_size,
61 &Ah_new, &Ah_new_size, &nvec_new, &plen_new,
62 A->p, A->h, A->nvec, Context) ;
63 if (info != GrB_SUCCESS)
64 {
65 // out of memory
66 return (info) ;
67 }
68 // free the old A->p, A->h, and A->Y
69 GB_phy_free (A) ;
70 // A->p, A->h, A->Y are now NULL and thus not shallow
71 ASSERT (!A->p_shallow) ;
72 ASSERT (!A->h_shallow) ;
73 ASSERT (!A->Y_shallow) ;

Callers 10

GB_emult_04Function · 0.85
GB_emult_02Function · 0.85
GB_subref_phase3Function · 0.85
GB_add_phase2Function · 0.85
GB_kronerFunction · 0.85
GB_emult_phase2Function · 0.85
GB_AxB_saxpy3Function · 0.85
GB_masker_phase2Function · 0.85
GB_split_sparseFunction · 0.85
mexFunctionFunction · 0.85

Calls 3

GB_nvec_nonemptyFunction · 0.85
GB_hyper_pruneFunction · 0.85
GB_phy_freeFunction · 0.85

Tested by

no test coverage detected