1 //------------------------------------------------------------------------------
2 // GxB_Matrix_export_FullC: export a full matrix, held by column
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_FullC(GrB_Matrix * A,GrB_Type * type,GrB_Index * nrows,GrB_Index * ncols,void ** Ax,GrB_Index * Ax_size,bool * is_uniform,const GrB_Descriptor desc)14 GrB_Info GxB_Matrix_export_FullC // export and free a full matrix, by column
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 void **Ax, // values
22 GrB_Index *Ax_size, // size of Ax in bytes
23 bool *is_uniform, // if true, A has uniform values (TODO:::unsupported)
24
25 const GrB_Descriptor desc
26 )
27 {
28
29 //--------------------------------------------------------------------------
30 // check inputs and get the descriptor
31 //--------------------------------------------------------------------------
32
33 GB_WHERE1 ("GxB_Matrix_export_FullC (&A, &type, &nrows, &ncols, "
34 "&Ax, &Ax_size, &is_uniform, desc)") ;
35 GB_BURBLE_START ("GxB_Matrix_export_FullC") ;
36 GB_RETURN_IF_NULL (A) ;
37 GB_RETURN_IF_NULL_OR_FAULTY (*A) ;
38 GB_GET_DESCRIPTOR (info, desc, xx1, xx2, xx3, xx4, xx5, xx6, xx7) ;
39
40 //--------------------------------------------------------------------------
41 // finish any pending work
42 //--------------------------------------------------------------------------
43
44 GB_MATRIX_WAIT (*A) ;
45 if (!GB_is_dense (*A))
46 {
47 // A must be dense or full
48 return (GrB_INVALID_VALUE) ;
49 }
50
51 //--------------------------------------------------------------------------
52 // ensure the matrix is full CSC
53 //--------------------------------------------------------------------------
54
55 // ensure the matrix is in CSC format
56 if (!((*A)->is_csc))
57 {
58 // A = A', done in-place, to put A in CSC format
59 GBURBLE ("(transpose) ") ;
60 GB_OK (GB_transpose (NULL, NULL, true, *A, // in_place_A
61 NULL, NULL, NULL, false, Context)) ;
62 GB_MATRIX_WAIT (*A) ;
63 }
64
65 GB_convert_any_to_full (*A) ;
66
67 //--------------------------------------------------------------------------
68 // export the matrix
69 //--------------------------------------------------------------------------
70
71 ASSERT (GB_IS_FULL (*A)) ;
72 ASSERT ((*A)->is_csc) ;
73 ASSERT (!GB_ZOMBIES (*A)) ;
74 ASSERT (!GB_JUMBLED (*A)) ;
75 ASSERT (!GB_PENDING (*A)) ;
76
77 int sparsity ;
78 bool is_csc ;
79
80 info = GB_export (A, type, nrows, ncols, false,
81 NULL, NULL, // Ap
82 NULL, NULL, // Ah
83 NULL, NULL, // Ab
84 NULL, NULL, // Ai
85 Ax, Ax_size, // Ax
86 NULL, NULL, NULL,
87 &sparsity, &is_csc, // full by col
88 is_uniform, Context) ;
89
90 if (info == GrB_SUCCESS)
91 {
92 ASSERT (sparsity == GxB_FULL) ;
93 ASSERT (is_csc) ;
94 }
95 GB_BURBLE_END ;
96 return (info) ;
97 }
98
99