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

Function l2_sub

nodedb-vector/src/quantize/pq.rs:261–268  ·  view source on GitHub ↗
(a: &[f32], b: &[f32])

Source from the content-addressed store, hash-verified

259/// L2 squared distance for sub-vectors (used in k-means and encoding).
260#[inline]
261fn l2_sub(a: &[f32], b: &[f32]) -> f32 {
262 let mut sum = 0.0f32;
263 for i in 0..a.len() {
264 let d = a[i] - b[i];
265 sum += d * d;
266 }
267 sum
268}
269
270/// Simple k-means clustering for PQ codebook training.
271///

Callers 4

build_distance_tableMethod · 0.85
nearest_centroidMethod · 0.85
kmeansFunction · 0.85

Calls 1

lenMethod · 0.45

Tested by 1