org.jscience.mathematics.algebraic.matrices
Class ComplexSparseMatrix

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.ComplexSparseMatrix
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Algebra.Member, Ring.Member, AbelianGroup.Member, Hypermatrix, Matrix, Module.Member, VectorSpace.Member, Member

public class ComplexSparseMatrix
extends AbstractComplexMatrix
implements java.lang.Cloneable, java.io.Serializable

The ComplexSparseMatrix class provides an object for encapsulating sparse matrices. Uses compressed row storage.

See Also:
Serialized Form

Constructor Summary
ComplexSparseMatrix(Complex[][] array)
          Constructs a matrix from an array.
ComplexSparseMatrix(ComplexSparseMatrix mat)
          Copy constructor.
ComplexSparseMatrix(int rowCount, int colCount)
          Constructs an empty matrix.
 
Method Summary
 AbstractComplexMatrix add(AbstractComplexMatrix m)
          Returns the addition of this matrix and another.
 ComplexMatrix add(ComplexMatrix m)
          DOCUMENT ME!
 ComplexSparseMatrix add(ComplexSparseMatrix m)
          Returns the addition of this matrix and another.
 java.lang.Object clone()
          Clone matrix into a new matrix.
 boolean equals(AbstractComplexMatrix m, double tol)
          Compares two Complex sparse matrices for equality.
 boolean equals(ComplexSparseMatrix m)
          DOCUMENT ME!
 boolean equals(ComplexSparseMatrix m, double tol)
          DOCUMENT ME!
 double frobeniusNorm()
          Returns the Frobenius (l2) norm.
 double getImagElement(int i, int j)
          DOCUMENT ME!
 Complex getPrimitiveElement(int i, int j)
          Returns an element of the matrix.
 double getRealElement(int i, int j)
          DOCUMENT ME!
 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.
 AbstractComplexMatrix multiply(AbstractComplexMatrix m)
          Returns the multiplication of this matrix and another.
 AbstractComplexVector multiply(AbstractComplexVector v)
          Returns the multiplication of a vector by this matrix.
 AbstractComplexMatrix multiply(ComplexMatrix m)
          DOCUMENT ME!
 AbstractComplexMatrix multiply(ComplexSparseMatrix m)
          Returns the multiplication of this matrix and another.
 AbstractDoubleMatrix real()
          Returns the real part of this complex matrix.
 AbstractComplexMatrix scalarDivide(Complex x)
          DOCUMENT ME!
 AbstractComplexMatrix scalarMultiply(Complex x)
          Returns the multiplication of this matrix by a scalar.
 Complex scalarProduct(AbstractComplexMatrix m)
          Returns the scalar product of this matrix and another.
 Complex scalarProduct(ComplexMatrix m)
          DOCUMENT ME!
 void setAllElements(Complex m)
          Sets the value of all elements of the matrix.
 void setElement(int i, int j, Complex x)
          Sets the value of an element of the matrix.
 AbstractComplexMatrix subtract(AbstractComplexMatrix m)
          Returns the subtraction of this matrix and another.
 ComplexMatrix subtract(ComplexMatrix m)
          DOCUMENT ME!
 ComplexSparseMatrix subtract(ComplexSparseMatrix m)
          Returns the addition of this matrix and another.
 Complex[][] toPrimitiveArray()
          Projects the matrix to an array.
 java.lang.String toString()
          Returns a string representing this matrix.
 Matrix transpose()
          Returns the transpose of this matrix.
 
Methods inherited from class org.jscience.mathematics.algebraic.matrices.AbstractComplexMatrix
abs, add, conjugate, directSum, equals, equals, getColumn, getElement, getMatrixAsColumns, getMatrixAsRows, getRow, getSet, getSubMatrix, hashCode, hermitianAdjoint, horizontalAxisSymmetry, mass, multiply, negate, read, reverse, scalarDivide, scalarDivide, scalarMultiply, scalarMultiply, setColumn, setElement, 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.Hypermatrix
getDimensions, numDimensions, numElements, numElements, toArray
 

Constructor Detail

ComplexSparseMatrix

public ComplexSparseMatrix(int rowCount,
                           int colCount)
Constructs an empty matrix.

Parameters:
rowCount - the number of rows
colCount - the number of columns

ComplexSparseMatrix

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

Parameters:
array - an assigned value

ComplexSparseMatrix

public ComplexSparseMatrix(ComplexSparseMatrix mat)
Copy constructor.

Parameters:
mat - an assigned value
Method Detail

equals

public boolean equals(AbstractComplexMatrix m,
                      double tol)
Compares two Complex sparse matrices for equality.

Overrides:
equals in class AbstractComplexMatrix
Parameters:
m - a Complex matrix
tol - DOCUMENT ME!
Returns:
DOCUMENT ME!

equals

public boolean equals(ComplexSparseMatrix m)
DOCUMENT ME!

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

equals

public boolean equals(ComplexSparseMatrix m,
                      double tol)
DOCUMENT ME!

Parameters:
m - DOCUMENT ME!
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!

real

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

Overrides:
real in class AbstractComplexMatrix
Returns:
a double matrix

imag

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

Overrides:
imag in class AbstractComplexMatrix
Returns:
a double 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 x)
Sets the value of an element of the matrix.

Specified by:
setElement in class AbstractComplexMatrix
Parameters:
i - row index of the element
j - column index of the element
x - a 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. You should think about using a ComplexSquareMatrix.

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

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!

add

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

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

add

public ComplexMatrix add(ComplexMatrix m)
DOCUMENT ME!

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

add

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

Parameters:
m - a double sparse matrix
Returns:
DOCUMENT ME!
Throws:
IllegalDimensionException - If the matrices are different sizes.

subtract

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

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

subtract

public ComplexMatrix subtract(ComplexMatrix m)
DOCUMENT ME!

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

subtract

public ComplexSparseMatrix subtract(ComplexSparseMatrix m)
Returns the addition of this matrix and another.

Parameters:
m - a double sparse matrix
Returns:
DOCUMENT ME!
Throws:
IllegalDimensionException - If the matrices are different sizes.

scalarMultiply

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

Overrides:
scalarMultiply in class AbstractComplexMatrix
Parameters:
x - a double
Returns:
a double sparse matrix

scalarDivide

public AbstractComplexMatrix scalarDivide(Complex x)
DOCUMENT ME!

Overrides:
scalarDivide in class AbstractComplexMatrix
Parameters:
x - DOCUMENT ME!
Returns:
DOCUMENT ME!

scalarProduct

public Complex scalarProduct(AbstractComplexMatrix m)
Returns the scalar product of this matrix and another.

Overrides:
scalarProduct in class AbstractComplexMatrix
Parameters:
m - a double matrix.
Returns:
DOCUMENT ME!
Throws:
IllegalDimensionException - If the matrices are different sizes.

scalarProduct

public Complex scalarProduct(ComplexMatrix m)
DOCUMENT ME!

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

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 AbstractComplexMatrix multiply(AbstractComplexMatrix m)
Returns the multiplication of this matrix and another.

Overrides:
multiply in class AbstractComplexMatrix
Parameters:
m - a Complex matrix
Returns:
DOCUMENT ME!
Throws:
IllegalDimensionException - If the matrices are incompatible.

multiply

public AbstractComplexMatrix multiply(ComplexMatrix m)
DOCUMENT ME!

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

multiply

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

Parameters:
m - a Complex sparse matrix
Returns:
DOCUMENT ME!
Throws:
IllegalDimensionException - If the matrices are incompatible.

transpose

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

Specified by:
transpose in interface Matrix
Overrides:
transpose in class AbstractComplexMatrix
Returns:
a Complex sparse 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 sparse 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 Complex array.