java.lang.Object
org.elasticsearch.index.codec.vectors.BQVectorUtils
Utility class for vector quantization calculations
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic doubleconstSqrt(double x) static intdiscretize(int value, int bucket) static voiddivideInPlace(float[] a, float b) static booleanisUnitVector(float[] v) static floatnorm(float[] vector) static voidpackAsBinary(byte[] vector, byte[] packed) static byte[]pad(byte[] vector, int dimensions) static float[]pad(float[] vector, int dimensions) static intpopcount(byte[] d) Copied from Lucene, replace with Lucene's implementation sometime after Lucene 10static doublesqrtNewtonRaphson(double x, double curr, double prev) static float[]subtract(float[] a, float[] b) static voidsubtractInPlace(float[] target, float[] other)
-
Constructor Details
-
BQVectorUtils
public BQVectorUtils()
-
-
Method Details
-
sqrtNewtonRaphson
public static double sqrtNewtonRaphson(double x, double curr, double prev) -
constSqrt
public static double constSqrt(double x) -
isUnitVector
public static boolean isUnitVector(float[] v) -
packAsBinary
public static void packAsBinary(byte[] vector, byte[] packed) -
discretize
public static int discretize(int value, int bucket) -
pad
public static float[] pad(float[] vector, int dimensions) -
pad
public static byte[] pad(byte[] vector, int dimensions) -
popcount
public static int popcount(byte[] d) Copied from Lucene, replace with Lucene's implementation sometime after Lucene 10- Parameters:
d- the byte array to count the number of set bits in- Returns:
- count of flipped bits in the byte array
-
divideInPlace
public static void divideInPlace(float[] a, float b) -
subtract
public static float[] subtract(float[] a, float[] b) -
subtractInPlace
public static void subtractInPlace(float[] target, float[] other) -
norm
public static float norm(float[] vector)
-