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
|
//------------------------------------------------------------------------------
// GB_hyper_hash_need: determine if a matrix needs its hyper_hash built
//------------------------------------------------------------------------------
// SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2025, All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
//------------------------------------------------------------------------------
// A hypersparse matrix A can use a hyper_hash matrix A->Y to speed up access
// to its hyper list, A->h. For extremely sparse matrices, building the
// hyper_hash can be costly, however.
// If A has pending work, this test is not useful, since the format of A can
// change, and A->nvec could change if zombies are removed and pending tuples
// assembled. This test should only be used if a matrix has no other pending
// work.
#include "GB.h"
bool GB_hyper_hash_need
(
GrB_Matrix A
)
{
if (A == NULL || !GB_IS_HYPERSPARSE (A) || A->no_hyper_hash)
{
// only hypersparse matrices require a hyper_hash
return (false) ;
}
if (A->Y != NULL)
{
// A already has a hyper_hash
return (false) ;
}
// A is hypersparse, and has no hyper_hash. Check how many non-empty
// vectors it has. A->Y should be built if A has a significant number of
// non-empty vectors.
int64_t hyper_hash = GB_Global_hyper_hash_get ( ) ;
return (A->nvec > hyper_hash) ;
}
|