File: test180.m

package info (click to toggle)
suitesparse 1%3A7.10.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, trixie
  • size: 254,920 kB
  • sloc: ansic: 1,134,743; cpp: 46,133; makefile: 4,875; fortran: 2,087; java: 1,826; sh: 996; ruby: 725; python: 495; asm: 371; sed: 166; awk: 44
file content (147 lines) | stat: -rw-r--r-- 5,445 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
function test180
%TEST180 subassign and assign

% SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2025, All Rights Reserved.
% SPDX-License-Identifier: Apache-2.0

% For test coverage, this test must be run with 1 thread

fprintf ('test180: --------------------------------- assign\n') ;

n = 20 ;
rng ('default') ;

Cin = GB_spec_random (n, n, 0.5, 1, 'double') ;
m = 6 ;
I1 = [2 3 5 1 9 11]' ;
J1 = [4 5 1 9 2 12]' ;
I0 = uint64 (I1) - 1 ;
J0 = uint64 (J1) - 1 ;
I32 = uint32 (I0) ;
J32 = uint32 (J0) ;
M1.matrix = logical (sprand (m, m, 0.5)) ;
M2.matrix = logical (sprand (n, n, 0.5)) ;
A = GB_spec_random (m, m, 0.8, 1, 'double') ;

dr = struct ('outp', 'replace') ;
dc = struct ('mask', 'complement') ;
drc = struct ('outp', 'replace', 'mask', 'complement') ;

for c = 1:15
    Cin.sparsity = c ;
    fprintf ('.') ;
    for a = 1:15
        A.sparsity = a ;

        % C(I,J) = A
        C1 = GB_spec_subassign (Cin, [ ], [ ], A, I1, J1, [ ], false) ;
        C2 = GB_mex_subassign  (Cin, [ ], [ ], A, I0, J0, [ ]) ;
        GB_spec_compare (C1, C2) ;

        % C(I,J) = A, with GrB_Vectors for I and J (64,64)
        C2 = GB_mex_subassign  (Cin, [ ], [ ], A, I0, J0, [ ], 3) ;
        GB_spec_compare (C1, C2) ;

        % C(I,J) = A, with GrB_Vectors for I and J (32,64)
        C2 = GB_mex_subassign  (Cin, [ ], [ ], A, I32, J0, [ ], 3) ;
        GB_spec_compare (C1, C2) ;

        % C(I,J) = A, with GrB_Vectors for I and J (64,32)
        C2 = GB_mex_subassign  (Cin, [ ], [ ], A, I0, J32, [ ], 3) ;
        GB_spec_compare (C1, C2) ;

        % C(I,J) = A, with GrB_Vectors for I and J (32,32)
        C2 = GB_mex_subassign  (Cin, [ ], [ ], A, I32, J32, [ ], 3) ;
        GB_spec_compare (C1, C2) ;

        for ms = [2 4]
            M1.sparsity = ms ;
            M2.sparsity = ms ;

            % C(I,J)<M> = A
            C1 = GB_spec_subassign (Cin, M1, [ ], A, I1, J1, [ ], false) ;
            C2 = GB_mex_subassign  (Cin, M1, [ ], A, I0, J0, [ ]) ;
            GB_spec_compare (C1, C2) ;

            % C(I,J)<M> = A, with GrB_Vectors for I and J (64,64)
            C2 = GB_mex_subassign  (Cin, M1, [ ], A, I0, J0, [ ], 3) ;
            GB_spec_compare (C1, C2) ;

            % C<M,repl>(I,J) = A
            C1 = GB_spec_assign (Cin, M2, [ ], A, I1, J1, dr, false) ;
            C2 = GB_mex_assign  (Cin, M2, [ ], A, I0, J0, dr) ;
            GB_spec_compare (C1, C2) ;

            % C<M,repl>(I,J) = A, using GrB_Vectors for I and J (64,64)
            C2 = GB_mex_assign  (Cin, M2, [ ], A, I0, J0, dr, 3) ;
            GB_spec_compare (C1, C2) ;

            % C<M,repl>(I,J) = A, using GrB_Vectors for I and J (32,64)
            C2 = GB_mex_assign  (Cin, M2, [ ], A, I32, J0, dr, 3) ;
            GB_spec_compare (C1, C2) ;

            % C<M,repl>(I,J) = A, using GrB_Vectors for I and J (64,32)
            C2 = GB_mex_assign  (Cin, M2, [ ], A, I0, J32, dr, 3) ;
            GB_spec_compare (C1, C2) ;

            % C<M,repl>(I,J) = A, using GrB_Vectors for I and J (32,32)
            C2 = GB_mex_assign  (Cin, M2, [ ], A, I32, J32, dr, 3) ;
            GB_spec_compare (C1, C2) ;

            % C<!M,repl>(I,J) = A
            C1 = GB_spec_assign (Cin, M2, [ ], A, I1, J1, drc, false) ;
            C2 = GB_mex_assign  (Cin, M2, [ ], A, I0, J0, drc) ;
            GB_spec_compare (C1, C2) ;

            % C<!M,repl>(I,J) = A, using GrB_Vectors for I and J (64,64)
            C2 = GB_mex_assign  (Cin, M2, [ ], A, I0, J0, drc, 3) ;
            GB_spec_compare (C1, C2) ;

            % C<!M,repl>(I,J) = A, using GrB_Vectors for I and J (32,64)
            C2 = GB_mex_assign  (Cin, M2, [ ], A, I32, J0, drc, 3) ;
            GB_spec_compare (C1, C2) ;

            % C<!M,repl>(I,J) = A, using GrB_Vectors for I and J (64,32)
            C2 = GB_mex_assign  (Cin, M2, [ ], A, I0, J32, drc, 3) ;
            GB_spec_compare (C1, C2) ;

            % C<!M,repl>(I,J) = A, using GrB_Vectors for I and J (32,32)
            C2 = GB_mex_assign  (Cin, M2, [ ], A, I32, J32, drc, 3) ;
            GB_spec_compare (C1, C2) ;

            % C(I,J)<M,repl> = A
            C1 = GB_spec_subassign (Cin, M1, [ ], A, I1, J1, dr, false) ;
            C2 = GB_mex_subassign  (Cin, M1, [ ], A, I0, J0, dr) ;
            GB_spec_compare (C1, C2) ;

            % C(I,J)<M,repl> += A
            C1 = GB_spec_subassign (Cin, M1, 'plus', A, I1, J1, dr, false) ;
            C2 = GB_mex_subassign  (Cin, M1, 'plus', A, I0, J0, dr) ;
            GB_spec_compare (C1, C2) ;

            % C(I,J)<M,repl> = scalar
            C1 = GB_spec_subassign (Cin, M1, [ ], 3, I1, J1, dr, true) ;
            C2 = GB_mex_subassign  (Cin, M1, [ ], 3, I0, J0, dr) ;
            GB_spec_compare (C1, C2) ;

            % C(I,J)<!M> = scalar
            C1 = GB_spec_subassign (Cin, M1, [ ], 3, I1, J1, dc, true) ;
            C2 = GB_mex_subassign  (Cin, M1, [ ], 3, I0, J0, dc) ;
            GB_spec_compare (C1, C2) ;

            % C(I,J)<!M> += scalar
            C1 = GB_spec_subassign (Cin, M1, 'plus', 3, I1, J1, dc, true) ;
            C2 = GB_mex_subassign  (Cin, M1, 'plus', 3, I0, J0, dc) ;
            GB_spec_compare (C1, C2) ;

            % C(I,J)<!M,repl> += scalar
            C1 = GB_spec_subassign (Cin, M1, 'plus', 3, I1, J1, drc, true) ;
            C2 = GB_mex_subassign  (Cin, M1, 'plus', 3, I0, J0, drc) ;
            GB_spec_compare (C1, C2) ;
        end

    end
end

fprintf ('\ntest180: all tests passed\n') ;