Class OpenMapRealVector

java.lang.Object
All Implemented Interfaces:
java.io.Serializable

public class OpenMapRealVector
extends SparseRealVector
implements java.io.Serializable
This class implements the 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.

Since:
2.0
See Also:
Serialized Form
  • Field Details

  • Constructor Details

    • OpenMapRealVector

      public OpenMapRealVector()
      Build a 0-length vector. Zero-length vectors may be used to initialized construction of vectors by data gathering. We start with zero-length and use either the OpenMapRealVector(OpenMapRealVector, int) constructor or one of the append method (append(double), append(RealVector)) to gather data into this vector.
    • OpenMapRealVector

      public OpenMapRealVector​(int dimension)
      Construct a vector of zeroes.
      Parameters:
      dimension - Size of the vector.
    • OpenMapRealVector

      public OpenMapRealVector​(int dimension, double epsilon)
      Construct a vector of zeroes, specifying zero tolerance.
      Parameters:
      dimension - Size of the vector.
      epsilon - Tolerance below which a value considered zero.
    • OpenMapRealVector

      protected OpenMapRealVector​(OpenMapRealVector v, int resize)
      Build a resized vector, for use with append.
      Parameters:
      v - Original vector.
      resize - Amount to add.
    • OpenMapRealVector

      public OpenMapRealVector​(int dimension, int expectedSize)
      Build a vector with known the sparseness (for advanced use only).
      Parameters:
      dimension - Size of the vector.
      expectedSize - The expected number of non-zero entries.
    • OpenMapRealVector

      public OpenMapRealVector​(int dimension, int expectedSize, double epsilon)
      Build a vector with known the sparseness and zero tolerance setting (for advanced use only).
      Parameters:
      dimension - Size of the vector.
      expectedSize - Expected number of non-zero entries.
      epsilon - Tolerance below which a value is considered zero.
    • OpenMapRealVector

      public OpenMapRealVector​(double[] values)
      Create from an array. Only non-zero entries will be stored.
      Parameters:
      values - Set of values to create from.
    • OpenMapRealVector

      public OpenMapRealVector​(double[] values, double epsilon)
      Create from an array, specifying zero tolerance. Only non-zero entries will be stored.
      Parameters:
      values - Set of values to create from.
      epsilon - Tolerance below which a value is considered zero.
    • OpenMapRealVector

      public OpenMapRealVector​(java.lang.Double[] values)
      Create from an array. Only non-zero entries will be stored.
      Parameters:
      values - The set of values to create from
    • OpenMapRealVector

      public OpenMapRealVector​(java.lang.Double[] values, double epsilon)
      Create from an array. Only non-zero entries will be stored.
      Parameters:
      values - Set of values to create from.
      epsilon - Tolerance below which a value is considered zero.
    • OpenMapRealVector

      public OpenMapRealVector​(OpenMapRealVector v)
      Copy constructor.
      Parameters:
      v - Instance to copy from.
    • OpenMapRealVector

      public OpenMapRealVector​(RealVector v)
      Generic copy constructor.
      Parameters:
      v - Instance to copy from.
  • Method Details