28 static int gammaHits=0;
31 static int gammaMisses=0;
36 #define LNPI_2 M_LNPI / 2
53 if (index >= 0 && index <
TBL_SIZE) {
63 return gsl_sf_lngamma(n);
77 if (index >= 0 && index <
TBL_SIZE) {
87 return gsl_sf_lngamma(n + 0.5);
98 double sum = 0, gamma1, gamma2, gamma3;
102 ns += stats->
count[i];
105 if (alphasize % 2 == 0) {
107 gamma2 = alpha_2 * M_LNPI;
112 gamma2 = (alpha_2 + 0.5) * M_LNPI;
116 return (gamma1 + gamma2 - gamma3 - sum) / M_LN2;
126 double loghalf = -0.6931471805599452862;
146 double loghalf = -0.6931471805599452862;
149 ns += distinct[stats->
symbols[i]];
150 if (distinct[stats->
symbols[i]] > 0) {
static double alphasizeLog
Log2 of the alphabet size.
Uint * count
List with the number of occurrences of each character in this state.
double escapeCost(statistics_t stats, Uint *distinct)
Calculates the cost of escapes in a node.
double kt(statistics_t stats)
Calculates the Krichevsky-Trofimov probability assignment.
static double evalLogGamma(int n)
Calculates Ln (gamma(n)).
double hAlpha()
Returns the binary entropy of 1/alphasize.
double log2Alpha()
Returns the log2 of the alphabet size.
Uint alphasize
Alphabet size.
unsigned long Uint
Unsigned int type.
Uint symbolCount
Number of occuring symbols.
#define TBL_SIZE
Size of the lookup tables.
#define LNPI_2
Ln of PI/2.
static double alphaEntropy
Binary entropy of 1/alphasize.
double logGammaTbl2[TBL_SIZE]
logGammaTbl[i] = ln(gamma(i + 1 + 1/2)).
static double evalLogGamma2(int n)
Calculates Ln (gamma(n + 1/2)).
Structure that saves statistics for each tree node in the encoder.
Uchar * symbols
List of occuring symbols.
double logGammaTbl[TBL_SIZE]
logGammaTbl[i] = ln(gamma(i+2)).
double nodeCost(statistics_t stats)
Calculates the cost of a node.