JSci.maths.vectors
Class AbstractComplexVector

java.lang.Object
  extended by JSci.maths.vectors.MathVector
      extended by JSci.maths.vectors.AbstractComplexVector
All Implemented Interfaces:
java.io.Serializable, BanachSpace.Member, HilbertSpace.Member, Module.Member, VectorSpace.Member, AbelianGroup.Member, Member
Direct Known Subclasses:
Complex2Vector, Complex3Vector, ComplexVector

public abstract class AbstractComplexVector
extends MathVector
implements HilbertSpace.Member

The AbstractComplexVector class encapsulates vectors containing complex numbers.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class JSci.maths.vectors.MathVector
N
 
Constructor Summary
protected AbstractComplexVector(int dim)
           
 
Method Summary
abstract  AbstractComplexVector add(AbstractComplexVector v)
          Returns the addition of this vector and another.
abstract  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)
           
abstract  Complex getComponent(int n)
          Returns a component of this vector.
abstract  double getImagComponent(int n)
           
abstract  double getRealComponent(int n)
           
 java.lang.Object getSet()
           
 int hashCode()
          Returns a hashcode for this vector.
abstract  AbstractDoubleVector imag()
          Returns the imaginary part of this complex vector.
 double infNorm()
          Returns the linfinity-norm.
abstract  AbstractComplexVector mapComponents(ComplexMapping f)
          Applies a function on all the vector components.
 double norm()
          Returns the l2-norm (magnitude).
 AbstractComplexVector normalize()
          Returns a normalised vector (a vector with norm equal to one).
abstract  AbstractDoubleVector real()
          Returns the real part of this complex vector.
abstract  AbstractComplexVector scalarDivide(Complex z)
          Returns the division of this vector by a scalar.
abstract  AbstractComplexVector scalarDivide(double x)
          Returns the division of this vector by a scalar.
abstract  AbstractComplexVector scalarMultiply(Complex z)
          Returns the multiplication of this vector by a scalar.
abstract  AbstractComplexVector scalarMultiply(double x)
          Returns the multiplication of this vector by a scalar.
abstract  Complex scalarProduct(AbstractComplexVector v)
          Returns the scalar product of this vector and another.
abstract  void setComponent(int n, Complex z)
          Sets the value of a component of this vector.
abstract  void setComponent(int n, double x, double y)
          Sets the value of a component of this vector.
abstract  AbstractComplexVector subtract(AbstractComplexVector v)
          Returns the subtraction of this vector by another.
 java.lang.String toString()
          Returns a comma delimited string representing the value of this vector.
 
Methods inherited from class JSci.maths.vectors.MathVector
dimension, getInvalidComponentMsg
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface JSci.maths.algebras.HilbertSpace.Member
scalarProduct
 
Methods inherited from interface JSci.maths.algebras.VectorSpace.Member
scalarDivide
 
Methods inherited from interface JSci.maths.algebras.Module.Member
scalarMultiply
 
Methods inherited from interface JSci.maths.groups.AbelianGroup.Member
add, negate, subtract
 

Constructor Detail

AbstractComplexVector

protected AbstractComplexVector(int dim)
Method Detail

equals

public final 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 zero tolerance.

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

equals

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

toString

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

Overrides:
toString in class java.lang.Object

hashCode

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

Overrides:
hashCode in class java.lang.Object

real

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


imag

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


getComponent

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

Parameters:
n - index of the vector component
Throws:
VectorDimensionException - If attempting to access an invalid component.

getRealComponent

public abstract double getRealComponent(int n)

getImagComponent

public abstract double getImagComponent(int n)

setComponent

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

Parameters:
n - index of the vector component
z - a complex number
Throws:
VectorDimensionException - If attempting to access an invalid component.

setComponent

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

Parameters:
n - index of the vector component
x - the real part of a complex number
y - the imaginary part of a complex number
Throws:
VectorDimensionException - If attempting to access an invalid component.

getSet

public java.lang.Object getSet()
Specified by:
getSet in interface Member

norm

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

Specified by:
norm in interface BanachSpace.Member
Specified by:
norm in class MathVector

infNorm

public double infNorm()
Returns the linfinity-norm.


conjugate

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


add

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

Parameters:
v - a complex vector
Throws:
VectorDimensionException - If the vectors are different sizes.

subtract

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

Parameters:
v - a complex vector
Throws:
VectorDimensionException - If the vectors are different sizes.

scalarMultiply

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

Parameters:
z - a complex number

scalarMultiply

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

Parameters:
x - a double

scalarDivide

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

Parameters:
z - a complex number
Throws:
java.lang.ArithmeticException - If divide by zero.

scalarDivide

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

Parameters:
x - a double
Throws:
java.lang.ArithmeticException - If divide by zero.

normalize

public AbstractComplexVector normalize()
Returns a normalised vector (a vector with norm equal to one).


scalarProduct

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

Parameters:
v - a complex vector
Throws:
VectorDimensionException - If the vectors are different sizes.

mapComponents

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

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