File: test05.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 (45 lines) | stat: -rw-r--r-- 928 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
function test05
%TEST05 test GrB_*_setElement

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

A = sparse (5,5) ;
A (2,2) = 42 ;

I = [1 2 3 2]' ;
J = [1 2 3 2]' ;

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


C1 = GB_mex_setElement (A, I0, J0, int8(X))  ;
C2 = GB_mex_setElement (A, I0, J0, int8(X), false, true)  ;

B = A ;
for k = 1:length(I)
    B (I (k), J (k)) = X (k) ;
end

assert (isequal (C1.matrix, B)) 
assert (isequal (C2.matrix, B)) 

A2.matrix = A ;

for A_is_hyper = 0:1
    for A_is_csc = 0:1
        A2.is_csc   = A_is_csc ;
        A2.is_hyper = A_is_hyper ;

        C3 = GB_mex_setElement (A2, I0, J0, int8(X))  ;
        C4 = GB_mex_setElement (A2, I0, J0, int8(X), false, true)  ;
        assert (isequal (C3.matrix, B)) 
        assert (isequal (C4.matrix, B)) 

    end
end

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