1function test84 2%TEST84 test GrB_assign (row and column with C in CSR/CSC format) 3 4% SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved. 5% SPDX-License-Identifier: Apache-2.0 6 7fprintf ('\ntest84: GrB_assign with row/col assignments\n') ; 8 9rng ('default') ; 10m = 10 ; 11n = 20 ; 12 13% create a CSR matrix 14C0 = GB_spec_random (m, n, 0.5, 100, 'double', false, false) ; 15 16Acol = sprandn (4, 1, 0.5) ; 17Arow = sprandn (4, 1, 0.5) ; 18 19J = [3 4 5 6] ; 20J0 = uint64 (J) - 1 ; 21I = 2 ; 22I0 = uint64 (I) - 1 ; 23 24for trial = 1:2 25 26 clear Mrow Mcol 27 if (trial == 1) 28 Mcol.matrix = sparse (ones (m,1)) ; % spones (sprandn (m, 1, 0.5)) ; 29 Mrow.matrix = sparse (ones (n,1)) ; % spones (sprandn (n, 1, 0.5)) ; 30 else 31 Mcol.matrix = spones (sprandn (m, 1, 0.5)) ; 32 Mrow.matrix = spones (sprandn (n, 1, 0.5)) ; 33 end 34 35 for M_sparsity = [1 2 4 8] 36 37 Mrow.sparsity = M_sparsity ; 38 Mcol.sparsity = M_sparsity ; 39 40 for sparsity_control = 1:15 41 fprintf ('.') ; 42 C0.sparsity = sparsity_control ; 43 for csc = 0:1 44 C0.is_csc = csc ; 45 46 % row assign 47 C1 = GB_mex_assign (C0, Mrow, 'plus', Arow, I0, J0, [], 2); 48 C2 = GB_spec_Row_assign (C0, Mrow, 'plus', Arow, I, J, []) ; 49 GB_spec_compare (C1, C2) ; 50 51 % col assign 52 C1 = GB_mex_assign (C0, Mcol, 'plus', Acol, J0, I0, [], 1); 53 C2 = GB_spec_Col_assign (C0, Mcol, 'plus', Acol, J, I, [ ]) ; 54 GB_spec_compare (C1, C2) ; 55 56 % row assign, no accum 57 C1 = GB_mex_assign (C0, Mrow, [ ], Arow, I0, J0, [ ], 2) ; 58 C2 = GB_spec_Row_assign (C0, Mrow, [ ], Arow, I, J, [ ]) ; 59 GB_spec_compare (C1, C2) ; 60 61 % col assign, no accum 62 C1 = GB_mex_assign (C0, Mcol, [ ], Acol, J0, I0, [ ], 1) ; 63 C2 = GB_spec_Col_assign (C0, Mcol, [ ], Acol, J, I, [ ]) ; 64 GB_spec_compare (C1, C2) ; 65 66 end 67 end 68 end 69end 70 71fprintf ('\ntest84: all tests passed\n') ; 72 73