## smithers.algorithms Class Matrix

```java.lang.Object
smithers.algorithms.Matrix
```

`public class Matrixextends java.lang.Object`

Implements a collection of useful matrix related algorithms. The methods of this class all require that the matrix arguments be rectangular; for efficiency they do not check this, hence if the arguments are invalid, they will likely throw `ArrayIndexOutOfBoundsException` or `NullPointerException`

Method Summary
`static void` ```decomposeLQ(float[][] matrix, float[][] l, float[][] q)```
Computes an LQ decomposition of a matrix.
`static float[]` ```product(float[][] matrix, float[] vector)```
Multiplies a matrix by a column vector.
`static float[][]` ```product(float[][] matrix1, float[][] matrix2)```
Multiplies two matrices together.
`static float[]` ```product(float[] vector, float[][] matrix)```
Multiplies a row vector by a matrix.
`static void` `rowReduce(float[][] matrix)`
Row reduce a matrix in-place.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### product

```public static float[][] product(float[][] matrix1,
float[][] matrix2)```
Multiplies two matrices together. The first matrix must have as many columns as the second has rows.

Parameters:
`matrix1` - a matrix
`matrix2` - another matrix
Returns:
`matrix1 * matrix2`

### product

```public static float[] product(float[][] matrix,
float[] vector)```
Multiplies a matrix by a column vector. The vector must have as many elements as the matrix has columns.

Parameters:
`matrix` - a matrix
`vector` - a vector
Returns:
`matrix * vector`

### product

```public static float[] product(float[] vector,
float[][] matrix)```
Multiplies a row vector by a matrix. The vector must have as many elements as the matrix has rows.

Parameters:
`vector` - a vector
`matrix` - a matrix
Returns:
`vector * matrix`

### rowReduce

`public static void rowReduce(float[][] matrix)`
Row reduce a matrix in-place. Uses Gauss-Jordan elimination with scaled partial pivoting.

Parameters:
`matrix` - the matrix to reduce

### decomposeLQ

```public static void decomposeLQ(float[][] matrix,
float[][] l,
float[][] q)```
Computes an LQ decomposition of a matrix. The matrix must have at least as many columns as rows. This computes L and Q such that A = LQ, with L lower triangular and Q orthogonal. Uses the modified Gram-Schmidt process, further modified to still work if A is not square or if the rows of A are not linearly independant; in the latter case the matrix L will have one or more zero entries on the diagonal.

Parameters:
`matrix` - the matrix to decompose
`l` - the matrix in which to store L; must have the same dimensions as `matrix`
`q` - the matrix in which to store Q; must be square of dimension equal to the number of columns of `matrix`