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
|
function gbtest78
%GBTEST78 test integer operators
% SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2022, All Rights Reserved.
% SPDX-License-Identifier: Apache-2.0
A = uint8 (magic (4)) ;
A = A (:,1:3) ;
A (1,1) = 0 ;
assert (GrB.isbycol (A)) ;
assert (~GrB.isbyrow (A)) ;
disp (A, GrB (5)) ;
G = GrB (A) ;
C = (G < -1) ;
assert (isequal (C, sparse (false (4,3)))) ;
C = (-1 < G) ;
assert (isequal (C, sparse (true (4,3)))) ;
C = GrB.empty ;
assert (isequal (C, [ ])) ;
C1 = bitset (A, 1, 1) ;
C2 = bitset (G, 1, GrB (1)) ;
assert (isequal (C1, C2)) ;
C1 = bitshift (uint64 (3), A) ;
C2 = bitshift (uint64 (3), G) ;
assert (isequal (C1, C2)) ;
types = {
'double'
'int8'
'int16'
'int32'
'int64'
'uint8'
'uint16'
'uint32'
'uint64'
} ;
% bitset (a,b,V) where a and b are scalars
V = magic (4) .* mod (magic (4), 2) ;
G = GrB (V) ;
for k = 1:length (types)
type = types {k} ;
fprintf ('%s ', type) ;
for a = 0:8
for b = 1:8
A = cast (a, type) ;
B = cast (b, type) ;
C1 = bitset (A, B, V) ;
C2 = bitset (A, B, G) ;
assert (isequal (C1, C2)) ;
end
end
end
fprintf ('\ngbtest78: all tests passed\n') ;
|