1function s = isa (G, type)
2%ISA Determine if a GraphBLAS matrix is of specific type.
3% For any GraphBLAS matrix G, isa (G, 'GrB') and isa (G, 'numeric') are
4% always true, even if G is logical, since many semirings are defined for
5% that type.
6%
7% isa (G, 'float') is the same as isfloat (G), and is true if the GrB
8% matrix G has type 'double', 'single', 'single complex', or 'double
9% complex'.
10%
11% isa (G, 'integer') is the same as isinteger (G), and is true if the GrB
12% matrix G has type 'int8', 'int16', 'int32', 'int64', 'uint8', 'uint16',
13% 'uint32', or 'uint64'.
14%
15% isa (G, type) is true if the type string matches the type of G.
16%
17% Otherwise, all other cases are handled with builtin ('isa',G,type).
18%
19% See also class, GrB.type, GrB/isnumeric, GrB/islogical, GrB/isfloat,
20% GrB/isinteger, isobject, GrB/issparse, GrB/isreal.
21
22% SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved.
23% SPDX-License-Identifier: GPL-3.0-or-later
24
25if (isequal (type, 'GrB') || isequal (type, 'numeric'))
26    % all GraphBLAS matrices are numeric, and have class name 'GrB'
27    s = true ;
28elseif (isequal (type, 'float'))
29    % GraphBLAS double, single, and complex matrices are 'float'
30    s = isfloat (G) ;
31elseif (isequal (type, 'integer'))
32    % GraphBLAS int* and uint* matrices are 'integer'
33    s = isinteger (G) ;
34elseif (isequal (GrB.type (G), type))
35    % specific cases, such as isa (G, 'double'), isa (G, 'int8'), etc
36    s = true ;
37else
38    % catch-all for cases not handled above
39    s = builtin ('isa', G, type) ;
40end
41
42