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

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

public class MatrixFactory
extends java.lang.Object

MatrixFactory creates matrices with different types of entries.


Field Summary
protected static java.lang.Class defaultMatrixClass
          Default matrix implementation class.
 
Constructor Summary
protected MatrixFactory()
          Don't allow instantiation but do allow overrides.
 
Method Summary
static Matrix createIdentityMatrix(int size)
          Create an identity matrix.
static Matrix createIdentityMatrix(int size, java.lang.Class matrixClass)
          Create an identity matrix.
static Matrix createMatrix(double[][] values)
          Create matrix with specified values.
static Matrix createMatrix(double[][] values, java.lang.Class matrixClass)
          Create matrix with specified values.
static Matrix createMatrix(int rows, int columns)
          Create matrix with specified dimensions.
static Matrix createMatrix(int rows, int columns, java.lang.Class matrixClass)
          Create matrix of specified dimensions and implementation class.
static Matrix createMatrix(int rows, int columns, double scalar)
          Create matrix with specified dimensions and a specified value.
static Matrix createMatrix(int rows, int columns, double[][] values)
          Create matrix with specified dimensions and values.
static Matrix createMatrix(int rows, int columns, double[][] values, java.lang.Class matrixClass)
          Create matrix with specified dimensions and values.
static Matrix createMatrix(int rows, int columns, double scalar, java.lang.Class matrixClass)
          Create matrix with specified dimensions and a specified value.
static Matrix createMatrix(java.util.List list)
          Create a column vector matrix from a list of double values.
static Matrix createMatrix(java.util.List list, java.lang.Class matrixClass)
          Create a column vector matrix from a list of double values.
static Matrix createMatrix(Matrix matrix)
          Create matrix from another matrix.
static Matrix createRandomMatrix(int rows, int columns)
          Create matrix with specified dimensions filled with random values.
static Matrix createRandomMatrix(int rows, int columns, java.lang.Class matrixClass)
          Create matrix with specified dimensions filled with random values.
static Matrix createScalarMatrix(int size, double diagonalValue)
          Creates a scalar matrix.
static Matrix createScalarMatrix(int size, double[] diagonalValues)
          Creates a scalar matrix.
static Matrix createScalarMatrix(int size, double[] diagonalValues, java.lang.Class matrixClass)
          Creates a scalar matrix.
static Matrix createScalarMatrix(int size, double diagonalValue, java.lang.Class matrixClass)
          Creates a scalar matrix.
static java.lang.Class getDefaultMatrixClass()
          Get default matrix class.
static boolean isMatrixClass(java.lang.Class possibleMatrixClass)
          Determine if a class implements the Matrix interface.
static void setDefaultMatrixClass(java.lang.Class matrixClass)
          Set default matrix class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

defaultMatrixClass

protected static java.lang.Class defaultMatrixClass
Default matrix implementation class.

Constructor Detail

MatrixFactory

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

Method Detail

createMatrix

public static Matrix createMatrix(int rows,
                                  int columns,
                                  java.lang.Class matrixClass)
Create matrix of specified dimensions and implementation class.

Parameters:
rows - Number of rows in the matrix (> 1).
columns - Number of columns in the matrix (> 1).
matrixClass - Implementation class for the matrix.
Returns:
Matrix of the given dimensions and matrix class with all entries set to zero.

createMatrix

public static Matrix createMatrix(int rows,
                                  int columns)
Create matrix with specified dimensions.

Parameters:
rows - Number of rows in the matrix (> 1).
columns - Number of columns in the matrix (> 1).
Returns:
Matrix of the given dimensions with all entries set to zero.

createMatrix

public static Matrix createMatrix(int rows,
                                  int columns,
                                  double scalar,
                                  java.lang.Class matrixClass)
Create matrix with specified dimensions and a specified value.

Parameters:
rows - Number of rows in the matrix (> 1).
columns - Number of columns in the matrix (> 1).
scalar - Initial value for each matrix element.
matrixClass - Implementation class for the matrix.
Returns:
Matrix of the given dimensions and value.

createMatrix

public static Matrix createMatrix(int rows,
                                  int columns,
                                  double scalar)
Create matrix with specified dimensions and a specified value.

Parameters:
rows - Number of rows in the matrix (> 1).
columns - Number of columns in the matrix (> 1).
scalar - Initial value for each matrix element.
Returns:
Matrix of the given dimensions and value.

createMatrix

public static Matrix createMatrix(int rows,
                                  int columns,
                                  double[][] values,
                                  java.lang.Class matrixClass)
Create matrix with specified dimensions and values.

All elements are set to values in the passed array.

Parameters:
rows - Number of rows in the matrix (> 1).
columns - Number of columns in the matrix (> 1).
values - Initial values of the matrix elements.
matrixClass - Implementation class for the matrix.
Returns:
Matrix of given dimensions and values.

createMatrix

public static Matrix createMatrix(int rows,
                                  int columns,
                                  double[][] values)
Create matrix with specified dimensions and values.

All elements are set to values in the passed array.

Parameters:
rows - Number of rows in the matrix (> 1).
columns - Number of columns in the matrix (> 1).
values - Initial values of the matrix elements.
Returns:
Matrix of given dimensions and values.

createMatrix

public static Matrix createMatrix(double[][] values,
                                  java.lang.Class matrixClass)
Create matrix with specified values.

Parameters:
values - Initial values of the matrix elements.
matrixClass - Implementation class for the matrix.
Returns:
Matrix of given values.

All elements are set to values in the passed array.


createMatrix

public static Matrix createMatrix(double[][] values)
Create matrix with specified values.

All elements are set to values in the passed array.

Parameters:
values - Initial values of the matrix elements.
Returns:
Matrix of given values.

createMatrix

public static Matrix createMatrix(java.util.List list,
                                  java.lang.Class matrixClass)
Create a column vector matrix from a list of double values.

Parameters:
list - List containing the Double values for the matrix.
matrixClass - Implementation class for the matrix.
Returns:
Matrix as a column vector with the specified values.

createMatrix

public static Matrix createMatrix(java.util.List list)
Create a column vector matrix from a list of double values.

Parameters:
list - List containing the Double values for the matrix.
Returns:
Matrix as a column vector with the specified values.

createMatrix

public static Matrix createMatrix(Matrix matrix)
Create matrix from another matrix.

Parameters:
matrix - Matrix to copy.
Returns:
Deep copy of source matrix. The implementation class of the copy is always the same as the source matrix.

createIdentityMatrix

public static Matrix createIdentityMatrix(int size,
                                          java.lang.Class matrixClass)
Create an identity matrix.

Parameters:
size - Row and column size of the square matrix.
matrixClass - Implementation class for the matrix.
Returns:
Square matrix with diagonal elements set to 1.

createIdentityMatrix

public static Matrix createIdentityMatrix(int size)
Create an identity matrix.

Parameters:
size - Row and column size of the square matrix.
Returns:
Square matrix with diagonal elements set to 1.

createScalarMatrix

public static Matrix createScalarMatrix(int size,
                                        double diagonalValue,
                                        java.lang.Class matrixClass)
Creates a scalar matrix.

Parameters:
size - Number of rows and columns in the square matrix.
diagonalValue - The value for each main diagonal element.
matrixClass - Implementation class for the matrix.
Returns:
Square matrix with all diagonal elements set to the specified diagonal value.

createScalarMatrix

public static Matrix createScalarMatrix(int size,
                                        double diagonalValue)
Creates a scalar matrix.

Parameters:
size - Number of rows and columns in the square matrix.
diagonalValue - The value for each main diagonal element.
Returns:
Square matrix with all diagonal elements set to the specified diagonal value.

createScalarMatrix

public static Matrix createScalarMatrix(int size,
                                        double[] diagonalValues,
                                        java.lang.Class matrixClass)
Creates a scalar matrix.

Parameters:
size - Number of rows and columns in the square matrix.
diagonalValues - double[] vector of values for each main diagonal element.
matrixClass - Implementation class for the matrix.
Returns:
Square matrix with all diagonal elements set to the specified diagonal values.

createScalarMatrix

public static Matrix createScalarMatrix(int size,
                                        double[] diagonalValues)
Creates a scalar matrix.

Parameters:
size - Number of rows and columns in the square matrix.
diagonalValues - double[] vector of values for each main diagonal element.
Returns:
Square matrix with all diagonal elements set to the specified diagonal values.

createRandomMatrix

public static Matrix createRandomMatrix(int rows,
                                        int columns,
                                        java.lang.Class matrixClass)
Create matrix with specified dimensions filled with random values.

Parameters:
rows - Number of rows in the matrix (> 1).
columns - Number of columns in the matrix (> 1).
matrixClass - Implementation class for the matrix.
Returns:
Matrix of the given dimensions with all entries set to uniform random numbers from [0,1].

createRandomMatrix

public static Matrix createRandomMatrix(int rows,
                                        int columns)
Create matrix with specified dimensions filled with random values.

Parameters:
rows - Number of rows in the matrix (> 1).
columns - Number of columns in the matrix (> 1).
Returns:
Matrix of the given dimensions with all entries set to uniform random numbers from [0,1].

isMatrixClass

public static boolean isMatrixClass(java.lang.Class possibleMatrixClass)
Determine if a class implements the Matrix interface.

Parameters:
possibleMatrixClass - The class to check.
Returns:
true if the class implements Matrix, else false.

getDefaultMatrixClass

public static java.lang.Class getDefaultMatrixClass()
Get default matrix class.

Returns:
The default matrix class for creating matrices.

setDefaultMatrixClass

public static void setDefaultMatrixClass(java.lang.Class matrixClass)
Set default matrix class.

Parameters:
matrixClass - The default matrix class for creating matrices.