VectorUtilSupport

Interface for implementations of VectorUtil support.

Inheritors

Functions

Link copied to clipboard
abstract fun cosine(a: ByteArray, b: ByteArray): Float

Returns the cosine similarity between the two byte vectors.

abstract fun cosine(v1: FloatArray, v2: FloatArray): Float

Returns the cosine similarity between the two vectors.

Link copied to clipboard
abstract fun dotProduct(a: ByteArray, b: ByteArray): Int

Returns the dot product computed over signed bytes.

abstract fun dotProduct(a: FloatArray, b: FloatArray): Float

Calculates the dot product of the given float arrays.

Link copied to clipboard
abstract fun findNextGEQ(buffer: IntArray, target: Int, from: Int, to: Int): Int

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.

Link copied to clipboard
abstract fun int4BitDotProduct(int4Quantized: ByteArray, binaryQuantized: ByteArray): Long

Compute the dot product between a quantized int4 vector and a binary quantized vector. It is assumed that the int4 quantized bits are packed in the byte array in the same way as the and that the binary bits are packed the same way as .

Link copied to clipboard
abstract fun int4DotProduct(a: ByteArray, apacked: Boolean, b: ByteArray, bpacked: Boolean): Int

Returns the dot product over the computed bytes, assuming the values are int4 encoded.

Link copied to clipboard
abstract fun squareDistance(a: ByteArray, b: ByteArray): Int

Returns the sum of squared differences of the two byte vectors.

Returns the sum of squared differences of the two vectors.