org.jscience.mathematics.algebraic.matrices
Class ComplexSparseVector

java.lang.Object
  extended by org.jscience.mathematics.algebraic.AbstractHypermatrix
      extended by org.jscience.mathematics.algebraic.AbstractMatrix
          extended by org.jscience.mathematics.algebraic.AbstractVector
              extended by org.jscience.mathematics.algebraic.matrices.AbstractComplexVector
                  extended by org.jscience.mathematics.algebraic.matrices.ComplexSparseVector
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Algebra.Member, BanachSpace.Member, HilbertSpace.Member, Ring.Member, AbelianGroup.Member, Hypermatrix, Matrix, Module.Member, VectorSpace.Member, Vector, Member

public class ComplexSparseVector
extends AbstractComplexVector
implements java.lang.Cloneable, java.io.Serializable

The ComplexSparseVector class encapsulates sparse vectors. Uses Morse-coding.

See Also:
Serialized Form

Constructor Summary
ComplexSparseVector(AbstractComplexVector vec)
          Constructs a vector by copying a vector.
ComplexSparseVector(Complex[] array)
          Constructs a vector from an array.
ComplexSparseVector(int dim)
          Constructs an empty vector.
 
Method Summary
 AbelianGroup.Member add(AbelianGroup.Member v)
          Returns the addition of this vector and another.
 AbstractComplexVector add(AbstractComplexVector v)
          Returns the addition of this vector and another.
 ComplexSparseVector add(ComplexSparseVector v)
          Returns the addition of this vector and another.
 ComplexVector add(ComplexVector v)
          DOCUMENT ME!
 java.lang.Object clone()
          Clone vector into a new vector.
 AbstractComplexVector conjugate()
          DOCUMENT ME!
 boolean equals(java.lang.Object obj, double tol)
          Compares two vectors for equality.
 Complex getPrimitiveElement(int n)
          Returns a component of this vector.
 AbstractDoubleVector imag()
          DOCUMENT ME!
 double infNorm()
          Returns the linfinity-norm.
 AbstractComplexVector mapElements(ComplexMapping f)
          Applies a function on all the vector components.
 AbelianGroup.Member negate()
          Returns the negative of this vector.
 double norm()
          Returns the l2-norm (magnitude).
 void normalize()
          Makes the norm of this vector equal to 1.
 AbstractDoubleVector real()
          DOCUMENT ME!
 AbstractComplexVector scalarDivide(Complex x)
          Returns the division of this vector by a scalar.
 AbstractComplexVector scalarDivide(double x)
          DOCUMENT ME!
 VectorSpace.Member scalarDivide(Field.Member x)
          Returns the division of this vector by a scalar.
 AbstractComplexVector scalarMultiply(Complex x)
          Returns the multiplication of this vector by a scalar.
 AbstractComplexVector scalarMultiply(double x)
          DOCUMENT ME!
 Module.Member scalarMultiply(Ring.Member x)
          Returns the multiplication of this vector by a scalar.
 Complex scalarProduct(AbstractComplexVector v)
          Returns the scalar product of this vector and another.
 Complex scalarProduct(ComplexSparseVector v)
          Returns the scalar product of this vector and another.
 Complex scalarProduct(ComplexVector v)
          DOCUMENT ME!
 Complex scalarProduct(HilbertSpace.Member v)
          DOCUMENT ME!
 void setAllElements(Complex r)
          Sets the value of all elements of the vector.
 void setElement(int n, Complex x)
          Sets the value of a component of this vector.
 void setElement(int n, double x, double y)
          DOCUMENT ME!
 AbelianGroup.Member subtract(AbelianGroup.Member v)
          Returns the subtraction of this vector by another.
 AbstractComplexVector subtract(AbstractComplexVector v)
          Returns the subtraction of this vector by another.
 ComplexSparseVector subtract(ComplexSparseVector v)
          Returns the subtraction of this vector by another.
 ComplexVector subtract(ComplexVector v)
          DOCUMENT ME!
 ComplexSparseMatrix tensorProduct(ComplexSparseVector v)
          Returns the tensor product of this vector and another.
 Complex[] toPrimitiveArray()
          Projects the vector to an array.
 
Methods inherited from class org.jscience.mathematics.algebraic.matrices.AbstractComplexVector
abs, equals, getColumn, getElement, getImagElement, getRealElement, getRow, getSubVector, hashCode, mass, multiply, read, reverse, setColumn, setRow, setSubVector, tensorProduct, toMatrix, toString, transpose
 
Methods inherited from class org.jscience.mathematics.algebraic.AbstractVector
getDimension, getElement, getInvalidElementMsg, toArray, toArray
 
Methods inherited from class org.jscience.mathematics.algebraic.AbstractMatrix
getElement, getInvalidElementMsg, numColumns, numRows, print, print, print, print, 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.Matrix
numColumns, numRows, toArray
 
Methods inherited from interface org.jscience.mathematics.algebraic.Hypermatrix
getDimensions, getElement, numDimensions, numElements, numElements, toArray
 

Constructor Detail

ComplexSparseVector

public ComplexSparseVector(int dim)
Constructs an empty vector.

Parameters:
dim - the dimension of the vector.

ComplexSparseVector

public ComplexSparseVector(Complex[] array)
Constructs a vector from an array.

Parameters:
array - DOCUMENT ME!

ComplexSparseVector

public ComplexSparseVector(AbstractComplexVector vec)
Constructs a vector by copying a vector.

Parameters:
vec - an assigned value
Method Detail

real

public AbstractDoubleVector real()
DOCUMENT ME!

Overrides:
real in class AbstractComplexVector
Returns:
DOCUMENT ME!

imag

public AbstractDoubleVector imag()
DOCUMENT ME!

Overrides:
imag in class AbstractComplexVector
Returns:
DOCUMENT ME!

equals

public boolean equals(java.lang.Object obj,
                      double tol)
Compares two vectors for equality.

Overrides:
equals in class AbstractComplexVector
Parameters:
obj - a complex sparse vector
tol - DOCUMENT ME!
Returns:
DOCUMENT ME!

getPrimitiveElement

public Complex getPrimitiveElement(int n)
Returns a component of this vector.

Specified by:
getPrimitiveElement in class AbstractComplexVector
Parameters:
n - index of the vector component
Returns:
DOCUMENT ME!
Throws:
IllegalDimensionException - If attempting to access an invalid component.

setElement

public void setElement(int n,
                       Complex x)
Sets the value of a component of this vector.

Specified by:
setElement in class AbstractComplexVector
Parameters:
n - index of the vector component
x - a number
Throws:
IllegalDimensionException - If attempting to access an invalid component.

setElement

public void setElement(int n,
                       double x,
                       double y)
DOCUMENT ME!

Overrides:
setElement in class AbstractComplexVector
Parameters:
n - DOCUMENT ME!
x - DOCUMENT ME!
y - DOCUMENT ME!

setAllElements

public void setAllElements(Complex r)
Sets the value of all elements of the vector. You should think about using a DoubleVector.

Overrides:
setAllElements in class AbstractComplexVector
Parameters:
r - a ring element

norm

public double norm()
Returns the l2-norm (magnitude).

Specified by:
norm in interface BanachSpace.Member
Overrides:
norm in class AbstractComplexVector
Returns:
DOCUMENT ME!
Throws:
java.lang.ArithmeticException - DOCUMENT ME!

normalize

public void normalize()
Makes the norm of this vector equal to 1.

Overrides:
normalize in class AbstractComplexVector

infNorm

public double infNorm()
Returns the linfinity-norm.

Overrides:
infNorm in class AbstractComplexVector
Returns:
DOCUMENT ME!
Throws:
java.lang.ArithmeticException - DOCUMENT ME!

conjugate

public AbstractComplexVector conjugate()
DOCUMENT ME!

Overrides:
conjugate in class AbstractComplexVector
Returns:
DOCUMENT ME!

negate

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

Specified by:
negate in interface AbelianGroup.Member
Returns:
DOCUMENT ME!

add

public AbelianGroup.Member add(AbelianGroup.Member v)
Returns the addition of this vector and another.

Specified by:
add in interface AbelianGroup.Member
Parameters:
v - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
java.lang.IllegalArgumentException - DOCUMENT ME!

add

public AbstractComplexVector add(AbstractComplexVector v)
Returns the addition of this vector and another.

Overrides:
add in class AbstractComplexVector
Parameters:
v - a complex vector
Returns:
DOCUMENT ME!
Throws:
IllegalDimensionException - If the vectors are different sizes.

add

public ComplexVector add(ComplexVector v)
DOCUMENT ME!

Parameters:
v - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
IllegalDimensionException - DOCUMENT ME!

add

public ComplexSparseVector add(ComplexSparseVector v)
Returns the addition of this vector and another.

Parameters:
v - a complex sparse vector
Returns:
DOCUMENT ME!
Throws:
IllegalDimensionException - If the vectors are different sizes.

subtract

public AbelianGroup.Member subtract(AbelianGroup.Member v)
Returns the subtraction of this vector by another.

Specified by:
subtract in interface AbelianGroup.Member
Parameters:
v - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
java.lang.IllegalArgumentException - DOCUMENT ME!

subtract

public AbstractComplexVector subtract(AbstractComplexVector v)
Returns the subtraction of this vector by another.

Overrides:
subtract in class AbstractComplexVector
Parameters:
v - a complex vector
Returns:
DOCUMENT ME!
Throws:
IllegalDimensionException - If the vectors are different sizes.

subtract

public ComplexVector subtract(ComplexVector v)
DOCUMENT ME!

Parameters:
v - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
IllegalDimensionException - DOCUMENT ME!

subtract

public ComplexSparseVector subtract(ComplexSparseVector v)
Returns the subtraction of this vector by another.

Parameters:
v - a complex sparse vector
Returns:
DOCUMENT ME!
Throws:
IllegalDimensionException - If the vectors are different sizes.

scalarMultiply

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

Specified by:
scalarMultiply in interface Module.Member
Parameters:
x - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
java.lang.IllegalArgumentException - DOCUMENT ME!

scalarMultiply

public AbstractComplexVector scalarMultiply(Complex x)
Returns the multiplication of this vector by a scalar.

Overrides:
scalarMultiply in class AbstractComplexVector
Parameters:
x - a complex
Returns:
DOCUMENT ME!

scalarMultiply

public AbstractComplexVector scalarMultiply(double x)
DOCUMENT ME!

Overrides:
scalarMultiply in class AbstractComplexVector
Parameters:
x - DOCUMENT ME!
Returns:
DOCUMENT ME!

scalarDivide

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

Specified by:
scalarDivide in interface VectorSpace.Member
Parameters:
x - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
java.lang.IllegalArgumentException - DOCUMENT ME!

scalarDivide

public AbstractComplexVector scalarDivide(Complex x)
Returns the division of this vector by a scalar.

Overrides:
scalarDivide in class AbstractComplexVector
Parameters:
x - a complex
Returns:
DOCUMENT ME!

scalarDivide

public AbstractComplexVector scalarDivide(double x)
DOCUMENT ME!

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

scalarProduct

public Complex scalarProduct(HilbertSpace.Member v)
DOCUMENT ME!

Specified by:
scalarProduct in interface HilbertSpace.Member
Parameters:
v - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
java.lang.IllegalArgumentException - DOCUMENT ME!

scalarProduct

public Complex scalarProduct(AbstractComplexVector v)
Returns the scalar product of this vector and another.

Overrides:
scalarProduct in class AbstractComplexVector
Parameters:
v - a complex vector
Returns:
DOCUMENT ME!
Throws:
IllegalDimensionException - If the vectors are different sizes.

scalarProduct

public Complex scalarProduct(ComplexVector v)
DOCUMENT ME!

Parameters:
v - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
IllegalDimensionException - DOCUMENT ME!

scalarProduct

public Complex scalarProduct(ComplexSparseVector v)
Returns the scalar product of this vector and another.

Parameters:
v - a complex sparse vector
Returns:
DOCUMENT ME!
Throws:
IllegalDimensionException - If the vectors are different sizes.

tensorProduct

public ComplexSparseMatrix tensorProduct(ComplexSparseVector v)
Returns the tensor product of this vector and another.

Parameters:
v - DOCUMENT ME!
Returns:
DOCUMENT ME!

mapElements

public AbstractComplexVector mapElements(ComplexMapping f)
Applies a function on all the vector components.

Overrides:
mapElements in class AbstractComplexVector
Parameters:
f - a user-defined function
Returns:
a complex sparse vector

toPrimitiveArray

public Complex[] toPrimitiveArray()
Projects the vector to an array.

Overrides:
toPrimitiveArray in class AbstractComplexVector
Returns:
a Complex array.

clone

public java.lang.Object clone()
Clone vector into a new vector.

Overrides:
clone in class java.lang.Object
Returns:
the cloned vector.