1 //------------------------------------------------------------------------------
2 // GxB_Matrix_export_BitmapR: export a bitmap matrix, held by row
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_Matrix_export_BitmapR(GrB_Matrix * A,GrB_Type * type,GrB_Index * nrows,GrB_Index * ncols,int8_t ** Ab,void ** Ax,GrB_Index * Ab_size,GrB_Index * Ax_size,bool * is_uniform,GrB_Index * nvals,const GrB_Descriptor desc)14 GrB_Info GxB_Matrix_export_BitmapR // export and free a bitmap matrix, by row
15 (
16 GrB_Matrix *A, // handle of matrix to export and free
17 GrB_Type *type, // type of matrix exported
18 GrB_Index *nrows, // number of rows of the matrix
19 GrB_Index *ncols, // number of columns of the matrix
20
21 int8_t **Ab, // bitmap
22 void **Ax, // values
23 GrB_Index *Ab_size, // size of Ab in bytes
24 GrB_Index *Ax_size, // size of Ax in bytes
25 bool *is_uniform, // if true, A has uniform values (TODO:::unsupported)
26
27 GrB_Index *nvals, // # of entries in bitmap
28 const GrB_Descriptor desc
29 )
30 {
31
32 //--------------------------------------------------------------------------
33 // check inputs and get the descriptor
34 //--------------------------------------------------------------------------
35
36 GB_WHERE1 ("GxB_Matrix_export_BitmapR (&A, &type, &nrows, &ncols, "
37 "&Ab, &Ax, &Ab_size, &Ax_size, &is_uniform, &nvals, desc)") ;
38 GB_BURBLE_START ("GxB_Matrix_export_BitmapR") ;
39 GB_RETURN_IF_NULL (A) ;
40 GB_RETURN_IF_NULL_OR_FAULTY (*A) ;
41 GB_GET_DESCRIPTOR (info, desc, xx1, xx2, xx3, xx4, xx5, xx6, xx7) ;
42
43 //--------------------------------------------------------------------------
44 // ensure the matrix is bitmap CSR
45 //--------------------------------------------------------------------------
46
47 // ensure the matrix is in CSR format
48 if ((*A)->is_csc)
49 {
50 // A = A', done in-place, to put A in CSR format
51 GBURBLE ("(transpose) ") ;
52 GB_OK (GB_transpose (NULL, NULL, false, *A, // in_place_A
53 NULL, NULL, NULL, false, Context)) ;
54 }
55
56 GB_OK (GB_convert_any_to_bitmap (*A, Context)) ;
57
58 //--------------------------------------------------------------------------
59 // export the matrix
60 //--------------------------------------------------------------------------
61
62 ASSERT (GB_IS_BITMAP (*A)) ;
63 ASSERT (!((*A)->is_csc)) ;
64 ASSERT (!GB_ZOMBIES (*A)) ;
65 ASSERT (!GB_JUMBLED (*A)) ;
66 ASSERT (!GB_PENDING (*A)) ;
67
68 int sparsity ;
69 bool is_csc ;
70
71 info = GB_export (A, type, ncols, nrows, false,
72 NULL, NULL, // Ap
73 NULL, NULL, // Ah
74 Ab, Ab_size, // Ab
75 NULL, NULL, // Ai
76 Ax, Ax_size, // Ax
77 nvals, NULL, NULL, // nvals for bitmap
78 &sparsity, &is_csc, // bitmap by col
79 is_uniform, Context) ;
80
81 if (info == GrB_SUCCESS)
82 {
83 ASSERT (sparsity == GxB_BITMAP) ;
84 ASSERT (!is_csc) ;
85 }
86 GB_BURBLE_END ;
87 return (info) ;
88 }
89
90