edu.northwestern.at.utils.math.matrix
Class MatrixTransformer

java.lang.Object
  extended by edu.northwestern.at.utils.math.matrix.MatrixTransformer

public class MatrixTransformer
extends java.lang.Object

Transform all matrix entries element-by-element.


Constructor Summary
protected MatrixTransformer()
          Don't allow instantiation but do allow overrides.
 
Method Summary
static Matrix cumulativeColumnProduct(Matrix matrix)
          Get cumulative column products for a matrix.
static Matrix cumulativeColumnSum(Matrix matrix)
          Get cumulative column sums for a matrix.
static Matrix diagonal(Matrix matrix)
          Get diagonal elements of a matrix.
static Matrix embedDiagonal(Matrix matrix, int offset)
          Compose matrix with a diagonal specified by row or column vector.
static Matrix extractDiagonal(Matrix matrix, int offset)
          Get elements of indicated diagonal (offset) as a column vector.
static Matrix extractLowerTriangle(Matrix matrix, int offset)
          Extracts lower triangular matrix given an offset that indicates the relative diagonal.
static Matrix extractUpperTriangle(Matrix matrix, int offset)
          Extracts upper triangular matrix given an offset that indicates the relative diagonal.
static Matrix inverse(Matrix matrix)
          Invert a square matrix.
static Matrix negate(Matrix matrix)
          Negate all elements of a matrix.
static Matrix pow(Matrix matrix, int power)
          Multiply square matrix by itself one or more times.
static Matrix transpose(Matrix matrix)
          Get transpose of matrix.
static Matrix zeroise(Matrix matrix, double tolerance)
          Zero out small elements (within specified tolerance) of a matrix.
static Matrix zeroize(Matrix matrix, double tolerance)
          Zero out small elements (within specified tolerance) of a matrix.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MatrixTransformer

protected MatrixTransformer()
Don't allow instantiation but do allow overrides.

Method Detail

cumulativeColumnProduct

public static Matrix cumulativeColumnProduct(Matrix matrix)
Get cumulative column products for a matrix.

Parameters:
matrix - The matrix.
Returns:
The cumulative column products as a matrix.

cumulativeColumnSum

public static Matrix cumulativeColumnSum(Matrix matrix)
Get cumulative column sums for a matrix.

Parameters:
matrix - The matrix.
Returns:
The cumulative column sums as a matrix.

diagonal

public static Matrix diagonal(Matrix matrix)
Get diagonal elements of a matrix.

Parameters:
matrix - The matrix.
Returns:
The diagonal elements in a matrix with one column.

embedDiagonal

public static Matrix embedDiagonal(Matrix matrix,
                                   int offset)
Compose matrix with a diagonal specified by row or column vector.

Parameters:
matrix - Row or column vector, e.g., (n x 1) or (1 x n) matrix.
offset - Diagonal to be embeded ( =0 will embed the elements as the main diagonal )
Returns:
Matrix with the specified diagonal elements set to the vector contents, and zero elsewhere.

extractDiagonal

public static Matrix extractDiagonal(Matrix matrix,
                                     int offset)
Get elements of indicated diagonal (offset) as a column vector.

Parameters:
matrix - The matrix.
offset - The diagonal to be extracted (=0 will extract the main diagonal)
Returns:
Column vector of elements extracted from the indicated diagonal.

extractLowerTriangle

public static Matrix extractLowerTriangle(Matrix matrix,
                                          int offset)
Extracts lower triangular matrix given an offset that indicates the relative diagonal.

Parameters:
matrix - The matrix.
offset - The diagonal to be extracted (=0 will extract the main diagonal)
Returns:
Matrix containing specified lower triangle.

extractUpperTriangle

public static Matrix extractUpperTriangle(Matrix matrix,
                                          int offset)
Extracts upper triangular matrix given an offset that indicates the relative diagonal.

Parameters:
matrix - The matrix.
offset - The diagonal to be extracted (=0 will extract the main diagonal)
Returns:
Matrix containing specified upper triangle.

inverse

public static Matrix inverse(Matrix matrix)
Invert a square matrix.

Parameters:
matrix - The matrix.
Returns:
The inverse of matrix, if matrix is square and of full rank.

negate

public static Matrix negate(Matrix matrix)
Negate all elements of a matrix.

Parameters:
matrix - Matrix.
Returns:
Matrix containing all elements of matrix negated.

pow

public static Matrix pow(Matrix matrix,
                         int power)
Multiply square matrix by itself one or more times.

Parameters:
matrix - The matrix (must be square).
power - If power > 1 performs the operation. If power <= 0 returns a matrix composed of ones.
Returns:
The resulting matrix.

transpose

public static Matrix transpose(Matrix matrix)
Get transpose of matrix.

Parameters:
matrix - The matrix whose transpose we want.
Returns:
The transpose of matrix.

zeroize

public static Matrix zeroize(Matrix matrix,
                             double tolerance)
Zero out small elements (within specified tolerance) of a matrix.

Parameters:
matrix - Matrix.
tolerance - Tolerance for zero checking.
Returns:
Matrix with elements whose absolute values is <= tolerance set to zero.

zeroise

public static Matrix zeroise(Matrix matrix,
                             double tolerance)
Zero out small elements (within specified tolerance) of a matrix.

Parameters:
matrix - Matrix.
tolerance - Tolerance for zero checking.
Returns:
Matrix with elements whose absolute values is <= tolerance set to zero.

Alternate spelling to keep Brits happy.