domtype -- the data type of an
object
Introductiondomtype(object) returns the domain type (the data type) of the object.
Call(s)domtype(object)
Parametersobject |
- | any MuPAD object |
Returnsthe data type, i.e., an object of type DOM_DOMAIN.
object
Related
Functionscoerce, DOM_DOMAIN, domain, hastype, testtype, type, Type
Detailsdomtype coincides with the type returned by the function
type. Only for
expressions of domain type DOM_EXPR, the function type yields a distinction
according to the 0-th operand. Cf. example 2.domtype does not
flatten arguments that are expression sequences.domtype is a function of the system kernel.
Example
1Real floating point numbers are of domain type DOM_FLOAT:
>> domtype(12.345)
DOM_FLOAT
Complex numbers are of domain type DOM_COMPLEX. The operands may be
integers (DOM_INT),
rational numbers (DOM_RAT), or floating point numbers
(DOM_FLOAT). The
operands can be accessed via op:
>> domtype(1 - 2*I), op(1 - 2*I); domtype(1/2 - I), op(1/2 - I); domtype(2.0 - 3.0*I), op(2.0 - 3.0*I)
DOM_COMPLEX, 1, -2
DOM_COMPLEX, 1/2, -1
DOM_COMPLEX, 2.0, -3.0
Example
2Expressions are objects of the domain type DOM_EXPR. The type of
expressions can be queried further with the function type:
>> domtype(x + y), type(x + y); domtype(x - 1.0*I), type(x - 1.0*I); domtype(x*I), type(x*I); domtype(x^y), type(x^y); domtype(x[i]), type(x[i])
DOM_EXPR, "_plus"
DOM_EXPR, "_plus"
DOM_EXPR, "_mult"
DOM_EXPR, "_power"
DOM_EXPR, "_index"
Example
3domtype evaluates its argument. In this
example, the assignment is first evaluated and domtype is
applied to the return value of the assignment. This is the right hand
side of the assignment, i.e., 5:
>> domtype((a := 5))
DOM_INT
>> delete a:
Example
4Here the identifier a is first evaluated to
the expression sequence
3, 4. Its domain type is DOM_EXPR, its type is "_exprseq":
>> a := 3, 4: domtype(a), type(a)
DOM_EXPR, "_exprseq"
>> delete a:
Example
5factor
creates objects of the domain type Factored:
>> domtype(factor(x^2 - x))
Factored
Example
6matrix
creates objects of the domain type Dom::Matrix():
>> domtype(matrix([[1, 2], [3, 4]]))
Dom::Matrix()
Example
7Domains are of the domain type DOM_DOMAIN:
>> domtype(DOM_INT), domtype(DOM_DOMAIN)
DOM_DOMAIN, DOM_DOMAIN
Example
8domtype is overloadable, i.e., a domain can pretend to be of
another domain type. The special slot "dom" always gives
the actual domain:
>> d := newDomain("d"): d::domtype := x -> "domain type d":
e := new(d, 1): e::dom, type(e), domtype(e)
d, d, "domain type d"
>> delete d, e: