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
|
function test159
%TEST159 test dot and saxpy with positional ops
% SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2022, All Rights Reserved.
% SPDX-License-Identifier: Apache-2.0
rng ('default') ;
[binops, ~, ~, ~, ~, ~] = GB_spec_opsall ;
pos = binops.positional ;
pos {end+1} = 'times' ;
pos {end+1} = 'div' ;
pos {end+1} = 'first' ;
pos {end+1} = 'second' ;
n = 10 ;
A = GB_spec_random (n, n, 0.05, 256, 'int64') ;
B = GB_spec_random (n, n, 0.05, 256, 'int64') ;
dnn = struct ;
dtn = struct ('inp0', 'tran') ;
dnt = struct ('inp1', 'tran') ;
dtt = struct ('inp0', 'tran', 'inp1', 'tran') ;
Cin = sparse (n,n) ;
semiring.add = 'plus' ;
A.class = 'int32' ;
B.class = 'double' ;
for c = 1:4
if (c == 1 || c == 2)
dnn.axb = 'saxpy' ;
dtn.axb = 'saxpy' ;
dnt.axb = 'saxpy' ;
dtt.axb = 'saxpy' ;
else
dnn.axb = 'dot' ;
dtn.axb = 'dot' ;
dnt.axb = 'dot' ;
dtt.axb = 'dot' ;
end
if (c == 1 || c == 3)
semiring.class = 'int64' ;
else
semiring.class = 'int32' ;
end
fprintf ('\ntypes: %s %s %s\n', A.class, B.class, semiring.class) ;
for k = 1:length(pos)
op = pos {k} ;
fprintf ('op: %s\n', op) ;
semiring.multiply = op ;
% C = A*B
C1 = GB_spec_mxm (Cin, [ ], [ ], semiring, A, B, dnn) ;
C2 = GB_mex_mxm (Cin, [ ], [ ], semiring, A, B, dnn) ;
C3 = GB_mex_mxm_generic (Cin, [ ], [ ], semiring, A, B, dnn) ;
GB_spec_compare (C1, C2) ;
GB_spec_compare (C1, C3) ;
% C = A'*B
C1 = GB_spec_mxm (Cin, [ ], [ ], semiring, A, B, dtn) ;
C2 = GB_mex_mxm (Cin, [ ], [ ], semiring, A, B, dtn) ;
C3 = GB_mex_mxm_generic (Cin, [ ], [ ], semiring, A, B, dtn) ;
GB_spec_compare (C1, C2) ;
GB_spec_compare (C1, C3) ;
% C = B*B'
C1 = GB_spec_mxm (Cin, [ ], [ ], semiring, B, A, dnt) ;
C2 = GB_mex_mxm (Cin, [ ], [ ], semiring, B, A, dnt) ;
C3 = GB_mex_mxm_generic (Cin, [ ], [ ], semiring, B, A, dnt) ;
GB_spec_compare (C1, C2) ;
GB_spec_compare (C1, C3) ;
% C = A'*B'
C1 = GB_spec_mxm (Cin, [ ], [ ], semiring, A, B, dtt) ;
C2 = GB_mex_mxm (Cin, [ ], [ ], semiring, A, B, dtt) ;
C3 = GB_mex_mxm_generic (Cin, [ ], [ ], semiring, A, B, dtt) ;
GB_spec_compare (C1, C2) ;
GB_spec_compare (C1, C3) ;
% C = B'*A
C1 = GB_spec_mxm (Cin, [ ], [ ], semiring, B, A, dtt) ;
C2 = GB_mex_mxm (Cin, [ ], [ ], semiring, B, A, dtt) ;
C3 = GB_mex_mxm_generic (Cin, [ ], [ ], semiring, B, A, dtt) ;
GB_spec_compare (C1, C2) ;
GB_spec_compare (C1, C3) ;
end
end
fprintf ('\ntest159: all tests passed\n') ;
|