ArrayTools
SuggestedDatatype
suggest Array datatype for an operation on two Arrays
Calling Sequence
Parameters
Description
Examples
Compatibility
SuggestedDatatype(X,Y)
X, Y
-
Array, hardware float, or general expression
SuggestedDatatype(X,Y) accepts two Arrays, X and Y, and suggests a datatype to use for a result involving an operation between X and Y.
If X or Y is a hardware float (hfloat), it is considered to be an Array with datatype float[8].
If X or Y is not an Array or hardware float, it is considered to be of type anything.
The suggested datatype for the resulting Array will be one that can represent any value appearing in either of the two Arrays. For example, if X has datatype integer[2] and Y has datatype float[4], then the suggested datatype will be float[4].
SuggestedDatatype does not know what operation will be performed between X and Y, so the suggestion might still be unsuitable. For example, if the elements of X and Y Arrays with datatype integer[1] are to be added, the resulting values may be too large. On the other hand, if the operation is to find the smaller of each pair of values, the resulting values will all fit into the datatype.
This function is part of the ArrayTools package, so it can be used in the short form SuggestedDatatype(..) only after executing the command with(ArrayTools). However, it can always be accessed through the long form of the command by using ArrayTools[SuggestedDatatype](..).
with⁡ArrayTools:
M1≔Matrix⁡1,2,3,4,datatype=integer2
M1≔1234
M2≔Vectorrow⁡1+2⁢I,3+4⁢I,datatype=complex8
M2≔1.+2.⁢I3.+4.⁢I
SuggestedDatatype⁡M1,M2
complex8
M3≔Vectorrow⁡hello,world,datatype=string
M3≔helloworld
SuggestedDatatype⁡M1,M3
anything
Because float[4] has less precision than integer[4], the datatype is promoted to float[8] when combining these two.
M4≔Vectorrow⁡1.2,3.4,datatype=float4
M4≔1.200000047683723.40000009536743
M5≔Vectorrow⁡7,8,9,datatype=integer4
M5≔789
SuggestedDatatype⁡M4,M5
float8
The ArrayTools[SuggestedDatatype] command was introduced in Maple 2021.
For more information on Maple 2021 changes, see Updates in Maple 2021.
See Also
ArrayTools[SuggestedOrder]
ArrayTools[SuggestedSubtype]
Download Help Document