MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / asymmetric_distance

Method asymmetric_distance

nodedb-vector/src/quantize/pq.rs:180–187  ·  view source on GitHub ↗
(&self, table: &[Vec<f32>], code: &[u8])

Source from the content-addressed store, hash-verified

178 /// O(M) per candidate — just M table lookups and additions.
179 #[inline]
180 pub fn asymmetric_distance(&self, table: &[Vec<f32>], code: &[u8]) -> f32 {
181 debug_assert_eq!(code.len(), self.m);
182 let mut dist = 0.0f32;
183 for (sub, &c) in code.iter().enumerate() {
184 dist += table[sub][c as usize];
185 }
186 dist
187 }
188
189 /// Decode a PQ code back to an approximate FP32 vector.
190 ///

Calls 1

iterMethod · 0.45