org.jscience.mathematics.algebraic.matrices
Class IntegerSquareMatrix

java.lang.Object
  extended by org.jscience.mathematics.algebraic.AbstractHypermatrix
      extended by org.jscience.mathematics.algebraic.AbstractMatrix
          extended by org.jscience.mathematics.algebraic.matrices.AbstractIntegerMatrix
              extended by org.jscience.mathematics.algebraic.matrices.AbstractIntegerSquareMatrix
                  extended by org.jscience.mathematics.algebraic.matrices.IntegerSquareMatrix
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Algebra.Member, Ring.Member, AbelianGroup.Member, Hypermatrix, Matrix, Module.Member, VectorSpace.Member, SquareMatrix, Member
Direct Known Subclasses:
IntegerSymmetricMatrix

public class IntegerSquareMatrix
extends AbstractIntegerSquareMatrix
implements java.lang.Cloneable, java.io.Serializable

The IntegerSquareMatrix class provides an object for encapsulating integer square matrices.

See Also:
Serialized Form

Field Summary
protected  int[][] matrix
          Array containing the elements of the matrix.
 
Fields inherited from class org.jscience.mathematics.algebraic.matrices.AbstractIntegerSquareMatrix
LU, LUpivot
 
Constructor Summary
IntegerSquareMatrix(AbstractIntegerVector[] array)
          Constructs a matrix from an array of vectors (columns).
IntegerSquareMatrix(int size)
          Constructs an empty matrix.
IntegerSquareMatrix(int[][] array)
          Constructs a matrix by wrapping an array.
IntegerSquareMatrix(IntegerSquareMatrix mat)
          Copy constructor.
 
Method Summary
 AbstractIntegerSquareMatrix add(AbstractIntegerSquareMatrix m)
          Returns the addition of this matrix and another.
 IntegerSquareMatrix add(IntegerSquareMatrix m)
           
 AbstractDoubleSquareMatrix[] choleskyDecompose()
          Returns the Cholesky decomposition of this matrix.
 java.lang.Object clone()
          Clone matrix into a new matrix.
 int det()
          Returns the determinant.
 AbstractIntegerSquareMatrix directSum(AbstractIntegerSquareMatrix m)
          Returns the direct sum of this matrix and another.
 boolean equals(AbstractIntegerMatrix m, double tol)
          Compares two ${nativeTyp} matrices for equality.
 double frobeniusNorm()
          Returns the Frobenius or Hilbert-Schmidt (l2) norm.
 int getPrimitiveElement(int i, int j)
          Returns an element of the matrix.
 int infNorm()
          Returns the linfinity-norm.
 AbstractDoubleSquareMatrix inverse()
          Returns the inverse of this matrix.
 AbstractDoubleSquareMatrix[] luDecompose(int[] pivot)
          Returns the LU decomposition of this matrix.
 AbstractIntegerSquareMatrix multiply(AbstractIntegerSquareMatrix m)
          Returns the multiplication of this matrix and another.
 AbstractIntegerVector multiply(AbstractIntegerVector v)
          Returns the multiplication of a vector by this matrix.
 IntegerSquareMatrix multiply(IntegerSquareMatrix m)
           
 AbelianGroup.Member negate()
          Returns the negative of this matrix.
 AbstractDoubleSquareMatrix[] qrDecompose()
          Returns the QR decomposition of this matrix.
 AbstractIntegerMatrix scalarMultiply(int x)
          Returns the multiplication of this matrix by a scalar.
 int scalarProduct(AbstractIntegerSquareMatrix m)
          Returns the scalar product of this matrix and another.
 int scalarProduct(IntegerSquareMatrix m)
           
 void setAllElements(int x)
          Sets the value of all elements of the matrix.
 void setElement(int i, int j, int x)
          Sets the value of an element of the matrix.
 AbstractDoubleSquareMatrix[] singularValueDecompose()
          Returns the singular value decomposition of this matrix.
 AbstractIntegerSquareMatrix subtract(AbstractIntegerSquareMatrix m)
          Returns the subtraction of this matrix by another.
 IntegerSquareMatrix subtract(IntegerSquareMatrix m)
           
 AbstractIntegerSquareMatrix tensorProduct(AbstractIntegerSquareMatrix m)
          Returns the tensor product of this matrix and another.
 AbstractComplexMatrix toComplexMatrix()
          Converts this matrix to a complex matrix.
 AbstractDoubleMatrix toDoubleMatrix()
          Converts this matrix to a double matrix.
 java.lang.String toString()
          Returns a string representing this matrix.
 int trace()
          Returns the trace.
 Matrix transpose()
          Returns the transpose of this matrix.
 
Methods inherited from class org.jscience.mathematics.algebraic.matrices.AbstractIntegerSquareMatrix
add, isSymmetric, isUnitary, scalarProduct, subtract
 
Methods inherited from class org.jscience.mathematics.algebraic.matrices.AbstractIntegerMatrix
abs, add, directSum, equals, equals, getColumn, getElement, getMatrixAsColumns, getMatrixAsRows, getRow, getSet, getSubMatrix, hashCode, horizontalAxisSymmetry, mapElements, mass, max, mean, min, multiply, multiply, read, reverse, scalarDivide, scalarMultiply, setColumn, setRow, setSubMatrix, subtract, tensorProduct, toPrimitiveArray, 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
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

matrix

protected final int[][] matrix
Array containing the elements of the matrix.

Constructor Detail

IntegerSquareMatrix

public IntegerSquareMatrix(int[][] array)
Constructs a matrix by wrapping an array.

Parameters:
array - an assigned value

IntegerSquareMatrix

public IntegerSquareMatrix(int size)
Constructs an empty matrix.


IntegerSquareMatrix

public IntegerSquareMatrix(AbstractIntegerVector[] array)
Constructs a matrix from an array of vectors (columns).

Parameters:
array - an assigned value

IntegerSquareMatrix

public IntegerSquareMatrix(IntegerSquareMatrix mat)
Copy constructor.

Parameters:
mat - an assigned value
Method Detail

equals

public boolean equals(AbstractIntegerMatrix m,
                      double tol)
Compares two ${nativeTyp} matrices for equality.

Overrides:
equals in class AbstractIntegerMatrix
Parameters:
m - a int matrix

toString

public java.lang.String toString()
Returns a string representing this matrix.

Overrides:
toString in class AbstractIntegerMatrix

toDoubleMatrix

public AbstractDoubleMatrix toDoubleMatrix()
Converts this matrix to a double matrix.

Overrides:
toDoubleMatrix in class AbstractIntegerSquareMatrix
Returns:
a double matrix

toComplexMatrix

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

Overrides:
toComplexMatrix in class AbstractIntegerSquareMatrix
Returns:
a complex matrix

getPrimitiveElement

public int getPrimitiveElement(int i,
                               int j)
Returns an element of the matrix.

Specified by:
getPrimitiveElement in class AbstractIntegerMatrix
Parameters:
i - row index of the element
j - column index of the element
Throws:
IllegalDimensionException - If attempting to access an invalid element.

setElement

public void setElement(int i,
                       int j,
                       int x)
Sets the value of an element of the matrix. Should only be used to initialise this matrix.

Specified by:
setElement in class AbstractIntegerMatrix
Parameters:
i - row index of the element
j - column index of the element
x - a number
Throws:
IllegalDimensionException - If attempting to access an invalid element.

setAllElements

public void setAllElements(int x)
Sets the value of all elements of the matrix.

Overrides:
setAllElements in class AbstractIntegerMatrix
Parameters:
x - a int element

infNorm

public int infNorm()
Returns the linfinity-norm.

Overrides:
infNorm in class AbstractIntegerMatrix

frobeniusNorm

public double frobeniusNorm()
Returns the Frobenius or Hilbert-Schmidt (l2) norm.

Overrides:
frobeniusNorm in class AbstractIntegerMatrix

det

public int det()
Returns the determinant.

Overrides:
det in class AbstractIntegerSquareMatrix

trace

public int trace()
Returns the trace.

Overrides:
trace in class AbstractIntegerSquareMatrix

negate

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

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

add

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

Overrides:
add in class AbstractIntegerSquareMatrix
Parameters:
m - a int matrix
Throws:
IllegalDimensionException - If the matrices are different sizes.

add

public IntegerSquareMatrix add(IntegerSquareMatrix m)

subtract

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

Overrides:
subtract in class AbstractIntegerSquareMatrix
Parameters:
m - a int matrix
Throws:
IllegalDimensionException - If the matrices are different sizes.

subtract

public IntegerSquareMatrix subtract(IntegerSquareMatrix m)

scalarMultiply

public AbstractIntegerMatrix scalarMultiply(int x)
Returns the multiplication of this matrix by a scalar.

Overrides:
scalarMultiply in class AbstractIntegerSquareMatrix
Parameters:
x - a int.
Returns:
a int square matrix.

scalarProduct

public int scalarProduct(AbstractIntegerSquareMatrix m)
Returns the scalar product of this matrix and another.

Overrides:
scalarProduct in class AbstractIntegerSquareMatrix
Parameters:
m - a int matrix.
Throws:
IllegalDimensionException - If the matrices are different sizes.

scalarProduct

public int scalarProduct(IntegerSquareMatrix m)

multiply

public AbstractIntegerVector multiply(AbstractIntegerVector v)
Returns the multiplication of a vector by this matrix.

Overrides:
multiply in class AbstractIntegerMatrix
Parameters:
v - a int vector.
Throws:
IllegalDimensionException - If the matrix and vector are incompatible.

multiply

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

Overrides:
multiply in class AbstractIntegerSquareMatrix
Parameters:
m - a int matrix
Returns:
a AbstractIntegerMatrix or a AbstractIntegerSquareMatrix as appropriate
Throws:
IllegalDimensionException - If the matrices are incompatible.

multiply

public IntegerSquareMatrix multiply(IntegerSquareMatrix m)

directSum

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

Overrides:
directSum in class AbstractIntegerSquareMatrix

tensorProduct

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

Overrides:
tensorProduct in class AbstractIntegerSquareMatrix

transpose

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

Specified by:
transpose in interface Matrix
Overrides:
transpose in class AbstractIntegerSquareMatrix
Returns:
a int matrix

inverse

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

Overrides:
inverse in class AbstractIntegerSquareMatrix
Returns:
a double square matrix.

luDecompose

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

Overrides:
luDecompose in class AbstractIntegerSquareMatrix
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.

Overrides:
choleskyDecompose in class AbstractIntegerSquareMatrix
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).

Overrides:
qrDecompose in class AbstractIntegerSquareMatrix
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).

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

clone

public java.lang.Object clone()
Clone matrix into a new matrix.

Overrides:
clone in class java.lang.Object
Returns:
the cloned matrix.