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
|
function test41
%TEST41 test AxB
% SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2022, All Rights Reserved.
% SPDX-License-Identifier: Apache-2.0
fprintf ('\n -------------- simple GB_mex_AxB numeric tests\n') ;
rng ('default') ;
for at = [false true]
for bt = [false true]
for ct = [false true]
% create the problem
% A or A' will be 4-by-5
if (at)
A = sprand (5000, 4000, 0.01) ;
else
A = sprand (4000, 5000, 0.01) ;
end
% B or B' will be 5-by-3
if (bt)
B = sprand (3000, 5000, 0.01) ;
else
B = sprand (5000, 3000, 0.01) ;
end
% C will be 4-by-3
% C' will be 3-by-4
fprintf ('\nat %d bt %d ct %d\n', at, bt, ct) ;
fprintf ('built-in: ') ;
tic
if (at)
if (bt)
if (ct)
C = (A'*B')' ;
else
C = (A'*B') ;
end
else
if (ct)
C = (A'*B)' ;
else
C = (A'*B) ;
end
end
else
if (bt)
if (ct)
C = (A*B')' ;
else
C = (A*B') ;
end
else
if (ct)
C = (A*B)' ;
else
C = (A*B) ;
end
end
end
toc
fprintf ('GrB num: ') ;
tic
S = GB_mex_AxB (A, B, at, bt) ;
if (ct)
S = S' ;
end
toc
assert (isequal (S, C)) ;
end
end
end
fprintf ('\ntest41: all tests passed\n') ;
|