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

Method exact_asymmetric_distance

nodedb-codec/src/vector_quant/ternary/codec.rs:105–114  ·  view source on GitHub ↗
(&self, q: &TernaryQuery, v: &Self::Quantized)

Source from the content-addressed store, hash-verified

103 }
104
105 fn exact_asymmetric_distance(&self, q: &TernaryQuery, v: &Self::Quantized) -> f32 {
106 let vh = v.0.header();
107
108 let v_hot = ensure_hot(v.0.packed_bits(), vh.quant_mode, self.dim);
109
110 let dot = ternary_dot(&q.trits_hot, &v_hot, self.dim);
111 let norm_q = scaled_norm_sq(&q.trits_hot, self.dim, q.scale);
112 let norm_v = scaled_norm_sq(&v_hot, self.dim, vh.global_scale);
113 l2_from_dot(dot, norm_q, norm_v, q.scale, vh.global_scale)
114 }
115}
116
117#[cfg(test)]

Callers

nothing calls this directly

Calls 6

ensure_hotFunction · 0.85
ternary_dotFunction · 0.85
scaled_norm_sqFunction · 0.85
l2_from_dotFunction · 0.85
packed_bitsMethod · 0.80
headerMethod · 0.45

Tested by

no test coverage detected