org.jscience.mathematics.algebraic.matrices
Class AbstractComplexVector

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
All Implemented Interfaces:
java.io.Serializable, Algebra.Member, BanachSpace.Member, HilbertSpace.Member, Ring.Member, AbelianGroup.Member, Hypermatrix, Matrix, Module.Member, VectorSpace.Member, Vector, Member
Direct Known Subclasses:
Complex2Vector, Complex3Vector, ComplexSparseVector, ComplexVector

public abstract class AbstractComplexVector
extends AbstractVector
implements HilbertSpace.Member

The AbstractComplexVector class encapsulates vectors containing complex numbers.

See Also:
Serialized Form

Constructor Summary
protected AbstractComplexVector(int dim)
          Creates a new AbstractComplexVector object.
 
Method Summary
 AbstractDoubleVector abs()
          Applies the abs function on all the vector components.
 AbstractComplexVector add(AbstractComplexVector v)
          Returns the addition of this vector and another.
 AbstractComplexVector conjugate()
          Returns the complex conjugate of this vector.
 boolean equals(java.lang.Object obj)
          Compares two Complex vectors for equality.
 boolean equals(java.lang.Object obj, double tol)
           
 AbstractComplexVector getColumn(int j)
          Returns the ith column.
 Complex getElement(int n)
          Returns an element of this vector.
 double getImagElement(int i)
          Returns the imag part of an element of the matrix.
abstract  Complex getPrimitiveElement(int n)
          Returns an element of this vector.
 double getRealElement(int i)
          Returns the real part of an element of the matrix.
 AbstractComplexVector getRow(int i)
          Returns the ith row.
 AbstractComplexVector getSubVector(int k1, int k2)
          Computes a sub vector from the parameters index.
 int hashCode()
          Returns a hashcode for this NON EMPTY vector.
 AbstractDoubleVector imag()
          Returns the imaginary part of this complex vector.
 double infNorm()
          Returns the linfinity-norm.
 AbstractComplexVector mapElements(ComplexMapping f)
          Applies a function on all the vector components.
 Complex mass()
          Returns the mass.
 Ring.Member multiply(Ring.Member r)
          DOCUMENT ME!
 double norm()
          Returns the l2-norm (magnitude).
 void normalize()
          Makes the norm of this vector equal to one.
static AbstractComplexVector read(java.io.BufferedReader input)
          Read a vector from a stream.
 AbstractDoubleVector real()
          Returns the real part of this complex vector.
 AbstractComplexVector reverse()
          Invert vector elements order from the last to the first.
 AbstractComplexVector scalarDivide(Complex z)
          Returns the division of this vector by a scalar.
 AbstractComplexVector scalarDivide(double x)
          Returns the division of this vector by a scalar.
 AbstractComplexVector scalarMultiply(Complex z)
          Returns the multiplication of this vector by a scalar.
 AbstractComplexVector scalarMultiply(double x)
          Returns the multiplication of this vector by a scalar.
 Complex scalarProduct(AbstractComplexVector v)
          Returns the scalar product of this vector and another.
 void setAllElements(Complex r)
          Sets the value of all elements of the vector.
 void setColumn(int j, AbstractComplexVector v)
          Returns the ith column.
abstract  void setElement(int n, Complex z)
          Sets the value of an element of this vector.
 void setElement(int n, double x, double y)
          Sets the value of an element of this vector.
 void setRow(int i, AbstractComplexVector v)
          Returns the ith row.
 AbstractComplexVector setSubVector(int k, AbstractComplexVector v)
          Set a sub vector.
 AbstractComplexVector subtract(AbstractComplexVector v)
          Returns the subtraction of this vector by another.
 ComplexMatrix tensorProduct(AbstractComplexVector v)
          Returns the tensor product of this vector and another.
 Matrix toMatrix()
          Projects the vector to the corresponding (n, 1) matrix class.
 Complex[] toPrimitiveArray()
          Projects the vector to an array.
 java.lang.String toString()
          Returns a comma delimited string representing the value of this vector.
 Matrix transpose()
          DOCUMENT ME!
 
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
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jscience.mathematics.algebraic.algebras.HilbertSpace.Member
scalarProduct
 
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.groups.AbelianGroup.Member
add, negate, subtract
 
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

AbstractComplexVector

protected AbstractComplexVector(int dim)
Creates a new AbstractComplexVector object.

Parameters:
dim - DOCUMENT ME!
Method Detail

toString

public java.lang.String toString()
Returns a comma delimited string representing the value of this vector.

Overrides:
toString in class java.lang.Object
Returns:
DOCUMENT ME!

hashCode

public int hashCode()
Returns a hashcode for this NON EMPTY vector.

Overrides:
hashCode in class java.lang.Object
Returns:
DOCUMENT ME!

real

public AbstractDoubleVector real()
Returns the real part of this complex vector.

Returns:
DOCUMENT ME!

imag

public AbstractDoubleVector imag()
Returns the imaginary part of this complex vector.

Returns:
DOCUMENT ME!

getElement

public Complex getElement(int n)
Returns an element of this vector.

Specified by:
getElement in interface Vector
Specified by:
getElement in class AbstractVector
Parameters:
n - index of the vector element
Returns:
DOCUMENT ME!

getRealElement

public double getRealElement(int i)
Returns the real part of an element of the matrix.

Parameters:
i - row index of the element
Throws:
IllegalDimensionException - If attempting to access an invalid element.

getImagElement

public double getImagElement(int i)
Returns the imag part of an element of the matrix.

Parameters:
i - row index of the element
Throws:
IllegalDimensionException - If attempting to access an invalid element.

getPrimitiveElement

public abstract Complex getPrimitiveElement(int n)
Returns an element of this vector.

Parameters:
n - index of the vector element
Returns:
DOCUMENT ME!

getRow

public AbstractComplexVector getRow(int i)
Returns the ith row.

Specified by:
getRow in interface Matrix
Parameters:
i - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
IllegalDimensionException - DOCUMENT ME!

getColumn

public AbstractComplexVector getColumn(int j)
Returns the ith column.

Specified by:
getColumn in interface Matrix
Parameters:
j - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
IllegalDimensionException - DOCUMENT ME!

setRow

public void setRow(int i,
                   AbstractComplexVector v)
Returns the ith row.


setColumn

public void setColumn(int j,
                      AbstractComplexVector v)
Returns the ith column.


setElement

public abstract void setElement(int n,
                                Complex z)
Sets the value of an element of this vector. Should only be used to initialise this vector.

Parameters:
n - index of the vector element
z - a complex number

setElement

public void setElement(int n,
                       double x,
                       double y)
Sets the value of an element of this vector. Should only be used to initialise this vector.

Parameters:
n - index of the vector element
x - the real part of a complex number
y - the imaginary part of a complex number

setAllElements

public void setAllElements(Complex r)
Sets the value of all elements of the vector.

Parameters:
r - a ring element

equals

public boolean equals(java.lang.Object obj)
Compares two Complex vectors for equality. Two vectors are considered to be equal if the norm of their difference is within the tolerance.

Overrides:
equals in class java.lang.Object
Parameters:
obj - a Complex vector

equals

public boolean equals(java.lang.Object obj,
                      double tol)

mass

public Complex mass()
Returns the mass.

Returns:
DOCUMENT ME!

norm

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

Specified by:
norm in interface BanachSpace.Member
Returns:
DOCUMENT ME!

normalize

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


infNorm

public double infNorm()
Returns the linfinity-norm.

Returns:
DOCUMENT ME!

abs

public AbstractDoubleVector abs()
Applies the abs function on all the vector components.


transpose

public Matrix transpose()
DOCUMENT ME!

Specified by:
transpose in interface Matrix
Returns:
DOCUMENT ME!

multiply

public Ring.Member multiply(Ring.Member r)
DOCUMENT ME!

Specified by:
multiply in interface Ring.Member
Parameters:
r - DOCUMENT ME!
Returns:
DOCUMENT ME!

conjugate

public AbstractComplexVector conjugate()
Returns the complex conjugate of this vector.

Returns:
DOCUMENT ME!

add

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

Parameters:
v - a complex vector
Returns:
DOCUMENT ME!

subtract

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

Parameters:
v - a complex vector
Returns:
DOCUMENT ME!

scalarMultiply

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

Parameters:
z - a complex number
Returns:
DOCUMENT ME!

scalarMultiply

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

Parameters:
x - a double
Returns:
DOCUMENT ME!

scalarDivide

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

Parameters:
z - a complex number
Returns:
DOCUMENT ME!

scalarDivide

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

Parameters:
x - a double
Returns:
DOCUMENT ME!

scalarProduct

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

Parameters:
v - a complex vector
Returns:
DOCUMENT ME!

tensorProduct

public ComplexMatrix tensorProduct(AbstractComplexVector v)
Returns the tensor product of this vector and another.

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

reverse

public AbstractComplexVector reverse()
Invert vector elements order from the last to the first.


getSubVector

public AbstractComplexVector getSubVector(int k1,
                                          int k2)
Computes a sub vector from the parameters index. If k1<0 k1 elements are added at the beginning of the returned vector If k2>getDimension() k2-getDimension() elements are added at the end of the returned vector Finally, if k1>k2 the vector is returned inverted.

Parameters:
k1 - the beginning index
k2 - the finishing index
Returns:
the sub vector.

setSubVector

public AbstractComplexVector setSubVector(int k,
                                          AbstractComplexVector v)
Set a sub vector. If k<0 the elements are added at the beginning of the returned vector If k+v.getDimension()>getDimension() k+v.getDimension()-getDimension() elements are added at the end of the returned vector

Parameters:
k - Initial row index to offset the patching vector
v - the patching vector

mapElements

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

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

toPrimitiveArray

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

Returns:
an double array.

toMatrix

public Matrix toMatrix()
Projects the vector to the corresponding (n, 1) matrix class.

Returns:
an Complex matrix.

read

public static AbstractComplexVector read(java.io.BufferedReader input)
                                  throws java.io.IOException
Read a vector from a stream. The format is DIFFERENT from the print method, so printed vector can be read back in (provided they were printed using US Locale). Elements are separated by whitespace, all the elements appear on a single line NOT a single column (use matrix.read() if you want this behavior).

Parameters:
input - the input stream.
Throws:
java.io.IOException