File: test181.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 (67 lines) | stat: -rw-r--r-- 1,950 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
function test181
%TEST181 test transpose with explicit zeros in the Mask

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

% see also test99

rng ('default') ;

fprintf ('test181: transpose with explicit zeros in the Mask\n') ;

masks = { '', 'complement', 'structural', 'structural complement' } ;
repls = { '', 'replace' } ;

for n = 10:20
    for d = 0:.1:1
        fprintf ('.') ;
        for k = 1:10

            C = sprand (n, n, 0.1) ;
            A = GB_spec_random (n, n, 0.1) ;
            A.sparsity = 4 ;
            if (d == 1)
                Mask = sparse (rand (n)) ;
            else
                Mask = sprand (n, n, d) ;
            end
            if (nnz (Mask) > 0)
                [i j x] = find (Mask) ;
                nz = length (x) ;
                p = randperm (nz, floor(nz/2)) ;
                x (p) = 0 ;
                i = uint64 (i-1) ;
                j = uint64 (j-1) ;
                Mask = GB_mex_Matrix_build (i,j,x,n,n,[]) ;
                Mask = Mask.matrix ;
            end

            for k1 = 1:length(masks)
                for k2 = 1:2

                    clear desc
                    desc.inp0 = 'tran' ;
                    if (~isempty (masks {k1}))
                        desc.mask = masks {k1} ;
                    end
                    if (~isempty (repls {k2}))
                        desc.outp = repls {k2} ;
                    end

                    C2 = GB_spec_transpose (C, Mask, [], A, desc) ;
                    C3 = GB_mex_transpose  (C, Mask, [], A, desc) ;
                    GB_spec_compare (C2, C3) ;

                    C2 = GB_spec_transpose (C, Mask, [], C, desc) ;
                    C3 = GB_mex_transpose  (C, Mask, [], C, desc) ;
                    GB_spec_compare (C2, C3) ;

                end
            end
        end
    end
end

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