1 //------------------------------------------------------------------------------
2 // GxB_Vector_export_CSC: export a vector in CSC format
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_CSC(GrB_Vector * v,GrB_Type * type,GrB_Index * n,GrB_Index ** vi,void ** vx,GrB_Index * vi_size,GrB_Index * vx_size,bool * is_uniform,GrB_Index * nvals,bool * jumbled,const GrB_Descriptor desc)14 GrB_Info GxB_Vector_export_CSC // export and free a CSC 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 GrB_Index **vi, // indices
21 void **vx, // values
22 GrB_Index *vi_size, // size of Ai in bytes
23 GrB_Index *vx_size, // size of Ax in bytes
24 bool *is_uniform, // if true, v has uniform values (TODO:::unsupported)
25
26 GrB_Index *nvals, // # of entries in vector
27 bool *jumbled, // if true, indices may be unsorted
28 const GrB_Descriptor desc
29 )
30 {
31
32 //--------------------------------------------------------------------------
33 // check inputs
34 //--------------------------------------------------------------------------
35
36 GB_WHERE1 ("GxB_Vector_export_CSC (&v, &type, &n, "
37 "&vi, &vx, &vi_size, &vx_size, &is_uniform, &nvals, &jumbled, desc)") ;
38 GB_BURBLE_START ("GxB_Vector_export_CSC") ;
39 GB_GET_DESCRIPTOR (info, desc, xx1, xx2, xx3, xx4, xx5, xx6, xx7) ;
40 GB_RETURN_IF_NULL (v) ;
41 GB_RETURN_IF_NULL_OR_FAULTY (*v) ;
42 GB_RETURN_IF_NULL (nvals) ;
43 ASSERT_VECTOR_OK (*v, "v to export", GB0) ;
44
45 //--------------------------------------------------------------------------
46 // finish any pending work
47 //--------------------------------------------------------------------------
48
49 if (jumbled == NULL)
50 {
51 // the exported vector cannot be jumbled
52 GB_MATRIX_WAIT (*v) ;
53 }
54 else
55 {
56 // the exported vector is allowed to be jumbled
57 GB_MATRIX_WAIT_IF_PENDING_OR_ZOMBIES (*v) ;
58 }
59
60 //--------------------------------------------------------------------------
61 // ensure the vector is sparse
62 //--------------------------------------------------------------------------
63
64 GB_OK (GB_convert_any_to_sparse ((GrB_Matrix) *v, Context)) ;
65
66 //--------------------------------------------------------------------------
67 // export the vector
68 //--------------------------------------------------------------------------
69
70 ASSERT (GB_IS_SPARSE (*v)) ;
71 ASSERT ((*v)->is_csc) ;
72 ASSERT (!GB_ZOMBIES (*v)) ;
73 ASSERT (GB_IMPLIES (jumbled == NULL, !GB_JUMBLED (*v))) ;
74 ASSERT (!GB_PENDING (*v)) ;
75
76 int sparsity ;
77 bool is_csc ;
78 GrB_Index vdim ;
79
80 info = GB_export ((GrB_Matrix *) v, type, n, &vdim, true,
81 NULL, NULL, // Ap
82 NULL, NULL, // Ah
83 NULL, NULL, // Ab
84 vi, vi_size, // Ai
85 vx, vx_size, // Ax
86 nvals, jumbled, NULL, // jumbled or not
87 &sparsity, &is_csc, // sparse by col
88 is_uniform, Context) ;
89
90 if (info == GrB_SUCCESS)
91 {
92 ASSERT (sparsity == GxB_SPARSE) ;
93 ASSERT (is_csc) ;
94 ASSERT (vdim == 1) ;
95 }
96 GB_BURBLE_END ;
97 return (info) ;
98 }
99
100