pub fn cosine_similarity(a: &[f32], b: &[f32]) -> f32Expand description
Compute cosine similarity between two f32 slices.
Returns a value in [0, 1] (mapped from raw [-1, 1] via (sim + 1) / 2).
Returns 0.0 for empty, mismatched-length, or zero-norm vectors.
Non-finite values (NaN, Inf) are treated as 0.0 per element.