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

Function matvec

nodedb-codec/src/vector_quant/opq.rs:201–208  ·  view source on GitHub ↗
(r: &[f32], v: &[f32], dim: usize)

Source from the content-addressed store, hash-verified

199/// Row-major matrix-vector multiply: returns R · v.
200#[inline]
201fn matvec(r: &[f32], v: &[f32], dim: usize) -> Vec<f32> {
202 let mut out = vec![0.0f32; dim];
203 for i in 0..dim {
204 let row = &r[i * dim..(i + 1) * dim];
205 out[i] = row.iter().zip(v.iter()).map(|(a, b)| a * b).sum();
206 }
207 out
208}
209
210fn pq_encode(v: &[f32], codebooks: &[Vec<Vec<f32>>], m: usize, sub_dim: usize) -> Vec<u8> {
211 let mut codes = Vec::with_capacity(m);

Callers 2

trainMethod · 0.85
apply_rotationMethod · 0.85

Calls 2

sumMethod · 0.80
iterMethod · 0.45

Tested by

no test coverage detected