1function test50
2%TEST50 test AxB numeric and symbolic
3
4% SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved.
5% SPDX-License-Identifier: Apache-2.0
6
7fprintf ('\n----------------------------- GB_mex_AxB\n') ;
8
9% Prob = ssget (2662) ;
10Prob = ssget (936)
11A = Prob.A ;
12A(1,2) = 443 ;
13
14for trial = 1:2
15
16    if (trial == 1)
17        B = A ;
18    else
19        % make it rectangular
20        [m k] = size (A) ;
21        A = A (:,1:k-1) ;
22        [m k] = size (A) ;
23        nz = nnz (A) ;
24        n = m+1 ;
25        B = sprand (k, n, nz / (k*n)) ;
26    end
27
28    fprintf ('\n---------------matlab: C=A*B\n') ;
29    tic ;
30    C = (A*B) ;
31    toc
32    C0 = cast (C, 'logical') ;
33    cnorm = norm (C, 1) ;
34    fprintf ('nnz(C) %d density %g mincol %d maxcol %d norm %g\n', ...
35        nnz (C0), nnz (C0) / prod (size (C0)), ...
36        full (min (sum (spones (C0)))), ...
37        full (max (sum (spones (C0)))), cnorm) ;
38    % figure (1)
39    % subplot (1,3,1) ; spy (A) ;
40    % subplot (1,3,2) ; spy (B) ;
41    % subplot (1,3,3) ; spy (C) ;
42
43    fprintf ('numerical matrix multiply (GraphBLAS):\n') ;
44    tic
45    S = GB_mex_AxB (A, B) ;
46    toc
47    assert (GB_spok (S*1) == 1) ;
48    err = norm (C-S,1) / cnorm ;
49    fprintf ('err %g\n', err) ;
50    assert (isequal (C, S)) ;
51
52    fprintf ('\n---------------matlab: C=(A*B)''\n') ;
53    tic ;
54    C = (A*B)' ;
55    toc
56    C0 = cast (C, 'logical') ;
57
58end
59
60fprintf ('\ntest50: all tests passed\n') ;
61
62