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

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

public class MatrixOperator
extends java.lang.Object

MatrixOperator provides operations that can be performed on two or more matrices.

Given two matrices A,B -yields- C, where C is another matrix.


Constructor Summary
protected MatrixOperator()
          Don't allow instantiation but do allow overrides.
 
Method Summary
static Matrix add(Matrix a, Matrix b)
          Matrix addition.
static Matrix applyEBEOperation(Matrix a, Matrix b, MatrixEBEOperation matrixOperation)
          Applies element-by-element operation combining elements of two matrices.
static Matrix divideEBE(Matrix a, Matrix b)
          Element by element matrix division.
static Matrix horizontalConcatenation(Matrix a, Matrix b)
          Concatenates a and b horizontally with b's columns attached to the end of a

rows of a must be equal to rows of b
Note: Matrix a's underlying implementation is propogated in the resulting matrix

static Matrix horizontalDirectProduct(Matrix a, Matrix b)
          Gets the Horizontal Direct Product of two matrices.
static Matrix kroneckerProduct(Matrix a, Matrix b)
          Gets the Kronecker (tensor) product of the two matrices.
static Matrix multiply(Matrix a, Matrix b)
          Matrix multiplication.
static Matrix multiplyEBE(Matrix a, Matrix b)
          Element by element matrix multiplication.
static Matrix solve(Matrix x, Matrix b)
          Solves system of equations.
static Matrix subtract(Matrix a, Matrix b)
          Matrix subtraction.
static Matrix verticalConcatenation(Matrix a, Matrix b)
          Concatenates a and b vertically with b's rows following the a's rows

cols of a must be equal to colss of b
Note: Matrix a's underlying implementation is propogated in the resulting matrix

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

Constructor Detail

MatrixOperator

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

Method Detail

applyEBEOperation

public static Matrix applyEBEOperation(Matrix a,
                                       Matrix b,
                                       MatrixEBEOperation matrixOperation)
Applies element-by-element operation combining elements of two matrices.

Parameters:
a - First matrix.
b - Second Matrix.
matrixOperation - Operation to be performed on corresponding elements of a and b.
Returns:
Matrix resulting from operation.
Throws:
MatrixMismatchedSizeException - when a and b are not the same size.

solve

public static Matrix solve(Matrix x,
                           Matrix b)
Solves system of equations.

Parameters:
x - The coefficient matrix. Need not be square.
b - The constant vector.
Returns:
The solution matrix or c = x / b .

When the matrix is square, uses an LU decomposition. Otherwise uses a QR decomposition.


add

public static Matrix add(Matrix a,
                         Matrix b)
Matrix addition.

Parameters:
a - First matrix.
b - Second matrix.
Returns:
Matrix containing elementwise sums of each element in a and b.

subtract

public static Matrix subtract(Matrix a,
                              Matrix b)
Matrix subtraction.

Parameters:
a - First matrix.
b - Second matrix.
Returns:
Matrix containing elementwise differences of each element in a and b.

multiply

public static Matrix multiply(Matrix a,
                              Matrix b)
Matrix multiplication.

Parameters:
a - First matrix.
b - Second matrix.
Returns:
Matrix multiplication of a * b .
Throws:
MatrixMismatchedSizeException - when a and b do not conform for multiplication.

multiplyEBE

public static Matrix multiplyEBE(Matrix a,
                                 Matrix b)
Element by element matrix multiplication.

Parameters:
a - First matrix.
b - Second matrix.
Returns:
Matrix containing elementwise products of each element in a and b.

divideEBE

public static Matrix divideEBE(Matrix a,
                               Matrix b)
Element by element matrix division.

Parameters:
a - First matrix.
b - Second matrix.
Returns:
Matrix containing elementwise quotients of each element in a and b.

If a division is attempted, the result is set to zero.


horizontalConcatenation

public static Matrix horizontalConcatenation(Matrix a,
                                             Matrix b)
Concatenates a and b horizontally with b's columns attached to the end of a

rows of a must be equal to rows of b
Note: Matrix a's underlying implementation is propogated in the resulting matrix

Parameters:
a - Matrix
b - Matrix
Returns:
c = a~b //gauss syntax

verticalConcatenation

public static Matrix verticalConcatenation(Matrix a,
                                           Matrix b)
Concatenates a and b vertically with b's rows following the a's rows

cols of a must be equal to colss of b
Note: Matrix a's underlying implementation is propogated in the resulting matrix

Parameters:
a - Matrix
b - Matrix
Returns:
c = a|b //gauss syntax

kroneckerProduct

public static Matrix kroneckerProduct(Matrix a,
                                      Matrix b)
Gets the Kronecker (tensor) product of the two matrices.

Parameters:
a - First matrix.
b - Second matrix.
Returns:
Matrix containing tensor product of a and b.

horizontalDirectProduct

public static Matrix horizontalDirectProduct(Matrix a,
                                             Matrix b)
Gets the Horizontal Direct Product of two matrices.

Parameters:
a - First matrix.
b - Second matrix.
Returns:
Matrix containing horizontal direct product of a and b.