1function test157 2%TEST157 test sparsity formats 3 4% SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved. 5% SPDX-License-Identifier: Apache-2.0 6 7rng ('default') ; 8 9[~, ~, ~, types, ~, ~] = GB_spec_opsall ; 10types = types.all ; 11 12for k1 = 1:length(types) 13 in_type = types {k1} ; 14 A = GB_spec_random (5, 5, 0.5, 10, in_type) ; 15 16 for sparsity_control = 0:15 17 A.sparsity = sparsity_control ; 18 C = GB_mex_dump (A, 2) ; 19 GB_spec_compare (C, A) ; 20 end 21 22 % try a full matrix 23 A.matrix = 10 * rand (5, 5) ; 24 A.pattern = true (5, 5) ; 25 26 for sparsity_control = 0:15 27 A.sparsity = sparsity_control ; 28 C = GB_mex_dump (A, 2) ; 29 GB_spec_compare (C, A) ; 30 end 31 32 % try a very sparse matrix 33 A = GB_spec_random (50, 50, 0.002, 10, in_type) ; 34 for is_hyper = 0:1 35 A.is_hyper = is_hyper ; 36 for sparsity_control = 0:15 37 A.sparsity = sparsity_control ; 38 C = GB_mex_dump (A, 2) ; 39 GB_spec_compare (C, A) ; 40 end 41 end 42end 43 44A = GrB (rand (40)) ; 45A (1,1) = sparse (0) 46 47fprintf ('test157: all tests passed\n') ; 48 49