functions:PROD
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
------------------------------------------------
PROD(X[I],I,1:5) 120
PROD(X,I,1:5) [1;32;243;1024;3125]
PROD((X^2+Y^2)[I],I,1:5) 4064125
PROD(PROD(M[I,J],I,1:3),J,1:4) 479001600