## MDX Object Oriented (OO) Extension : Matrix

icCube MDX support for matrix objects allows to perform fundamental operations of numerical linear algebra. Several ways of constructing matrices are available via the MDX Matrix() function.

### Operators

The MDX operators have been extended to support basic arithmetic operations (i.e., addition, multiplication, division, power) and comparison (i.e., equality, comparison). Some basic examples :

`Matrix( Vector(2,3),Vector(2,3) ) + 2 = Matrix( Vector(4,5),Vector(4,5) )`
`Matrix( Vector(2,3),Vector(2,3) ) - 2 = Matrix( Vector(0,1),Vector(0,1) )`
`Matrix( Vector(2,3),Vector(2,3) ) * 2 = Matrix( Vector(4,6),Vector(4,6) )`
`Matrix( Vector(2,3),Vector(2,3) ) / 2 = Matrix( Vector(1,2/3),Vector(1,2/3) )`
`Matrix( Vector(11,12),Vector(21,22) ) * Vector(1,2) = Vector( 11 * 1 + 21 * 2, 12*1 + 22 * 2) `

### Methods

The notation matrix -> method( ... ) allows for accessing the methods of the matrix. The conversion of the parameters (as well as the result) is handled automatically by the MDX engine. As an example, the following code return the number of elements in the matrix:

```        Matrix( { [Time].[Calendar].[2010], [Time].[Calendar].[2011] },
{ [Geography].[Geo].[Switzerland],[Geography].[Geo].[France] },
[Measures].[Amount]
) -> length()```

#### geometricMean()

Returns the geometric mean (exp( 1/n (sum of logs) )) of the elements of the matrix.

#### get(double n)

Returns the n-th element of the vector. If value is a numeric smaller than 1.0 returns the 'n * (length - 1)' element.

#### hist(double start, double stop)

Returns the number of elements of the matrix between start (inclusive) and stop (exclusive). A null value for start means -inf whereas a null value for stop means +inf.

#### length()

Returns the number of elements of the matrix.

#### max()

Returns the maximum of the elements of the matrix.

#### mean()

Returns the arithmetic mean of the elements of the matrix.

#### min()

Returns the minimum of the elements of the matrix.

#### percentile(double p)

Returns an estimate of the `p`th percentile of the values in the matrix.

#### phist(double start, double stop)

Returns hist(start,stop) / length.

#### product()

Returns the product of the values in the matrix.

#### stdev()

Returns the standard deviation of the values in the vector (square root of the variance).

#### sum()

Returns the sum of the values in the matrix.

#### sumLog()

Returns the sum of the natural logs of the values in the matrix.

#### sumSq()

Returns the sum of the squares of the values in the matrix.

#### variance()

Returns the variance (sum((x_i - mean)^2) / (n - 1)) of the values in the matrix.