JSci.maths.matrices
Class ComplexTridiagonalMatrix

java.lang.Object
  extended by JSci.maths.matrices.Matrix
      extended by JSci.maths.matrices.AbstractComplexMatrix
          extended by JSci.maths.matrices.AbstractComplexSquareMatrix
              extended by JSci.maths.matrices.ComplexTridiagonalMatrix
All Implemented Interfaces:
java.io.Serializable, Algebra.Member, BanachSpace.Member, CStarAlgebra.Member, Module.Member, VectorSpace.Member, Ring.Member, AbelianGroup.Member, SquareMatrix, TridiagonalMatrix, Member

public class ComplexTridiagonalMatrix
extends AbstractComplexSquareMatrix
implements TridiagonalMatrix

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

See Also:
Serialized Form

Field Summary
protected  double[] diagIm
           
protected  double[] diagRe
           
protected  double[] ldiagIm
          Tridiagonal data.
protected  double[] ldiagRe
          Tridiagonal data.
protected  double[] udiagIm
           
protected  double[] udiagRe
           
 
Fields inherited from class JSci.maths.matrices.AbstractComplexSquareMatrix
luCache
 
Fields inherited from class JSci.maths.matrices.Matrix
numCols, numRows
 
Constructor Summary
ComplexTridiagonalMatrix(Complex[][] array)
          Constructs a matrix from an array.
ComplexTridiagonalMatrix(int size)
          Constructs an empty matrix.
 
Method Summary
 AbstractComplexSquareMatrix add(AbstractComplexSquareMatrix m)
          Returns the addition of this matrix and another.
 ComplexSquareMatrix add(ComplexSquareMatrix m)
           
 ComplexTridiagonalMatrix add(ComplexTridiagonalMatrix m)
           
 AbstractComplexMatrix conjugate()
          Returns the complex conjugate of this matrix.
 boolean equals(AbstractComplexMatrix m, double tol)
          Compares two complex matrices for equality.
 double frobeniusNorm()
          Returns the Frobenius (l2) norm.
 Complex getElement(int i, int j)
          Returns an element of the matrix.
 double getImagElement(int i, int j)
          Returns the imag part of an element of the matrix.
 double getRealElement(int i, int j)
          Returns the real part of an element of the matrix.
 AbstractComplexMatrix hermitianAdjoint()
          Returns the hermitian adjoint of this matrix.
 AbstractDoubleMatrix imag()
          Returns the imaginary part of this complex matrix.
 double infNorm()
          Returns the linfinity-norm.
 AbstractComplexMatrix mapElements(ComplexMapping f)
          Applies a function on all the matrix elements.
 AbstractComplexSquareMatrix multiply(AbstractComplexSquareMatrix m)
          Returns the multiplication of this matrix and another.
 AbstractComplexVector multiply(AbstractComplexVector v)
          Returns the multiplication of a vector by this matrix.
 ComplexSquareMatrix multiply(ComplexSquareMatrix m)
           
 ComplexSquareMatrix multiply(ComplexTridiagonalMatrix m)
          Returns the multiplication of this matrix and another.
 double operatorNorm()
          Returns the operator norm.
 AbstractDoubleMatrix real()
          Returns the real part of this complex matrix.
 AbstractComplexMatrix scalarMultiply(Complex z)
          Returns the multiplication of this matrix by a scalar.
 AbstractComplexMatrix 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.
 AbstractComplexSquareMatrix subtract(AbstractComplexSquareMatrix m)
          Returns the subtraction of this matrix and another.
 ComplexSquareMatrix subtract(ComplexSquareMatrix m)
           
 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.matrices.AbstractComplexSquareMatrix
add, det, directSum, inverse, involution, isHermitian, isUnitary, luDecompose_cache, luDecompose, luDecompose, negate, norm, polarDecompose, scalarDivide, scalarDivide, scalarProduct, scalarProduct, subtract, tensor
 
Methods inherited from class JSci.maths.matrices.AbstractComplexMatrix
add, directSum, equals, equals, getSet, 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
 
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

ldiagRe

protected final double[] ldiagRe
Tridiagonal data.


ldiagIm

protected final double[] ldiagIm
Tridiagonal data.


diagRe

protected final double[] diagRe

diagIm

protected final double[] diagIm

udiagRe

protected final double[] udiagRe

udiagIm

protected final double[] udiagIm
Constructor Detail

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(AbstractComplexMatrix m,
                      double tol)
Compares two complex matrices for equality.

Overrides:
equals in class AbstractComplexMatrix
Parameters:
m - a complex matrix

toString

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

Overrides:
toString in class AbstractComplexMatrix

real

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

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

imag

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

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

getElement

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

Specified by:
getElement in class AbstractComplexMatrix
Parameters:
i - row index of the element
j - column index of the element
Throws:
MatrixDimensionException - If attempting to access an invalid element.

getRealElement

public double getRealElement(int i,
                             int j)
Description copied from class: AbstractComplexMatrix
Returns the real part of an element of the matrix.

Specified by:
getRealElement in class AbstractComplexMatrix
Parameters:
i - row index of the element
j - column index of the element

getImagElement

public double getImagElement(int i,
                             int j)
Description copied from class: AbstractComplexMatrix
Returns the imag part of an element of the matrix.

Specified by:
getImagElement in class AbstractComplexMatrix
Parameters:
i - row index of the element
j - column index of the 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.

Specified by:
setElement in class AbstractComplexMatrix
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.

Specified by:
setElement in class AbstractComplexMatrix
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 AbstractComplexSquareMatrix

infNorm

public double infNorm()
Returns the linfinity-norm.

Overrides:
infNorm in class AbstractComplexMatrix

frobeniusNorm

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

Overrides:
frobeniusNorm in class AbstractComplexMatrix

operatorNorm

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

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

add

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

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

add

public ComplexSquareMatrix add(ComplexSquareMatrix m)

add

public ComplexTridiagonalMatrix add(ComplexTridiagonalMatrix m)

subtract

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

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

subtract

public ComplexSquareMatrix subtract(ComplexSquareMatrix m)

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 AbstractComplexMatrix scalarMultiply(Complex z)
Returns the multiplication of this matrix by a scalar.

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

scalarMultiply

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

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

multiply

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

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

multiply

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

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

multiply

public ComplexSquareMatrix multiply(ComplexSquareMatrix m)

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 AbstractComplexMatrix hermitianAdjoint()
Returns the hermitian adjoint of this matrix.

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

conjugate

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

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

transpose

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

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

mapElements

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

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