Skip to main content

Module lorenzo

Module lorenzo 

Source
Expand description

Lorenzo-predictor codec for pointwise (max-abs) bounds, and for RMSE / PSNR targets through rate control of the bound.

Aimed at rough fields with one smooth (or repeating) axis, such as particle trajectories stored time × particle, where interpolating across the rough axis costs more than it predicts.

  1. Prediction, in row-major order on f32 reconstructions. Mode 0 is the full N-D Lorenzo predictor (inclusion–exclusion over the axes whose coordinate is > 0); mode k + 1 is the previous point along axis k (the N-D predictor where that coordinate is 0). The mode is picked by real stream size.
  2. Quantization, q = round((x − x̃)/2b), checked on the exact f32 reconstruction; failures are escaped raw (as in crate::interp).
  3. Coding. Adaptive binary range coding: a zero flag with contexts (symbol class of the previous point along the prediction axis and of the side neighbour, log₂ of the last step along the prediction axis in quanta), a sign bit keyed on the previous point’s sign, and an adaptive Elias-gamma magnitude keyed on the two neighbour classes.

Constants§

MAGIC
Stream magic of the Lorenzo codec.

Functions§

decode
Decode a Lorenzo stream.
encode_f32
Encode x (row-major, shape dims) with |x − x̂| ≤ b everywhere, trying each prediction mode and keeping the smallest stream.
encode_psnr_f32
encode_rmse_f32 at PSNR = 20 log₁₀(range / RMSE) dB.
encode_rmse_f32
Encode for an RMSE target (rmse absolute): the mode is picked at the bound rmse·√3, then that mode’s bound is rate controlled as in crate::interp::encode_rmse_f32. The target is checked on the exact reconstruction.