ptwm_core::entropy::arithmetic::model
ptwm_core::entropy::arithmetic::model
Byte models for the arithmetic plane codecs.
ptwm_core::entropy::arithmetic::model
crates/ptwm-core/src/entropy/arithmetic/model.rs:1mod modelByte models for the arithmetic plane codecs.
ptwm_core::entropy::arithmetic::model::ByteModel
crates/ptwm-core/src/entropy/arithmetic/model.rs:13pub trait ByteModelA byte probability model the range-coding driver can run. Stateful: adaptive models mutate via [`Self::update`]; static models no-op.
ptwm_core::entropy::arithmetic::model::decode_bytes
crates/ptwm-core/src/entropy/arithmetic/model.rs:42pub fn decode_bytes(model: &mut M, payload: &[u8], decoded_len: usize) -> Vec<u8>Inverse of [`encode_bytes`]; produces exactly `decoded_len` bytes.
ptwm_core::entropy::arithmetic::model::encode_bytes
crates/ptwm-core/src/entropy/arithmetic/model.rs:27pub fn encode_bytes(model: &mut M, data: &[u8]) -> Vec<u8>Drive `model` over `data`, returning the range-coded payload.
ptwm_core::entropy::arithmetic::model::Order0Adaptive
crates/ptwm-core/src/entropy/arithmetic/model.rs:203pub struct Order0AdaptiveOrder-0 model that starts uniform (every byte count = 1) and bumps the observed symbol's count after coding it. Rescales when the total nears [`TOTAL_CAP`]. No serialized state — encoder and decoder stay in lockstep.
ptwm_core::entropy::arithmetic::model::Order0Static
crates/ptwm-core/src/entropy/arithmetic/model.rs:65pub struct Order0StaticOrder-0 model with a fixed, normalized 256-bin count table.
ptwm_core::entropy::arithmetic::model::Order1Adaptive
crates/ptwm-core/src/entropy/arithmetic/model.rs:272pub struct Order1AdaptiveOrder-1 model: 256 independent adaptive sub-models keyed on the previous byte. Context starts at 0. Stateless on the wire.
ptwm_core::entropy::arithmetic::model::Order1Static
crates/ptwm-core/src/entropy/arithmetic/model.rs:372pub struct Order1StaticStatic order-1 (lag-1) model. Counts are fit once on the plane and frozen; [`update`] only advances the context. Contexts never observed as a predecessor fall back to the `marginal` (order-0) table. Every row is Laplace-smoothed and quantized to [`ORDER1_QUANT_TOTAL`], so no symbol is zero-width and the range coder never divides by zero.
ptwm_core::entropy::arithmetic::model::TOTAL_CAP
crates/ptwm-core/src/entropy/arithmetic/model.rs:9pub const TOTAL_CAPFixed PMF denominator cap. Kept well under the range coder's 2^24 renorm floor so `range / total >= 1` always holds.