JSci.maths
Class ComplexDiagonalMatrix

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

public final class ComplexDiagonalMatrix
extends ComplexTridiagonalMatrix

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

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

Field Summary
protected static int DIAGONAL
          Storage format identifier.
 
Fields inherited from class JSci.maths.ComplexTridiagonalMatrix
diagIm, diagRe, ldiagIm, ldiagRe, TRIDIAGONAL, udiagIm, 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
  ComplexDiagonalMatrix(Complex[] array)
          Constructs a matrix from an array containing the diagonal elements.
  ComplexDiagonalMatrix(Complex[][] array)
          Constructs a matrix from an array.
  ComplexDiagonalMatrix(double[] arrayRe, double[] arrayIm)
          Constructs a matrix by wrapping two arrays containing the diagonal elements.
  ComplexDiagonalMatrix(int size)
          Constructs an empty matrix.
protected ComplexDiagonalMatrix(int size, int storeID)
          Constructs a matrix.
 
Method Summary
 ComplexDiagonalMatrix add(ComplexDiagonalMatrix m)
          Returns the addition of this matrix and another.
 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.
 Complex det()
          Returns the determinant.
 boolean equals(java.lang.Object m)
          Compares two complex diagonal 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.
static ComplexDiagonalMatrix identity(int size)
          Creates an identity matrix.
 DoubleMatrix imag()
          Returns the imaginary part of this complex matrix.
 double infNorm()
          Returns the linfinity-norm.
 ComplexSquareMatrix inverse()
          Returns the inverse of this matrix.
 boolean isHermitian()
          Returns true if this matrix is hermitian.
 boolean isUnitary()
          Returns true if this matrix is unitary.
 ComplexSquareMatrix[] luDecompose(int[] pivot)
          Returns the LU decomposition of this matrix.
 ComplexMatrix mapElements(ComplexMapping f)
          Applies a function on all the matrix elements.
 ComplexDiagonalMatrix multiply(ComplexDiagonalMatrix m)
          Returns the multiplication of this matrix and another.
 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.
 ComplexDiagonalMatrix subtract(ComplexDiagonalMatrix m)
          Returns the subtraction of this matrix by another.
 ComplexMatrix subtract(ComplexMatrix m)
          Returns the subtraction of this matrix by another.
 ComplexSquareMatrix subtract(ComplexSquareMatrix m)
          Returns the subtraction of this matrix by another.
 ComplexTridiagonalMatrix subtract(ComplexTridiagonalMatrix m)
          Returns the subtraction of this matrix by another.
 Complex trace()
          Returns the trace.
 Matrix transpose()
          Returns the transpose of this matrix.
 
Methods inherited from class JSci.maths.ComplexTridiagonalMatrix
toString
 
Methods inherited from class JSci.maths.ComplexSquareMatrix
involution, 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

DIAGONAL

protected static final int DIAGONAL
Storage format identifier.

See Also:
Constant Field Values
Constructor Detail

ComplexDiagonalMatrix

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


ComplexDiagonalMatrix

public ComplexDiagonalMatrix(int size)
Constructs an empty matrix.

Parameters:
size - the number of rows/columns

ComplexDiagonalMatrix

public ComplexDiagonalMatrix(Complex[][] array)
Constructs a matrix from an array.

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

ComplexDiagonalMatrix

public ComplexDiagonalMatrix(double[] arrayRe,
                             double[] arrayIm)
Constructs a matrix by wrapping two arrays containing the diagonal elements.

Parameters:
arrayRe - an array of real values
arrayIm - an array of imaginary values

ComplexDiagonalMatrix

public ComplexDiagonalMatrix(Complex[] array)
Constructs a matrix from an array containing the diagonal elements.

Parameters:
array - an assigned value
Method Detail

identity

public static ComplexDiagonalMatrix identity(int size)
Creates an identity matrix.

Parameters:
size - the number of rows/columns

equals

public boolean equals(java.lang.Object m)
Compares two complex diagonal matrices for equality.

Overrides:
equals in class ComplexTridiagonalMatrix
Parameters:
m - a complex diagonal matrix

real

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

Overrides:
real in class ComplexTridiagonalMatrix
Returns:
a double diagonal matrix

imag

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

Overrides:
imag in class ComplexTridiagonalMatrix
Returns:
a double diagonal matrix

getElement

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

Overrides:
getElement in class ComplexTridiagonalMatrix
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 ComplexTridiagonalMatrix
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 ComplexTridiagonalMatrix
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.

isHermitian

public boolean isHermitian()
Returns true if this matrix is hermitian.

Overrides:
isHermitian in class ComplexSquareMatrix

isUnitary

public boolean isUnitary()
Returns true if this matrix is unitary.

Overrides:
isUnitary in class ComplexSquareMatrix

det

public Complex det()
Returns the determinant.

Overrides:
det in class ComplexSquareMatrix

trace

public Complex trace()
Returns the trace.

Overrides:
trace in class ComplexTridiagonalMatrix

infNorm

public double infNorm()
Returns the linfinity-norm.

Overrides:
infNorm in class ComplexTridiagonalMatrix

frobeniusNorm

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

Overrides:
frobeniusNorm in class ComplexTridiagonalMatrix

operatorNorm

public double operatorNorm()
Returns the operator norm.

Overrides:
operatorNorm in class ComplexTridiagonalMatrix

add

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

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

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

add

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

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

subtract

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

Overrides:
subtract in class ComplexTridiagonalMatrix
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 ComplexTridiagonalMatrix
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 by another.

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

subtract

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

Parameters:
m - a complex diagonal 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 ComplexTridiagonalMatrix
Parameters:
z - a complex number
Returns:
a complex diagonal matrix

scalarMultiply

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

Overrides:
scalarMultiply in class ComplexTridiagonalMatrix
Parameters:
x - a double
Returns:
a complex diagonal matrix

multiply

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

Overrides:
multiply in class ComplexTridiagonalMatrix
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 ComplexTridiagonalMatrix
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 ComplexTridiagonalMatrix
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.

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

multiply

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

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

inverse

public ComplexSquareMatrix inverse()
Returns the inverse of this matrix.

Overrides:
inverse in class ComplexSquareMatrix
Returns:
a complex diagonal matrix

hermitianAdjoint

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

Overrides:
hermitianAdjoint in class ComplexTridiagonalMatrix
Returns:
a complex diagonal matrix

conjugate

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

Overrides:
conjugate in class ComplexTridiagonalMatrix
Returns:
a complex diagonal matrix

transpose

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

Overrides:
transpose in class ComplexTridiagonalMatrix
Returns:
a complex diagonal matrix

luDecompose

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

Overrides:
luDecompose in class ComplexTridiagonalMatrix
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 ComplexTridiagonalMatrix
Parameters:
f - a user-defined function
Returns:
a complex diagonal matrix