JSci.maths.vectors
Class Double3Vector

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

public final class Double3Vector
extends AbstractDoubleVector

An optimised implementation of a 3D double vector.

See Also:
Serialized Form

Field Summary
protected  double x
           
protected  double y
           
protected  double z
           
 
Fields inherited from class JSci.maths.vectors.MathVector
N
 
Constructor Summary
Double3Vector()
          Constructs an empty 3-vector.
Double3Vector(double[] array)
          Constructs a 3-vector.
Double3Vector(double x, double y, double z)
          Constructs a 3-vector.
 
Method Summary
 AbelianGroup.Member add(AbelianGroup.Member vec)
          Returns the addition of this vector and another.
 AbstractDoubleVector add(AbstractDoubleVector vec)
          Returns the addition of this vector and another.
 boolean equals(java.lang.Object obj, double tol)
          Compares two double vectors for equality.
 double getComponent(int n)
          Returns a component of this vector.
 double infNorm()
          Returns the linfinity-norm.
 AbstractDoubleVector mapComponents(Mapping mapping)
          Applies a function on all the vector components.
 Double3Vector multiply(Double3Vector vec)
          Returns the vector product of this vector and another (so(3) algebra).
 AbelianGroup.Member negate()
          Returns the negative of this vector.
 double norm()
          Returns the l2-norm (magnitude).
 double norm(int n)
          Returns the ln-norm.
 AbstractDoubleVector 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.
 AbstractDoubleVector 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.
 double scalarProduct(AbstractDoubleVector vec)
          Returns the scalar product of this vector and another.
 void setComponent(int n, double value)
          Sets the value of a component of this vector.
 AbelianGroup.Member subtract(AbelianGroup.Member vec)
          Returns the subtraction of this vector by another.
 AbstractDoubleVector subtract(AbstractDoubleVector vec)
          Returns the subtraction of this vector by another.
 AbstractComplexVector toComplexVector()
          Converts this 3-vector to a complex 3-vector.
 AbstractIntegerVector toIntegerVector()
          Converts this 3-vector to an integer 3-vector.
 java.lang.String toString()
          Returns a comma delimited string representing the value of this vector.
 
Methods inherited from class JSci.maths.vectors.AbstractDoubleVector
equals, getSet, hashCode, mass, 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

x

protected double x

y

protected double y

z

protected double z
Constructor Detail

Double3Vector

public Double3Vector()
Constructs an empty 3-vector.


Double3Vector

public Double3Vector(double x,
                     double y,
                     double z)
Constructs a 3-vector.

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

Double3Vector

public Double3Vector(double[] array)
Constructs a 3-vector.

Method Detail

equals

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

Overrides:
equals in class AbstractDoubleVector
Parameters:
obj - a double 3-vector

toString

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

Overrides:
toString in class AbstractDoubleVector

toIntegerVector

public AbstractIntegerVector toIntegerVector()
Converts this 3-vector to an integer 3-vector.

Returns:
an integer 3-vector

toComplexVector

public AbstractComplexVector toComplexVector()
Converts this 3-vector to a complex 3-vector.

Returns:
a complex 3-vector

getComponent

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

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

setComponent

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

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

norm

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

Overrides:
norm in class AbstractDoubleVector

norm

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

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

infNorm

public double infNorm()
Returns the linfinity-norm.

Overrides:
infNorm in class AbstractDoubleVector

negate

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


add

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

Parameters:
vec - a group member

add

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

Specified by:
add in class AbstractDoubleVector
Parameters:
vec - a double 3-vector

subtract

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

Parameters:
vec - a group member

subtract

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

Specified by:
subtract in class AbstractDoubleVector
Parameters:
vec - a double 3-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 AbstractDoubleVector scalarMultiply(double k)
Returns the multiplication of this vector by a scalar.

Specified by:
scalarMultiply in class AbstractDoubleVector
Parameters:
k - a double
Returns:
a double 3-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 AbstractDoubleVector scalarDivide(double k)
Returns the division of this vector by a scalar.

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

scalarProduct

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

Specified by:
scalarProduct in class AbstractDoubleVector
Parameters:
vec - a double 3-vector

multiply

public Double3Vector multiply(Double3Vector vec)
Returns the vector product of this vector and another (so(3) algebra).

Parameters:
vec - a double 3-vector

mapComponents

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

Specified by:
mapComponents in class AbstractDoubleVector
Parameters:
mapping - a user-defined function
Returns:
a double 3-vector