JSci.maths
Class IntegerSquareMatrix

java.lang.Object
  extended by JSci.maths.Matrix
      extended by JSci.maths.IntegerMatrix
          extended by JSci.maths.IntegerSquareMatrix
All Implemented Interfaces:
java.io.Serializable, Algebra.Member, Module.Member, VectorSpace.Member, Ring.Member, AbelianGroup.Member, Member
Direct Known Subclasses:
IntegerTridiagonalMatrix

public class IntegerSquareMatrix
extends IntegerMatrix

The IntegerSquareMatrix class provides an object for encapsulating square matrices containing integers.

Version:
2.2
Author:
Mark Hale
See Also:
Serialized Form

Field Summary
protected  DoubleSquareMatrix[] LU
           
protected  int[] LUpivot
           
 
Fields inherited from class JSci.maths.IntegerMatrix
ARRAY_2D, matrix
 
Fields inherited from class JSci.maths.Matrix
CLASS_SPECIFIC, numCols, numRows, storageFormat
 
Constructor Summary
  IntegerSquareMatrix(int size)
          Constructs an empty matrix.
  IntegerSquareMatrix(int[][] array)
          Constructs a matrix by wrapping an array.
  IntegerSquareMatrix(IntegerVector[] array)
          Constructs a matrix from an array of vectors.
protected IntegerSquareMatrix(int size, int storeID)
          Constructs a matrix.
 
Method Summary
 IntegerMatrix add(IntegerMatrix m)
          Returns the addition of this matrix and another.
 IntegerSquareMatrix add(IntegerSquareMatrix m)
          Returns the addition of this matrix and another.
 DoubleSquareMatrix[] choleskyDecomposition()
          Returns the Cholesky decomposition of this matrix.
 int det()
          Returns the determinant.
 boolean isSymmetric()
          Returns true if this matrix is symmetric.
 boolean isUnitary()
          Returns true if this matrix is unitary.
 DoubleSquareMatrix[] luDecompose(int[] pivot)
          Returns the LU decomposition of this matrix.
 IntegerSquareMatrix multiply(IntegerSquareMatrix m)
          Returns the multiplication of this matrix and another.
 IntegerVector multiply(IntegerVector v)
          Returns the multiplication of a vector by this matrix.
 IntegerMatrix scalarMultiply(int x)
          Returns the multiplication of this matrix by a scalar.
 IntegerMatrix subtract(IntegerMatrix m)
          Returns the subtraction of this matrix by another.
 IntegerSquareMatrix subtract(IntegerSquareMatrix m)
          Returns the subtraction of this matrix by another.
 int trace()
          Returns the trace.
 Matrix transpose()
          Returns the transpose of this matrix.
 
Methods inherited from class JSci.maths.IntegerMatrix
add, equals, finalize, frobeniusNorm, getElement, hashCode, infNorm, multiply, multiply, negate, scalarDivide, scalarMultiply, setElement, subtract, toComplexMatrix, toDoubleMatrix, toString
 
Methods inherited from class JSci.maths.Matrix
columns, getInvalidElementMsg, rows
 
Methods inherited from class java.lang.Object
clone, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

LU

protected transient DoubleSquareMatrix[] LU

LUpivot

protected transient int[] LUpivot
Constructor Detail

IntegerSquareMatrix

protected IntegerSquareMatrix(int size,
                              int storeID)
Constructs a matrix.


IntegerSquareMatrix

public IntegerSquareMatrix(int size)
Constructs an empty matrix.

Parameters:
size - the number of rows/columns.

IntegerSquareMatrix

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

Parameters:
array - an assigned value.
Throws:
MatrixDimensionException - If the array is not square.

IntegerSquareMatrix

public IntegerSquareMatrix(IntegerVector[] array)
Constructs a matrix from an array of vectors. The vectors form columns in the matrix.

Parameters:
array - an assigned value.
Method Detail

isSymmetric

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


isUnitary

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


det

public int det()
Returns the determinant.


trace

public int trace()
Returns the trace.


add

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

Overrides:
add in class IntegerMatrix
Parameters:
m - an integer matrix
Throws:
MatrixDimensionException - If the matrices are different sizes.

add

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

Parameters:
m - an integer square matrix
Throws:
MatrixDimensionException - If the matrices are different sizes.

subtract

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

Overrides:
subtract in class IntegerMatrix
Parameters:
m - an integer matrix
Throws:
MatrixDimensionException - If the matrices are different sizes.

subtract

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

Parameters:
m - an integer square matrix
Throws:
MatrixDimensionException - If the matrices are different sizes.

scalarMultiply

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

Overrides:
scalarMultiply in class IntegerMatrix
Parameters:
x - an integer
Returns:
an integer square matrix

multiply

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

Overrides:
multiply in class IntegerMatrix
Parameters:
v - an integer vector
Throws:
DimensionException - If the matrix and vector are incompatible.

multiply

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

Parameters:
m - an integer square matrix
Throws:
MatrixDimensionException - If the matrices are incompatible.

transpose

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

Overrides:
transpose in class IntegerMatrix
Returns:
an integer square matrix

luDecompose

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

Parameters:
pivot - an empty array of length the number of rows 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.

choleskyDecomposition

public DoubleSquareMatrix[] choleskyDecomposition()
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.