File: test112.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 (55 lines) | stat: -rw-r--r-- 1,218 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
function test112
%TEST112 test row/col scale

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

fprintf ('test112: row/col scale\n') ;

rng ('default') ;

n = 2000 ;

    D = spdiags (rand (n,1), 0, n, n) ;
    A = sprand (n, n, 0.1) ;
    B = sprand (n, n, 0.1) ;
    p = randperm (n) ;
    P = D (p,:) ;

    % both diag
    fprintf ('\nboth diag:\n') ;
    C1 = D*D ;
    C2 = GB_mex_AxB (D, D) ;
    assert (norm (C1-C2,1) < 1e-14) ;

    % row scale
    fprintf ('\nA is diag:\n') ;
    C1 = D*B ;
    C2 = GB_mex_AxB (D, B) ;
    assert (norm (C1-C2,1) < 1e-14) ;

    % col scale
    fprintf ('\nB is diag:\n') ;
    C1 = A*D ;
    C2 = GB_mex_AxB (A, D) ;
    assert (norm (C1-C2,1) < 1e-14) ;

    % regular
    fprintf ('\nneither diag:\n') ;
    C1 = A*B ;
    C2 = GB_mex_AxB (A, B) ;
    assert (norm (C1-C2,1) < 1e-14) ;

    % permute
    fprintf ('\ncol permutation:\n') ;
    C1 = A*P ;
    C2 = GB_mex_AxB (A, P) ;
    assert (norm (C1-C2,1) < 1e-14) ;

    % permute
    fprintf ('\nrow permutation:\n') ;
    C1 = P*B ;
    C2 = GB_mex_AxB (P, B) ;
    assert (norm (C1-C2,1) < 1e-14) ;

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