File: test169.m

package info (click to toggle)
suitesparse 1%3A7.11.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 258,172 kB
  • sloc: ansic: 1,153,566; cpp: 48,145; makefile: 4,997; fortran: 2,087; java: 1,826; sh: 1,113; ruby: 725; python: 676; asm: 371; sed: 166; awk: 44
file content (54 lines) | stat: -rw-r--r-- 1,483 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
function test169
%TEST169 C<M>=A+B with different sparsity formats

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

rng ('default') ;

fprintf ('test169:\n') ;

n = 50 ;

desc = struct ('mask', 'complement') ;

for trial = 1:5

    C = GB_spec_random (n, n, 0.5, 1, 'double') ;
    M = GB_spec_random (n, n, 0.2, 1, 'double') ;
    A = GB_spec_random (n, n, 0.5, 1, 'double') ;
    B = GB_spec_random (n, n, 0.5, 1, 'double') ;

    % test the no_hyper_hash cases
    A.no_hyper_hash = true ;
    C.no_hyper_hash = true ;
    B.no_hyper_hash = true ;

    for C_sparsity = [1 2 4 8]
        C.sparsity = C_sparsity ;

        for M_sparsity = [1 2 4 8]
            M.sparsity = M_sparsity ;

            for A_sparsity = [1 2 4 8]
                A.sparsity = A_sparsity ;

                for B_sparsity = [1 2 4 8]
                    B.sparsity = B_sparsity ;

                    C1 = GB_spec_Matrix_eWiseAdd (C, M, [], 'plus', A, B, desc);
                    C2 = GB_mex_Matrix_eWiseAdd  (C, M, [], 'plus', A, B, desc);
                    GB_spec_compare (C1, C2) ;

                    C1 = GB_spec_Matrix_eWiseAdd (C, M, [], 'plus', A, B, [ ]) ;
                    C2 = GB_mex_Matrix_eWiseAdd  (C, M, [], 'plus', A, B, [ ]) ;
                    GB_spec_compare (C1, C2) ;
                end
            end
        end
        fprintf ('.') ;
    end
end

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