Class DefaultVectorUtilSupport

java.lang.Object
org.apache.lucene.internal.vectorization.DefaultVectorUtilSupport
All Implemented Interfaces:
VectorUtilSupport

final class DefaultVectorUtilSupport extends Object implements VectorUtilSupport
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    float
    cosine(byte[] a, byte[] b)
    Returns the cosine similarity between the two byte vectors.
    float
    cosine(float[] a, float[] b)
    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.
    int
    findNextGEQ(int[] buffer, int target, int from, int to)
    Given an array buffer that is sorted between indexes 0 inclusive and to exclusive, find the first array index whose value is greater than or equal to target.
    private static float
    fma(float a, float b, float c)
     
    int
    int4DotProduct(byte[] a, boolean apacked, byte[] b, boolean bpacked)
    Returns the dot product over the computed bytes, assuming the values are int4 encoded.
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • DefaultVectorUtilSupport

      DefaultVectorUtilSupport()
  • Method Details

    • fma

      private static float fma(float a, float b, float c)
    • dotProduct

      public float dotProduct(float[] a, float[] b)
      Description copied from interface: VectorUtilSupport
      Calculates the dot product of the given float arrays.
      Specified by:
      dotProduct in interface VectorUtilSupport
    • cosine

      public float cosine(float[] a, float[] b)
      Description copied from interface: VectorUtilSupport
      Returns the cosine similarity between the two vectors.
      Specified by:
      cosine in interface VectorUtilSupport
    • squareDistance

      public float squareDistance(float[] a, float[] b)
      Description copied from interface: VectorUtilSupport
      Returns the sum of squared differences of the two vectors.
      Specified by:
      squareDistance in interface VectorUtilSupport
    • dotProduct

      public int dotProduct(byte[] a, byte[] b)
      Description copied from interface: VectorUtilSupport
      Returns the dot product computed over signed bytes.
      Specified by:
      dotProduct in interface VectorUtilSupport
    • int4DotProduct

      public int int4DotProduct(byte[] a, boolean apacked, byte[] b, boolean bpacked)
      Description copied from interface: VectorUtilSupport
      Returns the dot product over the computed bytes, assuming the values are int4 encoded.
      Specified by:
      int4DotProduct in interface VectorUtilSupport
    • cosine

      public float cosine(byte[] a, byte[] b)
      Description copied from interface: VectorUtilSupport
      Returns the cosine similarity between the two byte vectors.
      Specified by:
      cosine in interface VectorUtilSupport
    • squareDistance

      public int squareDistance(byte[] a, byte[] b)
      Description copied from interface: VectorUtilSupport
      Returns the sum of squared differences of the two byte vectors.
      Specified by:
      squareDistance in interface VectorUtilSupport
    • findNextGEQ

      public int findNextGEQ(int[] buffer, int target, int from, int to)
      Description copied from interface: VectorUtilSupport
      Given an array buffer that is sorted between indexes 0 inclusive and to exclusive, find the first array index whose value is greater than or equal to target. This index is guaranteed to be at least from. If there is no such array index, to is returned.
      Specified by:
      findNextGEQ in interface VectorUtilSupport