org.jscience.mathematics.algebraic.matrices
Class ComplexSparseSquareMatrix

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

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

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

See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.jscience.mathematics.algebraic.matrices.AbstractComplexSquareMatrix
LU, LUpivot
 
Constructor Summary
ComplexSparseSquareMatrix(Complex[][] array)
          Constructs a matrix from an array.
ComplexSparseSquareMatrix(ComplexSparseSquareMatrix mat)
          Copy constructor.
ComplexSparseSquareMatrix(int size)
          Constructs an empty matrix.
 
Method Summary
 AbstractComplexSquareMatrix add(AbstractComplexSquareMatrix m)
          Returns the addition of this matrix and another.
 ComplexSparseSquareMatrix add(ComplexSparseSquareMatrix m)
          Returns the addition of this matrix and another.
 ComplexSquareMatrix add(ComplexSquareMatrix m)
          DOCUMENT ME!
 AbstractComplexSquareMatrix[] choleskyDecompose()
          Returns the Cholesky decomposition of this matrix.
 java.lang.Object clone()
          Clone matrix into a new matrix.
 Complex det()
          Returns the determinant.
 boolean equals(AbstractComplexSquareMatrix m, double tol)
          Compares two Complex sparse square matrices for equality.
 boolean equals(ComplexSparseSquareMatrix m)
          DOCUMENT ME!
 boolean equals(ComplexSparseSquareMatrix m, double tol)
          DOCUMENT ME!
 double frobeniusNorm()
          Returns the Frobenius (l2) norm.
 Complex getPrimitiveElement(int i, int j)
          Returns an element of the matrix.
 double infNorm()
          Returns the linfinity-norm.
 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.
 ComplexSparseSquareMatrix multiply(ComplexSparseSquareMatrix m)
          Returns the multiplication of this matrix and another.
 ComplexSquareMatrix multiply(ComplexSquareMatrix m)
          DOCUMENT ME!
 AbstractComplexMatrix scalarDivide(Complex x)
          DOCUMENT ME!
 AbstractComplexMatrix scalarMultiply(Complex x)
          Returns the multiplication of this matrix by a scalar.
 Complex scalarProduct(AbstractComplexSquareMatrix m)
          Returns the scalar product of this matrix and another.
 Complex scalarProduct(ComplexSquareMatrix 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.
 AbstractComplexSquareMatrix subtract(AbstractComplexSquareMatrix m)
          Returns the subtraction of this matrix and another.
 ComplexSparseSquareMatrix subtract(ComplexSparseSquareMatrix m)
          Returns the addition of this matrix and another.
 ComplexSquareMatrix subtract(ComplexSquareMatrix m)
          DOCUMENT ME!
 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, conjugate, directSum, hermitianAdjoint, imag, inverse, involution, isHermitian, isSymmetric, isUnitary, negate, norm, operatorNorm, polarDecompose, real, scalarDivide, scalarMultiply, scalarProduct, subtract, tensorProduct
 
Methods inherited from class org.jscience.mathematics.algebraic.matrices.AbstractComplexMatrix
abs, add, directSum, equals, equals, equals, getColumn, getElement, getImagElement, getMatrixAsColumns, getMatrixAsRows, getRealElement, getRow, getSet, getSubMatrix, hashCode, horizontalAxisSymmetry, mass, multiply, multiply, read, reverse, scalarDivide, 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.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
 

Constructor Detail

ComplexSparseSquareMatrix

public ComplexSparseSquareMatrix(int size)
Constructs an empty matrix.

Parameters:
size - the number of rows/columns

ComplexSparseSquareMatrix

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

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

ComplexSparseSquareMatrix

public ComplexSparseSquareMatrix(ComplexSparseSquareMatrix mat)
Copy constructor.

Parameters:
mat - an assigned value
Method Detail

equals

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

Parameters:
m - a Complex matrix
tol - DOCUMENT ME!
Returns:
DOCUMENT ME!

equals

public boolean equals(ComplexSparseSquareMatrix m)
DOCUMENT ME!

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

equals

public boolean equals(ComplexSparseSquareMatrix 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!

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.

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

det

public Complex det()
Returns the determinant.

Overrides:
det in class AbstractComplexSquareMatrix
Returns:
DOCUMENT ME!
Throws:
java.lang.ArithmeticException - 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!

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 ComplexSparseSquareMatrix add(ComplexSparseSquareMatrix m)
Returns the addition of this matrix and another.

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

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 ComplexSparseSquareMatrix subtract(ComplexSparseSquareMatrix m)
Returns the addition of this matrix and another.

Parameters:
m - a Complex 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 AbstractComplexSquareMatrix
Parameters:
x - a Complex
Returns:
a Complex sparse matrix

scalarDivide

public AbstractComplexMatrix scalarDivide(Complex x)
DOCUMENT ME!

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

scalarProduct

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

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

scalarProduct

public Complex scalarProduct(ComplexSquareMatrix 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 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 incompatible.

multiply

public ComplexSquareMatrix multiply(ComplexSquareMatrix m)
DOCUMENT ME!

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

multiply

public ComplexSparseSquareMatrix multiply(ComplexSparseSquareMatrix 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 AbstractComplexSquareMatrix
Returns:
a Complex sparse matrix

luDecompose

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

Overrides:
luDecompose in class AbstractComplexSquareMatrix
Parameters:
pivot - an empty array of length numRows()+1 to hold the pivot information (null if not interested)
Returns:
an array with [0] containing the L-matrix and [1] containing the U-matrix.

choleskyDecompose

public AbstractComplexSquareMatrix[] choleskyDecompose()
Returns the Cholesky decomposition of this matrix. Matrix must be symmetric and positive definite.

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