compute a general outer product of two Arrays
Array, list, or expression
function to apply to each pair of values from X and Y
(optional) one or more options
GeneralOuterProduct(X,f,g,Y) accepts two Arrays, X and Y, with N and M dimensions respectively. The result is an Array of N+M dimensions.
For each combination of indices of X and indices of Y, the function f is applied to the elements from X and Y.
For example, when X and Y are vectors of integers from 1 to 10, and f is the multiplication function (`*`), GeneralOuterProduct produces a matrix representing a traditional multiplication table.
If X or Y is a list, it is treated as one-dimensional Array.
If either X or Y is not an Array or list, it is interpreted as an Array with zero dimensions (and the value X or Y).
By default, the datatype of the resulting Array is determined by SuggestedDatatype based on the two inputs. Depending on f, this may not be suitable. For example, if X and Y have datatype integer and f is `*`, the computed values might be too large to store in that datatype.
The option ':-datatype'=dt, where dt is a valid Array datatype, can be used to override the default datatype for the result.
If option evalhf or evalhf=true is passed, the arguments passed to each call to f are first evaluated to hardware floating-point using evalhf, as is the result returned by f. Furthermore, unless the datatype option was specified, the resulting Array has datatype float.
The subtype of the result depends on the subtypes of X and Y, as described by SuggestedSubtype. The option ':-subtype'=st', where st is a valid rtable subtype, overrides the default subtype.
The storage order of the result is based on the storage orders of X and Y, as described by SuggestedOrder. This can be overridden using the option :-order=ord, where ord is one of C_order or Fortran_order.
This function is part of the ArrayTools package, so it can be used in the short form GeneralOuterProduct(..) only after executing the command with(ArrayTools). However, it can always be accessed through the long form of the command by using ArrayTools[GeneralOuterProduct](..).
Produce a multiplication table of integers from 1 to 10.
V ≔ `$`⁡1..10:
GeneralOuterProduct works with Arrays of arbitrary dimension. Generate a three-dimensional Array of the sum of all combinations of the roll of 3 dice:
R ≔ 1,2,3,4,5,6:
2-D intermediate result
R2 ≔ GeneralOuterProduct⁡R,`+`,R
3-D final result
R3 ≔ GeneralOuterProduct⁡R2,`+`,R
The possibilities when the last roll was 1.
The possibilities when the last roll was 6.
Count occurrences of each total from 1 to 18.
The datatype option can be used if the default datatype would not be suitable for the result.
A ≔ Vectorrow⁡4,8,12,datatype=integer1
Error, (in ArrayTools:-GeneralOuterProduct) unable to store '144' when datatype=integer
If the results of GeneralOuterProduct fall in the range 0..1, they can be visualized using ImageTools.
V ≔ Array⁡seq⁡i,i=0..1,numelems=101,datatype=float8:
img ≔ GeneralOuterProduct⁡V,max,V
The ArrayTools[GeneralOuterProduct] command was introduced in Maple 2021.
For more information on Maple 2021 changes, see Updates in Maple 2021.
Download Help Document
What kind of issue would you like to report? (Optional)