Affine quantization over the reals #
RealAffineQuantizer describes a positive-scale integer grid with bounded storage. Its rounding
function is supplied by the caller: order preservation, integer round trips, and error bounds
each require only the corresponding property of that function. In particular, the error result
is not restricted to nearest-even rounding.
AffineQuantizer.toReal embeds the executable rational quantizer's parameters without changing
the code interval. toReal_quantize and toReal_roundedValue transport any agreement between
rational and real integer rounding to the complete saturated operation. The Flocq rounding
adapter specializes this agreement to nearest-even; executable clients can continue importing
Affine alone without loading real-number theory.
A bounded affine grid with real-valued spacing and caller-supplied integer rounding.
- scale : ℝ
Distance between adjacent reconstructed values.
- zeroPoint : ℤ
Integer code whose reconstruction is zero. It need not be inside the storage interval.
- qmin : ℤ
Smallest stored code.
- qmax : ℤ
Largest stored code.
The grid spacing is strictly positive.
The storage interval is nonempty.
Instances For
Saturate an integer to the storage interval using the shared clamp.
Instances For
Integer code before saturation.
Instances For
Round onto the affine grid and saturate to the storage interval.
Instances For
Reconstruct the real value denoted by an integer code.
Instances For
Reconstructed value after rounding and saturation.
Instances For
Saturation fixes every code already in the storage interval.
The zero point reconstructs to zero, even if it lies outside the storage interval.
A monotone integer rounder gives monotone saturated quantization.
Reconstruction preserves integer-code order because the scale is positive.
A rounder that fixes integers preserves in-range codes under reconstruction and rounding.
Without clipping, an integer-rounding error bound scales by the grid spacing.
Without clipping, nearest integer rounding reconstructs within half a grid step.
View an executable rational grid as a real grid with the same integer codes.
Instances For
Reconstruction commutes with the exact rational-to-real embedding.
Agreement of integer rounding lifts to affine quantization, including saturation.
Reconstruction commutes with exact embedding whenever integer rounding does.