MCPcopy Create free account
hub / github.com/cosdata/cosdata / quantize_and_combine

Function quantize_and_combine

org/src/main.rs:281–291  ·  view source on GitHub ↗
(vec: &[f32], u32: length)

Source from the content-addressed store, hash-verified

279}
280
281fn quantize_and_combine(vec: &[f32], u32: length) -> Vec<u8> {
282 let mut result = Vec::with_capacity(length >> 1);
283
284 for i in (0..len).step_by(2) {
285 let even = ((vec[i] * 15.0).round() as u8) << 4;
286 let odd = ((vec[i + 1] * 15.0).round() as u8);
287 result.push(even | odd);
288 }
289
290 result
291}
292
293fn to_float_flag(x: f32, bits_per_value: usize, step: f32) -> Vec<bool> {
294 let mut num = ((x + 1.0) / step).floor() as usize;

Callers

nothing calls this directly

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected