File: test241.m

package info (click to toggle)
suitesparse-graphblas 7.4.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 67,112 kB
  • sloc: ansic: 1,072,243; cpp: 8,081; sh: 512; makefile: 506; asm: 369; python: 125; awk: 10
file content (58 lines) | stat: -rw-r--r-- 1,858 bytes parent folder | download | duplicates (3)
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
function test241
%TEST241 test GrB_mxm: swap_rule

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

fprintf ('test241 -------- GrB_mxm swap_rule\n') ;

rng ('default') ;

monoid.opname = 'plus' ;
monoid.optype = 'double' ;
semiring.add = monoid ;
semiring.multiply = 'times' ;
semiring.class = 'double' ;

n = 10 ;
is_csc = true ;

A_csc = GB_spec_random (n, n, 0.5, 100, 'double', true) ;
B_csc = GB_spec_random (n, n, 0.5, 100, 'double', true) ;

A_csr = GB_spec_random (n, n, 0.5, 100, 'double', false) ;
B_csr = GB_spec_random (n, n, 0.5, 100, 'double', false) ;
C_csr = GB_spec_random (n, n, 0.5, 100, 'double', false) ;

% C' = A'*B'
C1 = GB_mex_mxm  (C_csr, [ ], [ ], semiring, A_csr, B_csr, [ ]) ;
C2 = GB_spec_mxm (C_csr, [ ], [ ], semiring, A_csr, B_csr, [ ]) ;
GB_spec_compare (C1, C2, 0, 1e-12) ;

% C' = A'*B
C1 = GB_mex_mxm  (C_csr, [ ], [ ], semiring, A_csr, B_csc, [ ]) ;
C2 = GB_spec_mxm (C_csr, [ ], [ ], semiring, A_csr, B_csc, [ ]) ;
GB_spec_compare (C1, C2, 0, 1e-12) ;

% C' = A*B'
C1 = GB_mex_mxm  (C_csr, [ ], [ ], semiring, A_csc, B_csr, [ ]) ;
C2 = GB_spec_mxm (C_csr, [ ], [ ], semiring, A_csc, B_csr, [ ]) ;
GB_spec_compare (C1, C2, 0, 1e-12) ;

% C' = A*B
C1 = GB_mex_mxm  (C_csr, [ ], [ ], semiring, A_csc, B_csc, [ ]) ;
C2 = GB_spec_mxm (C_csr, [ ], [ ], semiring, A_csc, B_csc, [ ]) ;
GB_spec_compare (C1, C2, 0, 1e-12) ;

% C' = A'*B, triggering the swap_rule test
n = 1000 ;
A_csr = GB_spec_random (n, n, 0.01, 100, 'double', false) ;
B_csc = GB_spec_random (n, n, 0.01, 100, 'double', true) ;
C_csr = GB_spec_random (n, n, 0.01, 100, 'double', false) ;
C1 = GB_mex_mxm  (C_csr, [ ], [ ], semiring, A_csr, B_csc, [ ]) ;
C2 = A_csr.matrix * B_csc.matrix ;
GB_spec_compare (C1, C2, 0, 1e-12) ;

GrB.burble (0) ;
fprintf ('\ntest241: all tests passed\n') ;