functions:RPROD
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
-------------------------------------------------------------
RPROD(X[I],I,1:5) [1;2;6;24;120]
| 1 1 1 |
| 2 4 8 |
RPROD(X,I,1:3) | 3 9 27 |
| 4 16 64 |
| 5 25 125 |
RPROD((X^2+Y^2)[I],I,1:5) [5;65;1625;66625;4064125]
| 1 2 6 24 |
RPROD(RPROD(M[I,J],I,1:3),J,1:4) | 5 60 1260 40320 |
| 45 5400 1247400 479001600 |