prod

Syntax

prod(X)

Arguments

X is a scalar/vector/matrix.

Details

If X is a vector, return the product of all the elements in X.

If X is a matrix, calculate the product of all the elements in each column of X and return a vector.

As with all aggregate functions, NULL values are not included in the calculation.

Examples

$ prod(1 2 NULL 3);
6
$ m=matrix(1 2 3, 4 5 6);
$ m;

#0

#1

1

4

2

5

3

6

$ prod(m);
[6,120]