RealVector interface with a
OpenIntToDoubleHashMap 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, like multiplications, divisions or
functions mapping.
| Modifier and Type | Class and Description |
|---|---|
| protected class | OpenMapRealVector.
Implementation of |
| protected class | OpenMapRealVector.
Iterator class to do iteration over just the non-zero elements. |
| Modifier and Type | Field and Description |
|---|---|
| public static final double | DEFAULT_ZERO_TOLERANCE
Default Tolerance for having a value considered zero. |
| private final OpenIntToDoubleHashMap | entries
Entries of the vector. |
| private final double | epsilon
Tolerance for having a value considered zero. |
| private static final long | serialVersionUID
Serializable version identifier. |
| private final int | virtualSize
Dimension of the vector. |
| Access | Constructor and Description |
|---|---|
| public | |
| public | |
| public | OpenMapRealVector(int
Size of the vector. dimension, double Tolerance below which a value considered zero. epsilon)Construct a vector of zeroes, specifying zero tolerance. |
| protected | OpenMapRealVector(OpenMapRealVector
Original vector. v, int Amount to add. resize)Build a resized vector, for use with append. |
| public | OpenMapRealVector(int
Size of the vector. dimension, int The expected number of non-zero entries. expectedSize)Build a vector with known the sparseness (for advanced use only). |
| public | OpenMapRealVector(int
Size of the vector. dimension, int Expected number of non-zero entries. expectedSize, double Tolerance below which a value is considered zero. epsilon)Build a vector with known the sparseness and zero tolerance setting (for advanced use only). |
| public | |
| public | OpenMapRealVector(double[]
Set of values to create from. values, double Tolerance below which a value is considered zero. epsilon)Create from an array, specifying zero tolerance. |
| public | |
| public | OpenMapRealVector(Double[]
Set of values to create from. values, double Tolerance below which a value is considered zero. epsilon)Create from an array. |
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public RealVector | add(RealVector
Vector to be added. v)Overrides org. Compute the sum of this vector and |
| public OpenMapRealVector | Returns: the sum ofthis and v.Vector to add. v)Optimized method to add two OpenMapRealVectors. |
| public OpenMapRealVector | Returns: The result of appendingv to selfvector to append v)Optimized method to append a OpenMapRealVector. |
| public OpenMapRealVector | append(RealVector
vector to append to this one. v)Implements abstract org. Construct a new vector by appending a vector to this vector. |
| public OpenMapRealVector | append(double
double to append. d)Implements abstract org. Construct a new vector by appending a double to this vector. |
| public OpenMapRealVector | copy()
Implements abstract org. Returns a (deep) copy of this vector. |
| public double | Returns: the dot product of this vector withv.Vector. v)
Deprecated
as of 3.1 (to be removed in 4.0). The computation is
performed by the parent class. The method must be kept to maintain
backwards compatibility.
Computes the dot product. |
| public OpenMapRealVector | ebeDivide(RealVector
Vector by which instance elements must be divided. v)Implements abstract org. Element-by-element division. |
| public OpenMapRealVector | ebeMultiply(RealVector
Vector by which instance elements must be multiplied v)Implements abstract org. Element-by-element multiplication. |
| public boolean | equals(Object
Object to test for equality. obj)Overrides org. Test for the equality of two real vectors. |
| public int | getDimension()
Implements abstract org. Returns the size of the vector. |
| public double | Returns: the distance fromthis and v.Vector to compute distance to. v)Optimized method to compute distance. |
| public double | getDistance(RealVector
Vector to which distance is requested. v)Overrides org. Distance between two vectors. |
| private OpenIntToDoubleHashMap | |
| public double | getEntry(int
Index location of entry to be fetched. index)Implements abstract org. Return the entry at the specified index. |
| public double | Returns: distance between this vector andv.Vector to which distance is requested. v)Distance between two vectors. |
| public double | getL1Distance(RealVector
Vector to which distance is requested. v)Overrides org. Distance between two vectors. |
| private double | Returns: the LInfDistance.Vector to compute distance from. v)Optimized method to compute LInfDistance. |
| public double | getLInfDistance(RealVector
Vector to which distance is requested. v)Overrides org. Distance between two vectors. |
| public double | |
| public OpenMapRealVector | getSubVector(int
index of first element. index, int number of elements to be retrieved. n)Implements abstract org. Get a subvector from consecutive elements. |
| public int | hashCode()
Overrides org. Returns a hash code value for this object. |
| protected boolean | Returns: true if this value is within epsilon to zero,
false otherwise.Value to test value)Determine if this value is within epsilon of zero. |
| public boolean | isInfinite()
Implements abstract org. Check whether any coordinate of this vector is infinite and none are |
| public boolean | isNaN()
Implements abstract org. Check whether any coordinate of this vector is |
| public OpenMapRealVector | mapAdd(double
Value to be added to each entry. d)Overrides org. Add a value to each entry. |
| public OpenMapRealVector | mapAddToSelf(double
Value to be added to each entry. d)Overrides org. Add a value to each entry. |
| public void | set(double
Single value to set for all elements. value)Overrides org. Set all elements to a single value. |
| public void | setEntry(int
element index. index, double new value for the element. value)Implements abstract org. Set a single element. |
| public void | setSubVector(int
index of first element to be set. index, RealVector vector containing the values to set. v)Implements abstract org. Set a sequence of consecutive elements. |
| public Iterator | sparseIterator()
Overrides org. Create a sparse iterator over the vector, which may omit some entries. |
| public OpenMapRealVector | Returns: the difference ofthis and v.Vector to subtract from v)this.Optimized method to subtract OpenMapRealVectors. |
| public RealVector | subtract(RealVector
Vector to be subtracted. v)Overrides org. Subtract |
| public double[] | toArray()
Overrides org. Convert the vector to an array of |
| public void | unitize()
Overrides org. Converts this vector into a unit vector. |
| public OpenMapRealVector | unitVector()
Overrides org. Creates a unit vector pointing in the direction of this vector. |