LinearAlgebra
GetResultDataType
return the resulting datatype of a Matrix or Vector operation
Calling Sequence
Parameters
Description
Examples
GetResultDataType(t1, t2, h, oper)
t1, t2
-
types; Matrix or Vector datatypes
h
either 'true', 'false' or 'deduced'; specify hardware float type
oper
(optional) specific operation by which the two input types are to be mixed
The GetResultDataType(t1, t2, h, oper) function returns a datatype which can be used when constructing a new Matrix or Vector from two other such objects.
This routine can be used within routines that operate on a pair of input Matrices or Vectors to produce a new Matrix or Vector, and that need to set a datatype option on the result. The datatype returned by GetResultDataType is determined by the inputs:
A hardware float type if all the following are true: either input type is a float type, both input types are numeric, and the h parameter is true or the h parameter is deduced and Digits <= evalhf(Digits).
A software float type if all the following are true: either input type is a float type, both input types are numeric, and the h parameter is false, or the h parameter is deduced and Digits > evalhf(Digits).
A complex type if either input type is a complex type
The "larger" of the input types if neither input type is any kind of float type, according to the ordering hardware integer < integer < rational < numeric < extended_numeric and real < complex, except that numeric is replaced by extended_numeric (and fraction is replaced by rational) in the result type.
The optional parameter oper is used to determine the mixing of types. This parameter may be supplied as any of 'div', 'sqrt' or 'sqrtreal', which respectively represent the operations of division, taking the square root, and taking the real square root. If this parameter is omitted then the default operation of multiplication is assumed.
Not all Maple types are known to this routine, whose principal purpose is to facilitate numerical linear algebra. The known types fit into hierarchical orderings, for each of the known operations.
This function is part of the LinearAlgebra package, and so it can be used in the form GetResultDataType(..) only after executing the command with(LinearAlgebra). However, it can always be accessed through the long form of the command by using LinearAlgebra[GetResultDataType](..).
with⁡LinearAlgebra:
UseHardwareFloats
deduced
Digits
10
GetResultDataType⁡float,float,UseHardwareFloats
float8
Digits≔30:
sfloat
UseHardwareFloats≔true:
GetResultDataType⁡integer,integer,UseHardwareFloats
integer
GetResultDataType⁡float8,complex8,UseHardwareFloats
complex8
UseHardwareFloats≔false:
GetResultDataType⁡rational,float,UseHardwareFloats
A≔Matrix⁡2,datatype=complex⁡integer:
B≔Matrix⁡2,datatype=float:
GetResultDataType⁡MatrixOptions⁡A,datatype,MatrixOptions⁡B,datatype,true
GetResultDataType⁡integer,integer,UseHardwareFloats,div
rational
GetResultDataType⁡integer,float,true,sqrtreal
GetResultDataType⁡integer,float,true,sqrt
See Also
Matrix
type
Vector
Download Help Document