1function C = bitshift (A, B, assumedtype)
2%BITSHIFT bitwise left and right shift.
3% C = bitshift (A,B) is the bitwise shift of A; if B > 0 then A is shifted
4% left by B bits, and if B < 0 then A is shifted right by -B bits.  If
5% either A or B are scalars, they are expanded to the pattern of the other
6% matrix.  C has the pattern of A (after expansion, if needed).
7%
8% With a third parameter, C = bitshift (A,B,assumedtype) provides a data
9% type to convert A to if it is a floating-point type.  If A already has
10% an integer type, then it is not modified.  Otherwise, A is converted to
11% assumedtype, which can be 'int8', 'int16', 'int32', 'int64', 'uint8',
12% 'uint16', 'uint32' or 'uint64'.  The default is 'uint64'.
13%
14% Example:
15%
16%   A = uint8 (magic (4))
17%   G = GrB (magic (4), 'uint8') ;
18%   C1 = bitshift (A, -2) ;
19%   C2 = bitshift (G, -2)
20%   isequal (C2, C)
21%
22% See also GrB/bitor, GrB/bitand, GrB/bitxor, GrB/bitcmp, GrB/bitget,
23% GrB/bitset, GrB/bitclr.
24
25% SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved.
26% SPDX-License-Identifier: GPL-3.0-or-later
27
28% FUTURE: bitshift(A,B) for two matrices A and B is slower than it could be.
29% See comments in gb_union_op.
30
31if (nargin < 3)
32    assumedtype = 'uint64' ;
33end
34
35C = GrB (gb_bitwise ('bitshift', A, B, assumedtype)) ;
36
37