1function test05
2%TEST05 test GrB_*_setElement
3
4% SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved.
5% SPDX-License-Identifier: Apache-2.0
6
7A = sparse (5,5) ;
8A (2,2) = 42 ;
9
10I = [1 2 3 2]' ;
11J = [1 2 3 2]' ;
12
13I0 = uint64 (I-1) ;
14J0 = uint64 (I-1) ;
15X = [4 5 6 3]' ;
16
17
18A1 = GB_mex_setElement (A, I0, J0, int8(X))  ;
19
20% A1_matrix = A1.matrix
21
22B = A ;
23for k = 1:length(I)
24    B (I (k), J (k)) = X (k) ;
25end
26
27% B
28
29assert (isequal (A1.matrix, B))
30
31A2.matrix = A ;
32
33for A_is_hyper = 0:1
34    for A_is_csc = 0:1
35        A2.is_csc   = A_is_csc ;
36        A2.is_hyper = A_is_hyper ;
37
38        A3 = GB_mex_setElement (A2, I0, J0, int8(X))  ;
39        assert (isequal (A3.matrix, B))
40
41    end
42end
43
44fprintf ('\ntest05: all tests passed\n') ;
45
46