JSci.maths
Class ComplexTridiagonalMatrix

java.lang.Object
  extended by JSci.maths.Matrix
      extended by JSci.maths.ComplexMatrix
          extended by JSci.maths.ComplexSquareMatrix
              extended by JSci.maths.ComplexTridiagonalMatrix
All Implemented Interfaces:
java.io.Serializable, Algebra.Member, BanachSpace.Member, CStarAlgebra.Member, Module.Member, VectorSpace.Member, Ring.Member, AbelianGroup.Member, Member
Direct Known Subclasses:
ComplexDiagonalMatrix

public class ComplexTridiagonalMatrix
extends ComplexSquareMatrix

The ComplexTridiagonalMatrix class provides an object for encapsulating tridiagonal matrices containing complex numbers. Uses compressed diagonal storage.

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

Field Summary
protected  double[] diagIm
           
protected  double[] diagRe
           
protected  double[] ldiagIm
          Tridiagonal data.
protected  double[] ldiagRe
          Tridiagonal data.
protected static int TRIDIAGONAL
          Storage format identifier.
protected  double[] udiagIm
           
protected  double[] udiagRe
           
 
Fields inherited from class JSci.maths.ComplexSquareMatrix
LU, LUpivot
 
Fields inherited from class JSci.maths.ComplexMatrix
ARRAY_2D, matrixIm, matrixRe
 
Fields inherited from class JSci.maths.Matrix
CLASS_SPECIFIC, numCols, numRows, storageFormat
 
Constructor Summary
  ComplexTridiagonalMatrix(Complex[][] array)
          Constructs a matrix from an array.
  ComplexTridiagonalMatrix(int size)
          Constructs an empty matrix.
protected ComplexTridiagonalMatrix(int size, int storeID)
          Constructs a matrix.
 
Method Summary
 ComplexMatrix add(ComplexMatrix m)
          Returns the addition of this matrix and another.
 ComplexSquareMatrix add(ComplexSquareMatrix m)
          Returns the addition of this matrix and another.
 ComplexTridiagonalMatrix add(ComplexTridiagonalMatrix m)
          Returns the addition of this matrix and another.
 ComplexMatrix conjugate()
          Returns the complex conjugate of this matrix.
 boolean equals(java.lang.Object m)
          Compares two complex tridiagonal matrices for equality.
 double frobeniusNorm()
          Returns the Frobenius (l2) norm.
 Complex getElement(int i, int j)
          Returns an element of the matrix.
 ComplexMatrix hermitianAdjoint()
          Returns the hermitian adjoint of this matrix.
 DoubleMatrix imag()
          Returns the imaginary part of this complex matrix.
 double infNorm()
          Returns the linfinity-norm.
 ComplexSquareMatrix[] luDecompose(int[] pivot)
          Returns the LU decomposition of this matrix.
 ComplexMatrix mapElements(ComplexMapping f)
          Applies a function on all the matrix elements.
 ComplexMatrix multiply(ComplexMatrix m)
          Returns the multiplication of this matrix and another.
 ComplexSquareMatrix multiply(ComplexSquareMatrix m)
          Returns the multiplication of this matrix and another.
 ComplexSquareMatrix multiply(ComplexTridiagonalMatrix m)
          Returns the multiplication of this matrix and another.
 ComplexVector multiply(ComplexVector v)
          Returns the multiplication of a vector by this matrix.
 double operatorNorm()
          Returns the operator norm.
 DoubleMatrix real()
          Returns the real part of this complex matrix.
 ComplexMatrix scalarMultiply(Complex z)
          Returns the multiplication of this matrix by a scalar.
 ComplexMatrix scalarMultiply(double x)
          Returns the multiplication of this matrix by a scalar.
 void setElement(int i, int j, Complex z)
          Sets the value of an element of the matrix.
 void setElement(int i, int j, double x, double y)
          Sets the value of an element of the matrix.
 ComplexMatrix subtract(ComplexMatrix m)
          Returns the subtraction of this matrix and another.
 ComplexSquareMatrix subtract(ComplexSquareMatrix m)
          Returns the subtraction of this matrix by another.
 ComplexTridiagonalMatrix subtract(ComplexTridiagonalMatrix m)
          Returns the subtraction of this matrix and another.
 java.lang.String toString()
          Returns a string representing this matrix.
 Complex trace()
          Returns the trace.
 Matrix transpose()
          Returns the transpose of this matrix.
 
Methods inherited from class JSci.maths.ComplexSquareMatrix
det, inverse, involution, isHermitian, isUnitary, norm, polarDecompose
 
Methods inherited from class JSci.maths.ComplexMatrix
add, directSum, finalize, hashCode, multiply, negate, scalarDivide, scalarDivide, scalarDivide, scalarMultiply, subtract, tensorProduct
 
Methods inherited from class JSci.maths.Matrix
columns, getInvalidElementMsg, rows
 
Methods inherited from class java.lang.Object
clone, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface JSci.maths.fields.Ring.Member
multiply
 
Methods inherited from interface JSci.maths.algebras.VectorSpace.Member
scalarDivide
 
Methods inherited from interface JSci.maths.algebras.Module.Member
scalarMultiply
 

Field Detail

TRIDIAGONAL

protected static final int TRIDIAGONAL
Storage format identifier.

See Also:
Constant Field Values

ldiagRe

protected double[] ldiagRe
Tridiagonal data.


ldiagIm

protected double[] ldiagIm
Tridiagonal data.


diagRe

protected double[] diagRe

diagIm

protected double[] diagIm

udiagRe

protected double[] udiagRe

udiagIm

protected double[] udiagIm
Constructor Detail

ComplexTridiagonalMatrix

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


ComplexTridiagonalMatrix

public ComplexTridiagonalMatrix(int size)
Constructs an empty matrix.

Parameters:
size - the number of rows/columns

ComplexTridiagonalMatrix

public ComplexTridiagonalMatrix(Complex[][] 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 complex tridiagonal matrices for equality.

Overrides:
equals in class ComplexMatrix
Parameters:
m - a complex tridiagonal matrix

toString

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

Overrides:
toString in class ComplexMatrix

real

public DoubleMatrix real()
Returns the real part of this complex matrix.

Overrides:
real in class ComplexMatrix
Returns:
a double tridiagonal matrix

imag

public DoubleMatrix imag()
Returns the imaginary part of this complex matrix.

Overrides:
imag in class ComplexMatrix
Returns:
a double tridiagonal matrix

getElement

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

Overrides:
getElement in class ComplexMatrix
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,
                       Complex z)
Sets the value of an element of the matrix. Should only be used to initialise this matrix.

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

setElement

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

Overrides:
setElement in class ComplexMatrix
Parameters:
i - row index of the element
j - column index of the element
x - the real part of a complex number
y - the imaginary part of a complex number
Throws:
MatrixDimensionException - If attempting to access an invalid element.

trace

public Complex trace()
Returns the trace.

Overrides:
trace in class ComplexSquareMatrix

infNorm

public double infNorm()
Returns the linfinity-norm.

Overrides:
infNorm in class ComplexMatrix

frobeniusNorm

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

Overrides:
frobeniusNorm in class ComplexMatrix

operatorNorm

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

Overrides:
operatorNorm in class ComplexSquareMatrix
Throws:
MaximumIterationsExceededException - If it takes more than 50 iterations to determine an eigenvalue.

add

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

Overrides:
add in class ComplexSquareMatrix
Parameters:
m - a complex matrix
Throws:
MatrixDimensionException - If the matrices are different sizes.

add

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

Overrides:
add in class ComplexSquareMatrix
Parameters:
m - a complex square matrix
Throws:
MatrixDimensionException - If the matrices are different sizes.

add

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

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

subtract

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

Overrides:
subtract in class ComplexSquareMatrix
Parameters:
m - a complex matrix
Throws:
MatrixDimensionException - If the matrices are different sizes.

subtract

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

Overrides:
subtract in class ComplexSquareMatrix
Parameters:
m - a complex square matrix
Throws:
MatrixDimensionException - If the matrices are different sizes.

subtract

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

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

scalarMultiply

public ComplexMatrix scalarMultiply(Complex z)
Returns the multiplication of this matrix by a scalar.

Overrides:
scalarMultiply in class ComplexSquareMatrix
Parameters:
z - a complex number
Returns:
a complex tridiagonal matrix

scalarMultiply

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

Overrides:
scalarMultiply in class ComplexSquareMatrix
Parameters:
x - a double
Returns:
a complex tridiagonal matrix

multiply

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

Overrides:
multiply in class ComplexSquareMatrix
Parameters:
v - a complex vector
Throws:
DimensionException - If the matrix and vector are incompatible.

multiply

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

Overrides:
multiply in class ComplexMatrix
Parameters:
m - a complex matrix
Returns:
a ComplexMatrix or a ComplexSquareMatrix as appropriate
Throws:
MatrixDimensionException - If the matrices are different sizes.

multiply

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

Overrides:
multiply in class ComplexSquareMatrix
Parameters:
m - a complex square matrix
Throws:
MatrixDimensionException - If the matrices are different sizes.

multiply

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

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

hermitianAdjoint

public ComplexMatrix hermitianAdjoint()
Returns the hermitian adjoint of this matrix.

Overrides:
hermitianAdjoint in class ComplexSquareMatrix
Returns:
a complex tridiagonal matrix

conjugate

public ComplexMatrix conjugate()
Returns the complex conjugate of this matrix.

Overrides:
conjugate in class ComplexSquareMatrix
Returns:
a complex tridiagonal matrix

transpose

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

Overrides:
transpose in class ComplexSquareMatrix
Returns:
a complex tridiagonal matrix

luDecompose

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

Overrides:
luDecompose in class ComplexSquareMatrix
Returns:
an array with [0] containing the L-matrix and [1] containing the U-matrix.

mapElements

public ComplexMatrix mapElements(ComplexMapping f)
Applies a function on all the matrix elements.

Overrides:
mapElements in class ComplexSquareMatrix
Parameters:
f - a user-defined function
Returns:
a complex tridiagonal matrix