1function test193 2%TEST193 test GxB_Matrix_diag 3 4% SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved. 5% SPDX-License-Identifier: Apache-2.0 6 7fprintf ('test193 ----------- C = diag (v,k)\n') ; 8 9[~, ~, ~, types, ~, ~] = GB_spec_opsall ; 10types = types.all ; 11 12rng ('default') ; 13 14n = 20 ; 15 16for d = [1e-4 0.01 0.2 0.8 inf] 17 fprintf ('\nd = %g\n', d) ; 18 for ka = 1:length (types) 19 vtype = types {ka} ; 20 V = GB_spec_random (n, 1, d, 128, vtype) ; 21 for sparsity_control = [2 4 8] 22 fprintf ('.') ; 23 V.sparsity = sparsity_control ; 24 V.is_csc = true ; 25 for kc = 1:length (types) 26 ctype = types {kc} ; 27 for k = [-10 -2 0 3 30] 28 for csc = 0:1 29 C2 = GB_spec_mdiag (V, k, ctype) ; 30 C1 = GB_mex_mdiag (V, k, ctype, csc) ; 31 GB_spec_compare (C1, C2) ; 32 end 33 end 34 end 35 end 36 end 37end 38 39fprintf ('\n') ; 40fprintf ('test193: all tests passed\n') ; 41 42