org.jscience.mathematics.algebraic.matrices
Class ComplexTridiagonalMatrix

java.lang.Object
  extended by org.jscience.mathematics.algebraic.AbstractHypermatrix
      extended by org.jscience.mathematics.algebraic.AbstractMatrix
          extended by org.jscience.mathematics.algebraic.matrices.AbstractComplexMatrix
              extended by org.jscience.mathematics.algebraic.matrices.AbstractComplexSquareMatrix
                  extended by org.jscience.mathematics.algebraic.matrices.ComplexTridiagonalMatrix
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Algebra.Member, BanachSpace.Member, CStarAlgebra.Member, BandedMatrix, Ring.Member, AbelianGroup.Member, Hypermatrix, Matrix, Module.Member, VectorSpace.Member, SquareMatrix, TridiagonalMatrix, Member

public class ComplexTridiagonalMatrix
extends AbstractComplexSquareMatrix
implements java.lang.Cloneable, java.io.Serializable, 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
          DOCUMENT ME!
protected  double[] diagRe
          DOCUMENT ME!
protected  double[] ldiagIm
          Tridiagonal data.
protected  double[] ldiagRe
          Tridiagonal data.
protected  double[] udiagIm
          DOCUMENT ME!
protected  double[] udiagRe
          DOCUMENT ME!
 
Fields inherited from class org.jscience.mathematics.algebraic.matrices.AbstractComplexSquareMatrix
LU, LUpivot
 
Constructor Summary
ComplexTridiagonalMatrix(Complex[][] array)
          Constructs a matrix from an array.
ComplexTridiagonalMatrix(ComplexTridiagonalMatrix mat)
          Copy constructor.
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)
          DOCUMENT ME!
 ComplexTridiagonalMatrix add(ComplexTridiagonalMatrix m)
          DOCUMENT ME!
 java.lang.Object clone()
          Clone matrix into a new matrix.
 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.
 double getImagElement(int i, int j)
          DOCUMENT ME!
 int getK1()
          DOCUMENT ME!
 int getK2()
          DOCUMENT ME!
 Complex getPrimitiveElement(int i, int j)
          Returns an element of the matrix.
 double getRealElement(int i, int j)
          DOCUMENT ME!
 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.
 boolean isSymmetric()
          Returns true if this matrix is symmetric.
 AbstractComplexSquareMatrix[] luDecompose(int[] pivot)
          Returns the LU decomposition of this matrix.
 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)
          DOCUMENT ME!
 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 setAllElements(Complex r)
          Sets the value of all elements of the matrix.
 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)
          DOCUMENT ME!
 ComplexTridiagonalMatrix subtract(ComplexTridiagonalMatrix m)
          Returns the subtraction of this matrix and another.
 Complex[][] toPrimitiveArray()
          Projects the matrix to an array.
 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 org.jscience.mathematics.algebraic.matrices.AbstractComplexSquareMatrix
add, det, directSum, inverse, involution, isHermitian, isUnitary, negate, norm, polarDecompose, scalarDivide, scalarDivide, scalarProduct, scalarProduct, subtract, tensorProduct
 
Methods inherited from class org.jscience.mathematics.algebraic.matrices.AbstractComplexMatrix
abs, add, directSum, equals, equals, getColumn, getElement, getMatrixAsColumns, getMatrixAsRows, getRow, getSet, getSubMatrix, hashCode, horizontalAxisSymmetry, mass, multiply, multiply, read, reverse, scalarDivide, scalarMultiply, setColumn, setRow, setSubMatrix, subtract, tensorProduct, verticalAxisSymmetry
 
Methods inherited from class org.jscience.mathematics.algebraic.AbstractMatrix
getElement, getInvalidElementMsg, numColumns, numRows, print, print, print, print, toArray, toArray
 
Methods inherited from class org.jscience.mathematics.algebraic.AbstractHypermatrix
getDimensions, numDimensions, numElements, numElements, toArray
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jscience.mathematics.algebraic.Matrix
getColumn, getElement, getRow, numColumns, numRows, toArray
 
Methods inherited from interface org.jscience.mathematics.algebraic.Hypermatrix
getDimensions, getElement, numDimensions, numElements, numElements, toArray, toArray
 
Methods inherited from interface org.jscience.mathematics.algebraic.fields.Ring.Member
multiply
 
Methods inherited from interface org.jscience.mathematics.algebraic.modules.VectorSpace.Member
scalarDivide
 
Methods inherited from interface org.jscience.mathematics.algebraic.modules.Module.Member
scalarMultiply
 

Field Detail

ldiagRe

protected final double[] ldiagRe
Tridiagonal data.


ldiagIm

protected final double[] ldiagIm
Tridiagonal data.


diagRe

protected final double[] diagRe
DOCUMENT ME!


diagIm

protected final double[] diagIm
DOCUMENT ME!


udiagRe

protected final double[] udiagRe
DOCUMENT ME!


udiagIm

protected final double[] udiagIm
DOCUMENT ME!

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:
IllegalDimensionException - If the array is not square.

ComplexTridiagonalMatrix

public ComplexTridiagonalMatrix(ComplexTridiagonalMatrix mat)
Copy constructor.

Parameters:
mat - an assigned value
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
tol - DOCUMENT ME!
Returns:
DOCUMENT ME!

toString

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

Overrides:
toString in class AbstractComplexMatrix
Returns:
DOCUMENT ME!

getK1

public int getK1()
DOCUMENT ME!

Specified by:
getK1 in interface BandedMatrix
Returns:
DOCUMENT ME!

getK2

public int getK2()
DOCUMENT ME!

Specified by:
getK2 in interface BandedMatrix
Returns:
DOCUMENT ME!

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

getPrimitiveElement

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

Specified by:
getPrimitiveElement in class AbstractComplexMatrix
Parameters:
i - row index of the element
j - column index of the element
Returns:
DOCUMENT ME!
Throws:
IllegalDimensionException - If attempting to access an invalid element.

getRealElement

public double getRealElement(int i,
                             int j)
DOCUMENT ME!

Overrides:
getRealElement in class AbstractComplexMatrix
Parameters:
i - DOCUMENT ME!
j - DOCUMENT ME!
Returns:
DOCUMENT ME!

getImagElement

public double getImagElement(int i,
                             int j)
DOCUMENT ME!

Overrides:
getImagElement in class AbstractComplexMatrix
Parameters:
i - DOCUMENT ME!
j - DOCUMENT ME!
Returns:
DOCUMENT ME!

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:
IllegalDimensionException - 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 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:
IllegalDimensionException - If attempting to access an invalid element.

setAllElements

public void setAllElements(Complex r)
Sets the value of all elements of the matrix. This method will throw an error unless the paramter is Complex.ZERO. This is because you need a SquareMatrix to set all the contents of the matrix to a value. You should think about using a ComplexSquareMatrix.

Overrides:
setAllElements in class AbstractComplexMatrix
Parameters:
r - a Complex element
Throws:
java.lang.IllegalArgumentException - DOCUMENT ME!

isSymmetric

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

Specified by:
isSymmetric in interface SquareMatrix
Overrides:
isSymmetric in class AbstractComplexSquareMatrix
Returns:
DOCUMENT ME!

trace

public Complex trace()
Returns the trace.

Overrides:
trace in class AbstractComplexSquareMatrix
Returns:
DOCUMENT ME!
Throws:
java.lang.ArithmeticException - DOCUMENT ME!

infNorm

public double infNorm()
Returns the linfinity-norm.

Overrides:
infNorm in class AbstractComplexMatrix
Returns:
DOCUMENT ME!
Throws:
java.lang.ArithmeticException - DOCUMENT ME!

frobeniusNorm

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

Overrides:
frobeniusNorm in class AbstractComplexMatrix
Returns:
DOCUMENT ME!
Throws:
java.lang.ArithmeticException - DOCUMENT ME!

operatorNorm

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

Overrides:
operatorNorm in class AbstractComplexSquareMatrix
Returns:
DOCUMENT ME!
Throws:
MaximumIterationsExceededException - If it takes more than 50 iterations to determine an eigenvalue.
java.lang.ArithmeticException - DOCUMENT ME!

add

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

Overrides:
add in class AbstractComplexSquareMatrix
Parameters:
m - a complex matrix
Returns:
DOCUMENT ME!
Throws:
IllegalDimensionException - If the matrices are different sizes.

add

public ComplexSquareMatrix add(ComplexSquareMatrix m)
DOCUMENT ME!

Parameters:
m - DOCUMENT ME!
Returns:
DOCUMENT ME!

add

public ComplexTridiagonalMatrix add(ComplexTridiagonalMatrix m)
DOCUMENT ME!

Parameters:
m - DOCUMENT ME!
Returns:
DOCUMENT ME!

subtract

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

Overrides:
subtract in class AbstractComplexSquareMatrix
Parameters:
m - a complex matrix
Returns:
DOCUMENT ME!
Throws:
IllegalDimensionException - If the matrices are different sizes.

subtract

public ComplexSquareMatrix subtract(ComplexSquareMatrix m)
DOCUMENT ME!

Parameters:
m - DOCUMENT ME!
Returns:
DOCUMENT ME!

subtract

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

Parameters:
m - a complex tridiagonal matrix
Returns:
DOCUMENT ME!
Throws:
IllegalDimensionException - 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
Returns:
DOCUMENT ME!
Throws:
IllegalDimensionException - 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:
DOCUMENT ME!
Throws:
IllegalDimensionException - If the matrices are different sizes.

multiply

public ComplexSquareMatrix multiply(ComplexSquareMatrix m)
DOCUMENT ME!

Parameters:
m - DOCUMENT ME!
Returns:
DOCUMENT ME!

multiply

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

Parameters:
m - a complex tridiagonal matrix
Returns:
DOCUMENT ME!
Throws:
IllegalDimensionException - 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.

Specified by:
transpose in interface Matrix
Overrides:
transpose in class AbstractComplexSquareMatrix
Returns:
a complex tridiagonal matrix

luDecompose

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

Overrides:
luDecompose in class AbstractComplexSquareMatrix
Parameters:
pivot - DOCUMENT ME!
Returns:
an array with [0] containing the L-matrix and [1] containing the U-matrix.

mapElements

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

Overrides:
mapElements in class AbstractComplexMatrix
Parameters:
f - a user-defined function
Returns:
a Complex matrix

clone

public java.lang.Object clone()
Clone matrix into a new matrix.

Overrides:
clone in class java.lang.Object
Returns:
the cloned matrix.

toPrimitiveArray

public Complex[][] toPrimitiveArray()
Projects the matrix to an array.

Overrides:
toPrimitiveArray in class AbstractComplexMatrix
Returns:
an double array.