16#ifndef DC_PRIMITIVES_H
17#define DC_PRIMITIVES_H
34#include <boost/mpl/size.hpp>
35#include <boost/mpl/range_c.hpp>
36#include <boost/mpl/string.hpp>
40namespace data_compression
54template <
typename T, std::
size_t nbits>
71template <
typename T, T _min, T _max>
73 static std::size_t
const value = boost::mpl::size<boost::mpl::range_c<T, _min, _max>>
::value + 1;
82template <std::
size_t n>
89 static std::size_t
const value = 0;
150 template <
typename ValueT>
205template <
typename T, T _min, T _max,
206 typename NameT = boost::mpl::string<
'U',
'n',
'n',
'a',
'm',
'e',
'd'>
::type
216 using range = boost::mpl::range_c<T, _min, _max>;
217 using size = boost::mpl::plus<boost::mpl::size<range>, boost::mpl::int_<1>>;
232 }
else if (_min > 0) {
247 constexpr const char*
getName()
const {
return boost::mpl::c_str<NameT>::value; }
250 template <
typename ValueT>
289 if ((
n > _max) || (_max -
n < mValue)) {
335template <
typename T, T _max,
336 typename NameT = boost::mpl::string<
'U',
'n',
'n',
'a',
'm',
'e',
'd'>
::type
348template <
typename T, std::
size_t _nbits,
typename NameT = boost::mpl::
string<'U', 'n', 'n', 'a', 'm', 'e', 'd'>::type>
357template <
class Alphabet,
typename WeightType =
double>
376 return tmp.getName();
388 mProbabilityTable.clear();
390 for (
auto i : alphabet) {
400 for (
typename TableType::iterator
i = mProbabilityTable.begin();
i != mProbabilityTable.end();
i++) {
401 totalWeight +=
i->second;
402 i->second /= mTotalWeight;
406 mTotalWeight = totalWeight / mTotalWeight;
414 typename TableType::const_iterator
i = mProbabilityTable.find(
v);
415 if (
i != mProbabilityTable.end()) {
422 typename TableType::const_iterator
begin()
const {
return mProbabilityTable.begin(); }
424 typename TableType::const_iterator
end()
const {
return mProbabilityTable.end(); }
426 typename TableType::iterator
begin() {
return mProbabilityTable.begin(); }
428 typename TableType::iterator
end() {
return mProbabilityTable.end(); }
434 WeightType mTotalWeight;
a forward iterator to access the list of elements
bool operator!=(const self_type &other) const
std::forward_iterator_tag iterator_category
bool operator==(const self_type &other) const
self_type operator+(size_type n) const
Iterator(T value, bool isEnd)
self_type operator++(int)
std::ptrdiff_t difference_type
constexpr const char * getName() const
constexpr unsigned getIndexRange()
get the range of indices aka number of indices
ContiguousAlphabet()=default
iterator begin()
return forward iterator to begin of element list
static unsigned getIndex(value_type symbol)
const_iterator begin() const
return forward iterator to begin of element list
Iterator< value_type > iterator
~ContiguousAlphabet()=default
static bool isValid(value_type v)
check for valid value within range
iterator end()
the end of element list
const_iterator end() const
the end of element list
boost::mpl::plus< boost::mpl::size< range >, boost::mpl::int_< 1 > > size
boost::mpl::range_c< T, _min, _max > range
static value_type getSymbol(unsigned index)
get symbol from index
a forward iterator to access the list of elements
std::forward_iterator_tag iterator_category
bool operator!=(const self_type &other) const
bool operator==(const self_type &other) const
std::ptrdiff_t difference_type
self_type operator++(int)
iterator begin()
return forward iterator to begin of element list
const_iterator end() const
the end of element list
const_iterator begin() const
return forward iterator to begin of element list
iterator end()
the end of element list
static unsigned getIndex(value_type symbol)
get index of value
static value_type getSymbol(unsigned index)
get symbol from index
constexpr unsigned getIndexRange()
get the range of indices aka number of indices
static bool isValid(value_type v)
check for valid value within range
TableType::const_iterator end() const
static const value_type _default0
std::map< value_type, WeightType > TableType
typename Alphabet::value_type value_type
int addWeight(value_type value, weight_type weight=_default1)
TableType::iterator begin()
const WeightType & operator[](value_type v) const
constexpr const char * getName() const
TableType::iterator end()
TableType::const_iterator begin() const
int initWeight(Alphabet &alphabet, WeightType weight=_default1)
static const value_type _default1
~ProbabilityModel()=default
GLuint GLuint GLfloat weight
GLsizei const GLfloat * value
GLint GLint GLsizei GLint GLenum GLenum type
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
Get maximum of an n-bit number.
Get number of elements in a sequence of integral types This redirects to the size meta program of the...
Get the upper binary bound of a number The gives the number of bits required to present a number.
VectorOfTObjectPtrs other