JSci.maths.matrices
Class IntegerTridiagonalMatrix

java.lang.Object
  extended byJSci.maths.matrices.Matrix
      extended byJSci.maths.matrices.AbstractIntegerMatrix
          extended byJSci.maths.matrices.AbstractIntegerSquareMatrix
              extended byJSci.maths.matrices.IntegerTridiagonalMatrix
All Implemented Interfaces:
AbelianGroup.Member, Algebra.Member, Member, Module.Member, Ring.Member, java.io.Serializable, SquareMatrix, TridiagonalMatrix, VectorSpace.Member

public class IntegerTridiagonalMatrix
extends AbstractIntegerSquareMatrix
implements TridiagonalMatrix

The IntegerTridiagonalMatrix class provides an object for encapsulating integer tridiagonal matrices.

See Also:
Serialized Form

Field Summary
protected  int[] diag
           
protected  int[] ldiag
          Tridiagonal data.
protected  int[] udiag
           
 
Fields inherited from class JSci.maths.matrices.AbstractIntegerSquareMatrix
LU, LUpivot
 
Fields inherited from class JSci.maths.matrices.Matrix
numCols, numRows
 
Constructor Summary
IntegerTridiagonalMatrix(int size)
          Constructs an empty matrix.
IntegerTridiagonalMatrix(int[][] array)
          Constructs a matrix from an array.
 
Method Summary
 AbstractIntegerSquareMatrix add(AbstractIntegerSquareMatrix m)
          Returns the addition of this matrix and another.
 IntegerSquareMatrix add(IntegerSquareMatrix m)
           
 IntegerTridiagonalMatrix add(IntegerTridiagonalMatrix m)
          Returns the addition of this matrix and another.
 AbstractDoubleSquareMatrix[] choleskyDecompose()
          Returns the Cholesky decomposition of this matrix.
 boolean equals(AbstractIntegerMatrix m)
          Compares two ${nativeTyp} 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.
 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)
           
 IntegerSquareMatrix multiply(IntegerTridiagonalMatrix m)
           
 double operatorNorm()
          Returns the operator norm.
 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)
           
 int scalarProduct(IntegerTridiagonalMatrix m)
           
 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)
           
 IntegerTridiagonalMatrix subtract(IntegerTridiagonalMatrix m)
          Returns the subtraction 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 JSci.maths.matrices.AbstractIntegerSquareMatrix
add, det, directSum, inverse, isUnitary, luDecompose, negate, scalarProduct, subtract, tensor
 
Methods inherited from class JSci.maths.matrices.AbstractIntegerMatrix
add, directSum, equals, hashCode, multiply, multiply, scalarDivide, scalarMultiply, subtract, tensor
 
Methods inherited from class JSci.maths.matrices.Matrix
columns, getInvalidElementMsg, rows
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ldiag

protected final int[] ldiag
Tridiagonal data.


diag

protected final int[] diag

udiag

protected final int[] udiag
Constructor Detail

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(AbstractIntegerMatrix m)
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

getElement

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

Specified by:
getElement in class AbstractIntegerMatrix
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. 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:
MatrixDimensionException - If attempting to access an invalid element.

isSymmetric

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

Overrides:
isSymmetric in class AbstractIntegerSquareMatrix

trace

public int trace()
Returns the trace.

Overrides:
trace in class AbstractIntegerSquareMatrix

infNorm

public int infNorm()
Returns the linfinity-norm.

Overrides:
infNorm in class AbstractIntegerMatrix

frobeniusNorm

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

Overrides:
frobeniusNorm in class AbstractIntegerMatrix

operatorNorm

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

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

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:
MatrixDimensionException - If the matrices are different sizes.

add

public IntegerSquareMatrix add(IntegerSquareMatrix m)

add

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

Parameters:
m - a int tridiagonal matrix
Throws:
MatrixDimensionException - If the matrices are different sizes.

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:
MatrixDimensionException - If the matrices are different sizes.

subtract

public IntegerSquareMatrix subtract(IntegerSquareMatrix m)

subtract

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

Parameters:
m - a int tridiagonal matrix
Throws:
MatrixDimensionException - If the matrices are different sizes.

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:
MatrixDimensionException - If the matrices are different sizes.

scalarProduct

public int scalarProduct(IntegerSquareMatrix m)

scalarProduct

public int scalarProduct(IntegerTridiagonalMatrix 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:
DimensionException - 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:
MatrixDimensionException - If the matrices are incompatible.

multiply

public IntegerSquareMatrix multiply(IntegerSquareMatrix m)

multiply

public IntegerSquareMatrix multiply(IntegerTridiagonalMatrix m)

transpose

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

Overrides:
transpose in class AbstractIntegerSquareMatrix
Returns:
a int 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.
PlanetMath references:
QRDecomposition

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.