File: gbtest19.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 (53 lines) | stat: -rw-r--r-- 1,063 bytes parent folder | download | duplicates (2)
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
function gbtest19
%GBTEST19 test mpower

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

rng ('default') ;
A = rand (4) ;
G = GrB (A) ;
maxerr = 0 ;

for k = 0:10
    C1 = A^k ;
    C2 = G^k ;
    err = norm (C1 - C2, 1) ;
    assert (err < 1e-10) ;
    maxerr = max (maxerr, err) ;
    C1 = A.^k ;
    C2 = G.^k ;
    err = norm (C1 - C2, 1) ;
    assert (err < 1e-10) ;
    maxerr = max (maxerr, err) ;
end

a = pi ;
b = 3.7 ;
c1 = a^b ;
x = GrB (a) ;
c2 = x^b ;
err = abs (c1-c2) ;
assert (err < 1e-10) ;
maxerr = max (maxerr, err) ;

for type = { 'single', 'double' }
    I1 = complex (eye (4, type{1})) ;
    I2 = GrB (I1) ;
    C1 = I1^0 ;
    C2 = I2^0 ;
    assert (norm (C1 - C2, 1) == 0) ;
    C1 = A^0 ;
    C2 = G^0 ;
    assert (norm (C1 - C2, 1) == 0) ;
    C1 = A^1 ;
    C2 = G^1 ;
    assert (norm (C1 - C2, 1) == 0) ;
    C1 = I1^1 ;
    C2 = I2^1 ;
    assert (norm (C1 - C2, 1) == 0) ;
end

fprintf ('max error: %g\n', maxerr) ;
fprintf ('gbtest19: all tests passed\n') ;