JSci.maths
Class ComplexMatrix

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

public class ComplexMatrix
extends Matrix

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

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

Field Summary
protected static int ARRAY_2D
          Storage format identifier.
protected  double[][] matrixIm
          Arrays containing the elements of the matrix.
protected  double[][] matrixRe
          Arrays containing the elements of the matrix.
 
Fields inherited from class JSci.maths.Matrix
CLASS_SPECIFIC, numCols, numRows, storageFormat
 
Constructor Summary
  ComplexMatrix(Complex[][] array)
          Constructs a matrix from an array.
  ComplexMatrix(ComplexVector[] array)
          Constructs a matrix from an array of vectors (columns).
  ComplexMatrix(double[][] arrayRe, double[][] arrayIm)
          Constructs a matrix by wrapping two arrays.
  ComplexMatrix(int rows, int cols)
          Constructs an empty matrix.
protected ComplexMatrix(int rows, int cols, int storeID)
          Constructs a matrix.
 
Method Summary
 AbelianGroup.Member add(AbelianGroup.Member m)
          Returns the addition of this matrix and another.
 ComplexMatrix add(ComplexMatrix m)
          Returns the addition of this matrix and another.
 ComplexMatrix conjugate()
          Returns the complex conjugate of this matrix.
 ComplexMatrix directSum(ComplexMatrix m)
          Returns the direct sum of this matrix and another.
 boolean equals(java.lang.Object m)
          Compares two complex matrices for equality.
protected  void finalize()
          Finalize.
 double frobeniusNorm()
          Returns the Frobenius (l2) norm.
 Complex getElement(int i, int j)
          Returns an element of the matrix.
 int hashCode()
          Returns a hashcode for this 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.
 ComplexMatrix mapElements(ComplexMapping f)
          Applies a function on all the matrix elements.
 ComplexMatrix multiply(ComplexMatrix m)
          Returns the multiplication of this matrix and another.
 ComplexVector multiply(ComplexVector v)
          Returns the multiplication of a vector by this matrix.
 Ring.Member multiply(Ring.Member m)
          Returns the multiplication of this matrix and another.
 AbelianGroup.Member negate()
          Returns the negative of this matrix.
 DoubleMatrix real()
          Returns the real part of this complex matrix.
 ComplexMatrix scalarDivide(Complex z)
          Returns the division of this matrix by a scalar.
 ComplexMatrix scalarDivide(double x)
          Returns the division of this matrix by a scalar.
 VectorSpace.Member scalarDivide(Field.Member x)
          Returns the division of this matrix by a scalar.
 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.
 Module.Member scalarMultiply(Ring.Member 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.
 AbelianGroup.Member subtract(AbelianGroup.Member m)
          Returns the subtraction of this matrix by another.
 ComplexMatrix subtract(ComplexMatrix m)
          Returns the subtraction of this matrix by another.
 ComplexMatrix tensorProduct(ComplexMatrix m)
          Returns the tensor product of this matrix and another.
 java.lang.String toString()
          Returns a string representing this matrix.
 Matrix transpose()
          Returns the transpose of this matrix.
 
Methods inherited from class JSci.maths.Matrix
columns, getInvalidElementMsg, rows
 
Methods inherited from class java.lang.Object
clone, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ARRAY_2D

protected static final int ARRAY_2D
Storage format identifier.

See Also:
Constant Field Values

matrixRe

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


matrixIm

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

Constructor Detail

ComplexMatrix

protected ComplexMatrix(int rows,
                        int cols,
                        int storeID)
Constructs a matrix.


ComplexMatrix

public ComplexMatrix(int rows,
                     int cols)
Constructs an empty matrix.

Parameters:
rows - the number of rows
cols - the number of columns

ComplexMatrix

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

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

ComplexMatrix

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

Parameters:
array - an assigned value

ComplexMatrix

public ComplexMatrix(ComplexVector[] array)
Constructs a matrix from an array of vectors (columns).

Parameters:
array - an assigned value
Method Detail

finalize

protected void finalize()
                 throws java.lang.Throwable
Finalize.

Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable - Any that occur.

equals

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

Overrides:
equals in class java.lang.Object
Parameters:
m - a complex matrix

toString

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

Overrides:
toString in class java.lang.Object

hashCode

public int hashCode()
Returns a hashcode for this matrix.

Overrides:
hashCode in class java.lang.Object

real

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

Returns:
a double matrix

imag

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

Returns:
a double matrix

getElement

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

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.

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.

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.

infNorm

public double infNorm()
Returns the linfinity-norm.


frobeniusNorm

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


negate

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


add

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

Parameters:
m - a group member

add

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

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

subtract

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

Parameters:
m - a group member

subtract

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

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

scalarMultiply

public Module.Member scalarMultiply(Ring.Member x)
Returns the multiplication of this matrix by a scalar.

Parameters:
x - a ring member

scalarMultiply

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

Parameters:
z - a complex number
Returns:
a complex matrix

scalarMultiply

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

Parameters:
x - a double
Returns:
a complex matrix

scalarDivide

public VectorSpace.Member scalarDivide(Field.Member x)
Returns the division of this matrix by a scalar.

Parameters:
x - a field member

scalarDivide

public ComplexMatrix scalarDivide(Complex z)
Returns the division of this matrix by a scalar.

Parameters:
z - a complex number
Returns:
a complex matrix

scalarDivide

public ComplexMatrix scalarDivide(double x)
Returns the division of this matrix by a scalar.

Parameters:
x - a double
Returns:
a complex matrix

multiply

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

Parameters:
v - a complex vector
Throws:
DimensionException - If the matrix and vector are incompatible.

multiply

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

Parameters:
m - a ring member

multiply

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

Parameters:
m - a complex matrix
Returns:
a ComplexMatrix or a ComplexSquareMatrix as appropriate
Throws:
MatrixDimensionException - If the matrices are incompatible.

directSum

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


tensorProduct

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


hermitianAdjoint

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

Returns:
a complex matrix

conjugate

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

Returns:
a complex matrix

transpose

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

Specified by:
transpose in class Matrix
Returns:
a complex matrix

mapElements

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

Parameters:
f - a user-defined function
Returns:
a complex matrix