GetResultDataType - Maple Help

LinearAlgebra

 GetResultDataType
 return the resulting datatype of a Matrix or Vector operation

 Calling Sequence GetResultDataType(t1, t2, h, oper)

Parameters

 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

Description

 • 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](..).

Examples

 > $\mathrm{with}\left(\mathrm{LinearAlgebra}\right):$
 > $\mathrm{UseHardwareFloats}$
 ${\mathrm{deduced}}$ (1)
 > $\mathrm{Digits}$
 ${10}$ (2)
 > $\mathrm{GetResultDataType}\left(\mathrm{float},\mathrm{float},\mathrm{UseHardwareFloats}\right)$
 ${{\mathrm{float}}}_{{8}}$ (3)
 > $\mathrm{Digits}≔30:$
 > $\mathrm{GetResultDataType}\left(\mathrm{float},\mathrm{float},\mathrm{UseHardwareFloats}\right)$
 ${\mathrm{sfloat}}$ (4)
 > $\mathrm{UseHardwareFloats}≔\mathrm{true}:$
 > $\mathrm{GetResultDataType}\left(\mathrm{integer},\mathrm{integer},\mathrm{UseHardwareFloats}\right)$
 ${\mathrm{integer}}$ (5)
 > $\mathrm{GetResultDataType}\left(\mathrm{float}\left[8\right],\mathrm{complex}\left[8\right],\mathrm{UseHardwareFloats}\right)$
 ${{\mathrm{complex}}}_{{8}}$ (6)
 > $\mathrm{UseHardwareFloats}≔\mathrm{false}:$
 > $\mathrm{GetResultDataType}\left(\mathrm{rational},\mathrm{float},\mathrm{UseHardwareFloats}\right)$
 ${\mathrm{sfloat}}$ (7)
 > $A≔\mathrm{Matrix}\left(2,\mathrm{datatype}='\mathrm{complex}\left(\mathrm{integer}\right)'\right):$
 > $B≔\mathrm{Matrix}\left(2,\mathrm{datatype}='\mathrm{float}'\right):$
 > $\mathrm{GetResultDataType}\left(\mathrm{MatrixOptions}\left(A,\mathrm{datatype}\right),\mathrm{MatrixOptions}\left(B,\mathrm{datatype}\right),\mathrm{true}\right)$
 ${{\mathrm{complex}}}_{{8}}$ (8)
 > $\mathrm{GetResultDataType}\left(\mathrm{integer},\mathrm{integer},\mathrm{UseHardwareFloats},'\mathrm{div}'\right)$
 ${\mathrm{rational}}$ (9)
 > $\mathrm{GetResultDataType}\left(\mathrm{integer},\mathrm{float},\mathrm{true},\mathrm{sqrtreal}\right)$
 ${{\mathrm{float}}}_{{8}}$ (10)
 > $\mathrm{GetResultDataType}\left(\mathrm{integer},\mathrm{float},\mathrm{true},\mathrm{sqrt}\right)$
 ${{\mathrm{complex}}}_{{8}}$ (11)