35namespace std _GLIBCXX_VISIBILITY(default)
37_GLIBCXX_BEGIN_NAMESPACE_VERSION
49 template<
typename _Tp, _Tp __m, _Tp __a, _Tp __c>
51 _Mod<_Tp, __m, __a, __c, false, true>::
58 static const _Tp __q = __m / __a;
59 static const _Tp __r = __m % __a;
61 _Tp __t1 = __a * (__x % __q);
62 _Tp __t2 = __r * (__x / __q);
66 __x = __m - __t2 + __t1;
71 const _Tp __d = __m - __x;
80 template<
typename _InputIterator,
typename _OutputIterator,
83 __normalize(_InputIterator __first, _InputIterator __last,
84 _OutputIterator __result,
const _Tp& __factor)
86 for (; __first != __last; ++__first, ++__result)
87 *__result = *__first / __factor;
94#if ! __cpp_inline_variables
95 template<
typename _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
99 template<
typename _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
103 template<
typename _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
107 template<
typename _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
109 linear_congruential_engine<_UIntType, __a, __c, __m>::default_seed;
116 template<
typename _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
121 if ((__detail::__mod<_UIntType, __m>(__c) == 0)
122 && (__detail::__mod<_UIntType, __m>(
__s) == 0))
125 _M_x = __detail::__mod<_UIntType, __m>(
__s);
131 template<
typename _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
132 template<
typename _Sseq>
140 const _UIntType
__k = (
__k0 + 31) / 32;
145 for (
size_t __j = 0; __j <
__k; ++__j)
148 __factor *= __detail::_Shift<_UIntType, 32>::__value;
153 template<
typename _UIntType, _UIntType __a, _UIntType __c, _UIntType
__m,
154 typename _CharT,
typename _Traits>
162 const typename __ios_base::fmtflags __flags =
__os.flags();
163 const _CharT __fill =
__os.fill();
164 __os.flags(__ios_base::dec | __ios_base::fixed | __ios_base::left);
174 template<
typename _UIntType, _UIntType __a, _UIntType __c, _UIntType __m,
175 typename _CharT,
typename _Traits>
178 linear_congruential_engine<_UIntType, __a, __c, __m>& __lcr)
180 using __ios_base =
typename basic_istream<_CharT, _Traits>::ios_base;
182 const typename __ios_base::fmtflags __flags = __is.flags();
183 __is.flags(__ios_base::dec);
191#if ! __cpp_inline_variables
192 template<
typename _UIntType,
193 size_t __w,
size_t __n,
size_t __m,
size_t __r,
194 _UIntType __a,
size_t __u, _UIntType __d,
size_t __s,
195 _UIntType __b,
size_t __t, _UIntType __c,
size_t __l,
198 mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d,
199 __s, __b, __t, __c, __l, __f>::word_size;
201 template<
typename _UIntType,
202 size_t __w,
size_t __n,
size_t __m,
size_t __r,
203 _UIntType __a,
size_t __u, _UIntType __d,
size_t __s,
204 _UIntType __b,
size_t __t, _UIntType __c,
size_t __l,
207 mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d,
208 __s, __b, __t, __c, __l, __f>::state_size;
210 template<
typename _UIntType,
211 size_t __w,
size_t __n,
size_t __m,
size_t __r,
212 _UIntType __a,
size_t __u, _UIntType __d,
size_t __s,
213 _UIntType __b,
size_t __t, _UIntType __c,
size_t __l,
216 mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d,
217 __s, __b, __t, __c, __l, __f>::shift_size;
219 template<
typename _UIntType,
220 size_t __w,
size_t __n,
size_t __m,
size_t __r,
221 _UIntType __a,
size_t __u, _UIntType __d,
size_t __s,
222 _UIntType __b,
size_t __t, _UIntType __c,
size_t __l,
225 mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d,
226 __s, __b, __t, __c, __l, __f>::mask_bits;
228 template<
typename _UIntType,
229 size_t __w,
size_t __n,
size_t __m,
size_t __r,
230 _UIntType __a,
size_t __u, _UIntType __d,
size_t __s,
231 _UIntType __b,
size_t __t, _UIntType __c,
size_t __l,
234 mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d,
235 __s, __b, __t, __c, __l, __f>::xor_mask;
237 template<
typename _UIntType,
238 size_t __w,
size_t __n,
size_t __m,
size_t __r,
239 _UIntType __a,
size_t __u, _UIntType __d,
size_t __s,
240 _UIntType __b,
size_t __t, _UIntType __c,
size_t __l,
243 mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d,
244 __s, __b, __t, __c, __l, __f>::tempering_u;
246 template<
typename _UIntType,
247 size_t __w,
size_t __n,
size_t __m,
size_t __r,
248 _UIntType __a,
size_t __u, _UIntType __d,
size_t __s,
249 _UIntType __b,
size_t __t, _UIntType __c,
size_t __l,
252 mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d,
253 __s, __b, __t, __c, __l, __f>::tempering_d;
255 template<
typename _UIntType,
256 size_t __w,
size_t __n,
size_t __m,
size_t __r,
257 _UIntType __a,
size_t __u, _UIntType __d,
size_t __s,
258 _UIntType __b,
size_t __t, _UIntType __c,
size_t __l,
261 mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d,
262 __s, __b, __t, __c, __l, __f>::tempering_s;
264 template<
typename _UIntType,
265 size_t __w,
size_t __n,
size_t __m,
size_t __r,
266 _UIntType __a,
size_t __u, _UIntType __d,
size_t __s,
267 _UIntType __b,
size_t __t, _UIntType __c,
size_t __l,
270 mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d,
271 __s, __b, __t, __c, __l, __f>::tempering_b;
273 template<
typename _UIntType,
274 size_t __w,
size_t __n,
size_t __m,
size_t __r,
275 _UIntType __a,
size_t __u, _UIntType __d,
size_t __s,
276 _UIntType __b,
size_t __t, _UIntType __c,
size_t __l,
279 mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d,
280 __s, __b, __t, __c, __l, __f>::tempering_t;
282 template<
typename _UIntType,
283 size_t __w,
size_t __n,
size_t __m,
size_t __r,
284 _UIntType __a,
size_t __u, _UIntType __d,
size_t __s,
285 _UIntType __b,
size_t __t, _UIntType __c,
size_t __l,
288 mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d,
289 __s, __b, __t, __c, __l, __f>::tempering_c;
291 template<
typename _UIntType,
292 size_t __w,
size_t __n,
size_t __m,
size_t __r,
293 _UIntType __a,
size_t __u, _UIntType __d,
size_t __s,
294 _UIntType __b,
size_t __t, _UIntType __c,
size_t __l,
297 mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d,
298 __s, __b, __t, __c, __l, __f>::tempering_l;
300 template<
typename _UIntType,
301 size_t __w,
size_t __n,
size_t __m,
size_t __r,
302 _UIntType __a,
size_t __u, _UIntType __d,
size_t __s,
303 _UIntType __b,
size_t __t, _UIntType __c,
size_t __l,
306 mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d,
307 __s, __b, __t, __c, __l, __f>::
308 initialization_multiplier;
310 template<
typename _UIntType,
311 size_t __w,
size_t __n,
size_t __m,
size_t __r,
312 _UIntType __a,
size_t __u, _UIntType __d,
size_t __s,
313 _UIntType __b,
size_t __t, _UIntType __c,
size_t __l,
316 mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d,
317 __s, __b, __t, __c, __l, __f>::default_seed;
320 template<
typename _UIntType,
321 size_t __w,
size_t __n,
size_t __m,
size_t __r,
322 _UIntType __a,
size_t __u, _UIntType __d,
size_t __s,
323 _UIntType __b,
size_t __t, _UIntType __c,
size_t __l,
326 mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d,
327 __s, __b, __t, __c, __l, __f>::
328 seed(result_type __sd)
330 _M_x[0] = __detail::__mod<_UIntType,
331 __detail::_Shift<_UIntType, __w>::__value>(__sd);
333 for (
size_t __i = 1; __i < state_size; ++__i)
335 _UIntType __x = _M_x[__i - 1];
336 __x ^= __x >> (__w - 2);
338 __x += __detail::__mod<_UIntType, __n>(__i);
339 _M_x[__i] = __detail::__mod<_UIntType,
340 __detail::_Shift<_UIntType, __w>::__value>(__x);
345 template<
typename _UIntType,
346 size_t __w,
size_t __n,
size_t __m,
size_t __r,
347 _UIntType __a,
size_t __u, _UIntType __d,
size_t __s,
348 _UIntType __b,
size_t __t, _UIntType __c,
size_t __l,
350 template<
typename _Sseq>
352 mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d,
353 __s, __b, __t, __c, __l, __f>::
355 -> _If_seed_seq<_Sseq>
357 const _UIntType __upper_mask = (~_UIntType()) << __r;
358 const size_t __k = (__w + 31) / 32;
359 uint_least32_t __arr[__n * __k];
360 __q.generate(__arr + 0, __arr + __n * __k);
363 for (
size_t __i = 0; __i < state_size; ++__i)
365 _UIntType __factor = 1u;
366 _UIntType __sum = 0u;
367 for (
size_t __j = 0; __j < __k; ++__j)
369 __sum += __arr[__k * __i + __j] * __factor;
370 __factor *= __detail::_Shift<_UIntType, 32>::__value;
372 _M_x[__i] = __detail::__mod<_UIntType,
373 __detail::_Shift<_UIntType, __w>::__value>(__sum);
379 if ((_M_x[0] & __upper_mask) != 0u)
382 else if (_M_x[__i] != 0u)
387 _M_x[0] = __detail::_Shift<_UIntType, __w - 1>::__value;
391 template<
typename _UIntType,
size_t __w,
392 size_t __n,
size_t __m,
size_t __r,
393 _UIntType __a,
size_t __u, _UIntType __d,
size_t __s,
394 _UIntType __b,
size_t __t, _UIntType __c,
size_t __l,
397 mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d,
398 __s, __b, __t, __c, __l, __f>::
401 const _UIntType __upper_mask = (~_UIntType()) << __r;
402 const _UIntType __lower_mask = ~__upper_mask;
404 for (
size_t __k = 0; __k < (__n - __m); ++__k)
406 _UIntType __y = ((_M_x[__k] & __upper_mask)
407 | (_M_x[__k + 1] & __lower_mask));
408 _M_x[__k] = (_M_x[__k + __m] ^ (__y >> 1)
409 ^ ((__y & 0x01) ? __a : 0));
412 for (
size_t __k = (__n - __m); __k < (__n - 1); ++__k)
414 _UIntType __y = ((_M_x[__k] & __upper_mask)
415 | (_M_x[__k + 1] & __lower_mask));
416 _M_x[__k] = (_M_x[__k + (__m - __n)] ^ (__y >> 1)
417 ^ ((__y & 0x01) ? __a : 0));
420 _UIntType __y = ((_M_x[__n - 1] & __upper_mask)
421 | (_M_x[0] & __lower_mask));
422 _M_x[__n - 1] = (_M_x[__m - 1] ^ (__y >> 1)
423 ^ ((__y & 0x01) ? __a : 0));
427 template<
typename _UIntType,
size_t __w,
428 size_t __n,
size_t __m,
size_t __r,
429 _UIntType __a,
size_t __u, _UIntType __d,
size_t __s,
430 _UIntType __b,
size_t __t, _UIntType __c,
size_t __l,
433 mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d,
435 discard(
unsigned long long __z)
437 while (
__z > state_size - _M_p)
439 __z -= state_size - _M_p;
445 template<
typename _UIntType,
size_t __w,
446 size_t __n,
size_t __m,
size_t __r,
447 _UIntType __a,
size_t __u, _UIntType __d,
size_t __s,
448 _UIntType __b,
size_t __t, _UIntType __c,
size_t __l,
452 __s, __b, __t, __c,
__l, __f>::result_type
454 __s, __b, __t, __c,
__l, __f>::
458 if (_M_p >= state_size)
462 result_type
__z = _M_x[_M_p++];
465 __z ^= (
__z << __t) & __c;
471 template<
typename _UIntType,
size_t __w,
472 size_t __n,
size_t __m,
size_t __r,
473 _UIntType __a,
size_t __u, _UIntType __d,
size_t __s,
474 _UIntType __b,
size_t __t, _UIntType __c,
size_t __l,
475 _UIntType __f,
typename _CharT,
typename _Traits>
478 const mersenne_twister_engine<_UIntType, __w, __n, __m,
479 __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>& __x)
481 using __ios_base =
typename basic_ostream<_CharT, _Traits>::ios_base;
483 const typename __ios_base::fmtflags __flags = __os.flags();
484 const _CharT __fill = __os.fill();
485 const _CharT __space = __os.widen(
' ');
486 __os.flags(__ios_base::dec | __ios_base::fixed | __ios_base::left);
489 for (
size_t __i = 0; __i < __n; ++__i)
490 __os << __x._M_x[__i] << __space;
498 template<
typename _UIntType,
size_t __w,
499 size_t __n,
size_t __m,
size_t __r,
500 _UIntType __a,
size_t __u, _UIntType __d,
size_t __s,
501 _UIntType __b,
size_t __t, _UIntType __c,
size_t __l,
502 _UIntType __f,
typename _CharT,
typename _Traits>
505 mersenne_twister_engine<_UIntType, __w, __n, __m,
506 __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>& __x)
508 using __ios_base =
typename basic_istream<_CharT, _Traits>::ios_base;
510 const typename __ios_base::fmtflags __flags = __is.flags();
511 __is.flags(__ios_base::dec | __ios_base::skipws);
513 for (
size_t __i = 0; __i < __n; ++__i)
514 __is >> __x._M_x[__i];
521#if ! __cpp_inline_variables
522 template<
typename _UIntType,
size_t __w,
size_t __s,
size_t __r>
524 subtract_with_carry_engine<_UIntType, __w, __s, __r>::word_size;
526 template<
typename _UIntType,
size_t __w,
size_t __s,
size_t __r>
528 subtract_with_carry_engine<_UIntType, __w, __s, __r>::short_lag;
530 template<
typename _UIntType,
size_t __w,
size_t __s,
size_t __r>
532 subtract_with_carry_engine<_UIntType, __w, __s, __r>::long_lag;
534 template<
typename _UIntType,
size_t __w,
size_t __s,
size_t __r>
535 constexpr uint_least32_t
536 subtract_with_carry_engine<_UIntType, __w, __s, __r>::default_seed;
539 template<
typename _UIntType,
size_t __w,
size_t __s,
size_t __r>
548 __lcg(__value == 0
u ? default_seed : __value % 2147483563u);
550 const size_t __n = (
__w + 31) / 32;
552 for (
size_t __i = 0; __i < long_lag; ++__i)
556 for (
size_t __j = 0; __j < __n; ++__j)
558 __sum += __detail::__mod<uint_least32_t,
559 __detail::_Shift<uint_least32_t, 32>::__value>
561 __factor *= __detail::_Shift<_UIntType, 32>::__value;
563 _M_x[__i] = __detail::__mod<_UIntType,
564 __detail::_Shift<_UIntType, __w>::__value>(
__sum);
566 _M_carry = (_M_x[long_lag - 1] == 0) ? 1 : 0;
570 template<
typename _UIntType,
size_t __w,
size_t __s,
size_t __r>
571 template<
typename _Sseq>
577 const size_t __k = (
__w + 31) / 32;
581 for (
size_t __i = 0; __i < long_lag; ++__i)
585 for (
size_t __j = 0; __j <
__k; ++__j)
588 __factor *= __detail::_Shift<_UIntType, 32>::__value;
590 _M_x[__i] = __detail::__mod<_UIntType,
591 __detail::_Shift<_UIntType, __w>::__value>(
__sum);
593 _M_carry = (_M_x[long_lag - 1] == 0) ? 1 : 0;
597 template<
typename _UIntType,
size_t __w,
size_t __s,
size_t __r>
604 long __ps = _M_p - short_lag;
612 if (_M_x[
__ps] >= _M_x[_M_p] + _M_carry)
614 __xi = _M_x[
__ps] - _M_x[_M_p] - _M_carry;
619 __xi = (__detail::_Shift<_UIntType, __w>::__value
620 - _M_x[_M_p] - _M_carry + _M_x[
__ps]);
626 if (++_M_p >= long_lag)
632 template<
typename _UIntType,
size_t __w,
size_t __s,
size_t __r,
633 typename _CharT,
typename _Traits>
641 const typename __ios_base::fmtflags __flags =
__os.flags();
642 const _CharT __fill =
__os.fill();
644 __os.flags(__ios_base::dec | __ios_base::fixed | __ios_base::left);
647 for (
size_t __i = 0; __i < __r; ++__i)
656 template<
typename _UIntType,
size_t __w,
size_t __s,
size_t __r,
657 typename _CharT,
typename _Traits>
660 subtract_with_carry_engine<_UIntType, __w, __s, __r>& __x)
662 using __ios_base =
typename basic_istream<_CharT, _Traits>::ios_base;
664 const typename __ios_base::fmtflags __flags = __is.flags();
665 __is.flags(__ios_base::dec | __ios_base::skipws);
667 for (
size_t __i = 0; __i < __r; ++__i)
668 __is >> __x._M_x[__i];
669 __is >> __x._M_carry;
676#if ! __cpp_inline_variables
677 template<
typename _RandomNumberEngine,
size_t __p,
size_t __r>
679 discard_block_engine<_RandomNumberEngine, __p, __r>::block_size;
681 template<
typename _RandomNumberEngine,
size_t __p,
size_t __r>
683 discard_block_engine<_RandomNumberEngine, __p, __r>::used_block;
686 template<
typename _RandomNumberEngine,
size_t __p,
size_t __r>
687 typename discard_block_engine<_RandomNumberEngine,
688 __p, __r>::result_type
692 if (_M_n >= used_block)
694 _M_b.discard(block_size - _M_n);
701 template<
typename _RandomNumberEngine,
size_t __p,
size_t __r,
702 typename _CharT,
typename _Traits>
710 const typename __ios_base::fmtflags __flags =
__os.flags();
711 const _CharT __fill =
__os.fill();
713 __os.flags(__ios_base::dec | __ios_base::fixed | __ios_base::left);
723 template<
typename _RandomNumberEngine,
size_t __p,
size_t __r,
724 typename _CharT,
typename _Traits>
727 discard_block_engine<_RandomNumberEngine, __p, __r>& __x)
729 using __ios_base =
typename basic_istream<_CharT, _Traits>::ios_base;
731 const typename __ios_base::fmtflags __flags = __is.flags();
732 __is.flags(__ios_base::dec | __ios_base::skipws);
734 __is >> __x._M_b >> __x._M_n;
741 template<
typename _RandomNumberEngine,
size_t __w,
typename _UIntType>
742 typename independent_bits_engine<_RandomNumberEngine, __w, _UIntType>::
747 typedef typename _RandomNumberEngine::result_type
_Eresult_type;
750 ? _M_b.max() - _M_b.min() + 1 : 0);
761 for (
size_t __i = 0; __i < 2; ++__i)
765 const unsigned __w0 =
__w / __n;
795 __u = _M_b() - _M_b.min();
803 __u = _M_b() - _M_b.min();
810#if ! __cpp_inline_variables
811 template<
typename _RandomNumberEngine,
size_t __k>
819 template<
typename _Tp>
821 __representable_as_double(_Tp __x)
noexcept
828 || (!(__x & 1) && __detail::__representable_as_double(__x >> 1));
832 template<
typename _Tp>
834 __p1_representable_as_double(_Tp __x)
noexcept
840 && __detail::__representable_as_double(__x + 1u));
844 template<
typename _RandomNumberEngine,
size_t __k>
863 template<
typename _RandomNumberEngine,
size_t __k,
864 typename _CharT,
typename _Traits>
871 const typename __ios_base::fmtflags __flags =
__os.flags();
872 const _CharT __fill =
__os.fill();
874 __os.flags(__ios_base::dec | __ios_base::fixed | __ios_base::left);
878 for (
size_t __i = 0; __i <
__k; ++__i)
887 template<
typename _RandomNumberEngine,
size_t __k,
888 typename _CharT,
typename _Traits>
895 const typename __ios_base::fmtflags __flags =
__is.flags();
896 __is.flags(__ios_base::dec | __ios_base::skipws);
899 for (
size_t __i = 0; __i <
__k; ++__i)
900 __is >> __x._M_v[__i];
908 template<
typename _IntType,
typename _CharT,
typename _Traits>
911 const uniform_int_distribution<_IntType>& __x)
913 using __ios_base =
typename basic_ostream<_CharT, _Traits>::ios_base;
915 const typename __ios_base::fmtflags __flags = __os.flags();
916 const _CharT __fill = __os.fill();
917 const _CharT __space = __os.widen(
' ');
918 __os.flags(__ios_base::scientific | __ios_base::left);
921 __os << __x.a() << __space << __x.b();
928 template<
typename _IntType,
typename _CharT,
typename _Traits>
937 const typename __ios_base::fmtflags __flags =
__is.flags();
938 __is.flags(__ios_base::dec | __ios_base::skipws);
941 if (
__is >> __a >> __b)
942 __x.param(param_type(__a, __b));
949 template<
typename _RealType>
950 template<
typename _ForwardIterator,
951 typename _UniformRandomNumberGenerator>
956 const param_type& __p)
959 __detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
961 auto __range = __p.b() - __p.a();
966 template<
typename _RealType,
typename _CharT,
typename _Traits>
969 const uniform_real_distribution<_RealType>& __x)
971 using __ios_base =
typename basic_ostream<_CharT, _Traits>::ios_base;
973 const typename __ios_base::fmtflags __flags = __os.flags();
974 const _CharT __fill = __os.fill();
976 const _CharT __space = __os.widen(
' ');
977 __os.flags(__ios_base::scientific | __ios_base::left);
981 __os << __x.a() << __space << __x.b();
985 __os.precision(__precision);
989 template<
typename _RealType,
typename _CharT,
typename _Traits>
998 const typename __ios_base::fmtflags __flags =
__is.flags();
999 __is.flags(__ios_base::skipws);
1002 if (
__is >> __a >> __b)
1003 __x.param(param_type(__a, __b));
1005 __is.flags(__flags);
1010 template<
typename _ForwardIterator,
1011 typename _UniformRandomNumberGenerator>
1013 std::bernoulli_distribution::
1016 const param_type& __p)
1019 __detail::_Adaptor<_UniformRandomNumberGenerator, double>
1027 template<
typename _CharT,
typename _Traits>
1030 const bernoulli_distribution& __x)
1032 using __ios_base =
typename basic_ostream<_CharT, _Traits>::ios_base;
1034 const typename __ios_base::fmtflags __flags = __os.flags();
1035 const _CharT __fill = __os.fill();
1037 __os.flags(__ios_base::scientific | __ios_base::left);
1038 __os.fill(__os.widen(
' '));
1043 __os.flags(__flags);
1045 __os.precision(__precision);
1050 template<
typename _IntType>
1051 template<
typename _UniformRandomNumberGenerator>
1054 operator()(_UniformRandomNumberGenerator& __urng,
1055 const param_type& __param)
1059 const double __naf =
1062 const double __thr =
1064 __detail::_Adaptor<_UniformRandomNumberGenerator, double>
1069 __cand = std::floor(
std::log(1.0 - __aurng()) / __param._M_log_1_p);
1070 while (__cand >= __thr);
1072 return result_type(__cand + __naf);
1075 template<
typename _IntType>
1076 template<
typename _ForwardIterator,
1077 typename _UniformRandomNumberGenerator>
1087 const double __naf =
1090 const double __thr =
1092 __detail::_Adaptor<_UniformRandomNumberGenerator, double>
1107 template<
typename _IntType,
1108 typename _CharT,
typename _Traits>
1111 const geometric_distribution<_IntType>& __x)
1113 using __ios_base =
typename basic_ostream<_CharT, _Traits>::ios_base;
1115 const typename __ios_base::fmtflags __flags = __os.flags();
1116 const _CharT __fill = __os.fill();
1118 __os.flags(__ios_base::scientific | __ios_base::left);
1119 __os.fill(__os.widen(
' '));
1124 __os.flags(__flags);
1126 __os.precision(__precision);
1130 template<
typename _IntType,
1131 typename _CharT,
typename _Traits>
1139 const typename __ios_base::fmtflags __flags =
__is.flags();
1140 __is.flags(__ios_base::skipws);
1144 __x.param(param_type(__p));
1146 __is.flags(__flags);
1151 template<
typename _IntType>
1152 template<
typename _UniformRandomNumberGenerator>
1157 const double __y = _M_gd(
__urng);
1164 template<
typename _IntType>
1165 template<
typename _UniformRandomNumberGenerator>
1169 const param_type& __p)
1175 _M_gd(
__urng, param_type(__p.k(), (1.0 - __p.p()) / __p.p()));
1181 template<
typename _IntType>
1182 template<
typename _ForwardIterator,
1183 typename _UniformRandomNumberGenerator>
1185 negative_binomial_distribution<_IntType>::
1186 __generate_impl(_ForwardIterator __f, _ForwardIterator __t,
1187 _UniformRandomNumberGenerator& __urng)
1189 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
1192 const double __y = _M_gd(__urng);
1196 *__f++ = __poisson(__urng);
1200 template<
typename _IntType>
1201 template<
typename _ForwardIterator,
1202 typename _UniformRandomNumberGenerator>
1204 negative_binomial_distribution<_IntType>::
1205 __generate_impl(_ForwardIterator __f, _ForwardIterator __t,
1206 _UniformRandomNumberGenerator& __urng,
1207 const param_type& __p)
1209 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
1211 __p2(__p.k(), (1.0 - __p.p()) / __p.p());
1215 const double __y = _M_gd(__urng, __p2);
1218 *__f++ = __poisson(__urng);
1222 template<
typename _IntType,
typename _CharT,
typename _Traits>
1225 const negative_binomial_distribution<_IntType>& __x)
1227 using __ios_base =
typename basic_ostream<_CharT, _Traits>::ios_base;
1229 const typename __ios_base::fmtflags __flags = __os.flags();
1230 const _CharT __fill = __os.fill();
1232 const _CharT __space = __os.widen(
' ');
1233 __os.flags(__ios_base::scientific | __ios_base::left);
1234 __os.fill(__os.widen(
' '));
1237 __os << __x.k() << __space << __x.p()
1238 << __space << __x._M_gd;
1240 __os.flags(__flags);
1242 __os.precision(__precision);
1246 template<
typename _IntType,
typename _CharT,
typename _Traits>
1249 negative_binomial_distribution<_IntType>& __x)
1252 =
typename negative_binomial_distribution<_IntType>::param_type;
1253 using __ios_base =
typename basic_istream<_CharT, _Traits>::ios_base;
1255 const typename __ios_base::fmtflags __flags = __is.flags();
1256 __is.flags(__ios_base::skipws);
1260 if (__is >> __k >> __p >> __x._M_gd)
1261 __x.param(param_type(__k, __p));
1263 __is.flags(__flags);
1268 template<
typename _IntType>
1270 poisson_distribution<_IntType>::param_type::
1273#if _GLIBCXX_USE_C99_MATH_TR1
1276 const double __m = std::floor(_M_mean);
1278 _M_lfm = std::lgamma(__m + 1);
1281 const double __pi_4 = 0.7853981633974483096156608458198757L;
1285 const double __cx = 2 * __m + _M_d;
1290 _M_cb = 2 * __cx *
std::exp(-_M_d * _M_1cx * (1 + _M_d / 2))
1308 template<
typename _IntType>
1309 template<
typename _UniformRandomNumberGenerator>
1315 __detail::_Adaptor<_UniformRandomNumberGenerator, double>
1317#if _GLIBCXX_USE_C99_MATH_TR1
1323 const double __naf =
1325 const double __thr =
1328 const double __m = std::floor(
__param.mean());
1330 const double __spi_2 = 1.2533141373155002512078826424055226L;
1333 const double __c3 = __c2 + 1;
1336 const double __178 = 0.0128205128205128205128205128205128L;
1338 const double __e178 = 1.0129030479320018583185514777512983L;
1353 const double __n = _M_nd(
__urng);
1355 __x = std::floor(__y);
1356 __w = -__n * __n / 2;
1360 else if (
__u <= __c2)
1362 const double __n = _M_nd(
__urng);
1364 __x = std::ceil(__y);
1384 const double __y =
__param._M_d
1386 __x = std::ceil(__y);
1391 >
__param._M_lfm - std::lgamma(__x +
__m + 1));
1416 template<
typename _IntType>
1431 template<
typename _IntType,
1432 typename _CharT,
typename _Traits>
1435 const poisson_distribution<_IntType>& __x)
1437 using __ios_base =
typename basic_ostream<_CharT, _Traits>::ios_base;
1439 const typename __ios_base::fmtflags __flags = __os.flags();
1440 const _CharT __fill = __os.fill();
1442 const _CharT __space = __os.widen(
' ');
1443 __os.flags(__ios_base::scientific | __ios_base::left);
1447 __os << __x.mean() << __space << __x._M_nd;
1449 __os.flags(__flags);
1451 __os.precision(__precision);
1455 template<
typename _IntType,
1456 typename _CharT,
typename _Traits>
1459 poisson_distribution<_IntType>& __x)
1461 using param_type =
typename poisson_distribution<_IntType>::param_type;
1462 using __ios_base =
typename basic_istream<_CharT, _Traits>::ios_base;
1464 const typename __ios_base::fmtflags __flags = __is.flags();
1465 __is.flags(__ios_base::skipws);
1468 if (__is >> __mean >> __x._M_nd)
1469 __x.param(param_type(__mean));
1471 __is.flags(__flags);
1476 template<
typename _IntType>
1478 binomial_distribution<_IntType>::param_type::
1481 const double __p12 = _M_p <= 0.5 ? _M_p : 1.0 - _M_p;
1485#if _GLIBCXX_USE_C99_MATH_TR1
1486 if (_M_t * __p12 >= 8)
1489 const double __np = std::floor(_M_t * __p12);
1490 const double __pa = __np / _M_t;
1491 const double __1p = 1 - __pa;
1493 const double __pi_4 = 0.7853981633974483096156608458198757L;
1494 const double __d1x =
1496 / (81 * __pi_4 * __1p)));
1498 const double __d2x =
1500 / (__pi_4 * __pa)));
1504 const double __spi_2 = 1.2533141373155002512078826424055226L;
1505 _M_s1 =
std::sqrt(__np * __1p) * (1 + _M_d1 / (4 * __np));
1506 _M_s2 =
std::sqrt(__np * __1p) * (1 + _M_d2 / (4 * (_M_t * __1p)));
1507 _M_c = 2 * _M_d1 / __np;
1508 _M_a1 =
std::exp(_M_c) * _M_s1 * __spi_2;
1509 const double __a12 = _M_a1 + _M_s2 * __spi_2;
1510 const double __s1s = _M_s1 * _M_s1;
1511 _M_a123 = __a12 + (
std::exp(_M_d1 / (_M_t * __1p))
1513 *
std::exp(-_M_d1 * _M_d1 / (2 * __s1s)));
1514 const double __s2s = _M_s2 * _M_s2;
1515 _M_s = (_M_a123 + 2 * __s2s / _M_d2
1516 *
std::exp(-_M_d2 * _M_d2 / (2 * __s2s)));
1517 _M_lf = (std::lgamma(__np + 1)
1518 + std::lgamma(_M_t - __np + 1));
1521 _M_q = -
std::log(1 - (__p12 - __pa) / __1p);
1528 template<
typename _IntType>
1529 template<
typename _UniformRandomNumberGenerator>
1531 binomial_distribution<_IntType>::
1532 _M_waiting(_UniformRandomNumberGenerator& __urng,
1533 _IntType __t,
double __q)
1537 __detail::_Adaptor<_UniformRandomNumberGenerator, double>
1544 const double __e = -
std::log(1.0 - __aurng());
1545 __sum += __e / (__t - __x);
1548 while (__sum <= __q);
1563 template<
typename _IntType>
1564 template<
typename _UniformRandomNumberGenerator>
1571 const _IntType __t =
__param.t();
1572 const double __p =
__param.p();
1573 const double __p12 = __p <= 0.5 ? __p : 1.0 - __p;
1574 __detail::_Adaptor<_UniformRandomNumberGenerator, double>
1577#if _GLIBCXX_USE_C99_MATH_TR1
1583 const double __naf =
1585 const double __thr =
1588 const double __np = std::floor(__t *
__p12);
1591 const double __spi_2 = 1.2533141373155002512078826424055226L;
1607 const double __n = _M_nd(
__urng);
1613 __x = std::floor(__y);
1619 const double __n = _M_nd(
__urng);
1625 __x = std::floor(-__y);
1626 __v = -__e - __n * __n / 2;
1634 const double __y =
__param._M_d1
1636 __x = std::floor(__y);
1638 -__y / (2 *
__s1s)));
1646 const double __y =
__param._M_d2
1648 __x = std::floor(-__y);
1656 const double __lfx =
1657 std::lgamma(
__np + __x + 1)
1658 + std::lgamma(__t - (
__np + __x) + 1);
1669 const _IntType
__z = _M_waiting(
__urng, __t - _IntType(__x),
1682 template<
typename _IntType>
1697 template<
typename _IntType,
1698 typename _CharT,
typename _Traits>
1701 const binomial_distribution<_IntType>& __x)
1703 using __ios_base =
typename basic_ostream<_CharT, _Traits>::ios_base;
1705 const typename __ios_base::fmtflags __flags = __os.flags();
1706 const _CharT __fill = __os.fill();
1708 const _CharT __space = __os.widen(
' ');
1709 __os.flags(__ios_base::scientific | __ios_base::left);
1713 __os << __x.t() << __space << __x.p()
1714 << __space << __x._M_nd;
1716 __os.flags(__flags);
1718 __os.precision(__precision);
1722 template<
typename _IntType,
1723 typename _CharT,
typename _Traits>
1726 binomial_distribution<_IntType>& __x)
1728 using param_type =
typename binomial_distribution<_IntType>::param_type;
1729 using __ios_base =
typename basic_istream<_CharT, _Traits>::ios_base;
1731 const typename __ios_base::fmtflags __flags = __is.flags();
1732 __is.flags(__ios_base::dec | __ios_base::skipws);
1736 if (__is >> __t >> __p >> __x._M_nd)
1737 __x.param(param_type(__t, __p));
1739 __is.flags(__flags);
1744 template<
typename _RealType>
1745 template<
typename _ForwardIterator,
1746 typename _UniformRandomNumberGenerator>
1751 const param_type& __p)
1754 __detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
1760 template<
typename _RealType,
typename _CharT,
typename _Traits>
1763 const exponential_distribution<_RealType>& __x)
1765 using __ios_base =
typename basic_ostream<_CharT, _Traits>::ios_base;
1767 const typename __ios_base::fmtflags __flags = __os.flags();
1768 const _CharT __fill = __os.fill();
1770 __os.flags(__ios_base::scientific | __ios_base::left);
1771 __os.fill(__os.widen(
' '));
1774 __os << __x.lambda();
1776 __os.flags(__flags);
1778 __os.precision(__precision);
1782 template<
typename _RealType,
typename _CharT,
typename _Traits>
1791 const typename __ios_base::fmtflags __flags =
__is.flags();
1792 __is.flags(__ios_base::dec | __ios_base::skipws);
1798 __is.flags(__flags);
1809 template<
typename _RealType>
1810 template<
typename _UniformRandomNumberGenerator>
1817 __detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
1820 if (_M_saved_available)
1822 _M_saved_available =
false;
1832 __r2 = __x * __x + __y * __y;
1838 _M_saved_available =
true;
1846 template<
typename _RealType>
1860 if (_M_saved_available)
1862 _M_saved_available =
false;
1869 __detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
1872 while (__f + 1 < __t)
1879 __r2 = __x * __x + __y * __y;
1881 while (__r2 > 1.0 || __r2 == 0.0);
1884 *__f++ = __y * __mult * __param.stddev() + __param.mean();
1885 *__f++ = __x * __mult * __param.stddev() + __param.mean();
1895 __r2 = __x * __x + __y * __y;
1897 while (__r2 > 1.0 || __r2 == 0.0);
1900 _M_saved = __x * __mult;
1901 _M_saved_available =
true;
1902 *__f = __y * __mult * __param.stddev() + __param.mean();
1906 template<
typename _RealType>
1911 if (__d1._M_param == __d2._M_param
1912 && __d1._M_saved_available == __d2._M_saved_available)
1914 if (__d1._M_saved_available
1915 && __d1._M_saved == __d2._M_saved)
1917 else if(!__d1._M_saved_available)
1926 template<
typename _RealType,
typename _CharT,
typename _Traits>
1929 const normal_distribution<_RealType>& __x)
1931 using __ios_base =
typename basic_ostream<_CharT, _Traits>::ios_base;
1933 const typename __ios_base::fmtflags __flags = __os.flags();
1934 const _CharT __fill = __os.fill();
1936 const _CharT __space = __os.widen(
' ');
1937 __os.flags(__ios_base::scientific | __ios_base::left);
1941 __os << __x.mean() << __space << __x.stddev()
1942 << __space << __x._M_saved_available;
1943 if (__x._M_saved_available)
1944 __os << __space << __x._M_saved;
1946 __os.flags(__flags);
1948 __os.precision(__precision);
1952 template<
typename _RealType,
typename _CharT,
typename _Traits>
1955 normal_distribution<_RealType>& __x)
1957 using param_type =
typename normal_distribution<_RealType>::param_type;
1958 using __ios_base =
typename basic_istream<_CharT, _Traits>::ios_base;
1960 const typename __ios_base::fmtflags __flags = __is.flags();
1961 __is.flags(__ios_base::dec | __ios_base::skipws);
1963 double __mean, __stddev;
1965 if (__is >> __mean >> __stddev >> __saved_avail)
1967 if (!__saved_avail || (__is >> __x._M_saved))
1969 __x._M_saved_available = __saved_avail;
1970 __x.param(param_type(__mean, __stddev));
1974 __is.flags(__flags);
1979 template<
typename _RealType>
1980 template<
typename _ForwardIterator,
1981 typename _UniformRandomNumberGenerator>
1983 lognormal_distribution<_RealType>::
1984 __generate_impl(_ForwardIterator __f, _ForwardIterator __t,
1985 _UniformRandomNumberGenerator& __urng,
1986 const param_type& __p)
1988 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
1990 *__f++ =
std::exp(__p.s() * _M_nd(__urng) + __p.m());
1993 template<
typename _RealType,
typename _CharT,
typename _Traits>
1996 const lognormal_distribution<_RealType>& __x)
1998 using __ios_base =
typename basic_ostream<_CharT, _Traits>::ios_base;
2000 const typename __ios_base::fmtflags __flags = __os.flags();
2001 const _CharT __fill = __os.fill();
2003 const _CharT __space = __os.widen(
' ');
2004 __os.flags(__ios_base::scientific | __ios_base::left);
2008 __os << __x.m() << __space << __x.s()
2009 << __space << __x._M_nd;
2011 __os.flags(__flags);
2013 __os.precision(__precision);
2017 template<
typename _RealType,
typename _CharT,
typename _Traits>
2020 lognormal_distribution<_RealType>& __x)
2023 =
typename lognormal_distribution<_RealType>::param_type;
2024 using __ios_base =
typename basic_istream<_CharT, _Traits>::ios_base;
2026 const typename __ios_base::fmtflags __flags = __is.flags();
2027 __is.flags(__ios_base::dec | __ios_base::skipws);
2030 if (__is >> __m >> __s >> __x._M_nd)
2031 __x.param(param_type(__m, __s));
2033 __is.flags(__flags);
2037 template<
typename _RealType>
2038 template<
typename _ForwardIterator,
2039 typename _UniformRandomNumberGenerator>
2043 _UniformRandomNumberGenerator& __urng)
2045 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
2047 *__f++ = 2 * _M_gd(__urng);
2050 template<
typename _RealType>
2051 template<
typename _ForwardIterator,
2052 typename _UniformRandomNumberGenerator>
2056 _UniformRandomNumberGenerator& __urng,
2060 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
2062 *__f++ = 2 * _M_gd(__urng, __p);
2065 template<
typename _RealType,
typename _CharT,
typename _Traits>
2068 const chi_squared_distribution<_RealType>& __x)
2070 using __ios_base =
typename basic_ostream<_CharT, _Traits>::ios_base;
2072 const typename __ios_base::fmtflags __flags = __os.flags();
2073 const _CharT __fill = __os.fill();
2075 const _CharT __space = __os.widen(
' ');
2076 __os.flags(__ios_base::scientific | __ios_base::left);
2080 __os << __x.n() << __space << __x._M_gd;
2082 __os.flags(__flags);
2084 __os.precision(__precision);
2088 template<
typename _RealType,
typename _CharT,
typename _Traits>
2091 chi_squared_distribution<_RealType>& __x)
2094 =
typename chi_squared_distribution<_RealType>::param_type;
2095 using __ios_base =
typename basic_istream<_CharT, _Traits>::ios_base;
2097 const typename __ios_base::fmtflags __flags = __is.flags();
2098 __is.flags(__ios_base::dec | __ios_base::skipws);
2101 if (
__is >> __n >> __x._M_gd)
2102 __x.param(param_type(__n));
2104 __is.flags(__flags);
2109 template<
typename _RealType>
2110 template<
typename _UniformRandomNumberGenerator>
2114 const param_type& __p)
2116 __detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
2123 const _RealType __pi = 3.1415926535897932384626433832795029L;
2127 template<
typename _RealType>
2128 template<
typename _ForwardIterator,
2129 typename _UniformRandomNumberGenerator>
2134 const param_type& __p)
2137 const _RealType __pi = 3.1415926535897932384626433832795029L;
2138 __detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
2147 *__f++ = __p.a() + __p.b() *
std::tan(__pi *
__u);
2151 template<
typename _RealType,
typename _CharT,
typename _Traits>
2154 const cauchy_distribution<_RealType>& __x)
2156 using __ios_base =
typename basic_ostream<_CharT, _Traits>::ios_base;
2158 const typename __ios_base::fmtflags __flags = __os.flags();
2159 const _CharT __fill = __os.fill();
2161 const _CharT __space = __os.widen(
' ');
2162 __os.flags(__ios_base::scientific | __ios_base::left);
2166 __os << __x.a() << __space << __x.b();
2168 __os.flags(__flags);
2170 __os.precision(__precision);
2174 template<
typename _RealType,
typename _CharT,
typename _Traits>
2182 const typename __ios_base::fmtflags __flags =
__is.flags();
2183 __is.flags(__ios_base::dec | __ios_base::skipws);
2186 if (
__is >> __a >> __b)
2187 __x.param(param_type(__a, __b));
2189 __is.flags(__flags);
2194 template<
typename _RealType>
2195 template<
typename _ForwardIterator,
2196 typename _UniformRandomNumberGenerator>
2200 _UniformRandomNumberGenerator& __urng)
2202 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
2204 *__f++ = ((_M_gd_x(__urng) * n()) / (_M_gd_y(__urng) * m()));
2207 template<
typename _RealType>
2208 template<
typename _ForwardIterator,
2209 typename _UniformRandomNumberGenerator>
2213 _UniformRandomNumberGenerator& __urng,
2214 const param_type& __p)
2216 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
2219 param_type __p1(__p.m() / 2);
2220 param_type __p2(__p.n() / 2);
2222 *__f++ = ((_M_gd_x(__urng, __p1) * n())
2223 / (_M_gd_y(__urng, __p2) * m()));
2226 template<
typename _RealType,
typename _CharT,
typename _Traits>
2229 const fisher_f_distribution<_RealType>& __x)
2231 using __ios_base =
typename basic_ostream<_CharT, _Traits>::ios_base;
2233 const typename __ios_base::fmtflags __flags = __os.flags();
2234 const _CharT __fill = __os.fill();
2236 const _CharT __space = __os.widen(
' ');
2237 __os.flags(__ios_base::scientific | __ios_base::left);
2241 __os << __x.m() << __space << __x.n()
2242 << __space << __x._M_gd_x << __space << __x._M_gd_y;
2244 __os.flags(__flags);
2246 __os.precision(__precision);
2250 template<
typename _RealType,
typename _CharT,
typename _Traits>
2253 fisher_f_distribution<_RealType>& __x)
2256 =
typename fisher_f_distribution<_RealType>::param_type;
2257 using __ios_base =
typename basic_istream<_CharT, _Traits>::ios_base;
2259 const typename __ios_base::fmtflags __flags = __is.flags();
2260 __is.flags(__ios_base::dec | __ios_base::skipws);
2263 if (__is >> __m >> __n >> __x._M_gd_x >> __x._M_gd_y)
2264 __x.param(param_type(__m, __n));
2266 __is.flags(__flags);
2271 template<
typename _RealType>
2272 template<
typename _ForwardIterator,
2273 typename _UniformRandomNumberGenerator>
2277 _UniformRandomNumberGenerator& __urng)
2279 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
2281 *__f++ = _M_nd(__urng) *
std::sqrt(n() / _M_gd(__urng));
2284 template<
typename _RealType>
2285 template<
typename _ForwardIterator,
2286 typename _UniformRandomNumberGenerator>
2290 _UniformRandomNumberGenerator& __urng,
2291 const param_type& __p)
2293 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
2295 __p2(__p.n() / 2, 2);
2297 *__f++ = _M_nd(__urng) *
std::sqrt(__p.n() / _M_gd(__urng, __p2));
2300 template<
typename _RealType,
typename _CharT,
typename _Traits>
2303 const student_t_distribution<_RealType>& __x)
2305 using __ios_base =
typename basic_ostream<_CharT, _Traits>::ios_base;
2307 const typename __ios_base::fmtflags __flags = __os.flags();
2308 const _CharT __fill = __os.fill();
2310 const _CharT __space = __os.widen(
' ');
2311 __os.flags(__ios_base::scientific | __ios_base::left);
2315 __os << __x.n() << __space << __x._M_nd << __space << __x._M_gd;
2317 __os.flags(__flags);
2319 __os.precision(__precision);
2323 template<
typename _RealType,
typename _CharT,
typename _Traits>
2326 student_t_distribution<_RealType>& __x)
2329 =
typename student_t_distribution<_RealType>::param_type;
2330 using __ios_base =
typename basic_istream<_CharT, _Traits>::ios_base;
2332 const typename __ios_base::fmtflags __flags = __is.flags();
2333 __is.flags(__ios_base::dec | __ios_base::skipws);
2336 if (__is >> __n >> __x._M_nd >> __x._M_gd)
2337 __x.param(param_type(__n));
2339 __is.flags(__flags);
2344 template<
typename _RealType>
2346 gamma_distribution<_RealType>::param_type::
2349 _M_malpha = _M_alpha < 1.0 ? _M_alpha + _RealType(1.0) : _M_alpha;
2351 const _RealType __a1 = _M_malpha - _RealType(1.0) / _RealType(3.0);
2352 _M_a2 = _RealType(1.0) /
std::sqrt(_RealType(9.0) * __a1);
2360 template<
typename _RealType>
2361 template<
typename _UniformRandomNumberGenerator>
2367 __detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
2372 - _RealType(1.0) / _RealType(3.0));
2403 template<
typename _RealType>
2413 __detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
2418 - _RealType(1.0) / _RealType(3.0));
2432 __v = __v * __v * __v;
2435 while (__u >
result_type(1.0) - 0.0331 * __n * __n * __n * __n
2436 && (
std::log(__u) > (0.5 * __n * __n + __a1
2439 *__f++ = __a1 * __v * __param.beta();
2448 __n = _M_nd(__urng);
2453 __v = __v * __v * __v;
2456 while (__u >
result_type(1.0) - 0.0331 * __n * __n * __n * __n
2457 && (
std::log(__u) > (0.5 * __n * __n + __a1
2465 * __a1 * __v * __param.beta());
2469 template<
typename _RealType,
typename _CharT,
typename _Traits>
2472 const gamma_distribution<_RealType>& __x)
2474 using __ios_base =
typename basic_ostream<_CharT, _Traits>::ios_base;
2476 const typename __ios_base::fmtflags __flags = __os.flags();
2477 const _CharT __fill = __os.fill();
2479 const _CharT __space = __os.widen(
' ');
2480 __os.flags(__ios_base::scientific | __ios_base::left);
2484 __os << __x.alpha() << __space << __x.beta()
2485 << __space << __x._M_nd;
2487 __os.flags(__flags);
2489 __os.precision(__precision);
2493 template<
typename _RealType,
typename _CharT,
typename _Traits>
2496 gamma_distribution<_RealType>& __x)
2498 using param_type =
typename gamma_distribution<_RealType>::param_type;
2499 using __ios_base =
typename basic_istream<_CharT, _Traits>::ios_base;
2501 const typename __ios_base::fmtflags __flags = __is.flags();
2502 __is.flags(__ios_base::dec | __ios_base::skipws);
2504 _RealType __alpha_val, __beta_val;
2505 if (__is >> __alpha_val >> __beta_val >> __x._M_nd)
2506 __x.param(param_type(__alpha_val, __beta_val));
2508 __is.flags(__flags);
2513 template<
typename _RealType>
2514 template<
typename _UniformRandomNumberGenerator>
2517 operator()(_UniformRandomNumberGenerator& __urng,
2518 const param_type& __p)
2520 __detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
2526 template<
typename _RealType>
2527 template<
typename _ForwardIterator,
2528 typename _UniformRandomNumberGenerator>
2533 const param_type& __p)
2536 __detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
2545 template<
typename _RealType,
typename _CharT,
typename _Traits>
2552 const typename __ios_base::fmtflags __flags =
__os.flags();
2553 const _CharT __fill =
__os.fill();
2556 __os.flags(__ios_base::scientific | __ios_base::left);
2562 __os.flags(__flags);
2568 template<
typename _RealType,
typename _CharT,
typename _Traits>
2576 const typename __ios_base::fmtflags __flags =
__is.flags();
2577 __is.flags(__ios_base::dec | __ios_base::skipws);
2580 if (
__is >> __a >> __b)
2581 __x.param(param_type(__a, __b));
2583 __is.flags(__flags);
2588 template<
typename _RealType>
2589 template<
typename _UniformRandomNumberGenerator>
2592 operator()(_UniformRandomNumberGenerator& __urng,
2593 const param_type& __p)
2595 __detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
2601 template<
typename _RealType>
2602 template<
typename _ForwardIterator,
2603 typename _UniformRandomNumberGenerator>
2608 const param_type& __p)
2611 __detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
2619 template<
typename _RealType,
typename _CharT,
typename _Traits>
2622 const extreme_value_distribution<_RealType>& __x)
2624 using __ios_base =
typename basic_ostream<_CharT, _Traits>::ios_base;
2626 const typename __ios_base::fmtflags __flags = __os.flags();
2627 const _CharT __fill = __os.fill();
2629 const _CharT __space = __os.widen(
' ');
2630 __os.flags(__ios_base::scientific | __ios_base::left);
2634 __os << __x.a() << __space << __x.b();
2636 __os.flags(__flags);
2638 __os.precision(__precision);
2642 template<
typename _RealType,
typename _CharT,
typename _Traits>
2651 const typename __ios_base::fmtflags __flags =
__is.flags();
2652 __is.flags(__ios_base::dec | __ios_base::skipws);
2655 if (
__is >> __a >> __b)
2656 __x.param(param_type(__a, __b));
2658 __is.flags(__flags);
2663 template<
typename _IntType>
2665 discrete_distribution<_IntType>::param_type::
2668 if (_M_prob.size() < 2)
2675 _M_prob.end(), 0.0);
2676 __glibcxx_assert(__sum > 0);
2678 __detail::__normalize(_M_prob.begin(), _M_prob.end(), _M_prob.begin(),
2681 _M_cp.reserve(_M_prob.size());
2685 _M_cp[_M_cp.size() - 1] = 1.0;
2688 template<
typename _IntType>
2689 template<
typename _Func>
2690 discrete_distribution<_IntType>::param_type::
2691 param_type(
size_t __nw,
double __xmin,
double __xmax, _Func __fw)
2692 : _M_prob(), _M_cp()
2694 const size_t __n = __nw == 0 ? 1 : __nw;
2695 const double __delta = (__xmax - __xmin) / __n;
2697 _M_prob.reserve(__n);
2698 for (
size_t __k = 0; __k < __nw; ++__k)
2699 _M_prob.push_back(__fw(__xmin + __k * __delta + 0.5 * __delta));
2704 template<
typename _IntType>
2705 template<
typename _UniformRandomNumberGenerator>
2706 typename discrete_distribution<_IntType>::result_type
2707 discrete_distribution<_IntType>::
2708 operator()(_UniformRandomNumberGenerator& __urng,
2709 const param_type& __param)
2711 if (__param._M_cp.empty())
2712 return result_type(0);
2714 __detail::_Adaptor<_UniformRandomNumberGenerator, double>
2717 const double __p = __aurng();
2718 auto __pos = std::lower_bound(__param._M_cp.begin(),
2719 __param._M_cp.end(), __p);
2721 return __pos - __param._M_cp.begin();
2724 template<
typename _IntType>
2725 template<
typename _ForwardIterator,
2726 typename _UniformRandomNumberGenerator>
2728 discrete_distribution<_IntType>::
2729 __generate_impl(_ForwardIterator __f, _ForwardIterator __t,
2730 _UniformRandomNumberGenerator& __urng,
2731 const param_type& __param)
2733 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
2735 if (__param._M_cp.empty())
2738 *__f++ = result_type(0);
2742 __detail::_Adaptor<_UniformRandomNumberGenerator, double>
2747 const double __p = __aurng();
2748 auto __pos = std::lower_bound(__param._M_cp.begin(),
2749 __param._M_cp.end(), __p);
2751 *__f++ = __pos - __param._M_cp.begin();
2755 template<
typename _IntType,
typename _CharT,
typename _Traits>
2758 const discrete_distribution<_IntType>& __x)
2760 using __ios_base =
typename basic_ostream<_CharT, _Traits>::ios_base;
2762 const typename __ios_base::fmtflags __flags = __os.flags();
2763 const _CharT __fill = __os.fill();
2765 const _CharT __space = __os.widen(
' ');
2766 __os.flags(__ios_base::scientific | __ios_base::left);
2771 __os << __prob.size();
2772 for (
auto __dit = __prob.begin(); __dit != __prob.end(); ++__dit)
2773 __os << __space << *__dit;
2775 __os.flags(__flags);
2777 __os.precision(__precision);
2783 template<
typename _ValT,
typename _CharT,
typename _Traits>
2784 basic_istream<_CharT, _Traits>&
2785 __extract_params(basic_istream<_CharT, _Traits>& __is,
2786 vector<_ValT>& __vals,
size_t __n)
2788 __vals.reserve(__n);
2793 __vals.push_back(__val);
2801 template<
typename _IntType,
typename _CharT,
typename _Traits>
2804 discrete_distribution<_IntType>& __x)
2806 using __ios_base =
typename basic_istream<_CharT, _Traits>::ios_base;
2808 const typename __ios_base::fmtflags __flags = __is.flags();
2809 __is.flags(__ios_base::dec | __ios_base::skipws);
2815 if (__detail::__extract_params(__is, __prob_vec, __n))
2816 __x.param({__prob_vec.begin(), __prob_vec.end()});
2819 __is.flags(__flags);
2824 template<
typename _RealType>
2826 piecewise_constant_distribution<_RealType>::param_type::
2829 if (_M_int.size() < 2
2830 || (_M_int.size() == 2
2831 && _M_int[0] == _RealType(0)
2832 && _M_int[1] == _RealType(1)))
2841 __glibcxx_assert(__sum > 0);
2843 __detail::__normalize(_M_den.begin(), _M_den.end(), _M_den.begin(),
2846 _M_cp.reserve(_M_den.size());
2851 _M_cp[_M_cp.size() - 1] = 1.0;
2853 for (
size_t __k = 0; __k < _M_den.size(); ++__k)
2854 _M_den[__k] /= _M_int[__k + 1] - _M_int[__k];
2857 template<
typename _RealType>
2858 template<
typename _InputIteratorB,
typename _InputIteratorW>
2859 piecewise_constant_distribution<_RealType>::param_type::
2860 param_type(_InputIteratorB __bbegin,
2861 _InputIteratorB __bend,
2862 _InputIteratorW __wbegin)
2863 : _M_int(), _M_den(), _M_cp()
2865 if (__bbegin != __bend)
2869 _M_int.push_back(*__bbegin);
2871 if (__bbegin == __bend)
2874 _M_den.push_back(*__wbegin);
2882 template<
typename _RealType>
2883 template<
typename _Func>
2884 piecewise_constant_distribution<_RealType>::param_type::
2885 param_type(initializer_list<_RealType> __bl, _Func __fw)
2886 : _M_int(), _M_den(), _M_cp()
2888 _M_int.reserve(__bl.size());
2889 for (
auto __biter = __bl.begin(); __biter != __bl.end(); ++__biter)
2890 _M_int.push_back(*__biter);
2892 _M_den.reserve(_M_int.size() - 1);
2893 for (
size_t __k = 0; __k < _M_int.size() - 1; ++__k)
2894 _M_den.push_back(__fw(0.5 * (_M_int[__k + 1] + _M_int[__k])));
2899 template<
typename _RealType>
2900 template<
typename _Func>
2901 piecewise_constant_distribution<_RealType>::param_type::
2902 param_type(
size_t __nw, _RealType __xmin, _RealType __xmax, _Func __fw)
2903 : _M_int(), _M_den(), _M_cp()
2905 const size_t __n = __nw == 0 ? 1 : __nw;
2906 const _RealType __delta = (__xmax - __xmin) / __n;
2908 _M_int.reserve(__n + 1);
2909 for (
size_t __k = 0; __k <= __nw; ++__k)
2910 _M_int.push_back(__xmin + __k * __delta);
2912 _M_den.reserve(__n);
2913 for (
size_t __k = 0; __k < __nw; ++__k)
2914 _M_den.push_back(__fw(_M_int[__k] + 0.5 * __delta));
2919 template<
typename _RealType>
2920 template<
typename _UniformRandomNumberGenerator>
2921 typename piecewise_constant_distribution<_RealType>::result_type
2922 piecewise_constant_distribution<_RealType>::
2923 operator()(_UniformRandomNumberGenerator& __urng,
2924 const param_type& __param)
2926 __detail::_Adaptor<_UniformRandomNumberGenerator, double>
2929 const double __p = __aurng();
2930 if (__param._M_cp.empty())
2933 auto __pos = std::lower_bound(__param._M_cp.begin(),
2934 __param._M_cp.end(), __p);
2935 const size_t __i = __pos - __param._M_cp.begin();
2937 const double __pref = __i > 0 ? __param._M_cp[__i - 1] : 0.0;
2939 return __param._M_int[__i] + (__p - __pref) / __param._M_den[__i];
2942 template<
typename _RealType>
2943 template<
typename _ForwardIterator,
2944 typename _UniformRandomNumberGenerator>
2946 piecewise_constant_distribution<_RealType>::
2947 __generate_impl(_ForwardIterator __f, _ForwardIterator __t,
2948 _UniformRandomNumberGenerator& __urng,
2949 const param_type& __param)
2951 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
2952 __detail::_Adaptor<_UniformRandomNumberGenerator, double>
2955 if (__param._M_cp.empty())
2964 const double __p = __aurng();
2966 auto __pos = std::lower_bound(__param._M_cp.begin(),
2967 __param._M_cp.end(), __p);
2968 const size_t __i = __pos - __param._M_cp.begin();
2970 const double __pref = __i > 0 ? __param._M_cp[__i - 1] : 0.0;
2972 *__f++ = (__param._M_int[__i]
2973 + (__p - __pref) / __param._M_den[__i]);
2977 template<
typename _RealType,
typename _CharT,
typename _Traits>
2980 const piecewise_constant_distribution<_RealType>& __x)
2982 using __ios_base =
typename basic_ostream<_CharT, _Traits>::ios_base;
2984 const typename __ios_base::fmtflags __flags = __os.flags();
2985 const _CharT __fill = __os.fill();
2987 const _CharT __space = __os.widen(
' ');
2988 __os.flags(__ios_base::scientific | __ios_base::left);
2993 __os << __int.size() - 1;
2995 for (
auto __xit = __int.begin(); __xit != __int.end(); ++__xit)
2996 __os << __space << *__xit;
2999 for (
auto __dit = __den.begin(); __dit != __den.end(); ++__dit)
3000 __os << __space << *__dit;
3002 __os.flags(__flags);
3004 __os.precision(__precision);
3008 template<
typename _RealType,
typename _CharT,
typename _Traits>
3011 piecewise_constant_distribution<_RealType>& __x)
3013 using __ios_base =
typename basic_istream<_CharT, _Traits>::ios_base;
3015 const typename __ios_base::fmtflags __flags = __is.flags();
3016 __is.flags(__ios_base::dec | __ios_base::skipws);
3022 if (__detail::__extract_params(__is, __int_vec, __n + 1))
3025 if (__detail::__extract_params(__is, __den_vec, __n))
3027 __x.param({ __int_vec.begin(), __int_vec.end(),
3028 __den_vec.begin() });
3033 __is.flags(__flags);
3038 template<
typename _RealType>
3040 piecewise_linear_distribution<_RealType>::param_type::
3043 if (_M_int.size() < 2
3044 || (_M_int.size() == 2
3045 && _M_int[0] == _RealType(0)
3046 && _M_int[1] == _RealType(1)
3047 && _M_den[0] == _M_den[1]))
3055 _M_cp.reserve(_M_int.size() - 1);
3056 _M_m.reserve(_M_int.size() - 1);
3057 for (
size_t __k = 0; __k < _M_int.size() - 1; ++__k)
3059 const _RealType __delta = _M_int[__k + 1] - _M_int[__k];
3060 __sum += 0.5 * (_M_den[__k + 1] + _M_den[__k]) * __delta;
3061 _M_cp.push_back(__sum);
3062 _M_m.push_back((_M_den[__k + 1] - _M_den[__k]) / __delta);
3064 __glibcxx_assert(__sum > 0);
3067 __detail::__normalize(_M_den.begin(), _M_den.end(), _M_den.begin(),
3070 __detail::__normalize(_M_cp.begin(), _M_cp.end(), _M_cp.begin(), __sum);
3072 __detail::__normalize(_M_m.begin(), _M_m.end(), _M_m.begin(), __sum);
3075 _M_cp[_M_cp.size() - 1] = 1.0;
3078 template<
typename _RealType>
3079 template<
typename _InputIteratorB,
typename _InputIteratorW>
3080 piecewise_linear_distribution<_RealType>::param_type::
3081 param_type(_InputIteratorB __bbegin,
3082 _InputIteratorB __bend,
3083 _InputIteratorW __wbegin)
3084 : _M_int(), _M_den(), _M_cp(), _M_m()
3086 for (; __bbegin != __bend; ++__bbegin, ++__wbegin)
3088 _M_int.push_back(*__bbegin);
3089 _M_den.push_back(*__wbegin);
3095 template<
typename _RealType>
3096 template<
typename _Func>
3097 piecewise_linear_distribution<_RealType>::param_type::
3098 param_type(initializer_list<_RealType> __bl, _Func __fw)
3099 : _M_int(), _M_den(), _M_cp(), _M_m()
3101 _M_int.reserve(__bl.size());
3102 _M_den.reserve(__bl.size());
3103 for (
auto __biter = __bl.begin(); __biter != __bl.end(); ++__biter)
3105 _M_int.push_back(*__biter);
3106 _M_den.push_back(__fw(*__biter));
3112 template<
typename _RealType>
3113 template<
typename _Func>
3114 piecewise_linear_distribution<_RealType>::param_type::
3115 param_type(
size_t __nw, _RealType __xmin, _RealType __xmax, _Func __fw)
3116 : _M_int(), _M_den(), _M_cp(), _M_m()
3118 const size_t __n = __nw == 0 ? 1 : __nw;
3119 const _RealType __delta = (__xmax - __xmin) / __n;
3121 _M_int.reserve(__n + 1);
3122 _M_den.reserve(__n + 1);
3123 for (
size_t __k = 0; __k <= __nw; ++__k)
3125 _M_int.push_back(__xmin + __k * __delta);
3126 _M_den.push_back(__fw(_M_int[__k] + __delta));
3132 template<
typename _RealType>
3133 template<
typename _UniformRandomNumberGenerator>
3134 typename piecewise_linear_distribution<_RealType>::result_type
3135 piecewise_linear_distribution<_RealType>::
3136 operator()(_UniformRandomNumberGenerator& __urng,
3137 const param_type& __param)
3139 __detail::_Adaptor<_UniformRandomNumberGenerator, double>
3142 const double __p = __aurng();
3143 if (__param._M_cp.empty())
3146 auto __pos = std::lower_bound(__param._M_cp.begin(),
3147 __param._M_cp.end(), __p);
3148 const size_t __i = __pos - __param._M_cp.begin();
3150 const double __pref = __i > 0 ? __param._M_cp[__i - 1] : 0.0;
3152 const double __a = 0.5 * __param._M_m[__i];
3153 const double __b = __param._M_den[__i];
3154 const double __cm = __p - __pref;
3156 _RealType __x = __param._M_int[__i];
3161 const double __d = __b * __b + 4.0 * __a * __cm;
3162 __x += 0.5 * (
std::sqrt(__d) - __b) / __a;
3168 template<
typename _RealType>
3169 template<
typename _ForwardIterator,
3170 typename _UniformRandomNumberGenerator>
3172 piecewise_linear_distribution<_RealType>::
3173 __generate_impl(_ForwardIterator __f, _ForwardIterator __t,
3174 _UniformRandomNumberGenerator& __urng,
3175 const param_type& __param)
3177 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
3180 *__f++ = this->operator()(__urng, __param);
3183 template<
typename _RealType,
typename _CharT,
typename _Traits>
3186 const piecewise_linear_distribution<_RealType>& __x)
3188 using __ios_base =
typename basic_ostream<_CharT, _Traits>::ios_base;
3190 const typename __ios_base::fmtflags __flags = __os.flags();
3191 const _CharT __fill = __os.fill();
3193 const _CharT __space = __os.widen(
' ');
3194 __os.flags(__ios_base::scientific | __ios_base::left);
3199 __os << __int.size() - 1;
3201 for (
auto __xit = __int.begin(); __xit != __int.end(); ++__xit)
3202 __os << __space << *__xit;
3205 for (
auto __dit = __den.begin(); __dit != __den.end(); ++__dit)
3206 __os << __space << *__dit;
3208 __os.flags(__flags);
3210 __os.precision(__precision);
3214 template<
typename _RealType,
typename _CharT,
typename _Traits>
3217 piecewise_linear_distribution<_RealType>& __x)
3219 using __ios_base =
typename basic_istream<_CharT, _Traits>::ios_base;
3221 const typename __ios_base::fmtflags __flags = __is.flags();
3222 __is.flags(__ios_base::dec | __ios_base::skipws);
3227 vector<_RealType> __int_vec;
3228 if (__detail::__extract_params(__is, __int_vec, __n + 1))
3230 vector<double> __den_vec;
3231 if (__detail::__extract_params(__is, __den_vec, __n + 1))
3233 __x.param({ __int_vec.begin(), __int_vec.end(),
3234 __den_vec.begin() });
3238 __is.flags(__flags);
3243 template<
typename _IntType,
typename>
3246 _M_v.reserve(__il.size());
3247 for (
auto __iter = __il.begin(); __iter != __il.end(); ++__iter)
3248 _M_v.push_back(__detail::__mod<result_type,
3249 __detail::_Shift<result_type, 32>::__value>(*__iter));
3252 template<
typename _InputIterator>
3253 seed_seq::seed_seq(_InputIterator __begin, _InputIterator __end)
3255 if _GLIBCXX17_CONSTEXPR (__is_random_access_iter<_InputIterator>::value)
3258 for (_InputIterator __iter = __begin; __iter != __end; ++__iter)
3259 _M_v.push_back(__detail::__mod<result_type,
3260 __detail::_Shift<result_type, 32>::__value>(*__iter));
3263 template<
typename _RandomAccessIterator>
3265 seed_seq::generate(_RandomAccessIterator __begin,
3266 _RandomAccessIterator __end)
3268 typedef typename iterator_traits<_RandomAccessIterator>::value_type
3271 if (__begin == __end)
3274 std::fill(__begin, __end, _Type(0x8b8b8b8bu));
3276 const size_t __n = __end - __begin;
3277 const size_t __s = _M_v.size();
3278 const size_t __t = (__n >= 623) ? 11
3283 const size_t __p = (__n - __t) / 2;
3284 const size_t __q = __p + __t;
3285 const size_t __m =
std::max(
size_t(__s + 1), __n);
3287#ifndef __UINT32_TYPE__
3290 _Up(uint_least32_t v) : _M_v(v & 0xffffffffu) { }
3292 operator uint_least32_t()
const {
return _M_v; }
3294 uint_least32_t _M_v;
3296 using uint32_t = _Up;
3301 uint32_t __r1 = 1371501266u;
3302 uint32_t __r2 = __r1 + __s;
3303 __begin[__p] += __r1;
3304 __begin[__q] = (uint32_t)__begin[__q] + __r2;
3308 for (
size_t __k = 1; __k <= __s; ++__k)
3310 const size_t __kn = __k % __n;
3311 const size_t __kpn = (__k + __p) % __n;
3312 const size_t __kqn = (__k + __q) % __n;
3313 uint32_t __arg = (__begin[__kn]
3315 ^ __begin[(__k - 1) % __n]);
3316 uint32_t __r1 = 1664525u * (__arg ^ (__arg >> 27));
3317 uint32_t __r2 = __r1 + (uint32_t)__kn + _M_v[__k - 1];
3318 __begin[__kpn] = (uint32_t)__begin[__kpn] + __r1;
3319 __begin[__kqn] = (uint32_t)__begin[__kqn] + __r2;
3320 __begin[__kn] = __r2;
3323 for (
size_t __k = __s + 1; __k < __m; ++__k)
3325 const size_t __kn = __k % __n;
3326 const size_t __kpn = (__k + __p) % __n;
3327 const size_t __kqn = (__k + __q) % __n;
3328 uint32_t __arg = (__begin[__kn]
3330 ^ __begin[(__k - 1) % __n]);
3331 uint32_t __r1 = 1664525u * (__arg ^ (__arg >> 27));
3332 uint32_t __r2 = __r1 + (uint32_t)__kn;
3333 __begin[__kpn] = (uint32_t)__begin[__kpn] + __r1;
3334 __begin[__kqn] = (uint32_t)__begin[__kqn] + __r2;
3335 __begin[__kn] = __r2;
3338 for (
size_t __k = __m; __k < __m + __n; ++__k)
3340 const size_t __kn = __k % __n;
3341 const size_t __kpn = (__k + __p) % __n;
3342 const size_t __kqn = (__k + __q) % __n;
3343 uint32_t __arg = (__begin[__kn]
3345 + __begin[(__k - 1) % __n]);
3346 uint32_t __r3 = 1566083941u * (__arg ^ (__arg >> 27));
3347 uint32_t __r4 = __r3 - __kn;
3348 __begin[__kpn] ^= __r3;
3349 __begin[__kqn] ^= __r4;
3350 __begin[__kn] = __r4;
3354 template<
typename _RealType,
size_t __bits,
3355 typename _UniformRandomNumberGenerator>
3360 "template argument must be a floating point type");
3365 const long double __r =
static_cast<long double>(
__urng.max())
3366 -
static_cast<long double>(
__urng.min()) + 1.0L;
3371 _RealType
__sum = _RealType(0);
3372 _RealType
__tmp = _RealType(1);
3381#if _GLIBCXX_USE_C99_MATH_TR1
3382 __ret = std::nextafter(_RealType(1), _RealType(0));
3384 __ret = _RealType(1)
3391_GLIBCXX_END_NAMESPACE_VERSION
complex< _Tp > log(const complex< _Tp > &)
Return complex natural logarithm of z.
complex< _Tp > tan(const complex< _Tp > &)
Return complex tangent of z.
_Tp abs(const complex< _Tp > &)
Return magnitude of z.
complex< _Tp > exp(const complex< _Tp > &)
Return complex base e exponential of z.
complex< _Tp > pow(const complex< _Tp > &, int)
Return x to the y'th power.
complex< _Tp > sqrt(const complex< _Tp > &)
Return complex square root of z.
constexpr const _Tp & max(const _Tp &, const _Tp &)
This does what you think it does.
constexpr const _Tp & min(const _Tp &, const _Tp &)
This does what you think it does.
_RealType generate_canonical(_UniformRandomNumberGenerator &__g)
A function template for converting the output of a (integral) uniform random number generator to a fl...
constexpr back_insert_iterator< _Container > back_inserter(_Container &__x)
constexpr _Tp accumulate(_InputIterator __first, _InputIterator __last, _Tp __init)
Accumulate values in a range.
constexpr _OutputIterator partial_sum(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
Return list of partial sums.
ISO C++ entities toplevel namespace is std.
ptrdiff_t streamsize
Integral type for I/O operation counts and buffer sizes.
constexpr iterator_traits< _InputIterator >::difference_type distance(_InputIterator __first, _InputIterator __last)
A generalization of pointer arithmetic.
constexpr int __lg(int __n)
This is a helper function for the sort routines and for random.tcc.
std::basic_istream< _CharT, _Traits > & operator>>(std::basic_istream< _CharT, _Traits > &__is, bitset< _Nb > &__x)
Global I/O operators for bitsets.
std::basic_ostream< _CharT, _Traits > & operator<<(std::basic_ostream< _CharT, _Traits > &__os, const bitset< _Nb > &__x)
Global I/O operators for bitsets.
Template class basic_istream.
Template class basic_ostream.
static constexpr bool is_integer
static constexpr int digits
static constexpr bool is_signed
Properties of fundamental types.
static constexpr _Tp max() noexcept
static constexpr _Tp epsilon() noexcept
A model of a linear congruential random number generator.
static constexpr result_type multiplier
static constexpr result_type modulus
void seed(result_type __s=default_seed)
Reseeds the linear_congruential_engine random number generator engine sequence to the seed __s.
static constexpr result_type increment
The Marsaglia-Zaman generator.
void seed(result_type __sd=0u)
Seeds the initial state of the random number generator.
result_type operator()()
Gets the next random number in the sequence.
result_type operator()()
Gets the next value in the generated random number sequence.
result_type operator()()
Gets the next value in the generated random number sequence.
Produces random numbers by reordering random numbers from some base engine.
_RandomNumberEngine::result_type result_type
Uniform continuous distribution for random numbers.
A normal continuous distribution for random numbers.
result_type operator()(_UniformRandomNumberGenerator &__urng)
Generating functions.
A gamma continuous distribution for random numbers.
result_type operator()(_UniformRandomNumberGenerator &__urng)
Generating functions.
A chi_squared_distribution random number distribution.
A cauchy_distribution random number distribution.
result_type operator()(_UniformRandomNumberGenerator &__urng)
Generating functions.
A fisher_f_distribution random number distribution.
A student_t_distribution random number distribution.
A discrete binomial random number distribution.
result_type operator()(_UniformRandomNumberGenerator &__urng)
Generating functions.
A discrete geometric random number distribution.
result_type operator()(_UniformRandomNumberGenerator &__urng)
Generating functions.
result_type operator()(_UniformRandomNumberGenerator &__urng)
Generating functions.
A discrete Poisson random number distribution.
result_type operator()(_UniformRandomNumberGenerator &__urng)
Generating functions.
friend bool operator==(const poisson_distribution &__d1, const poisson_distribution &__d2)
Return true if two Poisson distributions have the same parameters and the sequences that would be gen...
friend std::basic_ostream< _CharT, _Traits > & operator<<(std::basic_ostream< _CharT, _Traits > &__os, const std::poisson_distribution< _IntType1 > &__x)
Inserts a poisson_distribution random number distribution __x into the output stream __os.
friend std::basic_istream< _CharT, _Traits > & operator>>(std::basic_istream< _CharT, _Traits > &__is, std::poisson_distribution< _IntType1 > &__x)
Extracts a poisson_distribution random number distribution __x from the input stream __is.
An exponential continuous distribution for random numbers.
A weibull_distribution random number distribution.
result_type operator()(_UniformRandomNumberGenerator &__urng)
Generating functions.
A extreme_value_distribution random number distribution.
result_type operator()(_UniformRandomNumberGenerator &__urng)
Generating functions.
Parallel STL function calls corresponding to stl_numeric.h. The functions defined here mainly do case...