Previous Page Next Page Contents

domtype -- the data type of an object

Introduction

domtype(object) returns the domain type (the data type) of the object.

Call(s)

domtype(object)

Parameters

object - any MuPAD object

Returns

the data type, i.e., an object of type DOM_DOMAIN.

Overloadable:

object

Related Functions

coerce, DOM_DOMAIN, domain, hastype, testtype, type, Type

Details

Example 1

Real 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 2

Expressions 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 3

domtype 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 4

Here 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 5

factor creates objects of the domain type Factored:

>> domtype(factor(x^2 - x))
                                 Factored

Example 6

matrix creates objects of the domain type Dom::Matrix():

>> domtype(matrix([[1, 2], [3, 4]]))
                               Dom::Matrix()

Example 7

Domains are of the domain type DOM_DOMAIN:

>> domtype(DOM_INT), domtype(DOM_DOMAIN)
                          DOM_DOMAIN, DOM_DOMAIN

Example 8

domtype 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:

Changes




Do you have questions or comments?


Copyright © SciFace Software GmbH & Co. KG 2000