File: test202.m

package info (click to toggle)
suitesparse 1%3A7.10.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 254,920 kB
  • sloc: ansic: 1,134,743; cpp: 46,133; makefile: 4,875; fortran: 2,087; java: 1,826; sh: 996; ruby: 725; python: 495; asm: 371; sed: 166; awk: 44
file content (107 lines) | stat: -rw-r--r-- 3,058 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
function test202
%TEST202 test iso add and emult

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

% GB_mex_burble (1) ;
n = 10 ;
A.matrix = pi * spones (sprandn (n, n, 0.5)) ;
A.class = 'double' ;
A.iso = true ;

B.matrix = pi * spones (sprandn (n, n, 0.5)) ;
B.class = 'double' ;
B.iso = true ;

op_plus.opname = 'plus' ;
op_plus.optype = 'double' ;

op_first.opname = 'first' ;
op_first.optype = 'double' ;

op_first_single.opname = 'first' ;
op_first_single.optype = 'single' ;

op_second.opname = 'second' ;
op_second.optype = 'double' ;

op_second_single.opname = 'second' ;
op_second_single.optype = 'single' ;

op_max.opname = 'max' ;
op_max.optype = 'double' ;

op_times.opname = 'times' ;
op_times.optype = 'double' ;

op_times_single.opname = 'times' ;
op_times_single.optype = 'single' ;

for A_sparsity = [1 2 4]
    for B_sparsity = [1 2 4]

        A.sparsity = A_sparsity ;
        B.sparsity = B_sparsity ;

        Cin = sparse (n,n) ;
        C1 = GB_mex_Matrix_eWiseAdd (Cin, [ ], [ ], op_plus, A, B, [ ]) ;
        C2 = A.matrix + B.matrix ;
        err = norm (C1.matrix - C2, 1) ;
        assert (err < 1e-12) 
        assert (~C1.iso) ;

        Cin = sparse (n,n) ;
        C1 = GB_mex_Matrix_eWiseMult (Cin, [ ], [ ], op_first_single, A, B, [ ]) ;
        C2 = pi * spones (A.matrix .* B.matrix) ;
        err = norm (C1.matrix - C2, 1) ;
        assert (err < 1e-6) 
        assert (C1.iso) ;

        Cin = sparse (n,n) ;
        C1 = GB_mex_Matrix_eWiseMult (Cin, [ ], [ ], op_first, A, B, [ ]) ;
        C2 = pi * spones (A.matrix .* B.matrix) ;
        err = norm (C1.matrix - C2, 1) ;
        assert (err < 1e-12) 
        assert (C1.iso) ;

        Cin = sparse (n,n) ;
        C1 = GB_mex_Matrix_eWiseMult (Cin, [ ], [ ], op_second_single, A, B, [ ]) ;
        C2 = pi * spones (A.matrix .* B.matrix) ;
        err = norm (C1.matrix - C2, 1) ;
        assert (err < 1e-6) 
        assert (C1.iso) ;

        Cin = sparse (n,n) ;
        C1 = GB_mex_Matrix_eWiseMult (Cin, [ ], [ ], op_second, A, B, [ ]) ;
        C2 = pi * spones (A.matrix .* B.matrix) ;
        err = norm (C1.matrix - C2, 1) ;
        assert (err < 1e-12) 
        assert (C1.iso) ;

        Cin = sparse (n,n) ;
        C1 = GB_mex_Matrix_eWiseMult (Cin, [ ], [ ], op_times_single, A, B, [ ]) ;
        C2 = A.matrix .* B.matrix ;
        err = norm (C1.matrix - C2, 1) ;
        assert (err < 1e-5) 
        assert (C1.iso) ;

        Cin = sparse (n,n) ;
        C1 = GB_mex_Matrix_eWiseMult (Cin, [ ], [ ], op_times, A, B, [ ]) ;
        C2 = A.matrix .* B.matrix ;
        err = norm (C1.matrix - C2, 1) ;
        assert (err < 1e-12) 
        assert (C1.iso) ;

        Cin = sparse (n,n) ;
        C1 = GB_mex_Matrix_eWiseAdd (Cin, [ ], [ ], op_max, A, B, [ ]) ;
        C2 = max (A.matrix, B.matrix) ;
        err = norm (C1.matrix - C2, 1) ;
        assert (err < 1e-12) 
        assert (C1.iso) ;
    end
end

% GB_mex_burble (0) ;
fprintf ('test202: all tests passed\n') ;