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 TypeMethodDescriptionfloat
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 arraybuffer
that is sorted between indexes0
inclusive andto
exclusive, find the first array index whose value is greater than or equal totarget
.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.
-
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 interfaceVectorUtilSupport
-
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 interfaceVectorUtilSupport
-
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 interfaceVectorUtilSupport
-
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 interfaceVectorUtilSupport
-
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 interfaceVectorUtilSupport
-
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 interfaceVectorUtilSupport
-
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 interfaceVectorUtilSupport
-
findNextGEQ
public int findNextGEQ(int[] buffer, int target, int from, int to) Description copied from interface:VectorUtilSupport
Given an arraybuffer
that is sorted between indexes0
inclusive andto
exclusive, 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,to
is returned.- Specified by:
findNextGEQ
in interfaceVectorUtilSupport
-