10 #if !defined(EXRANDOM_UNIT_EXPONENTIAL_DIST_HPP) 11 #define EXRANDOM_UNIT_EXPONENTIAL_DIST_HPP 1 17 # pragma warning (push) 18 # pragma warning (disable: 4127) 42 template<
typename digit_gen,
bool bit_optimized = true>
59 template<
typename Generator>
69 if (bit_optimized && (k % 2) != 0) x.
rawdigit(0) += (bm1 - 1U) / 2U + 1U;
82 template<
typename RealType,
typename Generator>
85 return _x.template value<RealType>(g);
96 static const uint_t
base = digit_gen::base;
98 static const uint_t bm1 = digit_gen::max_value;
102 static_assert(!bit_optimized || (bm1 & 1U),
103 "unit_exponential_dist: base must be even");
105 template<
typename Generator>
111 if (!_w.
init().less_than(g, p))
return true;
113 if (!_v.
init().less_than(g, _w))
return false;
114 if (!_w.
init().less_than(g, _v))
return true;
122 #if defined(_MSC_VER) 123 # pragma warning (pop) 126 #endif // EXRANDOM_UNIT_EXPONENTIAL_DIST_HPP void generate(Generator &g, u_rand< digit_gen > &x)
Sample u-rands exactly from the unit exponential distribution.
digit_gen & digit_generator() const
uint_t rawdigit(size_t k) const
RealType value(Generator &g)
The machinery to handle u-rands, arbitrary precision random deviates.
void set_integer(unsigned n)
bool less_than_half(Generator &g)
unit_exponential_dist(digit_gen &D)