org.jscience.mathematics.algebraic.matrices
Class Double3Vector

java.lang.Object
  extended by org.jscience.mathematics.algebraic.AbstractHypermatrix
      extended by org.jscience.mathematics.algebraic.AbstractMatrix
          extended by org.jscience.mathematics.algebraic.AbstractVector
              extended by org.jscience.mathematics.algebraic.matrices.AbstractDoubleVector
                  extended by org.jscience.mathematics.algebraic.matrices.Double3Vector
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Algebra.Member, BanachSpace.Member, Ring.Member, AbelianGroup.Member, Hypermatrix, Matrix, Module.Member, VectorSpace.Member, Vector, Member

public class Double3Vector
extends AbstractDoubleVector
implements java.lang.Cloneable, java.io.Serializable

An optimised implementation of a 3D double vector.

See Also:
Serialized Form

Field Summary
 double x
          DOCUMENT ME!
 double y
          DOCUMENT ME!
 double z
          DOCUMENT ME!
 
Constructor Summary
Double3Vector()
          Constructs an empty 3-vector.
Double3Vector(double[] array)
          Constructs a 3-vector.
Double3Vector(Double3Vector vec)
          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.
 java.lang.Object clone()
          Clone vector into a new vector.
 boolean equals(java.lang.Object obj)
          Compares two double vectors for equality.
 double getPrimitiveElement(int n)
          Returns a component of this vector.
 double getX()
          DOCUMENT ME!
 double getY()
          DOCUMENT ME!
 double getZ()
          DOCUMENT ME!
 double infNorm()
          Returns the linfinity-norm.
 AbstractDoubleVector mapElements(PrimitiveMapping mapping)
          Applies a function on all the vector components.
 double mass()
          Returns the mass.
 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.
 void normalize()
          DOCUMENT ME!
 void normalize(double n)
          DOCUMENT ME!
 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 setAllElements(double r)
          Sets the value of all elements of the vector.
 void setElement(int n, double value)
          Sets the value of a component of this vector.
 void setX(double d)
          DOCUMENT ME!
 void setY(double d)
          DOCUMENT ME!
 void setZ(double d)
          DOCUMENT ME!
 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.
 double sumSquares()
          Returns the sum of the squares of the components.
 AbstractComplexVector toComplexVector()
          Converts this 3-vector to a complex 3-vector.
 AbstractIntegerVector toIntegerVector()
          Converts this 3-vector to an integer 3-vector.
 double[] toPrimitiveArray()
          Projects the vector to an array.
 java.lang.String toString()
          Returns a comma delimited string representing the value of this vector.
 
Methods inherited from class org.jscience.mathematics.algebraic.matrices.AbstractDoubleVector
abs, equals, getColumn, getElement, getRow, getSubVector, hashCode, max, mean, min, multiply, read, reverse, setColumn, setElement, setRow, setSubVector, standardDeviation, tensorProduct, toMatrix, transpose, variance
 
Methods inherited from class org.jscience.mathematics.algebraic.AbstractVector
getDimension, getElement, getInvalidElementMsg, toArray, toArray
 
Methods inherited from class org.jscience.mathematics.algebraic.AbstractMatrix
getElement, getInvalidElementMsg, numColumns, numRows, print, print, print, print, toArray
 
Methods inherited from class org.jscience.mathematics.algebraic.AbstractHypermatrix
getDimensions, numDimensions, numElements, numElements, toArray
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jscience.mathematics.algebraic.Matrix
numColumns, numRows, toArray
 
Methods inherited from interface org.jscience.mathematics.algebraic.Hypermatrix
getDimensions, getElement, numDimensions, numElements, numElements, toArray
 

Field Detail

x

public double x
DOCUMENT ME!


y

public double y
DOCUMENT ME!


z

public double z
DOCUMENT ME!

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.

Parameters:
array - DOCUMENT ME!

Double3Vector

public Double3Vector(Double3Vector vec)
Constructs a 3-vector.

Parameters:
vec - DOCUMENT ME!
Method Detail

equals

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

Overrides:
equals in class AbstractDoubleVector
Parameters:
obj - a double 3-vector
Returns:
DOCUMENT ME!

toString

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

Overrides:
toString in class AbstractDoubleVector
Returns:
DOCUMENT ME!

toIntegerVector

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

Overrides:
toIntegerVector in class AbstractDoubleVector
Returns:
an integer 3-vector

toComplexVector

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

Overrides:
toComplexVector in class AbstractDoubleVector
Returns:
a complex 3-vector

getPrimitiveElement

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

Specified by:
getPrimitiveElement in class AbstractDoubleVector
Parameters:
n - index of the vector component
Returns:
DOCUMENT ME!
Throws:
IllegalDimensionException - If attempting to access an invalid component.

setElement

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

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

setAllElements

public void setAllElements(double r)
Sets the value of all elements of the vector.

Overrides:
setAllElements in class AbstractDoubleVector
Parameters:
r - a ring element

norm

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

Overrides:
norm in class AbstractDoubleVector
Parameters:
n - DOCUMENT ME!
Returns:
DOCUMENT ME!

norm

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

Specified by:
norm in interface BanachSpace.Member
Overrides:
norm in class AbstractDoubleVector
Returns:
DOCUMENT ME!

normalize

public void normalize()
DOCUMENT ME!

Overrides:
normalize in class AbstractDoubleVector

normalize

public void normalize(double n)
DOCUMENT ME!

Parameters:
n - DOCUMENT ME!

getX

public double getX()
DOCUMENT ME!

Returns:
DOCUMENT ME!

getY

public double getY()
DOCUMENT ME!

Returns:
DOCUMENT ME!

getZ

public double getZ()
DOCUMENT ME!

Returns:
DOCUMENT ME!

setX

public void setX(double d)
DOCUMENT ME!

Parameters:
d - DOCUMENT ME!

setY

public void setY(double d)
DOCUMENT ME!

Parameters:
d - DOCUMENT ME!

setZ

public void setZ(double d)
DOCUMENT ME!

Parameters:
d - DOCUMENT ME!

infNorm

public double infNorm()
Returns the linfinity-norm.

Overrides:
infNorm in class AbstractDoubleVector
Returns:
DOCUMENT ME!

sumSquares

public double sumSquares()
Returns the sum of the squares of the components.

Overrides:
sumSquares in class AbstractDoubleVector
Returns:
DOCUMENT ME!

mass

public double mass()
Returns the mass.

Overrides:
mass in class AbstractDoubleVector
Returns:
DOCUMENT ME!

negate

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

Specified by:
negate in interface AbelianGroup.Member
Returns:
DOCUMENT ME!

add

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

Specified by:
add in interface AbelianGroup.Member
Parameters:
vec - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
java.lang.IllegalArgumentException - DOCUMENT ME!

add

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

Overrides:
add in class AbstractDoubleVector
Parameters:
vec - a double 3-vector
Returns:
DOCUMENT ME!
Throws:
IllegalDimensionException - DOCUMENT ME!

subtract

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

Specified by:
subtract in interface AbelianGroup.Member
Parameters:
vec - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
java.lang.IllegalArgumentException - DOCUMENT ME!

subtract

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

Overrides:
subtract in class AbstractDoubleVector
Parameters:
vec - a double 3-vector
Returns:
DOCUMENT ME!
Throws:
IllegalDimensionException - DOCUMENT ME!

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 - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
java.lang.IllegalArgumentException - DOCUMENT ME!

scalarMultiply

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

Overrides:
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.

Specified by:
scalarDivide in interface VectorSpace.Member
Parameters:
x - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
java.lang.IllegalArgumentException - DOCUMENT ME!

scalarDivide

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

Overrides:
scalarDivide in class AbstractDoubleVector
Parameters:
k - a double
Returns:
a double 3-vector

scalarProduct

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

Overrides:
scalarProduct in class AbstractDoubleVector
Parameters:
vec - a double 3-vector
Returns:
DOCUMENT ME!
Throws:
IllegalDimensionException - DOCUMENT ME!

multiply

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

Parameters:
vec - a double 3-vector
Returns:
DOCUMENT ME!

mapElements

public AbstractDoubleVector mapElements(PrimitiveMapping mapping)
Applies a function on all the vector components.

Overrides:
mapElements in class AbstractDoubleVector
Parameters:
mapping - a user-defined function
Returns:
a double 3-vector

toPrimitiveArray

public double[] toPrimitiveArray()
Projects the vector to an array.

Overrides:
toPrimitiveArray in class AbstractDoubleVector
Returns:
an double array.

clone

public java.lang.Object clone()
Clone vector into a new vector.

Overrides:
clone in class java.lang.Object
Returns:
the cloned vector.