csli.util.math.matrix
Interface Matrix

All Superinterfaces:
Collection<Double>, Iterable<Double>
All Known Implementing Classes:
AbstractMatrix, ArrayMatrix

public interface Matrix
extends Collection<Double>


Nested Class Summary
static class Matrix.SingularMatrixException
           
 
Method Summary
 Matrix add(Matrix M)
           
 Matrix addIP(Matrix M)
           
 Matrix appendRight(Matrix M)
          Create a new matrix which contains the original matrix A and the argument B side by side, as [A B].
 Range cols()
           
 boolean equals(Object o)
           
 Matrix fill(int top, int left, Matrix M)
          Fill the matrix with the entries from M, starting at the (top, left) entry.
 double get(int i, int j)
           
 double[] getCol(int j)
          Return a double array containing the matrix's jth column.
 double[] getRow(int i)
          Return a double array containing the matrix's ith row.
 Matrix inverse()
           
 boolean isIdentity()
           
 boolean isZero()
           
 Matrix leftDivide(Matrix M)
          Matrix left-division: equal to A^(-1)*M.
 Matrix multiply(double c)
           
 Matrix multiply(Matrix M)
          Returns the product of this matrix with M.
 Matrix multiplyIP(double c)
           
 int numCols()
           
 int numRows()
           
 Matrix ref()
          Use Gaussian elimination to put the matrix in row echelon form.
 Range rows()
           
 Matrix rref()
          Puts this matrix in reduced row echelon form using Gauss-Jordan elimination.
 void set(int i, int j, double val)
           
 void setCol(int j, double[] col)
          Sets the jth column of the matrix equal to col.
 Matrix setDiag(double value)
          Set all the diagonal entries of the matrix equal to value.
 void setRow(int i, double[] row)
          Sets the ith row of the matrix equal to row.
 Matrix submatrix(int top, int left)
           
 Matrix submatrix(int top, int left, int rows, int cols)
           
 Matrix subtract(Matrix M)
           
 Matrix subtractIP(Matrix M)
           
 Matrix transpose()
           
 
Methods inherited from interface java.util.Collection
add, addAll, clear, contains, containsAll, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
 

Method Detail

numRows

int numRows()

numCols

int numCols()

rows

Range rows()

cols

Range cols()

get

double get(int i,
           int j)

set

void set(int i,
         int j,
         double val)

setDiag

Matrix setDiag(double value)
Set all the diagonal entries of the matrix equal to value.

Parameters:
value -
Returns:

isZero

boolean isZero()

isIdentity

boolean isIdentity()

equals

boolean equals(Object o)
Specified by:
equals in interface Collection<Double>
Overrides:
equals in class Object

multiply

Matrix multiply(Matrix M)
Returns the product of this matrix with M. Throws an IllegalArgumentException if this.numCols != M.numRows.

Parameters:
M -
Returns:
a this.numRows x M.numCols matrix.

add

Matrix add(Matrix M)

subtract

Matrix subtract(Matrix M)

multiply

Matrix multiply(double c)

addIP

Matrix addIP(Matrix M)

subtractIP

Matrix subtractIP(Matrix M)

multiplyIP

Matrix multiplyIP(double c)

submatrix

Matrix submatrix(int top,
                 int left)

submatrix

Matrix submatrix(int top,
                 int left,
                 int rows,
                 int cols)

appendRight

Matrix appendRight(Matrix M)
Create a new matrix which contains the original matrix A and the argument B side by side, as [A B].

Parameters:
M -
Returns:

inverse

Matrix inverse()
               throws Matrix.SingularMatrixException
Throws:
Matrix.SingularMatrixException

leftDivide

Matrix leftDivide(Matrix M)
                  throws Matrix.SingularMatrixException
Matrix left-division: equal to A^(-1)*M. Calculated by appending M to the right side of A, then row-reducing, and returning the result of the operation on M. If A is not invertible, throws a SingularMatrixException.

Throws:
Matrix.SingularMatrixException

rref

Matrix rref()
Puts this matrix in reduced row echelon form using Gauss-Jordan elimination. Note: this method is destructive: the original matrix is lost.

Returns:
The matrix.

ref

Matrix ref()
Use Gaussian elimination to put the matrix in row echelon form.

Returns:

getRow

double[] getRow(int i)
Return a double array containing the matrix's ith row.

Parameters:
i -
Returns:

getCol

double[] getCol(int j)
Return a double array containing the matrix's jth column.

Parameters:
j -
Returns:

setRow

void setRow(int i,
            double[] row)
Sets the ith row of the matrix equal to row. If row.length != cols(), throws an IllegalArgumentException.

Parameters:
i -
row -

setCol

void setCol(int j,
            double[] col)
Sets the jth column of the matrix equal to col. If col.length != rows(), throws an IllegalArgumentException.

Parameters:
j -
col -

transpose

Matrix transpose()
Returns:
the transpose of the matrix.

fill

Matrix fill(int top,
            int left,
            Matrix M)
Fill the matrix with the entries from M, starting at the (top, left) entry.

Parameters:
top -
left -
M -
Returns: