JSci.maths.vectors
Class AbstractDoubleVector

java.lang.Object
  extended byJSci.maths.vectors.MathVector
      extended byJSci.maths.vectors.AbstractDoubleVector
All Implemented Interfaces:
AbelianGroup.Member, BanachSpace.Member, Member, Module.Member, java.io.Serializable, VectorSpace.Member
Direct Known Subclasses:
Double2Vector, Double3Vector, DoubleSparseVector, DoubleVector

public abstract class AbstractDoubleVector
extends MathVector
implements BanachSpace.Member

The AbstractDoubleVector class encapsulates vectors containing doubles.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class JSci.maths.vectors.MathVector
N
 
Constructor Summary
protected AbstractDoubleVector(int dim)
           
 
Method Summary
abstract  AbstractDoubleVector add(AbstractDoubleVector v)
          Returns the addition of this vector and another.
 boolean equals(java.lang.Object obj)
          Compares two double vectors for equality.
abstract  double getComponent(int n)
          Returns a component of this vector.
 int hashCode()
          Returns a hashcode for this vector.
 double infNorm()
          Returns the linfinity-norm.
abstract  AbstractDoubleVector mapComponents(Mapping f)
          Applies a function on all the vector components.
 double mass()
          Returns the mass (l1-norm).
 double norm()
          Returns the l2-norm (magnitude).
 double norm(int n)
          Returns the ln-norm.
 AbstractDoubleVector normalize()
          Returns a normalised vector (a vector with norm equal to one).
abstract  AbstractDoubleVector scalarDivide(double x)
          Returns the division of this vector by a scalar.
abstract  AbstractDoubleVector scalarMultiply(double x)
          Returns the multiplication of this vector by a scalar.
abstract  double scalarProduct(AbstractDoubleVector v)
          Returns the scalar product of this vector and another.
abstract  void setComponent(int n, double x)
          Sets the value of a component of this vector.
abstract  AbstractDoubleVector subtract(AbstractDoubleVector 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.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

AbstractDoubleVector

protected AbstractDoubleVector(int dim)
Method Detail

equals

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

Parameters:
obj - a double vector

toString

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


hashCode

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


getComponent

public abstract double 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 abstract void setComponent(int n,
                                  double x)
Sets the value of a component of this vector.

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

norm

public double norm(int n)
Returns the ln-norm.

PlanetMath references:
VectorPnorm

norm

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

Specified by:
norm in interface BanachSpace.Member
Specified by:
norm in class MathVector
PlanetMath references:
VectorPnorm

infNorm

public double infNorm()
Returns the linfinity-norm.

PlanetMath references:
VectorPnorm

mass

public double mass()
Returns the mass (l1-norm).


add

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

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

subtract

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

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

scalarMultiply

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

Parameters:
x - a double.

scalarDivide

public abstract AbstractDoubleVector 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 AbstractDoubleVector normalize()
Returns a normalised vector (a vector with norm equal to one).


scalarProduct

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

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

mapComponents

public abstract AbstractDoubleVector mapComponents(Mapping f)
Applies a function on all the vector components.

Parameters:
f - a user-defined function.
Returns:
a double vector.