Skip to main content

Module math

Module math 

Source
Expand description

Small, dependency-free vector maths used by embedders and stores.

Functionsยง

cosine
Cosine similarity in [-1, 1]; returns 0 if either vector is zero-length.
dot
Dot product of two equal-length slices (unchecked length; extra tail ignored).
from_bytes
Decode a little-endian f32 byte blob back into a vector.
norm
Euclidean (L2) norm.
normalize
L2-normalize a vector in place. A zero vector is left unchanged.
to_bytes
Encode a vector as a little-endian f32 byte blob (for DB storage).