1function type = optype (a, b) 2%GRB.OPTYPE determine the default type of a binary operator. 3% type = GrB.optype (a, b) returns a string that defines the 4% default type of operator to use for two inputs A and B, of type 5% atype and btype, respectively. The input a can be either the 6% matrix A or the string atype = GrB.type (A), and likewise for b. 7% 8% The rules are listed below; the first one that applies is used: 9% 10% (0) for positional operators, int64 is used by default. 11% 12% (1) same: 13% 14% if A and B have the same type: optype is the type of A and B. 15% 16% (2) any logical: 17% 18% if A or B are logical: optype is from the other operand. 19% 20% (3) both integer: 21% 22% if A and B are both integers (with ka and kb bits, respectively): 23% optype is signed if either A or B are signed, and the optype has 24% max(ka,kb) bits. For example, uint32*int8 uses an int32 optype. 25% 26% (4) mixing integer and floating-point: 27% 28% if one operand is any integer, and the other is any floating-point 29% (single, double, single complex, or double complex): optype has 30% the floating-point type of the other operand. 31% 32% (5) both floating-point: 33% 34% if A or B are single: optype is from the other operand. 35% if A or B are double: if the other is single complex or double 36% complex, optype is double complex; otherwise optype is double. 37% if A or B are single complex: if the other operand is double or 38% double complex, optype is double complex; otherwise it is single 39% complex. 40% if A or B are double complex: optype is double complex. 41% 42% Example: 43% 44% GrB.optype ('uint32', 'int8') 45% GrB.optype (uint32 (magic (4)), rand (4)) 46% 47% See also GrB.binopinfo, GrB.semiringinfo, GrB.type. 48 49% SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved. 50% SPDX-License-Identifier: GPL-3.0-or-later 51 52if (ischar (a)) 53 atype = a ; 54elseif (isobject (a)) 55 a = a.opaque ; 56 atype = gbtype (a) ; 57else 58 atype = gbtype (a) ; 59end 60 61if (ischar (b)) 62 btype = b ; 63elseif (isobject (b)) 64 b = b.opaque ; 65 btype = gbtype (b) ; 66else 67 btype = gbtype (b) ; 68end 69 70type = gboptype (atype, btype) ; 71 72