12 #if !defined(RANDOMLIB_EXACTEXPONENTIAL_HPP)
13 #define RANDOMLIB_EXACTEXPONENTIAL_HPP 1
19 # pragma warning (push)
20 # pragma warning (disable: 4127)
188 template<
class Random>
bool
207 while (!ExpFraction(r, _x)) {
211 if (k & 1) _x.RawDigit(0) += 1U << (bits - 1);
212 _x.AddInteger(k >> 1);
216 template<
int bits>
template<
class Random>
bool
220 if (p.
Digit(r, 0) >> (bits - 1))
return false;
223 if (!_w.LessThan(r, p))
227 if (!_v.LessThan(r, _w))
230 if (!_w.LessThan(r, _v))
237 #if defined(_MSC_VER)
238 # pragma warning (pop)
241 #endif // RANDOMLIB_EXACTEXPONENTIAL_HPP
Generate random integers, reals, and booleans.
Infinite precision random numbers.
RandomNumber< bits > operator()(Random &r) const
unsigned Digit(Random &r, unsigned k)
Sample exactly from an exponential distribution.