32#ifndef _GLIBCXX_PARALLEL_RANDOM_NUMBER_H
33#define _GLIBCXX_PARALLEL_RANDOM_NUMBER_H 1
45 std::tr1::mt19937 _M_mt;
48 double _M_supremum_reciprocal;
49 double _M_rand_sup_reciprocal;
58 __scale_down(uint64_t __x,
60 uint64_t ,
double _M_supremum_reciprocal)
62 uint64_t _M_supremum,
double )
65#if _GLIBCXX_SCALE_DOWN_FPU
66 return uint32_t(__x * _M_supremum_reciprocal);
68 return static_cast<uint32_t
>(__x % _M_supremum);
75 : _M_mt(0), _M_supremum(0x100000000ULL),
76 _M_rand_sup(1ULL <<
std::numeric_limits<uint32_t>::digits),
77 _M_supremum_reciprocal(double(_M_supremum) / double(_M_rand_sup)),
78 _M_rand_sup_reciprocal(1.0 / double(_M_rand_sup)),
79 __cache(0), __bits_left(0) { }
86 : _M_mt(__seed), _M_supremum(_M_supremum),
87 _M_rand_sup(1ULL <<
std::numeric_limits<uint32_t>::digits),
88 _M_supremum_reciprocal(double(_M_supremum) / double(_M_rand_sup)),
89 _M_rand_sup_reciprocal(1.0 / double(_M_rand_sup)),
90 __cache(0), __bits_left(0) { }
95 {
return __scale_down(_M_mt(), _M_supremum, _M_supremum_reciprocal); }
102 return __scale_down(_M_mt(), local_supremum,
103 double(local_supremum * _M_rand_sup_reciprocal));
111 unsigned long __res = __cache & ((1 << __bits) - 1);
112 __cache = __cache >> __bits;
113 __bits_left -= __bits;
114 if (__bits_left < 32)
116 __cache |= ((uint64_t(_M_mt())) << __bits_left);
Basic types and typedefs. This file is a GNU parallel extension to the Standard C++ Library.
#define _GLIBCXX_SCALE_DOWN_FPU
Use floating-point scaling instead of modulo for mapping random numbers to a range....
ISO C++ entities toplevel namespace is std.
GNU parallel code for public use.
Random number generator, based on the Mersenne twister.
unsigned long __genrand_bits(int __bits)
Generate a number of random bits, run-time parameter.
uint32_t operator()(uint64_t local_supremum)
Generate unsigned random 32-bit integer in the interval [0,local_supremum).
uint32_t operator()()
Generate unsigned random 32-bit integer.
_RandomNumber()
Default constructor. Seed with 0.
_RandomNumber(uint32_t __seed, uint64_t _M_supremum=0x100000000ULL)
Constructor.