/// Raw dot product. Higher is more similar.
pub fn score(a: &[f32], b: &[f32]) -> f32 {
    debug_assert_eq!(a.len(), b.len());
    a.iter().zip(b.iter()).map(|(x, y)| x * y).sum()
}

#[cfg(test)]
mod tests {
    use super::*;
    use approx::assert_relative_eq;

    #[test]
    fn basic_dot() {
        let a = vec![1.0f32, 2.0, 3.0];
        let b = vec![4.0f32, 5.0, 6.0];
        assert_relative_eq!(score(&a, &b), 32.0, epsilon = 1e-6);
    }

    #[test]
    fn zero_vector() {
        let a = vec![0.0f32, 0.0, 0.0];
        let b = vec![1.0f32, 2.0, 3.0];
        assert_relative_eq!(score(&a, &b), 0.0, epsilon = 1e-6);
    }
}
