1 //------------------------------------------------------------------------------
2 // GxB_Vector_export_Bitmap: export a bitmap vector
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_export.h"
11 
12 #define GB_FREE_ALL ;
13 
GxB_Vector_export_Bitmap(GrB_Vector * v,GrB_Type * type,GrB_Index * n,int8_t ** vb,void ** vx,GrB_Index * vb_size,GrB_Index * vx_size,bool * is_uniform,GrB_Index * nvals,const GrB_Descriptor desc)14 GrB_Info GxB_Vector_export_Bitmap   // export and free a bitmap vector
15 (
16     GrB_Vector *v,      // handle of vector to export and free
17     GrB_Type *type,     // type of vector exported
18     GrB_Index *n,       // length of the vector
19 
20     int8_t **vb,        // bitmap
21     void **vx,          // values
22     GrB_Index *vb_size, // size of vb in bytes
23     GrB_Index *vx_size, // size of vx in bytes
24     bool *is_uniform,   // if true, v has uniform values (TODO:::unsupported)
25 
26     GrB_Index *nvals,    // # of entries in bitmap
27     const GrB_Descriptor desc
28 )
29 {
30 
31     //--------------------------------------------------------------------------
32     // check inputs
33     //--------------------------------------------------------------------------
34 
35     GB_WHERE1 ("GxB_Vector_export_Bitmap (&v, &type, &n, "
36         "&vb, &vx, &vb_size, &vx_size, &is_uniform, &nvals, desc)") ;
37     GB_BURBLE_START ("GxB_Vector_export_Bitmap") ;
38     GB_RETURN_IF_NULL (v) ;
39     GB_RETURN_IF_NULL_OR_FAULTY (*v) ;
40     GB_GET_DESCRIPTOR (info, desc, xx1, xx2, xx3, xx4, xx5, xx6, xx7) ;
41 
42     //--------------------------------------------------------------------------
43     // finish any pending work
44     //--------------------------------------------------------------------------
45 
46     GB_MATRIX_WAIT (*v) ;
47 
48     //--------------------------------------------------------------------------
49     // ensure the vector is bitmap CSC
50     //--------------------------------------------------------------------------
51 
52     ASSERT ((*v)->is_csc) ;
53     GB_OK (GB_convert_any_to_bitmap ((GrB_Matrix) *v, Context)) ;
54 
55     //--------------------------------------------------------------------------
56     // export the vector
57     //--------------------------------------------------------------------------
58 
59     ASSERT (GB_IS_BITMAP (*v)) ;
60     ASSERT ((*v)->is_csc) ;
61     ASSERT (!GB_ZOMBIES (*v)) ;
62     ASSERT (!GB_JUMBLED (*v)) ;
63     ASSERT (!GB_PENDING (*v)) ;
64 
65     int sparsity ;
66     bool is_csc ;
67     GrB_Index vdim ;
68 
69     info = GB_export ((GrB_Matrix *) v, type, n, &vdim, false,
70         NULL, NULL,     // Ap
71         NULL, NULL,     // Ah
72         vb,   vb_size,  // Ab
73         NULL, NULL,     // Ai
74         vx,   vx_size,  // Ax
75         nvals, NULL, NULL,                  // nvals for bitmap
76         &sparsity, &is_csc,                 // bitmap by col
77         is_uniform, Context) ;
78 
79     if (info == GrB_SUCCESS)
80     {
81         ASSERT (sparsity == GxB_BITMAP) ;
82         ASSERT (is_csc) ;
83         ASSERT (vdim == 1) ;
84     }
85     GB_BURBLE_END ;
86     return (info) ;
87 }
88 
89