ScanAlongDimension - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


ArrayTools

  

ScanAlongDimension

  

accumulate the elements of an Array by a function

 

Calling Sequence

Parameters

Description

Examples

Compatibility

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

withArrayTools:

MMatrixa,b,c,d,e,f

Mabcdef

(1)

ScanAlongDimension`+`,M,1

abca+db+ec+f

(2)

ScanAlongDimension`+`,M,2

aa+ba+b+cdd+ed+e+f

(3)

NMatrix1,5,3,2,4,3

N153243

(4)

ScanAlongDimensionmax,N,1

153253

(5)

ScanAlongDimensionmax,N,2

155244

(6)

vVectorrow1,2,3,2,1

v12321

(7)

ScanAlongDimensionmax,v

12333

(8)

ScanAlongDimensiona,b10a+b,v

112123123212321

(9)

AArray1..2,1..2,1..2,x,y,zaxyz

A1,A2

a111a112a121a122,a211a212a221a222

(10)

A1ScanAlongDimension`+`,A,1

A11,A12

a111a112a121a122,a111+a211a112+a212a121+a221a122+a222

(11)

A2ScanAlongDimension`+`,A,2

A21,A22

a111a112a111+a121a112+a122,a211a212a211+a221a212+a222

(12)

A3ScanAlongDimension`+`,A,3

A31,A32

a111a111+a112a121a121+a122,a211a211+a212a221a221+a222

(13)

The datatype option can be used if the input datatype would not be suitable for the result.

AArray1,40,80,30,40,50,datatype=integer1

A14080304050

(14)

ScanAlongDimension`+`,A,1

Error, (in ArrayTools:-ScanAlongDimension) unable to store '130' when datatype=integer[1]

ScanAlongDimension`+`,A,1,datatype=integer2

140803180130

(15)

Compatibility

• 

The ArrayTools[ScanAlongDimension] command was introduced in Maple 2021.

• 

For more information on Maple 2021 changes, see Updates in Maple 2021.

See Also

ArrayTools

ArrayTools[AddAlongDimension]

ArrayTools[MultiplyAlongDimension]

ArrayTools[ReduceAlongDimension]