Skip to main content

Module vector_distance

Module vector_distance 

Source
Expand description

Shared scalar distance metric implementations.

Pure scalar functions that the compiler auto-vectorizes. Used by both nodedb (with optional SIMD dispatch) and nodedb-lite (scalar only).

Enums§

DistanceMetric
Distance metric selection.

Functions§

chebyshev
Chebyshev (L-infinity) distance: max absolute difference.
cosine_distance
Cosine distance: 1.0 - cosine_similarity(a, b).
distance
Compute distance using the specified metric (scalar dispatch).
hamming_f32
Hamming distance for f32 vectors (values > 0.5 treated as 1).
jaccard
Jaccard distance for f32 vectors (values > 0.5 treated as set membership).
l2_squared
Euclidean (L2) squared distance.
manhattan
Manhattan (L1) distance: sum of absolute differences.
neg_inner_product
Negative inner product (for max-inner-product search via min-heap).
pearson
Pearson distance: 1 - Pearson correlation coefficient.