Exact asymmetric L2 distance using the dequantized stored vector. The query is exact centered FP32 (`q.centered`). The stored vector is reconstructed from its sign bits and `residual_norm` via [`BbqCodec::dequantize`]: each dimension ≈ ±residual_norm / √dim. This is the high-fidelity asymmetric path invoked during rerank on the `oversample × top_k` candidates returned by the coarse Hamming pass.
(&self, q: &BbqQuery, v: &BbqQuantized)
| 291 | /// This is the high-fidelity asymmetric path invoked during rerank on the |
| 292 | /// `oversample × top_k` candidates returned by the coarse Hamming pass. |
| 293 | fn exact_asymmetric_distance(&self, q: &BbqQuery, v: &BbqQuantized) -> f32 { |
| 294 | let header = v.0.header(); |
| 295 | let recon = Self::dequantize(v.0.packed_bits(), header.residual_norm, self.dim); |
| 296 | // L2(q.centered, recon) |
| 297 | q.centered |
| 298 | .iter() |
| 299 | .zip(recon.iter()) |
| 300 | .map(|(&a, &b)| (a - b) * (a - b)) |
| 301 | .sum::<f32>() |
| 302 | .sqrt() |
| 303 | } |
| 304 | } |
| 305 | |
| 306 | // ── Tests ──────────────────────────────────────────────────────────────────── |