pub fn cosine(a: &[f32], b: &[f32]) -> f32Expand description
Cosine similarity between two equal-length vectors.
Returns a value in [-1.0, 1.0]. Degenerate inputs (mismatched length,
either side a zero vector, or any non-finite component) return 0.0
rather than NaN so downstream ranking is always well-ordered. Callers
that want a [0, 1] “relatedness” score should max(0.0, sim).