1function test173 2%TEST173 test GrB_assign C<A>=A 3 4% SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved. 5% SPDX-License-Identifier: Apache-2.0 6 7% [~, ~, ~, types, ~, ~] = GB_spec_opsall ; 8% types = types.all ; 9 10types = { 'logical', 'double', 'double complex' } ; 11 12m = 10 ; 13n = 14 ; 14 15rng ('default') ; 16 17desc.mask = 'structural' ; 18 19for k = 1:length (types) 20 21 ctype = types {k} ; 22 fprintf ('%s, ', ctype) ; 23 24 for d = [0.5 inf] 25 26 C = GB_spec_random (m, n, d, 100, ctype) ; 27 C = GB_spec_matrix (C) ; 28 C.matrix = sparse (C.matrix) ; 29 30 A = GB_spec_random (m, n, 0.5, 100, ctype) ; 31 A.matrix = sparse (A.matrix) ; 32 A_nonzero = full (A.matrix ~= 0) ; 33 34 A_dense = GB_spec_random (m, n, inf, 100, ctype) ; 35 A_dense = GB_spec_matrix (A_dense) ; 36 A_dense.matrix = sparse (A_dense.matrix) ; 37 A_dense_nonzero = full (A_dense.matrix ~= 0) ; 38 39 for C_sparsity = 1:15 40 C.sparsity = C_sparsity ; 41 42 for A_sparsity = 1:15 43 A.sparsity = A_sparsity ; 44 A_dense.sparsity = A_sparsity ; 45 46 % C<A> = A 47 C1 = GB_mex_assign_alias_mask (C, A, [ ]) ; 48 C2 = full (C.matrix) ; 49 C2 (A_nonzero) = full (A.matrix (A_nonzero)) ; 50 err = norm (double (C2) - double (C1.matrix), 1) ; 51 assert (err == 0) ; 52 53 % C<A,struct> = A 54 B = A ; 55 B.matrix = sparse (B.matrix) ; 56 C3 = GB_mex_assign_alias_mask (C, B, desc) ; 57 err = norm (double (C2) - double (C3.matrix), 1) ; 58 assert (err == 0) ; 59 60 % C<A,struct> = A where A is dense 61 C1 = GB_mex_assign_alias_mask (C, A_dense, desc) ; 62 err = norm (double (A_dense.matrix) - double (C1.matrix), 1) ; 63 assert (err == 0) ; 64 65 % C<A> = A where A is dense 66 C1 = GB_mex_assign_alias_mask (C, A_dense, [ ]) ; 67 err = norm (double (A_dense.matrix) - double (C1.matrix), 1) ; 68 assert (err == 0) ; 69 70 end 71 end 72 end 73end 74 75fprintf ('\ntest173: all tests passed\n') ; 76 77