Expand description
Pure-Rust core for vecnorm. Bulk f32 matrix operations:
l2_normalize/l2_normalize_copy— row-wise unit-length scaling. Rows whose norm is belowEPSare left at zero rather than dividing by zero.cosine_similarity— single pair on 1-D vectors. Returns 0 for any pair where either side has zero norm.top_k_argmax/batch_top_k_argmax— partial-heap top-k that runs inO(n log k). Tied scores are broken by the original index ascending (deterministic).
Enums§
- VecNorm
Error - All errors surfaced by
vecnorm-core.
Constants§
- EPS
- Tiny norm below which a row is considered all-zero and left unscaled.
Functions§
- batch_
top_ k_ argmax - Batch top-k argmax over an
(n_rows, n_cols)matrix. Withparallel = truedistributes rows across rayon’s pool. - cosine_
distances - Cosine distance matrix between two
(n_a, d)and(n_b, d)matrices. Returns an(n_a, n_b)matrix whereout[i, j]is the cosine distance1 - cos(a_i, b_j). Inputs are not modified; this normalizes copies internally so accuracy is preserved on un-normalized inputs. - cosine_
similarity - Cosine similarity between two 1-D vectors. Returns 0 if either side is all-zero.
- l2_
normalize - L2-normalize
matrixin place, row by row. Rows with norm belowEPSare zeroed out (i.e. left unchanged at all-zero) to avoid NaN. - l2_
normalize_ copy - L2-normalize a copy. Same semantics as
l2_normalize. - top_
k_ argmax - Top-k argmax over a 1-D score vector. Returns
(index, score)pairs in descending order. Ties broken by ascending index.
Type Aliases§
- Result
- Crate-wide result alias.