ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches

Prediction by partial matching (chapter 12, Statistical Coding, of Ferragina's book), the model of contexts of Cleary and Witten in the version C of Moffat, on the arithmetic coder. More...

Files

file  ADS/compression/PPM.h
 Prediction by partial matching (chapter 12, Statistical Coding, of Ferragina's book), the model of contexts of Cleary and Witten in the version C of Moffat, on the arithmetic coder [see ArithmeticCoding.h].

Classes

class  ADS::PPMModel
 the model of contexts of PPM, version C with exclusion, of order \( K \) on the symbols \( [ 0 , \sigma ) \) More...

Functions

std::vector< std::uint8_t > ADS::ppmEncode (std::string_view s, int K)
 the code of the bytes of \( s \) by PPM of order \( K \)
std::string ADS::ppmDecode (std::span< const std::uint8_t > code, std::size_t n, int K)
 the \( n \) bytes of the code by PPM of order \( K \)

Detailed description

Prediction by partial matching (chapter 12, Statistical Coding, of Ferragina's book), the model of contexts of Cleary and Witten in the version C of Moffat, on the arithmetic coder.

The definitions, the invariants and the costs of the area are in Theory of compression.

Function documentation

◆ ppmDecode()

std::string ADS::ppmDecode ( std::span< const std::uint8_t > code,
std::size_t n,
int K )
inlinenodiscard

the \( n \) bytes of the code by PPM of order \( K \)

In pseudocode (chapter 12, Statistical Coding, of Ferragina's book), the model of the encoder rebuilt symbol by symbol:

\[\class{pseudocode}{\begin{array}{r@{\quad}l} 1 & \textbf{function}\ \mathrm{ppmDecode}( y , n , K ) \cr 2 & \quad M \gets \text{a } \mathrm{PPMModel} \text{ of order } K; \ D \gets \text{a } \mathrm{RangeDecoder} \text{ of } y \cr 3 & \quad \textbf{for}\ i \gets 1\ \textbf{to}\ n\ \textbf{do}\ s[ i ] \gets M.\mathrm{decode}( D );\ M.\mathrm{update}( s[ i ] ) \cr 4 & \quad \textbf{return}\ s \end{array}} \]

Precondition
\( K \ge 0 \)

◆ ppmEncode()

std::vector< std::uint8_t > ADS::ppmEncode ( std::string_view s,
int K )
inlinenodiscard

the code of the bytes of \( s \) by PPM of order \( K \)

In pseudocode (chapter 12, Statistical Coding, of Ferragina's book):

\[\class{pseudocode}{\begin{array}{r@{\quad}l} 1 & \textbf{function}\ \mathrm{ppmEncode}( s , K ) \cr 2 & \quad M \gets \text{a } \mathrm{PPMModel} \text{ of order } K; \ E \gets \text{a } \mathrm{RangeEncoder} \cr 3 & \quad \textbf{foreach}\ c \in s\ \textbf{do}\ M.\mathrm{encode}( c , E );\ M.\mathrm{update}( c ) \cr 4 & \quad \textbf{return}\ E.\mathrm{finish}() \end{array}} \]

Precondition
\( K \ge 0 \)
Postcondition
ppmDecode( result , s.size() , K ) is \( s \) (audit)