File: test206.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 (91 lines) | stat: -rw-r--r-- 2,360 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
function test206
%TEST206 test iso select

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

[~, ~, ~, types, ~, select_ops] = GB_spec_opsall ;
types = types.all ;

% GrB.burble (1) ;
rng ('default') ;
n = 10 ;
Cin = sparse (n,n) ;

A.matrix = spones (sprand (n, n, 0.5)) ;
A.iso = true ;

% sparse/hypersparse/bitmap case
for k2 = 1:length (select_ops)
    op = select_ops {k2} ;
    fprintf ('%s ', op) ;
    for s = [1 2 4]
        A.sparsity = s ;
        for k1 = 1:length (types)
            type = types {k1} ;
            A.class = type ;
            if (test_contains (type, 'complex'))
                continue ;
            end
            for Thunk = -1:1
                k = sparse (Thunk) ;
                C1 = GB_mex_select  (Cin, [ ], [ ], op, A, k, [ ]) ;
                C2 = GB_spec_select (Cin, [ ], [ ], op, A, k, [ ]) ;
                GB_spec_compare (C1, C2) ;
            end
        end
    end
end

% full case
A.matrix = sparse (ones (n,n)) ;
for k2 = 1:length (select_ops)
    op = select_ops {k2} ;
    fprintf ('%s ', op) ;
    for s = 8
        A.sparsity = s ;
        for k1 = 1:length (types)
            type = types {k1} ;
            A.class = type ;
            if (test_contains (type, 'complex'))
                continue ;
            end
            for Thunk = -1:1
                k = sparse (Thunk) ;
                C1 = GB_mex_select  (Cin, [ ], [ ], op, A, k, [ ]) ;
                C2 = GB_spec_select (Cin, [ ], [ ], op, A, k, [ ]) ;
                GB_spec_compare (C1, C2) ;
            end
        end
    end
end

% test iso resize
fprintf ('resize\n') ;
C1 = GB_spec_resize (A, 5, 15) ;
C2 = GB_mex_resize  (A, 5, 15) ;
GB_spec_compare (C1, C2) ;

A.class = 'double complex' ;
GB_builtin_complex_set (true) ;
C1 = GB_spec_resize (A, 5, 15) ;
C2 = GB_mex_resize  (A, 5, 15) ;
GB_spec_compare (C1, C2) ;
GB_builtin_complex_set (false) ;

% iso select with user selectop
A.class = 'double' ;
C1 = GB_mex_band (A, -2, 2) ;
C2 = triu (tril (A.matrix,2), -2) ;
assert (isequal (C1, C2)) ;

% non-iso select with user selectop (see also test27)
B = A.matrix ;
C1 = GB_mex_band (B, -2, 2) ;
C2 = triu (tril (B,2), -2) ;
assert (isequal (C1, C2)) ;

GrB.burble (0) ;
GB_builtin_complex_set (true) ;
fprintf ('\ntest206: all tests passed\n') ;