1function test10_compare (op, C1, C2, tol)
2%TEST10_COMPARE check results for test10
3%
4% Compare results for test10, results from unary operators.
5% Usage: test10_compare (op, C1, C2, tol) ;
6%
7% acos, asin, and other a* trig functions can return different but valid
8% results.
9
10% SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved.
11% SPDX-License-Identifier: Apache-2.0
12
13C1 = GB_spec_matrix (C1, 0) ;
14C2 = GB_spec_matrix (C2, 0) ;
15assert (isequal (C1.pattern, C2.pattern)) ;
16
17[i,j,x] = find (C2.matrix) ;
18[m,n] = size (C2.matrix) ;
19x = ones (size (x)) ;
20S = sparse (i,j,x,m,n) ;
21
22C1.matrix = double (C1.matrix) ;
23if (isequal (C1.class, 'single complex'))
24    C1.class = 'double complex' ;
25else
26    C1.class = 'double' ;
27end
28
29C2.matrix = double (C2.matrix) ;
30if (isequal (C2.class, 'single complex'))
31    C2.class = 'double complex' ;
32else
33    C2.class = 'double' ;
34end
35
36switch (op.opname)
37
38    case { 'acos' }
39        C1.matrix = cos (C1.matrix) .* S ;
40        C2.matrix = cos (C2.matrix) .* S ;
41        GB_spec_compare (C1, C2, 0, tol) ;
42
43    case { 'asin' }
44        C1.matrix = sin (C1.matrix) .* S ;
45        C2.matrix = sin (C2.matrix) .* S ;
46        GB_spec_compare (C1, C2, 0, tol) ;
47
48    case { 'atan' }
49        C1.matrix = tan (C1.matrix) .* S ;
50        C2.matrix = tan (C2.matrix) .* S ;
51        GB_spec_compare (C1, C2, 0, tol) ;
52
53    case { 'acosh' }
54        C1.matrix = cosh (C1.matrix) .* S ;
55        C2.matrix = cosh (C2.matrix) .* S ;
56        GB_spec_compare (C1, C2, 0, tol) ;
57
58    case { 'asinh' }
59        C1.matrix = sinh (C1.matrix) .* S ;
60        C2.matrix = sinh (C2.matrix) .* S ;
61        GB_spec_compare (C1, C2, 0, tol) ;
62
63    case { 'atanh' }
64        C1.matrix = tanh (C1.matrix) .* S ;
65        C2.matrix = tanh (C2.matrix) .* S ;
66        GB_spec_compare (C1, C2, 0, tol) ;
67
68    otherwise
69        GB_spec_compare (C1, C2, 0, tol) ;
70end
71
72