1function C = sparse (G)
2%SPARSE make a copy of a GraphBLAS sparse matrix.
3% If G is already sparse, C = sparse (G) simply makes a copy of G.
4% If G is full or bitmap, C = sparse (G) returns C as sparse or hypersparse.
5% Explicit zeros are not removed.  To remove them use C = GrB.prune(G).
6%
7% See also GrB/issparse, GrB/full, GrB.type, GrB/prune, GrB.
8
9% SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved.
10% SPDX-License-Identifier: GPL-3.0-or-later
11
12[~, sparsity] = gbformat (G.opaque) ;
13
14switch (sparsity)
15    case { 'hypersparse', 'sparse' }
16        % nothing to do; G is already sparse or hypersparse
17        C = G ;
18    case { 'bitmap', 'full' }
19        % convert G to sparse or hypersparse
20        C = GrB (G, 'sparse/hypersparse') ;
21end
22
23