File: test202.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 (99 lines) | stat: -rw-r--r-- 2,532 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
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
function test202
%TEST202 test iso add and emult

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

% GrB.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' ;

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) ;

% GrB.burble (0) ;
fprintf ('test202: all tests passed\n') ;