JSci.maths
Class ComplexVector

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

public class ComplexVector
extends MathVector
implements HilbertSpace.Member

The ComplexVector class encapsulates vectors containing complex numbers.

Version:
2.2
Author:
Mark Hale
See Also:
Serialized Form

Field Summary
protected static int ARRAY_1D
          Storage format identifier.
protected  double[] vectorIm
          Arrays containing the components of the vector.
protected  double[] vectorRe
          Arrays containing the components of the vector.
 
Fields inherited from class JSci.maths.MathVector
CLASS_SPECIFIC, N, storageFormat
 
Constructor Summary
  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.
protected ComplexVector(int dim, int storeID)
           
 
Method Summary
 AbelianGroup.Member add(AbelianGroup.Member v)
          Returns the addition of this vector and another.
 ComplexVector add(ComplexVector v)
          Returns the addition of this vector and another.
 ComplexVector add(DoubleVector v)
          Returns the addition of this vector and another.
 ComplexVector add(IntegerVector v)
          Returns the addition of this vector and another.
 ComplexVector conjugate()
          Returns the complex conjugate of this vector.
 boolean equals(java.lang.Object a)
          Compares two complex vectors for equality.
 Complex getComponent(int n)
          Returns a component of this vector.
 int hashCode()
          Returns a hashcode for this vector.
 DoubleVector imag()
          Returns the imaginary part of this complex vector.
 double infNorm()
          Returns the linfinity-norm.
 ComplexVector mapComponents(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.
 DoubleVector real()
          Returns the real part of this complex vector.
 ComplexVector scalarDivide(Complex z)
          Returns the division of this vector by a scalar.
 ComplexVector 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.
 ComplexVector scalarMultiply(Complex z)
          Returns the multiplication of this vector by a scalar.
 ComplexVector 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(ComplexVector 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 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 v)
          Returns the subtraction of this vector by another.
 ComplexVector subtract(ComplexVector v)
          Returns the subtraction of this vector by another.
 ComplexVector subtract(DoubleVector v)
          Returns the subtraction of this vector by another.
 ComplexVector subtract(IntegerVector 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.MathVector
dimension, getInvalidComponentMsg
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ARRAY_1D

protected static final int ARRAY_1D
Storage format identifier.

See Also:
Constant Field Values

vectorRe

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


vectorIm

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

Constructor Detail

ComplexVector

protected ComplexVector(int dim,
                        int storeID)

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
Method Detail

equals

public boolean equals(java.lang.Object a)
Compares two complex vectors for equality.

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

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 DoubleVector real()
Returns the real part of this complex vector.


imag

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


getComponent

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

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.

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.

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
Specified by:
norm in class MathVector

normalize

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


infNorm

public double infNorm()
Returns the linfinity-norm.


negate

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

Specified by:
negate in interface AbelianGroup.Member

conjugate

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


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 - a group member

add

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

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

add

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

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

add

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

Parameters:
v - an integer vector
Throws:
VectorDimensionException - 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 - a group member

subtract

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

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

subtract

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

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

subtract

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

Parameters:
v - an integer vector
Throws:
VectorDimensionException - 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 - a ring member

scalarMultiply

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

Parameters:
z - a complex number

scalarMultiply

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

Parameters:
x - a double

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 - a field member

scalarDivide

public ComplexVector 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 ComplexVector scalarDivide(double x)
Returns the division of this vector by a scalar.

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

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 - a Hilbert space vector

scalarProduct

public Complex scalarProduct(ComplexVector 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 ComplexVector mapComponents(ComplexMapping f)
Applies a function on all the vector components.

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