1function binopinfo (op, optype) 2%GRB.BINOPINFO list the details of a GraphBLAS binary operator. 3% 4% GrB.binopinfo 5% GrB.binopinfo (op) 6% GrB.binopinfo (op, optype) 7% 8% Binary operators are defined by a string of the form 'op.optype', or 9% just 'op', where the optype is inferred from the operands. Valid 10% optypes are 'logical', 'int8', 'int16', 'int32', 'int64', 'uint8', 11% 'uint16', 'uint32', 'uint64', 'single', 'double', 'single complex', 12% 'double complex' (the latter can be written as simply 'complex'). 13% 14% For GrB.binopinfo (op), the op must be a string of the form 'op.optype', 15% where 'op' is listed below. The second usage allows the optype to be 16% omitted from the first argument, as just 'op'. This is valid for all 17% GraphBLAS operations, since the optype can be determined from the 18% operands (see Typecasting, below). However, GrB.binopinfo does not have 19% any operands and thus the optype must be provided, either in the op as 20% GrB.binopinfo ('+.double'), or in the second argument as 21% GrB.binopinfo ('+', 'double'). 22% 23% The 6 comparator operators come in two flavors. For the is* operators, 24% the result has the same type as the inputs, x and y, with 1 for true and 25% 0 for false. For example isgt.double (pi, 3.0) is the double value 1.0. 26% For the second set of 6 operators (eq, ne, gt, lt, ge, le), the result 27% is always logical (true or false). In a semiring, the optype of the add 28% monoid must exactly match the type of the output of the multiply 29% operator, and thus 'plus.iseq.double' is valid (counting how many terms 30% are equal). The 'plus.eq.double' semiring is valid, but not the same 31% semiring since the 'plus' of 'plus.eq.double' has a logical type and is 32% thus equivalent to 'or.eq.double'. The 'or.eq' is true if any terms 33% are equal and false otherwise (it does not count the number of terms 34% that are equal). 35% 36% The following binary operators are available for most types. Many have 37% equivalent synonyms, so that '1st' and 'first' both define the 38% first(x,y) = x operator. 39% 40% operator name(s) f(x,y) | operator names(s) f(x,y) 41% ---------------- ------ | ----------------- ------ 42% 1st first x | iseq x == y 43% 2nd second y | isne x ~= y 44% min min(x,y) | isgt x > y 45% max max(x,y) | islt x < y 46% + plus x+y | isge x >= y 47% - minus x-y | isle x <= y 48% rminus y-x | == eq x == y 49% * times x*y | ~= ne x ~= y 50% / div x/y | > gt x > y 51% \ rdiv y/x | < lt x < y 52% | || or lor x | y | >= ge x >= y 53% & && and land x & y | <= le x <= y 54% xor lxor xor(x,y) | .^ pow x .^ y 55% pair 1 | any pick x or y 56% 57% All of the above operators are defined for logical operands, but many 58% are redundant. 'min.logical' is the same as 'and.logical', for example. 59% Most of the logical operators have aliases: ('lor', 'or', '|') are the 60% same, as are ('lxnor', 'xnor', 'eq', '==') for logical types. 61% 62% Positional operators return int32 or int64, and depend only on the position 63% of the entry in the matrix. They do not depend on the values of their 64% inputs, but on their position in the matrix instead: 65% 66% 1-based postional ops: in a semiring: in ewise operators: 67% operator name(s) f(A(i,k)*B(k,j)) f(A(i,j),B(i,j)) 68% ---------------- ---------------- ---------------- 69% firsti1 1sti1 firsti 1sti i i 70% firstj1 1stj1 firstj 1stj k j 71% secondi1 2ndi1 secondi 2ndi k i 72% secondj1 2ndj1 secondj 2ndj j j 73% 74% 0-based postional ops: in a semiring: in ewise operators: 75% operator name(s) f(A(i,k)*B(k,j)) f(A(i,j),B(i,j)) 76% ---------------- ---------------- ---------------- 77% firsti0 1sti0 i-1 i-1 78% firstj0 1stj0 k-1 j-1 79% secondi0 2ndi0 k-1 i-1 80% secondj0 2ndj0 j-1 j-1 81% 82% Comparators (*lt, *gt, *le, *ge) and min/max are not available for 83% complex types. 84% 85% The three logical operators, lor, land, and lxor, can be used with any 86% real types. z = lor.double (x,y) tests the condition (x~=0) || (y~=0), 87% and returns the double value 1.0 if true, or 0.0 if false. 88% 89% The following operators are avaiable for single and double (real); their 90% definitions are identical to the ANSI C11 versions of these functions: 91% atan2, hypot, fmod, remainder, copysign, ldxep (also called 'pow2'). 92% All produce the same type as the input, on output. 93% 94% z = cmplx(x,y) can be computed for x and y as single and double; z is 95% single complex or double complex, respectively. 96% 97% The bitwise ops bitor, bitand, bitxor, bitxnor, bitget, bitset, bitclr, 98% and bitshift are available for any signed or unsigned integer type. 99% 100% Typecasting: If the optype is omitted from the string (for example, 101% GrB.eadd (A, '+', B) or simply C = A+B), then the optype is inferred 102% from the type of A and B. See 'help GrB.optype' for details. 103% 104% Example: 105% 106% % valid binary operators 107% GrB.binopinfo ('+.double') ; % also a valid unary operator 108% GrB.binopinfo ('1st.int32') ; 109% GrB.binopinfo ('cmplx.single') ; 110% GrB.binopinfo ('pow2.double') ; % also a valid unary operator 111% GrB.unopinfo ('pow2.double') ; 112% 113% % invalid binary operator (an error; this is a unary op): 114% GrB.binopinfo ('abs.double') ; 115% 116% See also GrB.descriptorinfo, GrB.monoidinfo, GrB.selectopinfo, 117% GrB.semiringinfo, GrB.unopinfo, GrB.optype. 118 119% SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved. 120% SPDX-License-Identifier: GPL-3.0-or-later 121 122if (nargin == 0) 123 help GrB.binopinfo 124elseif (nargin == 1) 125 gbbinopinfo (op) ; 126else 127 gbbinopinfo (op, optype) ; 128end 129 130