org.jscience.mathematics.algebraic.matrices
Class ComplexVector

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.ComplexVector
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 ComplexVector
extends AbstractComplexVector
implements java.lang.Cloneable, java.io.Serializable

An array-based implementation of a complex vector.

See Also:
Serialized Form

Field Summary
protected  double[] vectorIm
          DOCUMENT ME!
protected  double[] vectorRe
          Arrays containing the components of the vector.
 
Constructor Summary
ComplexVector(AbstractComplexVector vec)
          Constructs a vector by copying a vector.
ComplexVector(Complex[] array)
          Constructs a vector from an array.
ComplexVector(double[] real, double[] imag)
          Constructs a vector by wrapping two arrays.
ComplexVector(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.
 AbstractComplexVector add(AbstractDoubleVector v)
          Returns the addition of this vector and another.
 AbstractComplexVector add(AbstractIntegerVector v)
          Returns the addition of this vector and another.
 ComplexVector add(ComplexVector v)
          DOCUMENT ME!
 ComplexVector add(DoubleVector v)
          DOCUMENT ME!
 ComplexVector add(IntegerVector v)
          DOCUMENT ME!
 java.lang.Object clone()
          Clone vector into a new vector.
 AbstractComplexVector conjugate()
          Returns the complex conjugate of this vector.
 boolean equals(java.lang.Object a, double tol)
          Compares two Complex vectors for equality.
 double getImagElement(int i)
          Returns the imag part of an element of the matrix.
 Complex getPrimitiveElement(int n)
          Returns a component of this vector.
 double getRealElement(int i)
          Returns the real part of an element of the matrix.
 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.
 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()
          Returns the real part of this complex vector.
 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.
 VectorSpace.Member scalarDivide(Field.Member 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.
 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(HilbertSpace.Member v)
          Returns the scalar product of this vector and another.
 void setAllElements(Complex r)
          Sets the value of all elements of the vector.
 void setElement(int n, Complex z)
          Sets the value of a component of this vector.
 void setElement(int n, double x, double y)
          Sets the value of a component of this vector.
 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.
 AbstractComplexVector subtract(AbstractDoubleVector v)
          Returns the subtraction of this vector by another.
 AbstractComplexVector subtract(AbstractIntegerVector v)
          Returns the subtraction of this vector by another.
 ComplexVector subtract(ComplexVector v)
          DOCUMENT ME!
 ComplexVector subtract(DoubleVector v)
          DOCUMENT ME!
 ComplexVector subtract(IntegerVector v)
          DOCUMENT ME!
 Complex[] toPrimitiveArray()
          Projects the vector to an array.
 java.lang.String toString()
          Returns a comma delimited string representing the value of this vector.
 
Methods inherited from class org.jscience.mathematics.algebraic.matrices.AbstractComplexVector
abs, equals, getColumn, getElement, getRow, getSubVector, hashCode, mass, multiply, read, reverse, setColumn, setRow, setSubVector, tensorProduct, toMatrix, 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
 

Field Detail

vectorRe

protected double[] vectorRe
Arrays containing the components of the vector.


vectorIm

protected double[] vectorIm
DOCUMENT ME!

Constructor Detail

ComplexVector

public ComplexVector(int dim)
Constructs an empty vector.

Parameters:
dim - the dimension of the vector.

ComplexVector

public ComplexVector(double[] real,
                     double[] imag)
Constructs a vector by wrapping two arrays.

Parameters:
real - an array of real values
imag - an array of imaginary values

ComplexVector

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

Parameters:
array - an assigned value

ComplexVector

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

Parameters:
vec - an assigned value
Method Detail

equals

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

Overrides:
equals in class AbstractComplexVector
Parameters:
a - a Complex vector.
tol - DOCUMENT ME!
Returns:
DOCUMENT ME!

toString

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

Overrides:
toString in class AbstractComplexVector
Returns:
DOCUMENT ME!

real

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

Overrides:
real in class AbstractComplexVector
Returns:
DOCUMENT ME!

imag

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

Overrides:
imag in class AbstractComplexVector
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.

getRealElement

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

Overrides:
getRealElement in class AbstractComplexVector
Parameters:
i - row index of the element
Returns:
DOCUMENT ME!
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.

Overrides:
getImagElement in class AbstractComplexVector
Parameters:
i - row index of the element
Returns:
DOCUMENT ME!
Throws:
IllegalDimensionException - If attempting to access an invalid element.

setElement

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

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

setElement

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

Overrides:
setElement in class AbstractComplexVector
Parameters:
n - index of the vector component
x - the real part of a complex number
y - the imaginary part of a complex number
Throws:
IllegalDimensionException - If attempting to access an invalid component.

setAllElements

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

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!

negate

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

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

conjugate

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

Overrides:
conjugate in class AbstractComplexVector
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 AbstractComplexVector add(AbstractDoubleVector v)
Returns the addition of this vector and another.

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

add

public ComplexVector add(DoubleVector v)
DOCUMENT ME!

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

add

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

Parameters:
v - an integer vector
Returns:
DOCUMENT ME!
Throws:
IllegalDimensionException - If the vectors are different sizes.

add

public ComplexVector add(IntegerVector v)
DOCUMENT ME!

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

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 AbstractComplexVector subtract(AbstractDoubleVector v)
Returns the subtraction of this vector by another.

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

subtract

public ComplexVector subtract(DoubleVector v)
DOCUMENT ME!

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

subtract

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

Parameters:
v - an integer vector
Returns:
DOCUMENT ME!
Throws:
IllegalDimensionException - If the vectors are different sizes.

subtract

public ComplexVector subtract(IntegerVector v)
DOCUMENT ME!

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

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 z)
Returns the multiplication of this vector by a scalar.

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

scalarMultiply

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

Overrides:
scalarMultiply in class AbstractComplexVector
Parameters:
x - a double
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 z)
Returns the division of this vector by a scalar.

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

scalarDivide

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

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

scalarProduct

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

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.

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 vector

toPrimitiveArray

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

Overrides:
toPrimitiveArray in class AbstractComplexVector
Returns:
an double array.

clone

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

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