1function test158
2%TEST158 test colscale (A*D) and rowscale (D*B) with positional ops
3
4% SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved.
5% SPDX-License-Identifier: Apache-2.0
6
7rng ('default') ;
8
9[binops, ~, ~, ~, ~, ~] = GB_spec_opsall ;
10pos = binops.positional ;
11pos {end+1} = 'times' ;
12pos {end+1} = 'div' ;
13
14n = 30 ;
15A = GB_spec_random (n, n, 0.05, 256, 'int64') ;
16D.matrix = speye (n) ;
17D.class = 'int64' ;
18D.pattern = logical (spones (D.matrix)) ;
19
20dnn = struct ;
21dtn = struct ('inp0', 'tran') ;
22dnt = struct ('inp1', 'tran') ;
23dtt = struct ('inp0', 'tran', 'inp1', 'tran') ;
24
25Cin = sparse (n,n) ;
26
27semiring.add = 'plus' ;
28semiring.class = 'int64' ;
29
30for c = 1:3
31
32    if (c == 1)
33        A.class = 'int32' ;
34        D.class = 'int32' ;
35        semiring.class = 'int32' ;
36    elseif (c == 2)
37        A.class = 'int64' ;
38        D.class = 'int64' ;
39        semiring.class = 'int64' ;
40    else
41        A.class = 'int32' ;
42        D.class = 'int64' ;
43        semiring.class = 'int64' ;
44    end
45
46    fprintf ('\ntypes: %s %s %s\n', D.class, A.class, semiring.class) ;
47
48    for k = 1:length(pos)
49
50        op = pos {k} ;
51        fprintf ('op: %s\n', op) ;
52        semiring.multiply = op ;
53
54        % colscale: C = A*D
55        C1 = GB_spec_mxm (Cin, [ ], [ ], semiring, A, D, [ ]) ;
56        C2 = GB_mex_mxm  (Cin, [ ], [ ], semiring, A, D, [ ]) ;
57        GB_spec_compare (C1, C2) ;
58
59        % rowscale: C = D*A
60        C1 = GB_spec_mxm (Cin, [ ], [ ], semiring, D, A, [ ]) ;
61        C2 = GB_mex_mxm  (Cin, [ ], [ ], semiring, D, A, [ ]) ;
62        GB_spec_compare (C1, C2) ;
63
64        % colscale: C = A'*D
65        C1 = GB_spec_mxm (Cin, [ ], [ ], semiring, A, D, dtn) ;
66        C2 = GB_mex_mxm  (Cin, [ ], [ ], semiring, A, D, dtn) ;
67        GB_spec_compare (C1, C2) ;
68
69        % colscale: C = D'*A
70        C1 = GB_spec_mxm (Cin, [ ], [ ], semiring, D, A, dtn) ;
71        C2 = GB_mex_mxm  (Cin, [ ], [ ], semiring, D, A, dtn) ;
72        GB_spec_compare (C1, C2) ;
73
74        % rowscale: C = D*A'
75        C1 = GB_spec_mxm (Cin, [ ], [ ], semiring, D, A, dnt) ;
76        C2 = GB_mex_mxm  (Cin, [ ], [ ], semiring, D, A, dnt) ;
77        GB_spec_compare (C1, C2) ;
78
79        % rowscale: C = A*D'
80        C1 = GB_spec_mxm (Cin, [ ], [ ], semiring, A, D, dnt) ;
81        C2 = GB_mex_mxm  (Cin, [ ], [ ], semiring, A, D, dnt) ;
82        GB_spec_compare (C1, C2) ;
83
84        % colscale: C = A'*D'
85        C1 = GB_spec_mxm (Cin, [ ], [ ], semiring, A, D, dtt) ;
86        C2 = GB_mex_mxm  (Cin, [ ], [ ], semiring, A, D, dtt) ;
87        GB_spec_compare (C1, C2) ;
88
89        % rowscale: C = D'*B'
90        C1 = GB_spec_mxm (Cin, [ ], [ ], semiring, D, A, dtt) ;
91        C2 = GB_mex_mxm  (Cin, [ ], [ ], semiring, D, A, dtt) ;
92        GB_spec_compare (C1, C2) ;
93
94    end
95
96end
97fprintf ('\ntest158: all tests passed\n') ;
98
99