1function C = bitand (A, B, assumedtype) 2%BITAND bitwise AND. 3% C = bitand (A,B) is the bitwise AND of A and B. If A and B are 4% matrices, the pattern of C is the set intersection of A and B. If one 5% of A or B is a nonzero scalar, the scalar is expanded into a sparse 6% matrix with the same pattern as the other matrix, and the result is a 7% sparse matrix. 8% 9% With a third parameter, C = bitand (A,B,assumedtype) provides a data 10% type to convert A and B to if they are floating-point types. If A or B 11% already have integer types, then they are not modified. Otherwise, A or 12% B are converted to assumedtype, which can be 'int8', 'int16', 'int32', 13% 'int64', 'uint8', 'uint16', 'uint32' or 'uint64'. The default is 14% 'uint64'. 15% 16% The input matrices must be real, and may be either GraphBLAS and/or 17% MATLAB matrices, in any combination. C is returned as a GraphBLAS 18% matrix. The type of C is given by GrB.optype (A,B), after any 19% conversion to assumedtype, if needed. 20% 21% Example: 22% 23% A = GrB (magic (4), 'uint8') 24% B = GrB (13 * eye (4), 'uint8') ; 25% B (3,4) = 107 26% C = bitand (A, B) 27% fprintf ('\nA: ') ; fprintf ('%3x ', A) ; fprintf ('\n') ; 28% fprintf ('\nB: ') ; fprintf ('%3x ', B) ; fprintf ('\n') ; 29% fprintf ('\nC: ') ; fprintf ('%3x ', C) ; fprintf ('\n') ; 30% % in MATLAB: 31% C2 = bitand (uint8 (A), uint8 (B)) 32% isequal (C2, C) 33% 34% See also GrB/bitor, GrB/bitxor, GrB/bitcmp, GrB/bitshift, GrB/bitget, 35% GrB/bitset, GrB/bitclr. 36 37% SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved. 38% SPDX-License-Identifier: GPL-3.0-or-later 39 40if (nargin < 3) 41 assumedtype = 'uint64' ; 42end 43 44C = GrB (gb_bitwise ('bitand', A, B, assumedtype)) ; 45 46