File: test10_compare.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 (71 lines) | stat: -rw-r--r-- 1,884 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
62
63
64
65
66
67
68
69
70
71
function test10_compare (op, C1, C2, tol)
%TEST10_COMPARE check results for test10
%
% Compare results for test10, results from unary operators.
% Usage: test10_compare (op, C1, C2, tol) ;
%
% acos, asin, and other a* trig functions can return different but valid
% results.

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

C1 = GB_spec_matrix (C1, 0) ;
C2 = GB_spec_matrix (C2, 0) ;
assert (isequal (C1.pattern, C2.pattern)) ;

[i,j,x] = find (C2.matrix) ;
[m,n] = size (C2.matrix) ;
x = ones (size (x)) ;
S = sparse (i,j,x,m,n) ;

C1.matrix = double (C1.matrix) ;
if (isequal (C1.class, 'single complex'))
    C1.class = 'double complex' ;
else
    C1.class = 'double' ;
end

C2.matrix = double (C2.matrix) ;
if (isequal (C2.class, 'single complex'))
    C2.class = 'double complex' ;
else
    C2.class = 'double' ;
end

switch (op.opname)

    case { 'acos' }
        C1.matrix = cos (C1.matrix) .* S ;
        C2.matrix = cos (C2.matrix) .* S ;
        GB_spec_compare (C1, C2, 0, tol) ;

    case { 'asin' }
        C1.matrix = sin (C1.matrix) .* S ;
        C2.matrix = sin (C2.matrix) .* S ;
        GB_spec_compare (C1, C2, 0, tol) ;

    case { 'atan' }
        C1.matrix = tan (C1.matrix) .* S ;
        C2.matrix = tan (C2.matrix) .* S ;
        GB_spec_compare (C1, C2, 0, tol) ;

    case { 'acosh' }
        C1.matrix = cosh (C1.matrix) .* S ;
        C2.matrix = cosh (C2.matrix) .* S ;
        GB_spec_compare (C1, C2, 0, tol) ;

    case { 'asinh' }
        C1.matrix = sinh (C1.matrix) .* S ;
        C2.matrix = sinh (C2.matrix) .* S ;
        GB_spec_compare (C1, C2, 0, tol) ;

    case { 'atanh' }
        C1.matrix = tanh (C1.matrix) .* S ;
        C2.matrix = tanh (C2.matrix) .* S ;
        GB_spec_compare (C1, C2, 0, tol) ;

    otherwise
        GB_spec_compare (C1, C2, 0, tol) ;
end