File: test84.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 (72 lines) | stat: -rw-r--r-- 2,162 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
function test84
%TEST84 test GrB_assign (row and column with C in CSR/CSC format)

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

fprintf ('\ntest84: GrB_assign with row/col assignments\n') ;

rng ('default') ;
m = 10 ;
n = 20 ;

% create a CSR matrix
C0 = GB_spec_random (m, n, 0.5, 100, 'double', false, false) ;

Acol = sprandn (4, 1, 0.5)  ;
Arow = sprandn (4, 1, 0.5)  ;

J = [3 4 5 6] ;
J0 = uint64 (J) - 1 ;
I = 2 ;
I0 = uint64 (I) - 1 ;

for trial = 1:2

    clear Mrow Mcol
    if (trial == 1)
        Mcol.matrix = sparse (ones (m,1)) ; % spones (sprandn (m, 1, 0.5)) ;
        Mrow.matrix = sparse (ones (n,1)) ; % spones (sprandn (n, 1, 0.5)) ;
    else
        Mcol.matrix = spones (sprandn (m, 1, 0.5)) ;
        Mrow.matrix = spones (sprandn (n, 1, 0.5)) ;
    end

    for M_sparsity = [1 2 4 8] 

        Mrow.sparsity = M_sparsity ;
        Mcol.sparsity = M_sparsity ;

        for sparsity_control = 1:15
            fprintf ('.') ;
            C0.sparsity = sparsity_control ;
            for csc = 0:1
                C0.is_csc = csc ;

                % row assign
                C1 = GB_mex_assign      (C0, Mrow, 'plus', Arow, I0, J0, [], 2);
                C2 = GB_spec_Row_assign (C0, Mrow, 'plus', Arow, I,  J,  []) ;
                GB_spec_compare (C1, C2) ;

                % col assign
                C1 = GB_mex_assign      (C0, Mcol, 'plus', Acol, J0, I0, [], 1);
                C2 = GB_spec_Col_assign (C0, Mcol, 'plus', Acol, J,  I,  [ ]) ;
                GB_spec_compare (C1, C2) ;

                % row assign, no accum
                C1 = GB_mex_assign      (C0, Mrow, [ ], Arow, I0, J0, [ ], 2) ;
                C2 = GB_spec_Row_assign (C0, Mrow, [ ], Arow, I,  J,  [ ]) ;
                GB_spec_compare (C1, C2) ;

                % col assign, no accum
                C1 = GB_mex_assign      (C0, Mcol, [ ], Acol, J0, I0, [ ], 1) ;
                C2 = GB_spec_Col_assign (C0, Mcol, [ ], Acol, J,  I,  [ ]) ;
                GB_spec_compare (C1, C2) ;

            end
        end
    end
end

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