pub fn quantize_dithered(
x: f32,
bits: u32,
eps: f32,
source: &mut impl DitherSource,
) -> f32Expand description
Quantize a single value with deterministic dither.
§Arguments
x– input activation in[-1.0, 1.0]bits– quantizer bit-width (e.g. 3, 5, 7, 8)eps– dither amplitude in LSB units (0.0 = no dither, 0.5 = half-LSB recommended)source– stateful dither sequence
Returns the quantized value in [-1.0, 1.0].
§Example
use ruvector_dither::{GoldenRatioDither, quantize_dithered};
let mut d = GoldenRatioDither::new(0.0);
let q = quantize_dithered(0.314, 8, 0.5, &mut d);
assert!(q >= -1.0 && q <= 1.0);