1 //------------------------------------------------------------------------------
2 // GB_convert_any_to_hyper: convert any matrix to hypersparse
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 #include "GB.h"
11 #define GB_FREE_ALL ;
12 
GB_convert_any_to_hyper(GrB_Matrix A,GB_Context Context)13 GrB_Info GB_convert_any_to_hyper // convert to hypersparse
14 (
15     GrB_Matrix A,           // matrix to convert to hypersparse
16     GB_Context Context
17 )
18 {
19 
20     //--------------------------------------------------------------------------
21     // check inputs
22     //--------------------------------------------------------------------------
23 
24     GrB_Info info ;
25     ASSERT_MATRIX_OK (A, "A being converted to hyper", GB0) ;
26     ASSERT (GB_ZOMBIES_OK (A)) ;
27     ASSERT (GB_JUMBLED_OK (A)) ;
28     ASSERT (GB_PENDING_OK (A)) ;
29 
30     //--------------------------------------------------------------------------
31     // convert A to hypersparse
32     //--------------------------------------------------------------------------
33 
34     if (GB_IS_HYPERSPARSE (A))
35     {
36         // already hypersparse, nothing to do
37         ;
38     }
39     else if (GB_IS_FULL (A))
40     {
41         // convert from full to hypersparse
42         GB_OK (GB_convert_full_to_sparse (A, Context)) ;
43         GB_OK (GB_convert_sparse_to_hyper (A, Context)) ;
44     }
45     else if (GB_IS_BITMAP (A))
46     {
47         // convert from bitmap to hypersparse
48         GB_OK (GB_convert_bitmap_to_sparse (A, Context)) ;
49         GB_OK (GB_convert_sparse_to_hyper (A, Context)) ;
50     }
51     else
52     {
53         // convert from sparse to hypersparse
54         GB_OK (GB_convert_sparse_to_hyper (A, Context)) ;
55     }
56 
57     //--------------------------------------------------------------------------
58     // return result
59     //--------------------------------------------------------------------------
60 
61     ASSERT_MATRIX_OK (A, "A to hypersparse", GB0) ;
62     ASSERT (GB_IS_HYPERSPARSE (A)) ;
63     ASSERT (GB_ZOMBIES_OK (A)) ;
64     ASSERT (GB_JUMBLED_OK (A)) ;
65     ASSERT (GB_PENDING_OK (A)) ;
66     return (GrB_SUCCESS) ;
67 }
68 
69