org.jmatrices.dbl
Class MatrixFactory

java.lang.Object
  extended byorg.jmatrices.dbl.MatrixFactory

public class MatrixFactory
extends java.lang.Object

MatrixFactory is one-stop shop for creating matrices.

  1. Rectangular(Square, Vector) matrices, initialized to 0.0, scalar or array of values
  2. Scalar Matrices including Identity matrix

todo how to provide a mechanism to change implementations (from LightMatrixImpl to HeavyMatrixImpl), intelligent choice or user's choice?
todo consider deserialization of matrices from ascii, mathml, xml files.
todo serialization? through matrix interface ?

Author: purangp

Date: 07.03.2004 Time: 15:56:59


Method Summary
static Matrix getEmptyMatrix()
          Deprecated.  
static Matrix getIdentityMatrix(int dim, Matrix hint)
          Gets an Identity matrix
static Matrix getMatrix(int rows, int cols, Matrix hint)
          Gets a matrix of the asked dimensions.
static Matrix getMatrix(int rows, int cols, Matrix hint, double scalar)
          Gets a matrix of the asked dimensions.
static Matrix getMatrix(int rows, int cols, Matrix hint, double[][] values)
          Gets a matrix of the asked dimensions.
static Matrix getMatrix(java.util.List list, Matrix hint)
          Gets a column vector with list values composing the vector's values.
static Matrix getRandomMatrix(int rows, int cols, Matrix hint)
          Gets a matrix of the asked dimensions, filled with random values

static Matrix getScalarMatrix(int dim, Matrix hint, double scalar)
          Gets a scalar matrix.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getEmptyMatrix

public static Matrix getEmptyMatrix()
Deprecated.  

Please refer to the java doc of EmptyMatrix to see the reason for deprecation

Returns:

getMatrix

public static Matrix getMatrix(int rows,
                               int cols,
                               Matrix hint)
Gets a matrix of the asked dimensions.

All elements are set to 0.0

Parameters:
rows - number of rows in the matrix (> 1)
cols - number of columns in the matrix (> 1)
hint - acts as a hint for the right implementation to use
Returns:
Matrix of the given dimensions

getRandomMatrix

public static Matrix getRandomMatrix(int rows,
                                     int cols,
                                     Matrix hint)
Gets a matrix of the asked dimensions, filled with random values

Parameters:
rows - number of rows in the matrix (> 1)
cols - number of columns in the matrix (> 1)
hint - acts as a hint for the right implementation to use
Returns:
Matrix of the given dimensions

getMatrix

public static Matrix getMatrix(int rows,
                               int cols,
                               Matrix hint,
                               double scalar)
Gets a matrix of the asked dimensions.

All elements are set to scalar.

Parameters:
rows - number of rows in the matrix (> 1)
cols - number of columns in the matrix (> 1)
hint - acts as a hint for the right implementation to use
scalar - initial value of the elements
Returns:
Matrix of the given dimensions and value

getMatrix

public static Matrix getMatrix(int rows,
                               int cols,
                               Matrix hint,
                               double[][] values)
Gets a matrix of the asked dimensions.

All elements are set to values in the passed array.

Parameters:
rows - number of rows in the matrix (> 1)
cols - number of columns in the matrix (> 1)
hint - acts as a hint for the right implementation to use
values - initial value of the elements
Returns:
Matrix of the given dimensions and values

getIdentityMatrix

public static Matrix getIdentityMatrix(int dim,
                                       Matrix hint)
Gets an Identity matrix

Parameters:
dim - dimension of the square matrix
hint - acts as a hint for the right implementation to use
Returns:
Square matrix with the diagonal elements set to 1.

getScalarMatrix

public static Matrix getScalarMatrix(int dim,
                                     Matrix hint,
                                     double scalar)
Gets a scalar matrix.

Parameters:
dim - dimension of the square matrix
hint - acts as a hint for the right implementation to use
scalar - the value the main diagonal elements have to be set to
Returns:
Square matrix with the diagonal elements set to scalar value.

getMatrix

public static Matrix getMatrix(java.util.List list,
                               Matrix hint)
Gets a column vector with list values composing the vector's values.
Note: will throw an IllegalArgumentException if list.size()<=0

Parameters:
list - list containing the Double values that will be used to compose the vector
hint - acts as a hint for the right implementation to use
Returns:
column vector