DefaultVectorUtilSupport

A common Kotlin implementation of the VectorUtilSupport interface.

Constructors

Link copied to clipboard
constructor()

Functions

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

Returns the cosine similarity between the two byte vectors.

open override fun cosine(v1: FloatArray, v2: FloatArray): Float

Returns the cosine similarity between the two vectors.

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

Returns the dot product computed over signed bytes.

open override fun dotProduct(a: FloatArray, b: FloatArray): Float

Calculates the dot product of the given float arrays.

Link copied to clipboard
open override 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
open override fun int4BitDotProduct(int4Quantized: ByteArray, binaryQuantized: ByteArray): Long

Compute the dot product between a quantized int4 vector and a binary quantized vector.

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

Returns the dot product over int4 encoded bytes.

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

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

open override fun squareDistance(a: FloatArray, b: FloatArray): Float

Returns the sum of squared differences of the two vectors.