1function test106
2%TEST106 GxB_subassign with alias
3
4% SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved.
5% SPDX-License-Identifier: Apache-2.0
6
7rng 'default'
8fprintf ('\ntest106: GxB_subassign with alias\n') ;
9
10for m = [0 1 5 100]
11    for n = [0 1 5 100]
12        I1 = randperm (m) ;
13        J1 = randperm (n) ;
14        I0 = uint64 (I1) - 1 ;
15        J0 = uint64 (J1) - 1 ;
16        for d = [0 0.1 0.5 1]
17            for is_csc = 0:1
18                for is_hyper = 0:1
19
20                    if (is_hyper)
21                        hyper_switch = 1 ;
22                    else
23                        hyper_switch = 0 ;
24                    end
25
26                    A = GB_spec_random (m, n, d, 100, 'double', ...
27                        is_csc, is_hyper, hyper_switch) ;
28                    B = GB_spec_random (m, n, d, 100, 'double', ...
29                        is_csc, is_hyper, hyper_switch) ;
30                    C = GB_spec_random (m, n, d, 100, 'double', ...
31                        is_csc, is_hyper, hyper_switch) ;
32                    M = GB_spec_random (m, n, d, 100, 'double', ...
33                        is_csc, is_hyper, hyper_switch) ;
34
35                    C1a = GB_mex_subassign  (C, [ ], [ ],  C,  I0, J0, [ ]) ;
36                    C2  = GB_spec_subassign (C, [ ], [ ],  C,  I1, J1, [ ], 0) ;
37                    GB_spec_compare (C1a, C2) ;
38                    C1b = GB_mex_subassign  (C, [ ], [ ], 'C', I0, J0, [ ]) ;
39                    GB_spec_compare (C1b, C2) ;
40
41                    C1a = GB_mex_subassign  (C,  C,  [ ], A, I0, J0, [ ]) ;
42                    C2  = GB_spec_subassign (C,  C,  [ ], A, I1, J1, [ ], 0) ;
43                    GB_spec_compare (C1a, C2) ;
44                    C1b = GB_mex_subassign  (C, 'C', [ ], A, I0, J0, [ ]) ;
45                    GB_spec_compare (C1b, C2) ;
46
47                end
48            end
49        end
50    end
51end
52
53fprintf ('\ntest106: all tests passed\n') ;
54
55