JScience v3.3

org.jscience.mathematics.vectors
Class Vector<F extends Field<F>>

java.lang.Object
  extended by javolution.context.RealtimeObject
      extended by org.jscience.mathematics.vectors.Vector<F>
All Implemented Interfaces:
java.io.Serializable, Realtime, Immutable, GroupAdditive<Vector<F>>, Structure<Vector<F>>, VectorSpace<Vector<F>,F>
Direct Known Subclasses:
ComplexVector, DenseVector, Float64Vector, MeasureVector, SparseVector

public abstract class Vector<F extends Field<F>>
extends RealtimeObject
implements VectorSpace<Vector<F>,F>, Immutable

This class represents an immutable element of a vector space.

Version:
3.3, January 2, 2007
Author:
Jean-Marie Dautelle
See Also:
Wikipedia: Vector Space, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javolution.context.RealtimeObject
RealtimeObject.Factory<T extends RealtimeObject>
 
Nested classes/interfaces inherited from interface javolution.context.Realtime
Realtime.ObjectSpace
 
Constructor Summary
protected Vector()
          Default constructor (for sub-classes).
 
Method Summary
 Vector<F> cross(Vector<F> that)
          Returns the cross product of two 3-dimensional vectors.
 boolean equals(java.lang.Object that)
          Indicates if this vector is equal to the object specified.
 boolean equals(Vector<F> that, java.util.Comparator<F> cmp)
          Indicates if this vector can be considered equals to the one specified using the specified comparator when testing for element equality.
abstract  F get(int i)
          Returns a single element from this vector.
abstract  int getDimension()
          Returns the number of elements held by this vector.
 int hashCode()
          Returns a hash code value for this vector.
 Vector<F> minus(Vector<F> that)
          Returns the difference between this vector and the one specified.
abstract  Vector<F> opposite()
          Returns the negation of this vector.
abstract  Vector<F> plus(Vector<F> that)
          Returns the sum of this vector with the one specified.
abstract  Vector<F> times(F k)
          Returns the product of this vector with the specified coefficient.
abstract  F times(Vector<F> that)
          Returns the dot product of this vector with the one specified.
 Text toText()
          Returns the text representation of this vector.
static Float64Vector valueOf(double... values)
          Deprecated. Since 3.3 - Replaced by Float64Vector.valueOf(double[])
static
<F extends Field<F>>
Vector<F>
valueOf(F... elements)
          Deprecated. Since 3.3 - Replaced by DenseVector.valueOf(Field[])
 
Methods inherited from class javolution.context.RealtimeObject
export, isLocal, move, moveHeap, preserve, toString, unpreserve
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface javolution.context.Realtime
move
 

Constructor Detail

Vector

protected Vector()
Default constructor (for sub-classes).

Method Detail

valueOf

public static <F extends Field<F>> Vector<F> valueOf(F... elements)
Deprecated. Since 3.3 - Replaced by DenseVector.valueOf(Field[])

Returns a vector implementation holding the specified elements (convenience method equivalent to DenseVector.valueOf(elements) )

Parameters:
elements - the vector elements.
Returns:
the dense vector having the specified elements.

valueOf

public static Float64Vector valueOf(double... values)
Deprecated. Since 3.3 - Replaced by Float64Vector.valueOf(double[])

Returns a vector implementation holding the specified double values (convenience method equivalent to Float64Vector.valueOf(values)).

Parameters:
values - the values of the vector elements.
Returns:
the vector having the specified elements values.

getDimension

public abstract int getDimension()
Returns the number of elements held by this vector.

Returns:
this vector dimension.

get

public abstract F get(int i)
Returns a single element from this vector.

Parameters:
i - the element index (range [0..n[).
Returns:
the element at i.
Throws:
java.lang.IndexOutOfBoundsException - (i < 0) || (i >= size())

opposite

public abstract Vector<F> opposite()
Returns the negation of this vector.

Specified by:
opposite in interface GroupAdditive<Vector<F extends Field<F>>>
Returns:
-this.

plus

public abstract Vector<F> plus(Vector<F> that)
Returns the sum of this vector with the one specified.

Specified by:
plus in interface GroupAdditive<Vector<F extends Field<F>>>
Parameters:
that - the vector to be added.
Returns:
this + that.
Throws:
DimensionException - is vectors dimensions are different.

minus

public Vector<F> minus(Vector<F> that)
Returns the difference between this vector and the one specified.

Parameters:
that - the vector to be subtracted.
Returns:
this - that.

times

public abstract Vector<F> times(F k)
Returns the product of this vector with the specified coefficient.

Specified by:
times in interface VectorSpace<Vector<F extends Field<F>>,F extends Field<F>>
Parameters:
k - the coefficient multiplier.
Returns:
this · k

times

public abstract F times(Vector<F> that)
Returns the dot product of this vector with the one specified.

Parameters:
that - the vector multiplier.
Returns:
this · that
Throws:
DimensionException - if this.dimension() != that.dimension()
See Also:
Wikipedia: Dot Product

cross

public Vector<F> cross(Vector<F> that)
Returns the cross product of two 3-dimensional vectors.

Parameters:
that - the vector multiplier.
Returns:
this x that
Throws:
DimensionException - if (this.getDimension() != 3) && (that.getDimension() != 3)

toText

public Text toText()
Returns the text representation of this vector.

Specified by:
toText in interface Realtime
Overrides:
toText in class RealtimeObject
Returns:
the text representation of this vector.

equals

public boolean equals(Vector<F> that,
                      java.util.Comparator<F> cmp)
Indicates if this vector can be considered equals to the one specified using the specified comparator when testing for element equality. The specified comparator may allow for some tolerance in the difference between the vector elements.

Parameters:
that - the vector to compare for equality.
cmp - the comparator to use when testing for element equality.
Returns:
true if this vector and the specified matrix are both vector with equal elements according to the specified comparator; false otherwise.

equals

public boolean equals(java.lang.Object that)
Indicates if this vector is equal to the object specified.

Overrides:
equals in class java.lang.Object
Parameters:
that - the object to compare for equality.
Returns:
true if this vector and the specified object are both vectors with equal elements; false otherwise.

hashCode

public int hashCode()
Returns a hash code value for this vector. Equals objects have equal hash codes.

Overrides:
hashCode in class java.lang.Object
Returns:
this vector hash code value.
See Also:
equals(org.jscience.mathematics.vectors.Vector, java.util.Comparator)

JScience v3.3

Copyright © 2006 JScience.