PRODUCT (array, [,dim] [,mask])
Class: Transformational function - Generic
Returns the product of all the elements in an entire array or in a
specified dimension of an array.
The "array" can be of integer or real type. The "dim" is optional
and must be a scalar integer with a value in the range 1 to n,
where "n" is the rank of "array". The "mask" is optional and must
be a logical array that is conformable with "array".
The result is the same data type as "array". The result is a
scalar if "dim" is absent or "array" has rank one. Otherwise, the
result is an array with rank that is one less than "array", and
shape (d1, d2,..., d"dim"-1, d"dim"+1,..., dn), where (d1, d2,...,
dn) is the shape of "array".
If only "array" appears, the result is the product of all elements
of "array". If "array" has size zero, the result is 1.
If "array" and "mask" both appear, the result is the product of all
elements of "array" corresponding to true elements of "mask". If
"array" has size zero, or every element of "mask" has the value
.FALSE., the result is 1.
If "dim" also appears and "array" has rank one, the value is the
same as PRODUCT (array [,mask=mask]). Otherwise, the value of
element (s1, s2,..., s"dim"-1, s"dim"+1,..., sn) of PRODUCT (array,
dim, [,mask]) is equal to PRODUCT (array (s1, s2,..., s"dim"-1, :,
s"dim"+1, ..., sn)) [mask=mask (s1, s2, ..., s"dim"-1, :, s "dim"+1
..., sn)].
Examples:
PRODUCT ((/2, 3, 4/)) and PRODUCT ((/2, 3, 4/), DIM=1) returns the
value 24.
PRODUCT (C, MASK=C .LT. 0.0) returns the product of the negative
elements of C.
Consider that A is the array |1 4 7|.
|2 3 5|
PRODUCT (A, DIM=1) returns the value (2, 12, 35).
PRODUCT (A, DIM=2) returns the value (28, 30).