org.jscience.mathematics.algebraic.matrices
Class AbstractDoubleSquareMatrix

java.lang.Object
  extended by org.jscience.mathematics.algebraic.AbstractHypermatrix
      extended by org.jscience.mathematics.algebraic.AbstractMatrix
          extended by org.jscience.mathematics.algebraic.matrices.AbstractDoubleMatrix
              extended by org.jscience.mathematics.algebraic.matrices.AbstractDoubleSquareMatrix
All Implemented Interfaces:
java.io.Serializable, Algebra.Member, Ring.Member, AbelianGroup.Member, Hypermatrix, Matrix, Module.Member, VectorSpace.Member, SquareMatrix, Member
Direct Known Subclasses:
DoubleDiagonalMatrix, DoubleSparseSquareMatrix, DoubleSquareMatrix, DoubleTridiagonalMatrix

public abstract class AbstractDoubleSquareMatrix
extends AbstractDoubleMatrix
implements SquareMatrix

The AbstractDoubleSquareMatrix class provides an object for encapsulating double square matrices.

See Also:
Serialized Form

Field Summary
protected  AbstractDoubleSquareMatrix[] LU
           
protected  int[] LUpivot
           
 
Constructor Summary
protected AbstractDoubleSquareMatrix(int size)
          Constructs a matrix.
 
Method Summary
 AbstractDoubleMatrix add(AbstractDoubleMatrix m)
          Returns the addition of this matrix and another.
 AbstractDoubleSquareMatrix add(AbstractDoubleSquareMatrix m)
          Returns the addition of this matrix and another.
 AbstractDoubleSquareMatrix[] choleskyDecompose()
          Returns the Cholesky decomposition of this matrix.
 double det()
          Returns the determinant.
 AbstractDoubleSquareMatrix directSum(AbstractDoubleSquareMatrix m)
          Returns the direct sum of this matrix and another.
 AbstractDoubleSquareMatrix inverse()
          Returns the inverse of this matrix.
 boolean isSymmetric()
          Returns true if this matrix is symmetric.
 boolean isUnitary()
          Returns true if this matrix is unitary.
 AbstractDoubleSquareMatrix[] luDecompose(int[] pivot)
          Returns the LU decomposition of this matrix.
 AbstractDoubleSquareMatrix multiply(AbstractDoubleSquareMatrix m)
          Returns the multiplication of this matrix and another.
 AbelianGroup.Member negate()
          Returns the negative of this matrix.
 double operatorNorm()
          Returns the operator norm.
 AbstractDoubleSquareMatrix[] polarDecompose()
          Returns the polar decomposition of this matrix.
 AbstractDoubleSquareMatrix[] qrDecompose()
          Returns the QR decomposition of this matrix.
 AbstractDoubleMatrix scalarDivide(double x)
          Returns the division of this matrix by a scalar.
 AbstractDoubleMatrix scalarMultiply(double x)
          Returns the multiplication of this matrix by a scalar.
 double scalarProduct(AbstractDoubleMatrix m)
          Returns the scalar product of this matrix and another.
 double scalarProduct(AbstractDoubleSquareMatrix m)
          Returns the scalar product of this matrix and another.
 AbstractDoubleSquareMatrix[] singularValueDecompose()
          Returns the singular value decomposition of this matrix.
 AbstractDoubleMatrix subtract(AbstractDoubleMatrix m)
          Returns the subtraction of this matrix and another.
 AbstractDoubleSquareMatrix subtract(AbstractDoubleSquareMatrix m)
          Returns the subtraction of this matrix by another.
 AbstractDoubleSquareMatrix tensorProduct(AbstractDoubleSquareMatrix m)
          Returns the tensor product of this matrix and another.
 AbstractComplexMatrix toComplexMatrix()
          Converts this matrix to a complex matrix.
 AbstractIntegerMatrix toIntegerMatrix()
          Converts this matrix to an integer matrix.
 double trace()
          Returns the trace.
 Matrix transpose()
          Returns the transpose of this matrix.
 
Methods inherited from class org.jscience.mathematics.algebraic.matrices.AbstractDoubleMatrix
abs, add, directSum, equals, equals, equals, frobeniusNorm, getColumn, getElement, getMatrixAsColumns, getMatrixAsRows, getPrimitiveElement, getRow, getSet, getSubMatrix, hashCode, horizontalAxisSymmetry, infNorm, mapElements, mass, max, mean, min, multiply, multiply, multiply, read, reverse, scalarDivide, scalarMultiply, setAllElements, setColumn, setElement, setRow, setSubMatrix, subtract, tensorProduct, toPrimitiveArray, toString, verticalAxisSymmetry
 
Methods inherited from class org.jscience.mathematics.algebraic.AbstractMatrix
getElement, getInvalidElementMsg, numColumns, numRows, print, print, print, print, toArray, toArray
 
Methods inherited from class org.jscience.mathematics.algebraic.AbstractHypermatrix
getDimensions, numDimensions, numElements, numElements, toArray
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jscience.mathematics.algebraic.Matrix
getColumn, getElement, getRow, numColumns, numRows, toArray
 
Methods inherited from interface org.jscience.mathematics.algebraic.Hypermatrix
getDimensions, getElement, numDimensions, numElements, numElements, toArray, toArray
 

Field Detail

LU

protected transient AbstractDoubleSquareMatrix[] LU

LUpivot

protected transient int[] LUpivot
Constructor Detail

AbstractDoubleSquareMatrix

protected AbstractDoubleSquareMatrix(int size)
Constructs a matrix.

Method Detail

toIntegerMatrix

public AbstractIntegerMatrix toIntegerMatrix()
Converts this matrix to an integer matrix.

Overrides:
toIntegerMatrix in class AbstractDoubleMatrix
Returns:
an integer square matrix

toComplexMatrix

public AbstractComplexMatrix toComplexMatrix()
Converts this matrix to a complex matrix.

Overrides:
toComplexMatrix in class AbstractDoubleMatrix
Returns:
a complex square matrix

isSymmetric

public boolean isSymmetric()
Returns true if this matrix is symmetric.

Specified by:
isSymmetric in interface SquareMatrix
Returns:
DOCUMENT ME!

isUnitary

public boolean isUnitary()
Returns true if this matrix is unitary.


det

public double det()
Returns the determinant.


trace

public double trace()
Returns the trace.


operatorNorm

public double operatorNorm()
                    throws MaximumIterationsExceededException
Returns the operator norm.

Throws:
MaximumIterationsExceededException - If it takes more than 50 iterations to determine an eigenvalue.

negate

public AbelianGroup.Member negate()
Returns the negative of this matrix.

Specified by:
negate in interface AbelianGroup.Member
Overrides:
negate in class AbstractDoubleMatrix
Returns:
DOCUMENT ME!

add

public final AbstractDoubleMatrix add(AbstractDoubleMatrix m)
Returns the addition of this matrix and another.

Overrides:
add in class AbstractDoubleMatrix
Parameters:
m - a double square matrix
Throws:
IllegalDimensionException - If the matrices are not square or different sizes.

add

public AbstractDoubleSquareMatrix add(AbstractDoubleSquareMatrix m)
Returns the addition of this matrix and another.

Parameters:
m - a double square matrix
Throws:
IllegalDimensionException - If the matrices are different sizes.

subtract

public final AbstractDoubleMatrix subtract(AbstractDoubleMatrix m)
Returns the subtraction of this matrix and another.

Overrides:
subtract in class AbstractDoubleMatrix
Parameters:
m - a double square matrix
Throws:
IllegalDimensionException - If the matrices are not square or different sizes.

subtract

public AbstractDoubleSquareMatrix subtract(AbstractDoubleSquareMatrix m)
Returns the subtraction of this matrix by another.

Parameters:
m - a double square matrix
Throws:
IllegalDimensionException - If the matrices are different sizes.

scalarMultiply

public AbstractDoubleMatrix scalarMultiply(double x)
Returns the multiplication of this matrix by a scalar.

Overrides:
scalarMultiply in class AbstractDoubleMatrix
Parameters:
x - a double.
Returns:
a double square matrix.

scalarDivide

public AbstractDoubleMatrix scalarDivide(double x)
Returns the division of this matrix by a scalar.

Overrides:
scalarDivide in class AbstractDoubleMatrix
Parameters:
x - a double.
Returns:
a double square matrix.

scalarProduct

public final double scalarProduct(AbstractDoubleMatrix m)
Returns the scalar product of this matrix and another.

Overrides:
scalarProduct in class AbstractDoubleMatrix
Parameters:
m - a double square matrix.
Throws:
IllegalDimensionException - If the matrices are not square or different sizes.

scalarProduct

public double scalarProduct(AbstractDoubleSquareMatrix m)
Returns the scalar product of this matrix and another.

Parameters:
m - a double square matrix.
Throws:
IllegalDimensionException - If the matrices are different sizes.

multiply

public AbstractDoubleSquareMatrix multiply(AbstractDoubleSquareMatrix m)
Returns the multiplication of this matrix and another.

Parameters:
m - a double square matrix
Throws:
IllegalDimensionException - If the matrices are different sizes.

directSum

public AbstractDoubleSquareMatrix directSum(AbstractDoubleSquareMatrix m)
Returns the direct sum of this matrix and another.


tensorProduct

public AbstractDoubleSquareMatrix tensorProduct(AbstractDoubleSquareMatrix m)
Returns the tensor product of this matrix and another.


transpose

public Matrix transpose()
Returns the transpose of this matrix.

Specified by:
transpose in interface Matrix
Overrides:
transpose in class AbstractDoubleMatrix
Returns:
a double square matrix

inverse

public AbstractDoubleSquareMatrix inverse()
Returns the inverse of this matrix.

Returns:
a double square matrix.

luDecompose

public AbstractDoubleSquareMatrix[] luDecompose(int[] pivot)
Returns the LU decomposition of this matrix.

Parameters:
pivot - an empty array of length numRows()+1 to hold the pivot information (null if not interested). The last array element will contain the parity.
Returns:
an array with [0] containing the L-matrix and [1] containing the U-matrix.

choleskyDecompose

public AbstractDoubleSquareMatrix[] choleskyDecompose()
Returns the Cholesky decomposition of this matrix. Matrix must be symmetric and positive definite.

Returns:
an array with [0] containing the L-matrix and [1] containing the U-matrix.

qrDecompose

public AbstractDoubleSquareMatrix[] qrDecompose()
Returns the QR decomposition of this matrix. Based on the code from JAMA (public domain).

Returns:
an array with [0] containing the Q-matrix and [1] containing the R-matrix.

singularValueDecompose

public AbstractDoubleSquareMatrix[] singularValueDecompose()
Returns the singular value decomposition of this matrix. Based on the code from JAMA (public domain).

Returns:
an array with [0] containing the U-matrix, [1] containing the S-matrix and [2] containing the V-matrix.

polarDecompose

public AbstractDoubleSquareMatrix[] polarDecompose()
Returns the polar decomposition of this matrix.