pub struct ContextModel { /* private fields */ }Expand description
A context model backed by a ContextMap (hash->state) + StateMap (state->prob). Now also produces run-count and byte-history predictions.
Implementations§
Source§impl ContextModel
impl ContextModel
Sourcepub fn new(cmap_size: usize) -> Self
pub fn new(cmap_size: usize) -> Self
Create a new context model with the given ContextMap size.
Sourcepub fn predict(&mut self, hash: u32) -> u32
pub fn predict(&mut self, hash: u32) -> u32
Predict probability of bit=1 for the given context hash. Returns 12-bit probability in [1, 4095].
Sourcepub fn predict_multi(&mut self, hash: u32) -> DualPrediction
pub fn predict_multi(&mut self, hash: u32) -> DualPrediction
Predict dual: (state_p, run_p).
Sourcepub fn update(&mut self, bit: u8)
pub fn update(&mut self, bit: u8)
Update the model after observing bit.
Must be called after predict() with the same context.
Sourcepub fn on_byte_complete(&mut self, _byte: u8)
pub fn on_byte_complete(&mut self, _byte: u8)
Notify model that a byte is complete (no-op).
Auto Trait Implementations§
impl Freeze for ContextModel
impl RefUnwindSafe for ContextModel
impl Send for ContextModel
impl Sync for ContextModel
impl Unpin for ContextModel
impl UnsafeUnpin for ContextModel
impl UnwindSafe for ContextModel
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more