Difference between revisions of "Cumulate"

Line 1: Line 1:
 
[[Category:Transforming functions]]
 
[[Category:Transforming functions]]
 
[[Category:Doc Status C]] <!-- For Lumina use, do not change -->
 
[[Category:Doc Status C]] <!-- For Lumina use, do not change -->
 +
 +
= Cumulate(X,I) =
  
 
Returns an array with each element being the sum of all of the elements of X along dimension I up to, and including, the corresponding element of X.
 
Returns an array with each element being the sum of all of the elements of X along dimension I up to, and including, the corresponding element of X.
Line 7: Line 9:
  
 
  Cumulate(X:Array[I] ; I : Index)
 
  Cumulate(X:Array[I] ; I : Index)
 +
 +
= Library =
 +
 +
Array Functions
  
 
= Examples =
 
= Examples =

Revision as of 15:54, 30 October 2008


Cumulate(X,I)

Returns an array with each element being the sum of all of the elements of X along dimension I up to, and including, the corresponding element of X.

Declaration

Cumulate(X:Array[I] ; I : Index)

Library

Array Functions

Examples

I → 1 2 3 4 5 6
X → 8 2 0 5 -3 7
Cumulate(X,I) → 8 10 10 15 12 19

Library

Array Functions

Notes

Recumulate

A useful variation is the Recumulate function, which resets the total to zero at selected points. This usage is:

Recumulate(x,b,I)

where b is an array of booleans indexed by I, having 1 at each point where the cumulation is to be reset to zero. Recumulate is implemented as a User-Defined Function in the example Recumulate example.ana. A clever usage of this function computes the number of time steps that the system has been in the same state (see the example).

See Also

Comments


You are not allowed to post comments.