org.jscience.mathematics.algebraic.matrices
Class ComplexSquareMatrix

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.ComplexSquareMatrix
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Algebra.Member, BanachSpace.Member, CStarAlgebra.Member, Ring.Member, AbelianGroup.Member, Hypermatrix, Matrix, Module.Member, VectorSpace.Member, SquareMatrix, Member
Direct Known Subclasses:
ComplexSymmetricMatrix, GammaMatrix

public class ComplexSquareMatrix
extends AbstractComplexSquareMatrix
implements java.lang.Cloneable, java.io.Serializable

The ComplexSquareMatrix class provides an object for encapsulating square matrices containing complex numbers.

See Also:
Serialized Form

Field Summary
protected  double[][] matrixIm
          Arrays containing the elements of the matrix.
protected  double[][] matrixRe
          Arrays containing the elements of the matrix.
 
Fields inherited from class org.jscience.mathematics.algebraic.matrices.AbstractComplexSquareMatrix
LU, LUpivot
 
Constructor Summary
ComplexSquareMatrix(AbstractComplexVector[] array)
          Constructs a matrix from an array of vectors.
ComplexSquareMatrix(Complex[][] array)
          Constructs a matrix from an array.
ComplexSquareMatrix(ComplexSquareMatrix mat)
          Copy constructor.
ComplexSquareMatrix(double[][] arrayRe, double[][] arrayIm)
          Constructs a matrix by wrapping two arrays.
ComplexSquareMatrix(int size)
          Constructs an empty matrix.
 
Method Summary
 AbstractComplexSquareMatrix add(AbstractComplexSquareMatrix m)
          Returns the addition of this matrix and another.
 ComplexSquareMatrix add(ComplexSquareMatrix m)
           
 java.lang.Object clone()
          Clone matrix into a new matrix.
 AbstractComplexMatrix conjugate()
          Returns the complex conjugate of this matrix.
 Complex det()
          Returns the determinant.
 AbstractComplexSquareMatrix directSum(AbstractComplexSquareMatrix m)
          Returns the direct sum of this matrix and another.
 boolean equals(AbstractComplexMatrix m, double tol)
          Compares two complex matrices for equality.
 double frobeniusNorm()
          Returns the Frobenius or Hilbert-Schmidt (l2) norm.
 double getImagElement(int i, int j)
          Returns the imag part of an element of the matrix.
 Complex getPrimitiveElement(int i, int j)
          Returns 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.
 AbstractComplexSquareMatrix inverse()
          Returns the inverse of this matrix.
 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)
           
 AbelianGroup.Member negate()
          Returns the negative of this matrix.
 AbstractComplexSquareMatrix[] polarDecompose()
          Returns the polar decomposition of this matrix.
 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 m)
          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 by another.
 ComplexSquareMatrix subtract(ComplexSquareMatrix m)
           
 AbstractComplexSquareMatrix tensorProduct(AbstractComplexSquareMatrix m)
          Returns the tensor product 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, involution, isHermitian, isSymmetric, isUnitary, norm, operatorNorm, scalarDivide, scalarDivide, scalarProduct, scalarProduct, subtract
 
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.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
 
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
 

Field Detail

matrixRe

protected final double[][] matrixRe
Arrays containing the elements of the matrix.


matrixIm

protected final double[][] matrixIm
Arrays containing the elements of the matrix.

Constructor Detail

ComplexSquareMatrix

public ComplexSquareMatrix(double[][] arrayRe,
                           double[][] arrayIm)
Constructs a matrix by wrapping two arrays.

Parameters:
arrayRe - an array of real values
arrayIm - an array of imaginary values
Throws:
IllegalDimensionException - If the array is not square.

ComplexSquareMatrix

public ComplexSquareMatrix(int size)
Constructs an empty matrix.

Parameters:
size - the number of rows/columns

ComplexSquareMatrix

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

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

ComplexSquareMatrix

public ComplexSquareMatrix(ComplexSquareMatrix mat)
Copy constructor.

Parameters:
mat - an assigned value

ComplexSquareMatrix

public ComplexSquareMatrix(AbstractComplexVector[] array)
Constructs a matrix from an array of vectors. The vectors form columns in the matrix.

Parameters:
array - an assigned value.
Throws:
IllegalDimensionException - 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 square matrix

imag

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

Overrides:
imag in class AbstractComplexSquareMatrix
Returns:
a double square 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
Throws:
IllegalDimensionException - 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.

Overrides:
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.

Overrides:
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:
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 m)
Sets the value of all elements of the matrix.

Overrides:
setAllElements in class AbstractComplexMatrix
Parameters:
m - a complex element

infNorm

public double infNorm()
Returns the linfinity-norm.

Overrides:
infNorm in class AbstractComplexMatrix

frobeniusNorm

public double frobeniusNorm()
Returns the Frobenius or Hilbert-Schmidt (l2) norm.

Overrides:
frobeniusNorm in class AbstractComplexMatrix

det

public Complex det()
Returns the determinant.

Overrides:
det in class AbstractComplexSquareMatrix

trace

public Complex trace()
Returns the trace.

Overrides:
trace in class AbstractComplexSquareMatrix

negate

public AbelianGroup.Member negate()
Returns the negative of this matrix.

Specified by:
negate in interface AbelianGroup.Member
Overrides:
negate in class AbstractComplexSquareMatrix
Returns:
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
Throws:
IllegalDimensionException - If the matrices are different sizes.

add

public ComplexSquareMatrix add(ComplexSquareMatrix m)

subtract

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

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

subtract

public ComplexSquareMatrix subtract(ComplexSquareMatrix m)

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 square 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 square 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:
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 square matrix
Returns:
an AbstractComplexMatrix or an AbstractComplexSquareMatrix as appropriate
Throws:
IllegalDimensionException - If the matrices are incompatible.

multiply

public ComplexSquareMatrix multiply(ComplexSquareMatrix m)

directSum

public AbstractComplexSquareMatrix directSum(AbstractComplexSquareMatrix m)
Returns the direct sum of this matrix and another.

Overrides:
directSum in class AbstractComplexSquareMatrix

tensorProduct

public AbstractComplexSquareMatrix tensorProduct(AbstractComplexSquareMatrix m)
Returns the tensor product of this matrix and another.

Overrides:
tensorProduct in class AbstractComplexSquareMatrix

hermitianAdjoint

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

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

conjugate

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

Overrides:
conjugate in class AbstractComplexSquareMatrix
Returns:
a complex square 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 square matrix

inverse

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

Overrides:
inverse in class AbstractComplexSquareMatrix
Returns:
a complex square matrix

luDecompose

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

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

polarDecompose

public AbstractComplexSquareMatrix[] polarDecompose()
Returns the polar decomposition of this matrix.

Overrides:
polarDecompose in class AbstractComplexSquareMatrix

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 square 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.