File: test50.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 (61 lines) | stat: -rw-r--r-- 1,450 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
59
60
61
function test50
%TEST50 test AxB numeric and symbolic

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

fprintf ('\n----------------------------- GB_mex_AxB\n') ;

% Prob = ssget (2662) ;
Prob = ssget (936)
A = Prob.A ;
A(1,2) = 443 ;

for trial = 1:2

    if (trial == 1)
        B = A ;
    else
        % make it rectangular
        [m k] = size (A) ;
        A = A (:,1:k-1) ;
        [m k] = size (A) ;
        nz = nnz (A) ;
        n = m+1 ;
        B = sprand (k, n, nz / (k*n)) ;
    end

    fprintf ('\n---------------builtin: C=A*B\n') ;
    tic ;
    C = (A*B) ;
    toc
    C0 = cast (C, 'logical') ;
    cnorm = norm (C, 1) ;
    fprintf ('nnz(C) %d density %g mincol %d maxcol %d norm %g\n', ...
        nnz (C0), nnz (C0) / prod (size (C0)), ...
        full (min (sum (spones (C0)))), ...
        full (max (sum (spones (C0)))), cnorm) ;
    % figure (1)
    % subplot (1,3,1) ; spy (A) ;
    % subplot (1,3,2) ; spy (B) ;
    % subplot (1,3,3) ; spy (C) ;

    fprintf ('numerical matrix multiply (GraphBLAS):\n') ;
    tic
    S = GB_mex_AxB (A, B) ;
    toc
    assert (GB_spok (S*1) == 1) ;
    err = norm (C-S,1) / cnorm ;
    fprintf ('err %g\n', err) ;
    assert (isequal (C, S)) ;

    fprintf ('\n---------------builtin: C=(A*B)''\n') ;
    tic ;
    C = (A*B)' ;
    toc
    C0 = cast (C, 'logical') ;

end

fprintf ('\ntest50: all tests passed\n') ;