suggest Array datatype for an operation on two Arrays
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.
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 and Y has datatype float, then the suggested datatype will be float.
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 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](..).
M1 ≔ Matrix⁡1,2,3,4,datatype=integer2
M2 ≔ Vectorrow⁡1+2⁢I,3+4⁢I,datatype=complex8
M3 ≔ Vectorrow⁡hello,world,datatype=string
Because float has less precision than integer, the datatype is promoted to float when combining these two.
M4 ≔ Vectorrow⁡1.2,3.4,datatype=float4
M5 ≔ Vectorrow⁡7,8,9,datatype=integer4
The ArrayTools[SuggestedDatatype] command was introduced in Maple 2021.
For more information on Maple 2021 changes, see Updates in Maple 2021.
Download Help Document