Interface VectorUtilSupport


public interface VectorUtilSupport
Interface for implementations of VectorUtil support.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addInPlace(float[] v1, float[] v2)
    Adds v2 into v1, in place (v1 will be modified)
    float
    assembleAndSum(float[] data, int baseIndex, byte[] baseOffsets)
    Calculates the sum of sparse points in a vector.
    float
    cosine(byte[] a, byte[] b)
    Returns the cosine similarity between the two byte vectors.
    float
    cosine(float[] v1, float[] v2)
    Returns the cosine similarity between the two vectors.
    int
    dotProduct(byte[] a, byte[] b)
    Returns the dot product computed over signed bytes.
    float
    dotProduct(float[] a, float[] b)
    Calculates the dot product of the given float arrays.
    float
    dotProduct(float[] a, int aoffset, float[] b, int boffset, int length)
    Calculates the dot product of float arrays of differing sizes, or a subset of the data
    int
    hammingDistance(long[] v1, long[] v2)
     
    void
    scale(float[] vector, float multiplier)
    Divide vector by divisor, in place (vector will be modified)
    int
    squareDistance(byte[] a, byte[] b)
    Returns the sum of squared differences of the two byte vectors.
    float
    squareDistance(float[] a, float[] b)
    Returns the sum of squared differences of the two vectors.
    float
    squareDistance(float[] a, int aoffset, float[] b, int boffset, int length)
    Calculates the sum of squared differences of float arrays of differing sizes, or a subset of the data
    float[]
    sub(float[] lhs, float[] rhs)
     
    void
    subInPlace(float[] v1, float[] v2)
    Subtracts v2 from v1, in place (v1 will be modified)
    float
    sum(float[] vector)
    return the sum of the components of the vector
    float[]
    sum(List<float[]> vectors)
    returns the sum of the given vectors.
  • Method Details

    • dotProduct

      float dotProduct(float[] a, float[] b)
      Calculates the dot product of the given float arrays.
    • dotProduct

      float dotProduct(float[] a, int aoffset, float[] b, int boffset, int length)
      Calculates the dot product of float arrays of differing sizes, or a subset of the data
    • cosine

      float cosine(float[] v1, float[] v2)
      Returns the cosine similarity between the two vectors.
    • squareDistance

      float squareDistance(float[] a, float[] b)
      Returns the sum of squared differences of the two vectors.
    • squareDistance

      float squareDistance(float[] a, int aoffset, float[] b, int boffset, int length)
      Calculates the sum of squared differences of float arrays of differing sizes, or a subset of the data
    • dotProduct

      int dotProduct(byte[] a, byte[] b)
      Returns the dot product computed over signed bytes.
    • cosine

      float cosine(byte[] a, byte[] b)
      Returns the cosine similarity between the two byte vectors.
    • squareDistance

      int squareDistance(byte[] a, byte[] b)
      Returns the sum of squared differences of the two byte vectors.
    • sum

      float[] sum(List<float[]> vectors)
      returns the sum of the given vectors.
    • sum

      float sum(float[] vector)
      return the sum of the components of the vector
    • scale

      void scale(float[] vector, float multiplier)
      Divide vector by divisor, in place (vector will be modified)
    • addInPlace

      void addInPlace(float[] v1, float[] v2)
      Adds v2 into v1, in place (v1 will be modified)
    • subInPlace

      void subInPlace(float[] v1, float[] v2)
      Subtracts v2 from v1, in place (v1 will be modified)
    • sub

      float[] sub(float[] lhs, float[] rhs)
      Returns:
      lhs - rhs, element-wise
    • assembleAndSum

      float assembleAndSum(float[] data, int baseIndex, byte[] baseOffsets)
      Calculates the sum of sparse points in a vector. This assumes the data vector is a 2d matrix which has been flattened into 1 dimension so rather than data[n][m] it's data[n * m]. With this layout this method can quickly assemble the data from this heap and sum it.
      Parameters:
      data - the vector of all datapoints
      baseIndex - the start of the data in the offset table (scaled by the index of the lookup table)
      baseOffsets - bytes that represent offsets from the baseIndex
      Returns:
      the sum of the points
    • hammingDistance

      int hammingDistance(long[] v1, long[] v2)