 SuggestedDatatype - Maple Help

ArrayTools

 SuggestedDatatype
 suggest Array datatype for an operation on two Arrays Calling Sequence SuggestedDatatype(X,Y) Parameters

 X, Y - Array, hardware float, or general expression Description

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

 > $\mathrm{with}\left(\mathrm{ArrayTools}\right):$
 > $\mathrm{M1}≔\mathrm{Matrix}\left(\left[\left[1,2\right],\left[3,4\right]\right],\mathrm{datatype}=\mathrm{integer}\left[2\right]\right)$
 ${\mathrm{M1}}{≔}\left[\begin{array}{cc}{1}& {2}\\ {3}& {4}\end{array}\right]$ (1)
 > $\mathrm{M2}≔\mathrm{Vector}\left[\mathrm{row}\right]\left(\left[1+2I,3+4I\right],\mathrm{datatype}=\mathrm{complex}\left[8\right]\right)$
 ${\mathrm{M2}}{≔}\left[\begin{array}{cc}{1.}{+}{2.}{}{I}& {3.}{+}{4.}{}{I}\end{array}\right]$ (2)
 > $\mathrm{SuggestedDatatype}\left(\mathrm{M1},\mathrm{M2}\right)$
 ${{\mathrm{complex}}}_{{8}}$ (3)
 > $\mathrm{M3}≔\mathrm{Vector}\left[\mathrm{row}\right]\left(\left["hello","world"\right],\mathrm{datatype}=\mathrm{string}\right)$
 ${\mathrm{M3}}{≔}\left[\begin{array}{cc}{"hello"}& {"world"}\end{array}\right]$ (4)
 > $\mathrm{SuggestedDatatype}\left(\mathrm{M1},\mathrm{M3}\right)$
 ${\mathrm{anything}}$ (5)

Because float has less precision than integer, the datatype is promoted to float when combining these two.

 > $\mathrm{M4}≔\mathrm{Vector}\left[\mathrm{row}\right]\left(\left[1.2,3.4\right],\mathrm{datatype}=\mathrm{float}\left[4\right]\right)$
 ${\mathrm{M4}}{≔}\left[\begin{array}{cc}{1.20000004768372}& {3.40000009536743}\end{array}\right]$ (6)
 > $\mathrm{M5}≔\mathrm{Vector}\left[\mathrm{row}\right]\left(\left[7,8,9\right],\mathrm{datatype}=\mathrm{integer}\left[4\right]\right)$
 ${\mathrm{M5}}{≔}\left[\begin{array}{ccc}{7}& {8}& {9}\end{array}\right]$ (7)
 > $\mathrm{SuggestedDatatype}\left(\mathrm{M4},\mathrm{M5}\right)$
 ${{\mathrm{float}}}_{{8}}$ (8) Compatibility

 • The ArrayTools[SuggestedDatatype] command was introduced in Maple 2021.
 • For more information on Maple 2021 changes, see Updates in Maple 2021.