Method
quantize
(&self, value: f32, values_upper_bound: f32)
Source from the content-addressed store, hash-verified
| 166 | } |
| 167 | |
| 168 | pub fn quantize(&self, value: f32, values_upper_bound: f32) -> u8 { |
| 169 | let quantization = ((1u32 << self.quantization_bits) - 1) as u8; |
| 170 | let max_val = quantization as f32; |
| 171 | (((value / values_upper_bound) * max_val).clamp(0.0, max_val) as u8).min(quantization) |
| 172 | } |
| 173 | |
| 174 | /// Inserts a value into the index at the specified dimension index. |
| 175 | /// Finds the quantized value and pushes the vec_Id in array at index = quantized_value |
Tested by
no test coverage detected