Vector

data class Vector(val values: List<Double>)(source)

Represents a vector of floating-point values. Used for storing embeddings of text.

Constructors

Link copied to clipboard
constructor(values: List<Double>)

Properties

Link copied to clipboard

Returns the dimension (size) of the vector.

Link copied to clipboard

The floating-point values that make up the vector.

Functions

Link copied to clipboard

Calculates the cosine similarity between this vector and another vector. The result is a value between -1 and 1, where 1 means the vectors are identical, 0 means they are orthogonal, and -1 means they are completely opposite.

Link copied to clipboard
infix fun dotProduct(other: Vector): Double

Calculates the dot product of this vector and the given vector. The dot product is the sum of the products of the corresponding elements of the two vectors.

Link copied to clipboard

Calculates the Euclidean distance between this vector and another vector. The result is a non-negative value, where 0 means the vectors are identical.

Link copied to clipboard

Checks if the vector is a null vector, i.e., all its components are equal to 0.0.

Link copied to clipboard

Computes the magnitude (Euclidean norm) of the vector. The magnitude is calculated as the square root of the sum of the squares of the vector's elements.