reduce - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.
Our website is currently undergoing maintenance, which may result in occasional errors while browsing. We apologize for any inconvenience this may cause and are working swiftly to restore full functionality. Thank you for your patience.

Online Help

All Products    Maple    MapleSim


reduce

reduce a container with a function

 

Calling Sequence

Parameters

Description

Thread Safety

Examples

Compatibility

Calling Sequence

reduce(fcn, expr)

reduce[evalhf](fcn, expr)

reduce[scan](fcn, expr)

reduce[inplace](fcn, expr)

reduce[dimension=n](fcn, expr)

Parameters

fcn

-

expression of type appliable; typically, a procedure or name

expr

-

any expression

Description

• 

The reduce function applies the reduction operation specified by fcn to the operands or elements of expr.

• 

Some options can be specified in square brackets as an index to the reduce function. These options can be used by themselves or in combination with other options.

• 

When reducing over an rtable (Array, Vector, or Matrix), if the evalhf option is passed, each evaluation of fcn is evaluated using evalhf.

• 

If the scan option is passed, the reduction is performed cumulatively on the elements of expr, producing a result with the same dimensions as expr.

  

When expr is an rtable, the inplace option can be used in conjunction with the scan option to compute the result in-place in expr.

• 

The dimension option (alternately axis) restricts the reduction along one dimension of an rtable, producing a result with one less dimension than expr.

  

The inplace and evalhf options are currently ignored if the dimension option is used.

Thread Safety

• 

The reduce function is thread safe, provided that evaluating fcn is thread safe.

• 

For more information on thread safety, see index/threadsafe.

Examples

reduce`+`,1,2,3,4,5

15

(1)

reducescan`+`,1,2,3,4,5

1,3,6,10,15

(2)

reduce`+`,1|2,3|4

10

(3)

reducedimension=1`+`,a|b,c|d

a+cb+d

(4)

reducedimension=2`+`,a|b,c|d

a+bc+d

(5)

reducedimension=1,scan`+`,a|b,c|d

aba+cb+d

(6)

reducedimension=2,scan`+`,a|b,c|d

aa+bcc+d

(7)

Compatibility

• 

The reduce command was introduced in Maple 2021.

• 

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

See Also

ArrayTools[ReduceAlongDimension]

ArrayTools[ScanAlongDimension]

map