Contents Previous Next Subchapters

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

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

Vectors
If x is a vector, p is a scalar and
     p = x  * x  * ... * x
          1    2          n
where n is the number of elements in x. If you enter
     x = [ 1, 2, 3 ]
     prod(x)
O-Matrix will respond
     6
If you enter
     x = { 1, 2, 3 }
     prod(x)
O-Matrix will respond
     6

Matrices
If x is not a vector, p is a row vector with the same column dimension as x and
     p  =  x    * x     * ... * x
      j     1,j    2,j           m,j
where m is the number of rows in the matrix x. If you enter
     x = { [ 1, 2, 3 ], [3, 4, 5] }
     prod(x)
O-Matrix will respond
     {
     [ 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] }
     prod(x, 2)
O-Matrix will respond
     {
     6
     60
     }