Template Function ADS::arithmeticEncode

Function Documentation

template<class C>
std::vector<std::uint8_t> ADS::arithmeticEncode(std::span<const C> text, const std::map<C, std::uint64_t> &counts, int w = 32)

the arithmetic code of text with the static model of the counts

Pre:

the counts positive with total at most 2^( w - 2 ), each symbol of text in counts, 2 <= w <= 32

Post:

arithmeticDecode( result , text.size() , counts , w ) == text (an audit)