56 using source_type =
typename histogram_T::source_type;
57 std::vector<source_type>
samples{};
61 auto makeSymbolTable = [](
const histogram_T& hist) {
62 using source_type =
typename histogram_T::source_type;
63 if constexpr (std::is_same_v<histogram_T, DenseHistogram<source_type>>) {
65 }
else if constexpr (std::is_same_v<histogram_T, AdaptiveHistogram<source_type>>) {
68 static_assert(std::is_same_v<histogram_T, SparseHistogram<source_type>>);
73 const auto symbolTable = makeSymbolTable(
f);
78 const auto escapeSymbol = symbolTable.getEscapeSymbol();
84 for (
auto iter = symbolTable.begin(); iter != symbolTable.end(); ++iter) {
89 const int outOfRangeSymbols[] = {-100, 100};
90 for (
auto symbol : outOfRangeSymbols) {
91 const auto outOfRange = symbolTable[symbol];
100 using source_type =
typename histogram_T::source_type;
102 std::vector<uint32_t> frequencies{1, 1, 2, 2, 2, 2, 6, 8, 4, 10, 8, 14, 10, 19, 26, 30, 31, 35, 41, 45, 51, 44, 47, 39, 58, 52, 42, 53, 50, 34, 50, 30, 32, 24, 30, 20, 17, 12, 16, 6, 8, 5, 6, 4, 4, 2, 2, 2, 1};
103 histogram_T histogram{frequencies.begin(), frequencies.end(),
static_cast<uint8_t
>(0)};
104 const size_t scaleBits = 8;
106 auto makeSymbolTable = [](histogram_T&& hist,
size_t scaleBits,
RenormingPolicy renormingPolicy,
size_t cutoff) {
107 using source_type =
typename histogram_T::source_type;
108 if constexpr (std::is_same_v<histogram_T, DenseHistogram<source_type>>) {
110 }
else if constexpr (std::is_same_v<histogram_T, AdaptiveHistogram<source_type>>) {
113 static_assert(std::is_same_v<histogram_T, SparseHistogram<source_type>>);
118 const auto symbolTable = makeSymbolTable(std::move(histogram), scaleBits, RenormingPolicy::ForceIncompressible, 1);
120 const std::vector<uint32_t> rescaledFrequencies{1, 2, 1, 3, 2, 3, 3, 5, 6, 7, 8, 9, 10, 11, 13, 11, 12, 10, 14, 13, 10, 13, 12, 8, 12, 7, 8, 6, 7, 5, 4, 3, 4, 2, 2, 1, 2, 1, 1};
121 std::vector<uint32_t> cumulativeFrequencies;
122 std::exclusive_scan(rescaledFrequencies.begin(), rescaledFrequencies.end(), std::back_inserter(cumulativeFrequencies), 0);
127 auto symbol = symbolTable[
index + 6];
132 const auto escapeSymbol = symbolTable.getEscapeSymbol();
134 BOOST_CHECK_EQUAL(escapeSymbol.getCumulative(), cumulativeFrequencies.back() + rescaledFrequencies.back());
137 const int outOfRangeSymbols[] = {-100, 100};
138 for (
auto symbol : outOfRangeSymbols) {
139 const auto escapeSymbol = symbolTable.getEscapeSymbol();
140 const auto outOfRange = symbolTable[symbol];