in cpc/include/cpc_compressor_impl.hpp [445:465]
uint8_t cpc_compressor<A>::determine_pseudo_phase(uint8_t lg_k, uint32_t c) {
const uint32_t k = 1 << lg_k;
// This mid-range logic produces pseudo-phases. They are used to select encoding tables.
// The thresholds were chosen by hand after looking at plots of measured compression.
if (1000 * c < 2375 * k) {
if ( 4 * c < 3 * k) return 16 + 0; // mid-range table
else if ( 10 * c < 11 * k) return 16 + 1; // mid-range table
else if ( 100 * c < 132 * k) return 16 + 2; // mid-range table
else if ( 3 * c < 5 * k) return 16 + 3; // mid-range table
else if (1000 * c < 1965 * k) return 16 + 4; // mid-range table
else if (1000 * c < 2275 * k) return 16 + 5; // mid-range table
else return 6; // steady-state table employed before its actual phase
} else { // This steady-state logic produces true phases. They are used to select
// encoding tables, and also column permutations for the "Sliding" flavor.
if (lg_k < 4) throw std::logic_error("lgK < 4");
const size_t tmp = c >> (lg_k - 4);
const uint8_t phase = tmp & 15;
if (phase >= 16) throw std::out_of_range("wrong phase");
return phase;
}
}