JSci.maths.vectors
Class Complex2Vector

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

public final class Complex2Vector
extends AbstractComplexVector

An optimised implementation of a 2D complex vector.

See Also:
Serialized Form

Field Summary
protected  double xim
           
protected  double xre
           
protected  double yim
           
protected  double yre
           
 
Fields inherited from class JSci.maths.vectors.MathVector
N
 
Constructor Summary
Complex2Vector()
          Constructs an empty 2-vector.
Complex2Vector(Complex x, Complex y)
          Constructs a 2-vector.
Complex2Vector(double xRe, double xIm, double yRe, double yIm)
           
 
Method Summary
 AbelianGroup.Member add(AbelianGroup.Member vec)
          Returns the addition of this vector and another.
 AbstractComplexVector add(AbstractComplexVector vec)
          Returns the addition of this vector and another.
 AbstractComplexVector add(AbstractDoubleVector vec)
          Returns the addition of this vector and another.
 AbstractComplexVector add(AbstractIntegerVector vec)
          Returns the addition of this vector and another.
 AbstractComplexVector conjugate()
          Returns the complex conjugate of this vector.
 boolean equals(java.lang.Object obj, double tol)
          Compares two complex vectors for equality.
 Complex getComponent(int n)
          Returns a component of this vector.
 double getImagComponent(int n)
           
 double getRealComponent(int n)
           
 AbstractDoubleVector imag()
          Returns the imaginary part of this complex 2-vector.
 double infNorm()
          Returns the linfinity-norm.
 AbstractComplexVector mapComponents(ComplexMapping mapping)
          Applies a function on all the vector components.
 AbelianGroup.Member negate()
          Returns the negative of this vector.
 double norm()
          Returns the l2-norm (magnitude).
 AbstractDoubleVector real()
          Returns the real part of this complex 2-vector.
 AbstractComplexVector scalarDivide(Complex z)
          Returns the division of this vector by a scalar.
 AbstractComplexVector scalarDivide(double k)
          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 k)
          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 vec)
          Returns the scalar product of this vector and another.
 Complex scalarProduct(Complex2Vector vec)
          Returns the scalar product of this vector and another.
 Complex scalarProduct(HilbertSpace.Member vec)
          Returns the scalar product of this vector and another.
 void setComponent(int n, Complex z)
          Sets the value of a component of this vector.
 void setComponent(int n, double x, double y)
          Sets the value of a component of this vector.
 AbelianGroup.Member subtract(AbelianGroup.Member vec)
          Returns the subtraction of this vector by another.
 AbstractComplexVector subtract(AbstractComplexVector vec)
          Returns the subtraction of this vector by another.
 AbstractComplexVector subtract(AbstractDoubleVector vec)
          Returns the subtraction of this vector by another.
 AbstractComplexVector subtract(AbstractIntegerVector vec)
          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.AbstractComplexVector
equals, getSet, hashCode, normalize
 
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
 

Field Detail

xre

protected double xre

xim

protected double xim

yre

protected double yre

yim

protected double yim
Constructor Detail

Complex2Vector

public Complex2Vector()
Constructs an empty 2-vector.


Complex2Vector

public Complex2Vector(Complex x,
                      Complex y)
Constructs a 2-vector.

Parameters:
x - x coordinate.
y - y coordinate.

Complex2Vector

public Complex2Vector(double xRe,
                      double xIm,
                      double yRe,
                      double yIm)
Method Detail

equals

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

Overrides:
equals in class AbstractComplexVector
Parameters:
obj - a complex 2-vector

toString

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

Overrides:
toString in class AbstractComplexVector

real

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

Specified by:
real in class AbstractComplexVector

imag

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

Specified by:
imag in class AbstractComplexVector

getComponent

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

Specified by:
getComponent in class AbstractComplexVector
Parameters:
n - index of the vector component
Throws:
VectorDimensionException - If attempting to access an invalid component.

getRealComponent

public double getRealComponent(int n)
Specified by:
getRealComponent in class AbstractComplexVector

getImagComponent

public double getImagComponent(int n)
Specified by:
getImagComponent in class AbstractComplexVector

setComponent

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

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

setComponent

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

Specified by:
setComponent 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:
VectorDimensionException - If attempting to access an invalid component.

norm

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

Specified by:
norm in interface BanachSpace.Member
Overrides:
norm in class AbstractComplexVector

infNorm

public double infNorm()
Returns the linfinity-norm.

Overrides:
infNorm in class AbstractComplexVector

negate

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


conjugate

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

Specified by:
conjugate in class AbstractComplexVector
Returns:
a complex 2-vector

add

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

Parameters:
vec - a group member

add

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

Specified by:
add in class AbstractComplexVector
Parameters:
vec - a complex 2-vector

add

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

Parameters:
vec - a double 2-vector

add

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

Parameters:
vec - an integer 2-vector

subtract

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

Parameters:
vec - a group member

subtract

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

Specified by:
subtract in class AbstractComplexVector
Parameters:
vec - a complex 2-vector

subtract

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

Parameters:
vec - a double 2-vector

subtract

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

Parameters:
vec - an integer 2-vector

scalarMultiply

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

Parameters:
x - a ring member

scalarMultiply

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

Specified by:
scalarMultiply in class AbstractComplexVector
Parameters:
z - a complex number
Returns:
a complex 2-vector

scalarMultiply

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

Specified by:
scalarMultiply in class AbstractComplexVector
Parameters:
k - a double
Returns:
a complex 2-vector

scalarDivide

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

Parameters:
x - a field member

scalarDivide

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

Specified by:
scalarDivide in class AbstractComplexVector
Parameters:
z - a complex number
Returns:
a complex 2-vector
Throws:
java.lang.ArithmeticException - If divide by zero.

scalarDivide

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

Specified by:
scalarDivide in class AbstractComplexVector
Parameters:
k - a double
Returns:
a complex 2-vector
Throws:
java.lang.ArithmeticException - If divide by zero.

scalarProduct

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

Parameters:
vec - a Hilbert space vector

scalarProduct

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

Specified by:
scalarProduct in class AbstractComplexVector
Parameters:
vec - a complex vector
Throws:
VectorDimensionException - If the vectors are different sizes.

scalarProduct

public Complex scalarProduct(Complex2Vector vec)
Returns the scalar product of this vector and another.

Parameters:
vec - a complex 2-vector

mapComponents

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

Specified by:
mapComponents in class AbstractComplexVector
Parameters:
mapping - a user-defined function
Returns:
a complex 2-vector