Package org.jscience.mathematics.vector
Class Vector<F extends Field<F>>
java.lang.Object
org.jscience.mathematics.vector.Vector<F>
- All Implemented Interfaces:
javolution.lang.Immutable,javolution.lang.Realtime,javolution.lang.ValueType,GroupAdditive<Vector<F>>,Structure<Vector<F>>,VectorSpace<Vector<F>,F>
- Direct Known Subclasses:
ComplexVector,DenseVector,Float64Vector,SparseVector
public abstract class Vector<F extends Field<F>>
extends Object
implements VectorSpace<Vector<F>,F>, javolution.lang.ValueType, javolution.lang.Realtime
This class represents an immutable element of a vector space.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncopy()Returns a copy of this vectorallocatedby the calling thread (possibly on the stack).Returns the cross product of two 3-dimensional vectors.booleanIndicates if this vector is equal to the object specified.booleanequals(Vector<F> that, 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 Fget(int i) Returns a single element from this vector.abstract intReturns the number of elements held by this vector.inthashCode()Returns a hash code value for this vector.Returns the difference between this vector and the one specified.opposite()Returns the negation of this vector.Returns the sum of this vector with the one specified.Returns the product of this vector with the specified coefficient.abstract FReturns the dot product of this vector with the one specified.final StringtoString()Returns the text representation of this vector as ajava.lang.String.javolution.text.TexttoText()Returns the text representation of this vector.
-
Constructor Details
-
Vector
protected Vector()Default constructor (for sub-classes).
-
-
Method Details
-
getDimension
public abstract int getDimension()Returns the number of elements held by this vector.- Returns:
- this vector dimension.
-
get
Returns a single element from this vector.- Parameters:
i- the element index (range [0..n[).- Returns:
- the element at
i. - Throws:
IndexOutOfBoundsException-(i < 0) || (i >= size())
-
opposite
Returns the negation of this vector.- Specified by:
oppositein interfaceGroupAdditive<F extends Field<F>>- Returns:
-this.
-
plus
Returns the sum of this vector with the one specified.- Specified by:
plusin interfaceGroupAdditive<F extends Field<F>>- Parameters:
that- the vector to be added.- Returns:
this + that.- Throws:
DimensionException- is vectors dimensions are different.
-
minus
Returns the difference between this vector and the one specified.- Parameters:
that- the vector to be subtracted.- Returns:
this - that.
-
times
Returns the product of this vector with the specified coefficient. -
times
Returns the dot product of this vector with the one specified.- Parameters:
that- the vector multiplier.- Returns:
this · that- Throws:
DimensionException- ifthis.dimension() != that.dimension()- See Also:
-
cross
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 javolution.text.Text toText()Returns the text representation of this vector.- Specified by:
toTextin interfacejavolution.lang.Realtime- Returns:
- the text representation of this vector.
-
toString
Returns the text representation of this vector as ajava.lang.String. -
equals
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:
trueif this vector and the specified matrix are both vector with equal elements according to the specified comparator;falseotherwise.
-
equals
Indicates if this vector is equal to the object specified. -
hashCode
public int hashCode()Returns a hash code value for this vector. Equals objects have equal hash codes. -
copy
Returns a copy of this vectorallocatedby the calling thread (possibly on the stack).- Specified by:
copyin interfacejavolution.lang.ValueType- Returns:
- an identical and independant copy of this matrix.
-