JSci.maths
Class IntegerTridiagonalMatrix

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

public class IntegerTridiagonalMatrix
extends IntegerSquareMatrix

The IntegerTridiagonalMatrix class provides an object for encapsulating tridiagonal matrices containing integers. Uses compressed diagonal storage.

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

Field Summary
protected  int[] diag
           
protected  int[] ldiag
          Tridiagonal data.
protected static int TRIDIAGONAL
          Storage format identifier.
protected  int[] udiag
           
 
Fields inherited from class JSci.maths.IntegerSquareMatrix
LU, 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
  IntegerTridiagonalMatrix(int size)
          Constructs an empty matrix.
  IntegerTridiagonalMatrix(int[][] array)
          Constructs a matrix from an array.
protected IntegerTridiagonalMatrix(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.
 IntegerTridiagonalMatrix add(IntegerTridiagonalMatrix m)
          Returns the addition of this matrix and another.
 DoubleSquareMatrix[] choleskyDecompose()
          Returns the Cholesky decomposition of this matrix.
 boolean equals(java.lang.Object m)
          Compares two integer tridiagonal matrices for equality.
 double frobeniusNorm()
          Returns the Frobenius (l2) norm.
 int getElement(int i, int j)
          Returns an element of the matrix.
 int infNorm()
          Returns the linfinity-norm.
 boolean isSymmetric()
          Returns true if this matrix is symmetric.
 DoubleSquareMatrix[] luDecompose(int[] pivot)
          Returns the LU decomposition of this matrix.
 IntegerMatrix multiply(IntegerMatrix m)
          Returns the multiplication of this matrix and another.
 IntegerSquareMatrix multiply(IntegerSquareMatrix m)
          Returns the multiplication of this matrix and another.
 IntegerSquareMatrix multiply(IntegerTridiagonalMatrix 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.
 void setElement(int i, int j, int x)
          Sets the value of an element of the matrix.
 IntegerMatrix subtract(IntegerMatrix m)
          Returns the subtraction of this matrix and another.
 IntegerSquareMatrix subtract(IntegerSquareMatrix m)
          Returns the subtraction of this matrix by another.
 IntegerTridiagonalMatrix subtract(IntegerTridiagonalMatrix m)
          Returns the subtraction of this matrix by another.
 ComplexMatrix toComplexMatrix()
          Converts this matrix to a complex matrix.
 DoubleMatrix 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 JSci.maths.IntegerSquareMatrix
choleskyDecomposition, det, isUnitary
 
Methods inherited from class JSci.maths.IntegerMatrix
add, finalize, hashCode, multiply, negate, scalarDivide, scalarMultiply, subtract
 
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

TRIDIAGONAL

protected static final int TRIDIAGONAL
Storage format identifier.

See Also:
Constant Field Values

ldiag

protected int[] ldiag
Tridiagonal data.


diag

protected int[] diag

udiag

protected int[] udiag
Constructor Detail

IntegerTridiagonalMatrix

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


IntegerTridiagonalMatrix

public IntegerTridiagonalMatrix(int size)
Constructs an empty matrix.

Parameters:
size - the number of rows/columns

IntegerTridiagonalMatrix

public IntegerTridiagonalMatrix(int[][] array)
Constructs a matrix from an array. Any non-tridiagonal elements in the array are ignored.

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

equals

public boolean equals(java.lang.Object m)
Compares two integer tridiagonal matrices for equality.

Overrides:
equals in class IntegerMatrix
Parameters:
m - a integer tridiagonal matrix

toString

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

Overrides:
toString in class IntegerMatrix

toDoubleMatrix

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

Overrides:
toDoubleMatrix in class IntegerMatrix
Returns:
a double tridiagonal matrix

toComplexMatrix

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

Overrides:
toComplexMatrix in class IntegerMatrix
Returns:
a complex tridiagonal matrix

getElement

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

Overrides:
getElement in class IntegerMatrix
Parameters:
i - row index of the element
j - column index of the element
Throws:
MatrixDimensionException - 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.

Overrides:
setElement in class IntegerMatrix
Parameters:
i - row index of the element
j - column index of the element
x - a number
Throws:
MatrixDimensionException - If attempting to access an invalid element.

isSymmetric

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

Overrides:
isSymmetric in class IntegerSquareMatrix

trace

public int trace()
Returns the trace.

Overrides:
trace in class IntegerSquareMatrix

infNorm

public int infNorm()
Returns the linfinity-norm.

Overrides:
infNorm in class IntegerMatrix

frobeniusNorm

public double frobeniusNorm()
Returns the Frobenius (l2) norm.

Overrides:
frobeniusNorm in class IntegerMatrix

add

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

Overrides:
add in class IntegerSquareMatrix
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.

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

add

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

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

subtract

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

Overrides:
subtract in class IntegerSquareMatrix
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.

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

subtract

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

Parameters:
m - an integer tridiagonal 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 IntegerSquareMatrix
Parameters:
x - an integer
Returns:
an integer tridiagonal matrix

multiply

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

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

multiply

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

Overrides:
multiply in class IntegerMatrix
Parameters:
m - an integer matrix
Returns:
an IntegerMatrix or a IntegerSquareMatrix as appropriate
Throws:
MatrixDimensionException - If the matrices are different sizes.

multiply

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

Overrides:
multiply in class IntegerSquareMatrix
Parameters:
m - an integer square matrix
Throws:
MatrixDimensionException - If the matrices are different sizes.

multiply

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

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

transpose

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

Overrides:
transpose in class IntegerSquareMatrix
Returns:
an integer tridiagonal matrix

luDecompose

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

Overrides:
luDecompose in class IntegerSquareMatrix
Parameters:
pivot - an empty array of length rows()+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 DoubleSquareMatrix[] 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.