KASKADE 7 development version
Loading...
Searching...
No Matches
Alphabet< UInt > Class Template Reference

A simple alphabet of symbols with frequencies to be used with the range coder. More...

#include <rangecoder.hh>

Public Member Functions

template<class InIter>
 Alphabet (InIter first, InIter last)
template<class InIter>
void update (InIter first, InIter last)
 Modifies the symbols' half-open ranges to represent the symbols' frequencies given in the range [first,last[.
UInt totalRange () const
 Returns the total range, i.e. the maximum upper range bound of any symbol in the alphabet.
UInt size () const
 Returns the number of symbols in the alphabet.
UInt symbol (UInt value) const
 Returns the symbol that contains the given value.
std::pair< UInt, UInt > range (UInt symbol) const
 Returns the symbol's half-open cumulative frequency range.
template<class InIter>
 Alphabet (InIter first, InIter last, UInt maxRange=std::numeric_limits< UInt >::max())
 Constructor. Constructs an alphabet from a sequence of frequencies of symbols. Note that for each symbol the frequency must be larger than 0.
template<class InIter>
void update (InIter first, InIter last)
 Modifies the symbols' half-open ranges to represent the symbols' frequencies given in the range [first,last[.
UInt totalRange () const
 Returns the total range, i.e. the maximum upper range bound of any symbol in the alphabet.
UInt size () const
 Returns the number of symbols in the alphabet.
double entropy () const
 Returns the entropy of the alphabet.
UInt symbol (UInt value) const
 Returns the symbol that contains the given value.
std::pair< UInt, UInt > range (UInt symbol) const
 Returns the symbol's half-open cumulative frequency range.

Detailed Description

template<class UInt>
class Alphabet< UInt >

A simple alphabet of symbols with frequencies to be used with the range coder.

The symbols are consecutive integers 0..(size()-1). The half-open ranges associated to the symbols are derived from given frequencies of the symbols.

Definition at line 342 of file rangecoder.hh.

Constructor & Destructor Documentation

◆ Alphabet() [1/2]

template<class UInt>
template<class InIter>
Alphabet< UInt >::Alphabet ( InIter first,
InIter last )
inline

Constructs an alphabet from a sequence of frequencies of symbols. Note that for each symbol the frequency must be larger than 0.

Definition at line 350 of file rangecoder.hh.

◆ Alphabet() [2/2]

template<class UInt>
template<class InIter>
Alphabet< UInt >::Alphabet ( InIter first,
InIter last,
UInt maxRange = std::numeric_limits<UInt>::max() )
inline

Constructor. Constructs an alphabet from a sequence of frequencies of symbols. Note that for each symbol the frequency must be larger than 0.

Definition at line 91 of file alphabet.hh.

Member Function Documentation

◆ entropy()

template<class UInt>
double Alphabet< UInt >::entropy ( ) const
inline

Returns the entropy of the alphabet.

The entropy is \( H = -\sum_{s\in A} p_s \log_2 p_s \) and gives the expected number of bits/symbol with optimal coding.

Definition at line 161 of file alphabet.hh.

◆ range() [1/2]

template<class UInt>
std::pair< UInt, UInt > Alphabet< UInt >::range ( UInt symbol) const
inline

Returns the symbol's half-open cumulative frequency range.

Definition at line 403 of file rangecoder.hh.

Referenced by RangeDecoder< UInt >::decodeSymbol(), and RangeEncoder< UInt >::encodeSymbol().

◆ range() [2/2]

template<class UInt>
std::pair< UInt, UInt > Alphabet< UInt >::range ( UInt symbol) const
inline

Returns the symbol's half-open cumulative frequency range.

Definition at line 192 of file alphabet.hh.

◆ size() [1/2]

template<class UInt>
UInt Alphabet< UInt >::size ( ) const
inline

◆ size() [2/2]

template<class UInt>
UInt Alphabet< UInt >::size ( ) const
inline

Returns the number of symbols in the alphabet.

Definition at line 150 of file alphabet.hh.

◆ symbol() [1/2]

template<class UInt>
UInt Alphabet< UInt >::symbol ( UInt value) const
inline

Returns the symbol that contains the given value.

Definition at line 391 of file rangecoder.hh.

Referenced by RangeDecoder< UInt >::decodeSymbol(), and range().

◆ symbol() [2/2]

template<class UInt>
UInt Alphabet< UInt >::symbol ( UInt value) const
inline

Returns the symbol that contains the given value.

Definition at line 176 of file alphabet.hh.

◆ totalRange() [1/2]

template<class UInt>
UInt Alphabet< UInt >::totalRange ( ) const
inline

Returns the total range, i.e. the maximum upper range bound of any symbol in the alphabet.

Definition at line 375 of file rangecoder.hh.

Referenced by Alphabet(), RangeDecoder< UInt >::decodeSymbol(), RangeEncoder< UInt >::encodeSymbol(), and entropy().

◆ totalRange() [2/2]

template<class UInt>
UInt Alphabet< UInt >::totalRange ( ) const
inline

Returns the total range, i.e. the maximum upper range bound of any symbol in the alphabet.

Definition at line 142 of file alphabet.hh.

◆ update() [1/2]

template<class UInt>
template<class InIter>
void Alphabet< UInt >::update ( InIter first,
InIter last )
inline

Modifies the symbols' half-open ranges to represent the symbols' frequencies given in the range [first,last[.

Note that for each symbol the frequency must be larger than 0. The length of the given sequence must match the size of the alphabet.

Definition at line 365 of file rangecoder.hh.

Referenced by LossyStorage< Grid, VariableSet, Space, QuantizationPolicy >::decode(), LossyStorage< Grid, VariableSet, Space, QuantizationPolicy >::decode(), LossyStorage< Grid, VariableSet, Space, QuantizationPolicy >::decode(), LossyStorage< Grid, VariableSet, Space, QuantizationPolicy >::encode(), LossyStorage< Grid, VariableSet, Space, QuantizationPolicy >::encode(), and LossyStorage< Grid, VariableSet, Space, QuantizationPolicy >::encode().

◆ update() [2/2]

template<class UInt>
template<class InIter>
void Alphabet< UInt >::update ( InIter first,
InIter last )
inline

Modifies the symbols' half-open ranges to represent the symbols' frequencies given in the range [first,last[.

Note that for each symbol the frequency must be larger than 0. The length of the given sequence must match the size of the alphabet.

Definition at line 132 of file alphabet.hh.


The documentation for this class was generated from the following files: