12template <
class SymbolType >
15 unsigned m_global_high;
19 unsigned frequency = 0;
22 m_global_high = frequency + 1;
26 for (
auto i = m_high_cumulative_frequency.find ( symbol );
i != m_high_cumulative_frequency.
end ( ) ; ++
i )
32 auto i = m_high_cumulative_frequency.find ( c );
33 high_prob =
i->second;
36 if (
i != m_high_cumulative_frequency.
begin ( ) )
37 low_prob = std::prev (
i )->second;
41 low_prob = m_global_high - 1;
42 high_prob = m_global_high;
45 SymbolType getChar (
unsigned scaled_value,
unsigned & low_prob,
unsigned & high_prob )
const {
46 for (
auto i = m_high_cumulative_frequency.
begin ( );
i != m_high_cumulative_frequency.
end ( ); ++
i )
47 if ( scaled_value < i->
second ) {
48 high_prob =
i->second;
51 if (
i != m_high_cumulative_frequency.
begin ( ) )
52 low_prob = std::prev (
i )->second;
56 throw std::logic_error(
"error");
59 bool isEof (
unsigned scaled_value )
const {
60 return scaled_value == m_global_high - 1;
Definition: ArithmeticModel.h:13
void update(const SymbolType &symbol)
Definition: ArithmeticModel.h:25
void getProbability(const SymbolType &c, unsigned &low_prob, unsigned &high_prob) const
Definition: ArithmeticModel.h:31
bool isEof(unsigned scaled_value) const
Definition: ArithmeticModel.h:59
void getProbabilityEof(unsigned &low_prob, unsigned &high_prob) const
Definition: ArithmeticModel.h:40
ArithmeticModel(const ext::set< SymbolType > &alphabet)
Definition: ArithmeticModel.h:18
unsigned getCount() const
Definition: ArithmeticModel.h:63
SymbolType getChar(unsigned scaled_value, unsigned &low_prob, unsigned &high_prob) const
Definition: ArithmeticModel.h:45
Class extending the map class from the standard library. Original reason is to allow printing of the ...
Definition: map.hpp:48
auto begin() &
Inherited behavior of begin for non-const instance.
Definition: map.hpp:185
std::pair< iterator, bool > insert(const T &key, const R &value)
Insert variant with explicit key and value parameters.
Definition: map.hpp:118
auto end() &
Inherited behavior of end for non-const instance.
Definition: map.hpp:215
Definition: BarSymbol.cpp:12
p second
Definition: ToRegExpAlgebraic.h:126
int i
Definition: AllEpsilonClosure.h:118
typename T::SymbolType SymbolType
Definition: ReachableStates.h:176
constexpr auto make_pair(T1 &&x, T2 &&y)
Definition: pair.hpp:79