pub fn cosine(a: &[f32], b: &[f32]) -> f32Expand description
Cosine similarity between two equal-length dense vectors.
Returns 1.0 when both vectors are zero (consistent with the
TF-IDF axis: empty-vs-empty is a perfect match — neither has any
semantic content to differ on). Returns 0.0 when exactly one is
zero. Otherwise the standard (a·b) / (‖a‖ · ‖b‖).
The result is clamped to [-1.0, 1.0] to absorb floating-point
drift.