1function test41
2%TEST41 test AxB
3
4% SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved.
5% SPDX-License-Identifier: Apache-2.0
6
7fprintf ('\n -------------- simple GB_mex_AxB numeric tests\n') ;
8
9rng ('default') ;
10
11for at = [false true]
12    for bt = [false true]
13        for ct = [false true]
14
15
16                % create the problem
17
18                % A or A' will be 4-by-5
19                if (at)
20                    A = sprand (5000, 4000, 0.01) ;
21                else
22                    A = sprand (4000, 5000, 0.01) ;
23                end
24
25                % B or B' will be 5-by-3
26                if (bt)
27                    B = sprand (3000, 5000, 0.01) ;
28                else
29                    B = sprand (5000, 3000, 0.01) ;
30                end
31
32                % C will be 4-by-3
33                % C' will be 3-by-4
34
35                fprintf ('\nat %d bt %d ct %d\n', at, bt, ct) ;
36
37                fprintf ('matlab:  ') ;
38                tic
39                if (at)
40                    if (bt)
41                        if (ct)
42                            C = (A'*B')' ;
43                        else
44                            C = (A'*B') ;
45                        end
46                    else
47                        if (ct)
48                            C = (A'*B)' ;
49                        else
50                            C = (A'*B) ;
51                        end
52                    end
53                else
54                    if (bt)
55                        if (ct)
56                            C = (A*B')' ;
57                        else
58                            C = (A*B') ;
59                        end
60                    else
61                        if (ct)
62                            C = (A*B)' ;
63                        else
64                            C = (A*B) ;
65                        end
66                    end
67                end
68                toc
69
70                fprintf ('GrB num: ') ;
71                tic
72                S = GB_mex_AxB (A, B, at, bt) ;
73                if (ct)
74                    S = S' ;
75                end
76                toc
77                assert (isequal (S, C)) ;
78
79        end
80    end
81end
82
83fprintf ('\ntest41: all tests passed\n') ;
84
85