|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
ObjectVector<F>
public abstract class Vector<F extends Field<F>>
This class represents an immutable element of a vector space.
Instances of this class are usually created from static factory methods.
// Creates a vector of 64 bits floating points numbers.
Vector<Float64> V0 = Vector.valueOf(1.1, 1.2, 1.3);
// Creates a dense vector of rational numbers.
DenseVector<Rational> V1 = DenseVector.valueOf(Rational.valueOf(23, 45), Rational.valueOf(33, 75));
// Creates the sparse vector { 0, 0, 0, 3.3, 0, 0, 0, -3.7 } of decimal numbers.
SparseVector<Decimal> V2 =
SparseVector.valueOf(3, Decimal.valueOf("3.3"), 8).plus(
SparseVector.valueOf(7, Decimal.valueOf("-3.7"), 8));
| Field Summary | |
|---|---|
protected static TextFormat<Vector> |
TEXT_FORMAT
Holds the default text format for vectors (formatting only). |
| Constructor Summary | |
|---|---|
protected |
Vector()
Default constructor (for sub-classes). |
| Method Summary | |
|---|---|
abstract Vector<F> |
copy()
Returns a copy of this vector allocated
by the calling thread (possibly on the stack). |
Vector<F> |
cross(Vector<F> that)
Returns the cross product of two 3-dimensional vectors. |
boolean |
equals(Object that)
Indicates if this vector is equal to the object specified. |
boolean |
equals(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 F |
get(int i)
Returns a single element from this vector. |
abstract int |
getDimension()
Returns the number of elements held by this vector. |
abstract Vector<F> |
getSubVector(List<Index> indices)
Returns the sub-vector formed by the elements having the specified indices. |
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. |
String |
toString()
Returns the text representation of this vector as a java.lang.String. |
Text |
toText()
Returns the textual representation of this vector. |
static Vector<Float64> |
valueOf(double... values)
Returns a vector holding the specified double values
(convenience method). |
| Methods inherited from class Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected static final TextFormat<Vector> TEXT_FORMAT
The default text format for any class can be retrieved using the
TextFormat.getDefault(java.lang.Class extends T>) static method.
| Constructor Detail |
|---|
protected Vector()
| Method Detail |
|---|
public static Vector<Float64> valueOf(double... values)
double values
(convenience method).
values - the vector values.
public abstract int getDimension()
public abstract F get(int i)
i - the element index (range [0..n[).
i.
IndexOutOfBoundsException - (i < 0) || (i >= getDimension())public abstract Vector<F> getSubVector(List<Index> indices)
getSubVector(Index.valuesOf(1, 0)) returns the subvector
holding the first two elements of this vector exchanged.
IndexOutOfBoundsException - if any of the indices is greater
than this vector dimension.public abstract Vector<F> opposite()
opposite in interface GroupAdditive<Vector<F extends Field<F>>>-this.public abstract Vector<F> plus(Vector<F> that)
plus in interface GroupAdditive<Vector<F extends Field<F>>>that - the vector to be added.
this + that.
DimensionException - is vectors dimensions are different.public Vector<F> minus(Vector<F> that)
that - the vector to be subtracted.
this - that.public abstract Vector<F> times(F k)
times in interface VectorSpace<Vector<F extends Field<F>>,F extends Field<F>>k - the coefficient multiplier.
this · kpublic abstract F times(Vector<F> that)
that - the vector multiplier.
this · that
DimensionException - if this.dimension() != that.dimension()public Vector<F> cross(Vector<F> that)
that - the vector multiplier.
this x that
DimensionException - if
(this.getDimension() != 3) && (that.getDimension() != 3)public Text toText()
TextFormat for this vector.
toText in interface RealtimeTextFormat.getInstance(this.getClass()).format(this)public final String toString()
java.lang.String.
toString in class ObjecttoText().toString()
public boolean equals(Vector<F> that,
Comparator<F> cmp)
that - the vector to compare for equality.cmp - the comparator to use when testing for element equality.
true if this vector and the specified matrix are
both vector with equal elements according to the specified
comparator; false otherwise.public boolean equals(Object that)
equals in class Objectthat - the object to compare for equality.
true if this vector and the specified object are
both vectors with equal elements; false otherwise.public int hashCode()
hashCode in class Objectequals(org.jscience.mathematics.vector.Vector, java.util.Comparator) public abstract Vector<F> copy()
allocated
by the calling thread (possibly on the stack).
copy in interface ValueType
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||