barrel_vectordb_distance (barrel_vectordb v2.1.1)
View SourceVector Distance Computation Module
Provides SIMD-accelerated distance computations via NIF. Falls back to pure Erlang implementation if NIF is not available.
Supports: - Cosine distance - Euclidean distance - Dot product
Vectors can be represented as: - Lists of floats (Erlang native, slower) - Binaries of 32-bit floats (NIF optimized, faster)
Summary
Functions
Compute cosine distance: 1 - cos(a, b)
Compute cosine distance for pre-normalized vectors (faster)
Compute dot product of two vectors
Compute Euclidean distance
Convert binary vector to list of floats
Check if NIF is available
Return SIMD backend information
Convert list of floats to binary vector (32-bit floats)
Types
Functions
Compute cosine distance: 1 - cos(a, b)
Compute cosine distance for pre-normalized vectors (faster)
Compute dot product of two vectors
Compute Euclidean distance
Convert binary vector to list of floats
-spec nif_available() -> boolean().
Check if NIF is available
-spec simd_info() -> #{backend => avx2 | neon | scalar | erlang}.
Return SIMD backend information
Convert list of floats to binary vector (32-bit floats)