Expand description
Distance metrics for vector similarity computation
§Table of Contents
- Distance: Enum of supported distance metrics
- compute_distance: Core distance computation function
- SIMD optimizations: AVX2/SSE vectorized implementations
§Performance
SIMD implementations provide 4-8x speedup on modern CPUs. Auto-vectorization is enabled for scalar fallbacks.
Enums§
- Distance
- Supported distance metrics for similarity computation
Functions§
- cosine_
distance_ fast - Fast cosine distance
- cosine_
distance_ normalized - Cosine distance for pre-normalized vectors (fast path) Assumes both vectors have unit length, skips norm calculation
- dot_
product - Raw dot product (not negated)
- dot_
product_ fast - Fast dot product - uses AVX2 when available, falls back to unrolled scalar
- euclidean_
distance_ squared - Squared Euclidean distance (avoids sqrt for faster comparison)
- euclidean_
squared_ fast - Fast squared Euclidean distance