cumprod

Syntax

cumprod(X)

Arguments

X is a vector/matrix.

Details

If X is a vector, cumulatively calculate the product of the elements in X and return a vector of the same length as X.

If X is a matrix, perform the calculation mentioned above along each row and return a matrix of the same dimension as X.

Examples

$ cumprod(2 3 4);
[2,6,24]
// equivalent to  [2, 2*3, 2*3*4]

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

#0

#1

1

4

2

5

3

6

$ cumprod(m);

#0

#1

1

4

2

20

6

120

Related functions: cummax, cummin, cumsum, cumPositiveStreak