1function gbtest78 2%GBTEST78 test integer operators 3 4% SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved. 5% SPDX-License-Identifier: GPL-3.0-or-later 6 7A = uint8 (magic (4)) ; 8A = A (:,1:3) ; 9A (1,1) = 0 ; 10 11assert (GrB.isbycol (A)) ; 12assert (~GrB.isbyrow (A)) ; 13 14disp (A, GrB (5)) ; 15 16G = GrB (A) ; 17 18C = (G < -1) ; 19assert (isequal (C, sparse (false (4,3)))) ; 20 21C = (-1 < G) ; 22assert (isequal (C, sparse (true (4,3)))) ; 23 24C = GrB.empty ; 25assert (isequal (C, [ ])) ; 26 27C1 = bitset (A, 1, 1) ; 28C2 = bitset (G, 1, GrB (1)) ; 29assert (isequal (C1, C2)) ; 30 31C1 = bitshift (uint64 (3), A) ; 32C2 = bitshift (uint64 (3), G) ; 33assert (isequal (C1, C2)) ; 34 35types = { 36 'double' 37 'int8' 38 'int16' 39 'int32' 40 'int64' 41 'uint8' 42 'uint16' 43 'uint32' 44 'uint64' 45 } ; 46 47% bitset (a,b,V) where a and b are scalars 48V = magic (4) .* mod (magic (4), 2) ; 49G = GrB (V) ; 50for k = 1:length (types) 51 type = types {k} ; 52 fprintf ('%s ', type) ; 53 for a = 0:8 54 for b = 1:8 55 A = cast (a, type) ; 56 B = cast (b, type) ; 57 C1 = bitset (A, B, V) ; 58 C2 = bitset (A, B, G) ; 59 assert (isequal (C1, C2)) ; 60 end 61 end 62end 63 64fprintf ('\ngbtest78: all tests passed\n') ; 65 66