FieldVector interface with a OpenIntToFieldHashMap backing store.Caveat
This implementation assumes that, for any x,
the equality x * 0d == 0d holds. But it is is not true for
NaN. Moreover, zero entries will lose their sign.
Some operations (that involve NaN and/or infinities) may
thus give incorrect results.
| Modifier and Type | Field and Description |
|---|---|
| private final OpenIntToFieldHashMap | entries
Entries of the vector. |
| private final Field | field
Field to which the elements belong. |
| private static final long | serialVersionUID
Serialization identifier. |
| private final int | virtualSize
Dimension of the vector. |
| Access | Constructor and Description |
|---|---|
| public | |
| public | SparseFieldVector(Field<T>
Field to which the elements belong. field, int Size of the vector. dimension)Construct a vector of zeroes. |
| protected | SparseFieldVector(SparseFieldVector<T>
Original vector v, int Amount to add. resize)Build a resized vector, for use with append. |
| public | SparseFieldVector(Field<T>
Field to which the elements belong. field, int Size of the vector. dimension, int Expected number of non-zero entries. expectedSize)Build a vector with known the sparseness (for advanced use only). |
| public | SparseFieldVector(Field<T>
Field to which the elements belong. field, T[] Set of values to create from. values)Create from a Field array. |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public FieldVector | |
| public FieldVector | add(FieldVector<T>
vector to be added v)Implements org. Compute the sum of |
| public FieldVector | Returns: a new vector.Vector to append to this one. v)Implements org. Construct a vector by appending a vector to this vector. |
| public FieldVector | append(FieldVector<T>
vector to append to this one. v)Implements org. Construct a vector by appending a vector to this vector. |
| public FieldVector | append(T
T to append. d)Implements org. Construct a vector by appending a T to this vector. |
| private void | |
| private void | checkIndices(final int
the index of the first entry of the subvector start, final int the index of the last entry of the subvector (inclusive) end)Checks that the indices of a subvector are valid. |
| protected void | checkVectorDimensions(int
Expected dimension. n)Check if instance dimension is equal to some expected value. |
| public FieldVector | |
| public T | dotProduct(FieldVector<T>
vector with which dot product should be computed v)Implements org. Compute the dot product. |
| public FieldVector | ebeDivide(FieldVector<T>
vector by which instance elements must be divided v)Implements org. Element-by-element division. |
| public FieldVector | ebeMultiply(FieldVector<T>
vector by which instance elements must be multiplied v)Implements org. Element-by-element multiplication. |
| public boolean | equals(Object
the reference object with which to compare. obj)Overrides java. Indicates whether some other object is "equal to" this one. |
| public T[] | getData()
Implements org.
Deprecated
as of 3.1, to be removed in 4.0. Please use the
toArray() method instead.
Returns vector entries as a T array. |
| public int | getDimension()
Implements org. Returns the size of the vector. |
| private OpenIntToFieldHashMap | |
| public T | getEntry(int
Index location of entry to be fetched. index)Implements org. Returns the entry in the specified index. |
| public Field | getField()
Implements org. Get the type of field elements of the vector. |
| public FieldVector | getSubVector(int
index of first element. index, int number of elements to be retrieved. n)Implements org. Get a subvector from consecutive elements. |
| public int | |
| public FieldVector | mapAdd(T
value to be added to each entry d)Implements org. Map an addition operation to each entry. |
| public FieldVector | mapAddToSelf(T
value to be added to each entry d)Implements org. Map an addition operation to each entry. |
| public FieldVector | mapDivide(T
value to divide all entries by d)Implements org. Map a division operation to each entry. |
| public FieldVector | mapDivideToSelf(T
value to divide all entries by d)Implements org. Map a division operation to each entry. |
| public FieldVector | mapInv()
Implements org. Map the 1/x function to each entry. |
| public FieldVector | mapInvToSelf()
Implements org. Map the 1/x function to each entry. |
| public FieldVector | mapMultiply(T
value to multiply all entries by d)Implements org. Map a multiplication operation to each entry. |
| public FieldVector | mapMultiplyToSelf(T
value to multiply all entries by d)Implements org. Map a multiplication operation to each entry. |
| public FieldVector | mapSubtract(T
value to be subtracted to each entry d)Implements org. Map a subtraction operation to each entry. |
| public FieldVector | mapSubtractToSelf(T
value to be subtracted to each entry d)Implements org. Map a subtraction operation to each entry. |
| public FieldMatrix | Returns: the matrix outer product between instance and vvector with which outer product should be computed v)Optimized method to compute outer product when both vectors are sparse. |
| public FieldMatrix | outerProduct(FieldVector<T>
vector with which outer product should be computed v)Implements org. Compute the outer product. |
| public FieldVector | projection(FieldVector<T>
vector onto which v)this must be projectedImplements org. Find the orthogonal projection of this vector onto another vector. |
| public void | set(T
single value to set for all elements value)Implements org. Set all elements to a single value. |
| public void | setEntry(int
element index. index, T new value for the element. value)Implements org. Set a single element. |
| public void | setSubVector(int
index of first element to be set. index, FieldVector<T> vector containing the values to set. v)Implements org. Set a set of consecutive elements. |
| public SparseFieldVector | Returns: this - vvector to be subtracted v)Optimized method to compute |
| public FieldVector | subtract(FieldVector<T>
vector to be subtracted v)Implements org. Compute |
| public T[] | toArray()
Implements org. Convert the vector to a T array. |
| public T | Returns: the value returned byFieldVectorPreservingVisitor#end()
at the end of the walkthe visitor to be used to process the entries of this
vector visitor)Visits (but does not alter) all entries of this vector in default order (increasing index). |
| public T | Returns: the value returned byFieldVectorPreservingVisitor#end()
at the end of the walkvisitor to be used to process the entries of this vector visitor, final int the index of the first entry to be visited start, final int the index of the last entry to be visited (inclusive) end)Visits (but does not alter) some entries of this vector in default order (increasing index). |
| public T | Returns: the value returned byFieldVectorChangingVisitor#end()
at the end of the walkthe visitor to be used to process and modify the entries
of this vector visitor)Visits (and possibly alters) all entries of this vector in default order (increasing index). |
| public T | Returns: the value returned byFieldVectorChangingVisitor#end()
at the end of the walkvisitor to be used to process the entries of this vector visitor, final int the index of the first entry to be visited start, final int the index of the last entry to be visited (inclusive) end)Visits (and possibly alters) some entries of this vector in default order (increasing index). |
| public T | Returns: the value returned byFieldVectorPreservingVisitor#end()
at the end of the walkthe visitor to be used to process the entries of this
vector visitor)Visits (but does not alter) all entries of this vector in optimized order. |
| public T | Returns: the value returned byFieldVectorPreservingVisitor#end()
at the end of the walkvisitor to be used to process the entries of this vector visitor, final int the index of the first entry to be visited start, final int the index of the last entry to be visited (inclusive) end)Visits (but does not alter) some entries of this vector in optimized order. |
| public T | Returns: the value returned byFieldVectorChangingVisitor#end()
at the end of the walkthe visitor to be used to process the entries of this
vector visitor)Visits (and possibly alters) all entries of this vector in optimized order. |
| public T | Returns: the value returned byFieldVectorChangingVisitor#end()
at the end of the walkvisitor to be used to process the entries of this vector visitor, final int the index of the first entry to be visited start, final int the index of the last entry to be visited (inclusive) end)Visits (and possibly change) some entries of this vector in optimized order. |