pub fn norm(v: &[f32]) -> f32Expand description
The euclidean length of a vector, to the bit.
This is a strange shape for a sum of squares and every part of it is on
purpose. Redis computes this one in hnsw.c, in a loop unrolled by four that
adds the four squares together and then adds that to the running total, and
the compiler fuses three of the four multiplies into the adds next to them.
The result is a different last bit from a plain sum, from a fully fused sum
and from an exact one, and it is the number VEMB prints and the number the
stored direction was divided by, so getting it right is the difference
between matching a real server on every vector and matching it on about
nine in ten.
f32::mul_add is fused by contract in Rust rather than by whatever the
compiler felt like, so this answers the same on every machine it runs on,
which is a thing a real server cannot quite say about its own.