sim.util.mantissa.linalg
Class SquareMatrix

java.lang.Object
  extended by sim.util.mantissa.linalg.Matrix
      extended by sim.util.mantissa.linalg.SquareMatrix
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
DiagonalMatrix, GeneralSquareMatrix, LowerTriangularMatrix, UpperTriangularMatrix

public abstract class SquareMatrix
extends Matrix
implements java.io.Serializable, java.lang.Cloneable

This class factor all services common to square matrices of linear algebra.

This class is the base class of all square matrix implementations. It extends the Matrix class with methods specific to square matrices.

This file is from the "Mantissa" Java software package found at http://www.spaceroots.org/software/mantissa/index.html. The license is included at the end of the source file.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class sim.util.mantissa.linalg.Matrix
columns, data, rows
 
Constructor Summary
protected SquareMatrix(int order)
          Simple constructor.
protected SquareMatrix(int order, double[] data)
          Simple constructor.
protected SquareMatrix(SquareMatrix m)
          Copy constructor.
 
Method Summary
abstract  double getDeterminant(double epsilon)
          Get the determinant of the matrix.
 SquareMatrix getInverse(double epsilon)
          Invert the instance.
abstract  Matrix solve(Matrix b, double epsilon)
          Solve the A.X = B equation.
 SquareMatrix solve(SquareMatrix b, double epsilon)
          Solve the A.X = B equation.
 
Methods inherited from class sim.util.mantissa.linalg.Matrix
add, duplicate, getColumns, getElement, getRangeForColumn, getRangeForRow, getRows, getTranspose, mul, mul, selfMul, setElement, sub, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SquareMatrix

protected SquareMatrix(int order)
Simple constructor. Build a matrix with null elements.

Parameters:
order - order of the matrix

SquareMatrix

protected SquareMatrix(int order,
                       double[] data)
Simple constructor. Build a matrix with specified elements.

Parameters:
order - order of the matrix
data - table of the matrix elements (stored row after row)

SquareMatrix

protected SquareMatrix(SquareMatrix m)
Copy constructor.

Parameters:
m - matrix to copy
Method Detail

getDeterminant

public abstract double getDeterminant(double epsilon)
Get the determinant of the matrix.

Parameters:
epsilon - threshold on matrix elements below which the matrix is considered singular (this is used by the derived classes that use a factorization to compute the determinant)
Returns:
the determinant of the matrix

getInverse

public SquareMatrix getInverse(double epsilon)
                        throws SingularMatrixException
Invert the instance.

Parameters:
epsilon - threshold on matrix elements below which the matrix is considered singular
Returns:
the inverse matrix of the instance
Throws:
SingularMatrixException - if the matrix is singular

solve

public abstract Matrix solve(Matrix b,
                             double epsilon)
                      throws SingularMatrixException
Solve the A.X = B equation.

Parameters:
b - second term of the equation
epsilon - threshold on matrix elements below which the matrix is considered singular
Returns:
a matrix X such that A.X = B, where A is the instance
Throws:
SingularMatrixException - if the matrix is singular

solve

public SquareMatrix solve(SquareMatrix b,
                          double epsilon)
                   throws SingularMatrixException
Solve the A.X = B equation.

Parameters:
b - second term of the equation
epsilon - threshold on matrix elements below which the matrix is considered singular
Returns:
a matrix X such that A.X = B, where A is the instance
Throws:
SingularMatrixException - if the matrix is singular