pub struct LookupDecoderModel<Symbol, Probability, SymbolTable, LookupTable, const PRECISION: usize>
where Probability: BitArray,
{ /* private fields */ }
Expand description

A tabularized DecoderModel that is optimized for fast decoding of i.i.d. symbols

You will usually want to use this type through one of the type aliases SmallContiguousLookupDecoderModel or SmallNonContiguousLookupDecoderModel. See these types for extended documentation and examples.

Implementations§

source§

impl<Symbol, Probability, const PRECISION: usize> LookupDecoderModel<Symbol, Probability, NonContiguousSymbolTable<Vec<(Probability, Symbol)>>, Box<[Probability]>, PRECISION>
where Probability: BitArray + Into<usize>, usize: AsPrimitive<Probability>, Symbol: Copy + Default,

source

pub fn from_symbols_and_floating_point_probabilities<F>( symbols: &[Symbol], probabilities: &[F] ) -> Result<Self, ()>
where F: FloatCore + Sum<F> + Into<f64>, Probability: Into<f64> + AsPrimitive<usize>, f64: AsPrimitive<Probability>, usize: AsPrimitive<Probability>,

Create a LookupDecoderModel over arbitrary symbols.

TODO: example

source

pub fn from_symbols_and_nonzero_fixed_point_probabilities<S, P>( symbols: S, probabilities: P, infer_last_probability: bool ) -> Result<Self, ()>
where S: IntoIterator<Item = Symbol>, P: IntoIterator, P::Item: Borrow<Probability>,

Create a LookupDecoderModel over arbitrary symbols.

TODO: example

source

pub fn from_iterable_entropy_model<'m, M>(model: &'m M) -> Self
where M: IterableEntropyModel<'m, PRECISION, Symbol = Symbol, Probability = Probability> + ?Sized,

TODO: test

source§

impl<Symbol, Probability, const PRECISION: usize> LookupDecoderModel<Symbol, Probability, ContiguousSymbolTable<Vec<Probability>>, Box<[Probability]>, PRECISION>
where Probability: BitArray + Into<usize>, usize: AsPrimitive<Probability>, Symbol: Copy + Default,

source

pub fn from_floating_point_probabilities_contiguous<F>( probabilities: &[F] ) -> Result<Self, ()>
where F: FloatCore + Sum<F> + Into<f64>, Probability: Into<f64> + AsPrimitive<usize>, f64: AsPrimitive<Probability>, usize: AsPrimitive<Probability>,

Create a LookupDecoderModel over a contiguous range of symbols.

TODO: example

source

pub fn from_nonzero_fixed_point_probabilities_contiguous<I>( probabilities: I, infer_last_probability: bool ) -> Result<Self, ()>
where I: IntoIterator, I::Item: Borrow<Probability>,

Create a LookupDecoderModel over a contiguous range of symbols using fixed point arighmetic.

Example

See SmallContiguousLookupDecoderModel.

source§

impl<Probability, Table, LookupTable, const PRECISION: usize> LookupDecoderModel<Probability, Probability, ContiguousSymbolTable<Table>, LookupTable, PRECISION>
where Probability: BitArray + Into<usize>, usize: AsPrimitive<Probability>, Table: AsRef<[Probability]>, LookupTable: AsRef<[Probability]>,

source

pub fn as_view( &self ) -> LookupDecoderModel<Probability, Probability, ContiguousSymbolTable<&[Probability]>, &[Probability], PRECISION>

Makes a very cheap shallow copy of the model that can be used much like a shared reference.

The returned LookupDecoderModel implements Copy, which is a requirement for some methods, such as Decode::decode_iid_symbols. These methods could also accept a shared reference to a NonContiguousCategoricalDecoderModel (since all references to entropy models are also entropy models, and all shared references implement Copy), but passing a view instead may be slightly more efficient because it avoids one level of dereferencing.

source

pub fn as_contiguous_categorical( &self ) -> ContiguousCategoricalEntropyModel<Probability, &[Probability], PRECISION>

TODO: documentation

source

pub fn into_contiguous_categorical( self ) -> ContiguousCategoricalEntropyModel<Probability, Table, PRECISION>

TODO: documentation

source§

impl<Symbol, Probability, Table, LookupTable, const PRECISION: usize> LookupDecoderModel<Symbol, Probability, NonContiguousSymbolTable<Table>, LookupTable, PRECISION>
where Probability: BitArray + Into<usize>, usize: AsPrimitive<Probability>, Table: AsRef<[(Probability, Symbol)]>, LookupTable: AsRef<[Probability]>,

source

pub fn as_view( &self ) -> LookupDecoderModel<Symbol, Probability, NonContiguousSymbolTable<&[(Probability, Symbol)]>, &[Probability], PRECISION>

Makes a very cheap shallow copy of the model that can be used much like a shared reference.

The returned LookupDecoderModel implements Copy, which is a requirement for some methods, such as Decode::decode_iid_symbols. These methods could also accept a shared reference to a NonContiguousCategoricalDecoderModel (since all references to entropy models are also entropy models, and all shared references implement Copy), but passing a view instead may be slightly more efficient because it avoids one level of dereferencing.

Trait Implementations§

source§

impl<Symbol: Clone, Probability, SymbolTable: Clone, LookupTable: Clone, const PRECISION: usize> Clone for LookupDecoderModel<Symbol, Probability, SymbolTable, LookupTable, PRECISION>
where Probability: BitArray + Clone,

source§

fn clone( &self ) -> LookupDecoderModel<Symbol, Probability, SymbolTable, LookupTable, PRECISION>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<Symbol: Debug, Probability, SymbolTable: Debug, LookupTable: Debug, const PRECISION: usize> Debug for LookupDecoderModel<Symbol, Probability, SymbolTable, LookupTable, PRECISION>
where Probability: BitArray + Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<Symbol, Probability, Table, LookupTable, const PRECISION: usize> DecoderModel<PRECISION> for LookupDecoderModel<Symbol, Probability, Table, LookupTable, PRECISION>
where Probability: BitArray + Into<usize>, Table: SymbolTable<Symbol, Probability>, LookupTable: AsRef<[Probability]>, Symbol: Clone,

source§

fn quantile_function( &self, quantile: Probability ) -> (Symbol, Probability, Probability::NonZero)

Looks up the symbol for a given quantile. Read more
source§

impl<Symbol, Probability, Table, LookupTable, const PRECISION: usize> EntropyModel<PRECISION> for LookupDecoderModel<Symbol, Probability, Table, LookupTable, PRECISION>
where Probability: BitArray + Into<usize>,

§

type Symbol = Symbol

The type of data over which the entropy model is defined. Read more
§

type Probability = Probability

The type used to represent probabilities, cumulatives, and quantiles. Read more
source§

impl<'m, Probability, Table, const PRECISION: usize> From<&'m ContiguousCategoricalEntropyModel<Probability, Table, PRECISION>> for LookupDecoderModel<Probability, Probability, ContiguousSymbolTable<Vec<Probability>>, Box<[Probability]>, PRECISION>
where Probability: BitArray + Into<usize>, usize: AsPrimitive<Probability>, Table: AsRef<[Probability]>,

source§

fn from( model: &'m ContiguousCategoricalEntropyModel<Probability, Table, PRECISION> ) -> Self

Converts to this type from the input type.
source§

impl<'m, Symbol, Probability, M, const PRECISION: usize> From<&'m M> for LookupDecoderModel<Symbol, Probability, NonContiguousSymbolTable<Vec<(Probability, Symbol)>>, Box<[Probability]>, PRECISION>
where Probability: BitArray + Into<usize>, Symbol: Copy + Default, usize: AsPrimitive<Probability>, M: IterableEntropyModel<'m, PRECISION, Symbol = Symbol, Probability = Probability> + ?Sized,

source§

fn from(model: &'m M) -> Self

Converts to this type from the input type.
source§

impl<'m, Probability, Table, LookupTable, const PRECISION: usize> IterableEntropyModel<'m, PRECISION> for LookupDecoderModel<Probability, Probability, ContiguousSymbolTable<Table>, LookupTable, PRECISION>
where Probability: BitArray + Into<usize>, usize: AsPrimitive<Probability>, Table: AsRef<[Probability]>, LookupTable: AsRef<[Probability]>,

§

type Iter = SymbolTableIter<Probability, Probability, ContiguousSymbolTable<&'m [Probability]>>

The type of the iterator returned by symbol_table. Read more
source§

fn symbol_table(&'m self) -> Self::Iter

Iterates over all symbols in the unique order that is consistent with the cumulative distribution. Read more
source§

fn floating_point_symbol_table<F>( &'m self ) -> FloatingPointSymbolTable<F, Self::Iter, PRECISION>
where F: From<Self::Probability>,

Similar to symbol_table, but yields both cumulatives and probabilities in floating point representation. Read more
source§

fn entropy_base2<F>(&'m self) -> F
where F: Float + Sum, Self::Probability: Into<F>,

Returns the entropy in units of bits (i.e., base 2). Read more
source§

impl<'m, Symbol, Probability, Table, LookupTable, const PRECISION: usize> IterableEntropyModel<'m, PRECISION> for LookupDecoderModel<Symbol, Probability, NonContiguousSymbolTable<Table>, LookupTable, PRECISION>
where Symbol: Clone + 'm, Probability: BitArray + Into<usize>, usize: AsPrimitive<Probability>, Table: AsRef<[(Probability, Symbol)]>, LookupTable: AsRef<[Probability]>,

§

type Iter = SymbolTableIter<Symbol, Probability, NonContiguousSymbolTable<&'m [(Probability, Symbol)]>>

The type of the iterator returned by symbol_table. Read more
source§

fn symbol_table(&'m self) -> Self::Iter

Iterates over all symbols in the unique order that is consistent with the cumulative distribution. Read more
source§

fn floating_point_symbol_table<F>( &'m self ) -> FloatingPointSymbolTable<F, Self::Iter, PRECISION>
where F: From<Self::Probability>,

Similar to symbol_table, but yields both cumulatives and probabilities in floating point representation. Read more
source§

fn entropy_base2<F>(&'m self) -> F
where F: Float + Sum, Self::Probability: Into<F>,

Returns the entropy in units of bits (i.e., base 2). Read more
source§

impl<Symbol: Copy, Probability, SymbolTable: Copy, LookupTable: Copy, const PRECISION: usize> Copy for LookupDecoderModel<Symbol, Probability, SymbolTable, LookupTable, PRECISION>
where Probability: BitArray + Copy,

Auto Trait Implementations§

§

impl<Symbol, Probability, SymbolTable, LookupTable, const PRECISION: usize> RefUnwindSafe for LookupDecoderModel<Symbol, Probability, SymbolTable, LookupTable, PRECISION>
where LookupTable: RefUnwindSafe, Probability: RefUnwindSafe, Symbol: RefUnwindSafe, SymbolTable: RefUnwindSafe,

§

impl<Symbol, Probability, SymbolTable, LookupTable, const PRECISION: usize> Send for LookupDecoderModel<Symbol, Probability, SymbolTable, LookupTable, PRECISION>
where LookupTable: Send, Probability: Send, Symbol: Send, SymbolTable: Send,

§

impl<Symbol, Probability, SymbolTable, LookupTable, const PRECISION: usize> Sync for LookupDecoderModel<Symbol, Probability, SymbolTable, LookupTable, PRECISION>
where LookupTable: Sync, Probability: Sync, Symbol: Sync, SymbolTable: Sync,

§

impl<Symbol, Probability, SymbolTable, LookupTable, const PRECISION: usize> Unpin for LookupDecoderModel<Symbol, Probability, SymbolTable, LookupTable, PRECISION>
where LookupTable: Unpin, Probability: Unpin, Symbol: Unpin, SymbolTable: Unpin,

§

impl<Symbol, Probability, SymbolTable, LookupTable, const PRECISION: usize> UnwindSafe for LookupDecoderModel<Symbol, Probability, SymbolTable, LookupTable, PRECISION>
where LookupTable: UnwindSafe, Probability: UnwindSafe, Symbol: UnwindSafe, SymbolTable: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.