1 //------------------------------------------------------------------------------
2 // GB_convert_sparse_to_hyper_test: test for sparse to hypersparse conversion
3 //------------------------------------------------------------------------------
4
5 // SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved.
6 // SPDX-License-Identifier: Apache-2.0
7
8 //------------------------------------------------------------------------------
9
10 // Returns true if a sparse matrix should be converted to hypersparse.
11 // Returns false if the matrix should stay sparse.
12
13 // A matrix with vdim <= 1 must always be sparse, not hypersparse;
14 // that is, a GrB_Vector is never hypersparse.
15
16 #include "GB.h"
17
GB_convert_sparse_to_hyper_test(float hyper_switch,int64_t k,int64_t vdim)18 bool GB_convert_sparse_to_hyper_test // test sparse to hypersparse conversion
19 (
20 float hyper_switch, // A->hyper_switch
21 int64_t k, // # of non-empty vectors of A (an estimate is OK)
22 int64_t vdim // A->vdim
23 )
24 {
25
26 // get the vector dimension of this matrix
27 float n = (float) vdim ;
28
29 // ensure k is in the range 0 to n, inclusive
30 k = GB_IMAX (k, 0) ;
31 k = GB_IMIN (k, n) ;
32
33 return (n > 1 && (((float) k) <= n * hyper_switch)) ;
34 }
35
36