const LANES: usize = 8;
#[inline]
pub fn l2_squared(a: &[f32], b: &[f32]) -> f32 {
debug_assert_eq!(a.len(), b.len());
let mut acc = [0.0_f32; LANES];
let mut ca = a.chunks_exact(LANES);
let mut cb = b.chunks_exact(LANES);
for (av, bv) in ca.by_ref().zip(cb.by_ref()) {
for l in 0..LANES {
let d = av[l] - bv[l];
acc[l] += d * d;
}
}
let mut s = 0.0_f32;
for l in 0..LANES {
s += acc[l];
}
for (x, y) in ca.remainder().iter().zip(cb.remainder()) {
let d = x - y;
s += d * d;
}
s
}
#[inline]
pub fn l2_squared_range(a: &[f32], b: &[f32], len: usize) -> f32 {
l2_squared(&a[..len], &b[..len])
}