32 #ifndef _GLIBCXX_PARALLEL_RANDOM_NUMBER_H
33 #define _GLIBCXX_PARALLEL_RANDOM_NUMBER_H 1
39 namespace __gnu_parallel
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);