Contents Previous Next Subchapters

Running Cumulative Product of Elements of a Matrix
Syntax cumprod(x)
cumprod(xd)
See Also prod , cumsum , rowsum , colsum , sum , colrange

Description
Returns the cumulative product of the elements of the matrix x as a matrix with the same type and dimension as x where x is an integer, real, double-precision or complex matrix.

Vectors
If x is a vector, the i-th element of the return value is
     x  * x  * ... * x
      1    2          i
If you enter
     x = [ 1, 2, 3 ]
     cumprod(x)
O-Matrix will respond
     [ 1 , 2 , 6 ]
If you enter
     x = { 1, 2, 3 }
     cumprod(x)
O-Matrix will respond
     {
     1
     2
     6
     }

Matrices
If x is a matrix, the (i,j)-th element of the return value is
     x    * x     * ... * x
      1,j    2,j           i,j
If you enter
     x = { [ 1, 2, 3 ], [3, 4, 5] }
     cumprod(x)
O-Matrix will respond
     {
     [ 1 , 2 , 3 ]
     [ 3 , 8 , 15 ]
     }

Dimension
If the argument d is present, it specifies which dimension the product is taken with respect to. It must be an integer, real, or double-precision scalar equal to 1 or 2. If you enter
     x = { [ 1, 2, 3 ], [3, 4, 5] }
     cumprod(x, 2)
O-Matrix will respond
     {
     [ 1 , 2 , 6 ]
     [ 3 , 12 , 60 ]
     }