Module org.apache.lucene.core
Class DefaultVectorUtilSupport
java.lang.Object
org.apache.lucene.internal.vectorization.DefaultVectorUtilSupport
- All Implemented Interfaces:
VectorUtilSupport
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfloatcosine(byte[] a, byte[] b) Returns the cosine similarity between the two byte vectors.floatcosine(float[] a, float[] b) Returns the cosine similarity between the two vectors.intdotProduct(byte[] a, byte[] b) Returns the dot product computed over signed bytes.floatdotProduct(float[] a, float[] b) Calculates the dot product of the given float arrays.intfindNextGEQ(int[] buffer, int target, int from, int to) Given an arraybufferthat is sorted between indexes0inclusive andtoexclusive, find the first array index whose value is greater than or equal totarget.private static floatfma(float a, float b, float c) intint4DotProduct(byte[] a, boolean apacked, byte[] b, boolean bpacked) Returns the dot product over the computed bytes, assuming the values are int4 encoded.intsquareDistance(byte[] a, byte[] b) Returns the sum of squared differences of the two byte vectors.floatsquareDistance(float[] a, float[] b) Returns the sum of squared differences of the two vectors.
-
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:VectorUtilSupportCalculates the dot product of the given float arrays.- Specified by:
dotProductin interfaceVectorUtilSupport
-
cosine
public float cosine(float[] a, float[] b) Description copied from interface:VectorUtilSupportReturns the cosine similarity between the two vectors.- Specified by:
cosinein interfaceVectorUtilSupport
-
squareDistance
public float squareDistance(float[] a, float[] b) Description copied from interface:VectorUtilSupportReturns the sum of squared differences of the two vectors.- Specified by:
squareDistancein interfaceVectorUtilSupport
-
dotProduct
public int dotProduct(byte[] a, byte[] b) Description copied from interface:VectorUtilSupportReturns the dot product computed over signed bytes.- Specified by:
dotProductin interfaceVectorUtilSupport
-
int4DotProduct
public int int4DotProduct(byte[] a, boolean apacked, byte[] b, boolean bpacked) Description copied from interface:VectorUtilSupportReturns the dot product over the computed bytes, assuming the values are int4 encoded.- Specified by:
int4DotProductin interfaceVectorUtilSupport
-
cosine
public float cosine(byte[] a, byte[] b) Description copied from interface:VectorUtilSupportReturns the cosine similarity between the two byte vectors.- Specified by:
cosinein interfaceVectorUtilSupport
-
squareDistance
public int squareDistance(byte[] a, byte[] b) Description copied from interface:VectorUtilSupportReturns the sum of squared differences of the two byte vectors.- Specified by:
squareDistancein interfaceVectorUtilSupport
-
findNextGEQ
public int findNextGEQ(int[] buffer, int target, int from, int to) Description copied from interface:VectorUtilSupportGiven an arraybufferthat is sorted between indexes0inclusive andtoexclusive, find the first array index whose value is greater than or equal totarget. This index is guaranteed to be at leastfrom. If there is no such array index,tois returned.- Specified by:
findNextGEQin interfaceVectorUtilSupport
-