functions:RSUM
All the looping functions mimic standard mathematical notation. The
looping functions require a previously declared scalar dummy variable
as second argument. A dummy variable is declared with the SCALAR\DUMMY
command. A dummy variable is different from other scalar variables in
that its value is only defined while inside the looping function. The
third argument of a looping function is always the range of this dummy
variable, and must be a vector. The first argument of a looping function
would normally be some function of the dummy variable, but it is not
necessary that the dummy variable appear in the first argument.
| 1 2 3 4 |
| 5 6 7 8 |
Suppose X=[1;2;3;4;5], Y=[2;3;4;5;6], M= | 9 10 11 12 | and I and J
| 13 14 15 16 |
have been declared to be dummy variables with SCALAR\DUMMY I J.
function result
------------------------------------------------
RSUM(X[I],I,1:5) [1;3;6;10;15]
| 1 2 3 |
| 2 4 6 |
RSUM(X,I,1:3) | 3 6 9 |
| 4 8 12 |
| 5 10 15 |
RSUM((X^2+Y^2)[I],I,1:5) [5;18;43;84;145]
| 1 3 6 10 |
RSUM(RSUM(M[I,J],I,1:3),J,1:4) | 6 14 24 36 |
| 15 33 54 78 |