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

Function l2_sq

nodedb-codec/src/vector_quant/opq_kmeans.rs:9–11  ·  view source on GitHub ↗
(a: &[f32], b: &[f32])

Source from the content-addressed store, hash-verified

7/// L2 squared distance between two equal-length slices.
8#[inline]
9pub fn l2_sq(a: &[f32], b: &[f32]) -> f32 {
10 a.iter().zip(b.iter()).map(|(x, y)| (x - y).powi(2)).sum()
11}
12
13/// Lloyd's k-means clustering.
14///

Callers 6

lloydFunction · 0.85
pq_encodeFunction · 0.85
prepare_queryMethod · 0.85

Calls 2

sumMethod · 0.80
iterMethod · 0.45