1function [xdomain, ydomain] = GB_spec_opdomain (op)
2%GB_SPEC_OPDOMAIN determine domain of a unary or binary operator
3%
4%   [xdomain, ydomain] = GB_spec_opdomain (op) determines the domains of
5%   x and y where the unary or binary operator is valid.  Each output is an
6%   array of size two.  Divide-by-zero is ignored.
7%
8%   An error results if the operator is not defined at all (op.opname = 'erf'
9%   and op.opname = 'single complex' for example).
10%
11% See also GB_spec_op.
12
13% SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved.
14% SPDX-License-Identifier: Apache-2.0
15
16% get the operator name and type
17[opname optype ztype xtype ytype] = GB_spec_operator (op, 'double') ;
18
19xdomain = [-inf, inf] ;
20ydomain = [-inf, inf] ;
21
22if (contains (optype, 'complex'))
23    % complex operators z=f(x,y) are valid over all x and y
24    return
25end
26
27% find the domain of a real operator
28
29switch opname
30
31    case { 'pow', 'sqrt', 'log', 'log10', 'log2', 'gammaln', 'lgamma' }
32        xdomain = [0, inf] ;
33
34    case { 'asin', 'acos', 'atanh' }
35        xdomain = [-1, 1] ;
36
37    case { 'acosh', 'asech' }
38        xdomain = [1, inf] ;
39
40    case 'log1p'
41        xdomain = [-1, inf] ;
42
43    otherwise
44        % op is defined for all x and y
45
46end
47
48