20 #ifndef _HARMONICNUMBERS_INTERNAL_HPP_
21 #define _HARMONICNUMBERS_INTERNAL_HPP_
23 #include "HarmonicNumbers.hpp"
30 double HarmonicNumbers<A>::getBitMapEstimate(
const int bitVectorLength,
const int numBitsSet) {
31 return (bitVectorLength * (harmonicNumber(bitVectorLength) - harmonicNumber(bitVectorLength - numBitsSet)));
34 static const int NUM_EXACT_HARMONIC_NUMBERS = 25;
36 static double tableOfExactHarmonicNumbers[] = {
54 42142223.0 / 12252240.0,
55 14274301.0 / 4084080.0,
56 275295799.0 / 77597520.0,
57 55835135.0 / 15519504.0,
58 18858053.0 / 5173168.0,
59 19093197.0 / 5173168.0,
60 444316699.0 / 118982864.0,
61 1347822955.0 / 356948592.0
64 static const double EULER_MASCHERONI_CONSTANT = 0.577215664901532860606512090082;
67 double HarmonicNumbers<A>::harmonicNumber(
const uint64_t x_i) {
68 if (x_i < NUM_EXACT_HARMONIC_NUMBERS) {
69 return tableOfExactHarmonicNumbers[x_i];
71 double x =
static_cast<double>(x_i);
72 double invSq = 1.0 / (x * x);
73 double sum = log(x) + EULER_MASCHERONI_CONSTANT + (1.0 / (2.0 * x));
77 sum -= pow * (1.0 / 12.0);
79 sum += pow * (1.0 / 120.0);
81 sum -= pow * (1.0 / 252.0);
83 sum += pow * (1.0 / 240.0);
DataSketches namespace.
Definition: binomial_bounds.hpp:38