File: test81.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 (84 lines) | stat: -rw-r--r-- 2,440 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
function test81
%TEST81 test GrB_Matrix_extract with index range, stride, & backwards

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

fprintf ('test81:  GrB_Matrix_extract with index range, stride, backwards\n') ;

rng ('default') ;

n = 10 ;
A = sprand (n, n, 0.5) ;
S = sparse (n, n) ;

Ahyper.matrix = A ;
Ahyper.is_hyper = true ;
Ahyper.is_csc = true ;

for ilo = 1:2:n
    for ihi = 1:2:n
        fprintf ('#') ;
        for i_inc = [-n:n inf]
            clear I
            I.begin = ilo-1 ;
            I.end = ihi-1 ;
            if (isfinite (i_inc))
                I.inc = i_inc ;
                iinc = i_inc ;
            else
                iinc = 1 ;
            end

            fprintf (':') ;
            for jlen = [1:2:n]
                clear J
                J = randperm (n) ;
                J = J (1:jlen) ;
                J0 = uint64 (J) - 1 ;
                C1 = A (ilo:iinc:ihi, J) ;
                [sm sn] = size (C1) ;
                S = sparse (sm, sn) ;
                C2 = GB_mex_Matrix_extract (S, [ ], [ ], A, I, J0, [ ]) ;
                assert (isequal (C1, C2.matrix)) ;
                C3 = GB_mex_Matrix_extract (S, [ ], [ ], ...
                    Ahyper, I, J0, [ ]) ;
                assert (isequal (C1, C3.matrix)) ;
            end

            fprintf ('.') ;
            for jlo = 1:2:n
                for jhi = 1:2:n
                    for j_inc = [-n:n inf]

                        clear J
                        J.begin = jlo-1 ;
                        J.end = jhi-1 ;
                        if (isfinite (j_inc))
                            J.inc = j_inc ;
                            jinc = j_inc ;
                        else
                            jinc = 1 ;
                        end

                        C1 = A (ilo:iinc:ihi, jlo:jinc:jhi) ;
                        [sm sn] = size (C1) ;
                        S = sparse (sm, sn) ;

                        C2 = GB_mex_Matrix_extract (S, [ ], [ ], A, I, J, [ ]) ;
                        assert (isequal (C1, C2.matrix)) ;

                        C3 = GB_mex_Matrix_extract (S, [ ], [ ], ...
                            Ahyper, I, J, [ ]) ;
                        assert (isequal (C1, C3.matrix)) ;

                    end
                end
            end

        end
    end
end

fprintf ('\ntest81: all tests passed\n') ;