|
Calling Sequence
|
|
ScanAlongDimension(fcn,A,dim,opts)
|
|
Parameters
|
|
fcn
|
-
|
function to accumulate along a dimension to a single value
|
A
|
-
|
Array
|
dim
|
-
|
(optional) dimension to add along
|
opts
|
-
|
(optional) one or more options
|
|
|
|
|
Description
|
|
•
|
ScanAlongDimension(fcn,A,dim) accumulates with function fcn the elements in dimension dim of an N-dimensional Array to produce another Array with N dimensions.
|
•
|
When dim is not specified, the first non-singleton dimension is used for accumulation. If the dimension specified is a higher dimension than the number of dimensions in the input, the input itself is returned.
|
•
|
By default, the datatype of the result Array is the same as that of input Array A. Depending on fcn, this may not be suitable. For example, if A has datatype integer[1], and fcn adds up values, the result may 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 fcn are first evaluated to hardware floating-point using evalhf, as is the result returned by fcn. Furthermore, unless the datatype option was specified, the result Array will have datatype float[8].
|
•
|
ScanAlongDimensions usually returns a new Array with the same dimensions (but possibly different datatype) as A. Passing the option inplace or inplace=true causes A to be updated in-place. This option only applies to dense rectangular Arrays with no indexing functions, and causes the datatype option to be ignored.
|
•
|
This function is part of the ArrayTools package, so it can be used in the short form ScanAlongDimension(..) only after executing the command with(ArrayTools). However, it can always be accessed through the long form of the command by using ArrayTools[ScanAlongDimension](..).
|
|
|
Examples
|
|
>
|
|
>
|
|
>
|
|
>
|
|
>
|
|
>
|
|
>
|
|
>
|
|
>
|
|
>
|
|
| (10) |
>
|
|
| (11) |
>
|
|
| (12) |
>
|
|
| (13) |
The datatype option can be used if the input datatype would not be suitable for the result.
>
|
|
>
|
|
>
|
|
|
|
Compatibility
|
|
•
|
The ArrayTools[ScanAlongDimension] command was introduced in Maple 2021.
|
|
|
|