Skip to main content

Module scalar

Module scalar 

Source
Expand description

Scalar (non-SIMD) distance metric implementations.

Re-exports scalar implementations from nodedb-types. Works on all targets: native, WASM, iOS, Android.

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.
scalar_distance
Compute distance between two vectors using scalar implementations.