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, (void) ++__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>
136 -> _If_seed_seq<_Sseq>
140 const _UIntType __k = (__k0 + 31) / 32;
141 uint_least32_t __arr[__k + 3];
142 __q.generate(__arr + 0, __arr + __k + 3);
143 _UIntType __factor = 1u;
144 _UIntType __sum = 0u;
145 for (
size_t __j = 0; __j < __k; ++__j)
147 __sum += __arr[__j + 3] * __factor;
148 __factor *= __detail::_Shift<_UIntType, 32>::__value;
153 template<
typename _UIntType, _UIntType __a, _UIntType __c, _UIntType __m,
154 typename _CharT,
typename _Traits>
158 __a, __c, __m>& __lcr)
160 using __ios_base =
typename basic_ostream<_CharT, _Traits>::ios_base;
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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>
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,
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,
434 __s, __b, __t, __c, __l, __f>::
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++];
463 __z ^= (__z >> __u) & __d;
464 __z ^= (__z << __s) & __b;
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>
503 std::basic_istream<_CharT, _Traits>&
504 operator>>(std::basic_istream<_CharT, _Traits>& __is,
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 == 0u ? default_seed : __value % 2147483563u);
550 const size_t __n = (__w + 31) / 32;
552 for (
size_t __i = 0; __i < long_lag; ++__i)
554 _UIntType __sum = 0u;
555 _UIntType __factor = 1u;
556 for (
size_t __j = 0; __j < __n; ++__j)
558 __sum += __detail::__mod<uint_least32_t,
559 __detail::_Shift<uint_least32_t, 32>::__value>
560 (__lcg()) * __factor;
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>
575 -> _If_seed_seq<_Sseq>
577 const size_t __k = (__w + 31) / 32;
578 uint_least32_t __arr[__r * __k];
579 __q.generate(__arr + 0, __arr + __r * __k);
581 for (
size_t __i = 0; __i < long_lag; ++__i)
583 _UIntType __sum = 0u;
584 _UIntType __factor = 1u;
585 for (
size_t __j = 0; __j < __k; ++__j)
587 __sum += __arr[__k * __i + __j] * __factor;
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>
639 using __ios_base =
typename basic_ostream<_CharT, _Traits>::ios_base;
641 const typename __ios_base::fmtflags __flags = __os.
flags();
642 const _CharT __fill = __os.
fill();
643 const _CharT __space = __os.
widen(
' ');
644 __os.
flags(__ios_base::dec | __ios_base::fixed | __ios_base::left);
647 for (
size_t __i = 0; __i < __r; ++__i)
648 __os << __x._M_x[__i] << __space;
649 __os << __x._M_carry << __space << __x._M_p;
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>
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>
708 using __ios_base =
typename basic_ostream<_CharT, _Traits>::ios_base;
710 const typename __ios_base::fmtflags __flags = __os.
flags();
711 const _CharT __fill = __os.
fill();
712 const _CharT __space = __os.
widen(
' ');
713 __os.
flags(__ios_base::dec | __ios_base::fixed | __ios_base::left);
716 __os << __x.base() << __space << __x._M_n;
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>
747 typedef typename _RandomNumberEngine::result_type _Eresult_type;
748 const _Eresult_type __r
750 ? _M_b.max() - _M_b.min() + 1 : 0);
752 const unsigned __m = __r ?
std::__lg(__r) : __edig;
759 __ctype __s0, __s1, __y0, __y1;
761 for (
size_t __i = 0; __i < 2; ++__i)
763 __n = (__w + __m - 1) / __m + __i;
764 __n0 = __n - __w % __n;
765 const unsigned __w0 = __w / __n;
771 __s0 = __ctype(1) << __w0;
779 __y0 = __s0 * (__r / __s0);
781 __y1 = __s1 * (__r / __s1);
783 if (__r - __y0 <= __y0 / __n)
791 for (
size_t __k = 0; __k < __n0; ++__k)
795 __u = _M_b() - _M_b.min();
796 while (__y0 && __u >= __y0);
797 __sum = __s0 * __sum + (__s0 ? __u % __s0 : __u);
799 for (
size_t __k = __n0; __k < __n; ++__k)
803 __u = _M_b() - _M_b.min();
804 while (__y1 && __u >= __y1);
805 __sum = __s1 * __sum + (__s1 ? __u % __s1 : __u);
810#if ! __cpp_inline_variables
811 template<
typename _RandomNumberEngine,
size_t __k>
813 shuffle_order_engine<_RandomNumberEngine, __k>::table_size;
819 template<
typename _Tp>
821 __representable_as_double(_Tp __x)
noexcept
826 return (__x <= (1ull << __DBL_MANT_DIG__))
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>
852#pragma GCC diagnostic push
853#pragma GCC diagnostic ignored "-Wc++17-extensions"
855 if constexpr (__detail::__p1_representable_as_double(__range))
856 __j *= __y / (__range + 1.0);
858 __j *= __y / (__range + 1.0L);
859#pragma GCC diagnostic pop
866 template<
typename _RandomNumberEngine,
size_t __k,
867 typename _CharT,
typename _Traits>
872 using __ios_base =
typename basic_ostream<_CharT, _Traits>::ios_base;
874 const typename __ios_base::fmtflags __flags = __os.
flags();
875 const _CharT __fill = __os.
fill();
876 const _CharT __space = __os.
widen(
' ');
877 __os.
flags(__ios_base::dec | __ios_base::fixed | __ios_base::left);
881 for (
size_t __i = 0; __i < __k; ++__i)
882 __os << __space << __x._M_v[__i];
883 __os << __space << __x._M_y;
890 template<
typename _RandomNumberEngine,
size_t __k,
891 typename _CharT,
typename _Traits>
896 using __ios_base =
typename basic_istream<_CharT, _Traits>::ios_base;
898 const typename __ios_base::fmtflags __flags = __is.
flags();
899 __is.
flags(__ios_base::dec | __ios_base::skipws);
902 for (
size_t __i = 0; __i < __k; ++__i)
903 __is >> __x._M_v[__i];
910#if __glibcxx_philox_engine
912 template<
typename _UIntType,
size_t __w,
size_t __n,
size_t __r,
913 _UIntType... __consts>
915 philox_engine<_UIntType, __w, __n, __r, __consts...>::
916 _S_mulhi(_UIntType __a, _UIntType __b)
918 using __type =
typename __detail::_Select_uint_least_t<__w * 2>::type;
919 const __type __num =
static_cast<__type
>(__a) * __b;
920 return static_cast<_UIntType
>(__num >> __w) &
max();
923 template<
typename _UIntType,
size_t __w,
size_t __n,
size_t __r,
924 _UIntType... __consts>
926 philox_engine<_UIntType, __w, __n, __r, __consts...>::
927 _S_mullo(_UIntType __a, _UIntType __b)
929 return static_cast<_UIntType
>((__a * __b) &
max());
932 template<
typename _UIntType,
size_t __w,
size_t __n,
size_t __r,
933 _UIntType... __consts>
935 philox_engine<_UIntType, __w, __n, __r, __consts...>::_M_transition()
941 using __type =
typename __detail::_Select_uint_least_t<__w * 2>::type;
944 if constexpr (__n == 4)
947 = (
static_cast<__type
>(_M_x[1]) << __w)
948 | (
static_cast<__type
>(_M_x[0]) + 1);
950 = (
static_cast<__type
>(_M_x[3]) << __w)
951 |
static_cast<__type
>(_M_x[2]);
953 = ~__type(0) >> ((
sizeof(__type) * __CHAR_BIT__) - (__w * 2));
954 if ((__uh & __bigMask) == 0)
959 _M_x[0] =
static_cast<_UIntType
>(__uh &
max());
960 _M_x[1] =
static_cast<_UIntType
>((__uh >> (__w)) &
max());
961 _M_x[2] =
static_cast<_UIntType
>(__lh &
max());
962 _M_x[3] =
static_cast<_UIntType
>((__lh >> (__w)) &
max());
967 (
static_cast<__type
>(_M_x[1]) << __w)
968 | (
static_cast<__type
>(_M_x[0]) + 1);
969 _M_x[0] = __num &
max();
970 _M_x[1] = (__num >> __w) &
max();
975 template<
typename _UIntType,
size_t __w,
size_t __n,
size_t __r,
976 _UIntType... __consts>
978 philox_engine<_UIntType, __w, __n, __r, __consts...>::_M_philox()
981 for (
size_t __j = 0; __j < __r; ++__j)
984 if constexpr (__n == 4)
986 __intermedSeq[0] = __outputSeq[2];
987 __intermedSeq[1] = __outputSeq[1];
988 __intermedSeq[2] = __outputSeq[0];
989 __intermedSeq[3] = __outputSeq[3];
993 __intermedSeq[0] = __outputSeq[0];
994 __intermedSeq[1] = __outputSeq[1];
996 for (
unsigned long __k = 0; __k < (__n/2); ++__k)
999 = _S_mulhi(__intermedSeq[2*__k], multipliers[__k])
1000 ^ (((_M_k[__k] + (__j * round_consts[__k])) &
max()))
1001 ^ __intermedSeq[2*__k+1];
1003 __outputSeq[(2*__k)+1]
1004 = _S_mullo(__intermedSeq[2*__k], multipliers[__k]);
1010 template<
typename _UIntType,
size_t __w,
size_t __n,
size_t __r,
1011 _UIntType... __consts>
1012 template<
typename _Sseq>
1014 philox_engine<_UIntType, __w, __n, __r, __consts...>::seed(_Sseq& __q)
1015 requires __is_seed_seq<_Sseq>
1019 const unsigned __p = 1 + ((__w - 1) / 32);
1020 uint_least32_t __tmpArr[(__n/2) * __p];
1021 __q.generate(__tmpArr + 0, __tmpArr + ((__n/2) * __p));
1022 for (
unsigned __k = 0; __k < (__n/2); ++__k)
1024 unsigned long long __precalc = 0;
1025 for (
unsigned __j = 0; __j < __p; ++__j)
1027 unsigned long long __multiplicand = (1ull << (32 * __j));
1028 __precalc += (__tmpArr[__k * __p + __j] * __multiplicand) &
max();
1030 _M_k[__k] = __precalc;
1035 template<
typename _IntType,
typename _CharT,
typename _Traits>
1036 std::basic_ostream<_CharT, _Traits>&
1037 operator<<(std::basic_ostream<_CharT, _Traits>& __os,
1040 using __ios_base =
typename basic_ostream<_CharT, _Traits>::ios_base;
1042 const typename __ios_base::fmtflags __flags = __os.
flags();
1043 const _CharT __fill = __os.
fill();
1044 const _CharT __space = __os.
widen(
' ');
1045 __os.
flags(__ios_base::scientific | __ios_base::left);
1048 __os << __x.a() << __space << __x.b();
1050 __os.
flags(__flags);
1055 template<
typename _IntType,
typename _CharT,
typename _Traits>
1056 std::basic_istream<_CharT, _Traits>&
1062 using __ios_base =
typename basic_istream<_CharT, _Traits>::ios_base;
1064 const typename __ios_base::fmtflags __flags = __is.
flags();
1065 __is.
flags(__ios_base::dec | __ios_base::skipws);
1068 if (__is >> __a >> __b)
1069 __x.
param(param_type(__a, __b));
1071 __is.
flags(__flags);
1076 template<
typename _RealType>
1077 template<
typename _ForwardIterator,
1078 typename _UniformRandomNumberGenerator>
1082 _UniformRandomNumberGenerator& __urng,
1083 const param_type& __p)
1085 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
1086 __detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
1088 auto __range = __p.b() - __p.a();
1090 *__f++ = __aurng() * __range + __p.a();
1093 template<
typename _RealType,
typename _CharT,
typename _Traits>
1096 const uniform_real_distribution<_RealType>& __x)
1098 using __ios_base =
typename basic_ostream<_CharT, _Traits>::ios_base;
1100 const typename __ios_base::fmtflags __flags = __os.
flags();
1101 const _CharT __fill = __os.
fill();
1103 const _CharT __space = __os.
widen(
' ');
1104 __os.
flags(__ios_base::scientific | __ios_base::left);
1108 __os << __x.a() << __space << __x.b();
1110 __os.
flags(__flags);
1116 template<
typename _RealType,
typename _CharT,
typename _Traits>
1117 std::basic_istream<_CharT, _Traits>&
1123 using __ios_base =
typename basic_istream<_CharT, _Traits>::ios_base;
1125 const typename __ios_base::fmtflags __flags = __is.
flags();
1126 __is.
flags(__ios_base::skipws);
1129 if (__is >> __a >> __b)
1130 __x.
param(param_type(__a, __b));
1132 __is.
flags(__flags);
1137 template<
typename _ForwardIterator,
1138 typename _UniformRandomNumberGenerator>
1140 std::bernoulli_distribution::
1141 __generate_impl(_ForwardIterator __f, _ForwardIterator __t,
1142 _UniformRandomNumberGenerator& __urng,
1143 const param_type& __p)
1145 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
1146 __detail::_Adaptor<_UniformRandomNumberGenerator, double>
1148 auto __limit = __p.p() * (__aurng.max() - __aurng.min());
1151 *__f++ = (__aurng() - __aurng.min()) < __limit;
1154 template<
typename _CharT,
typename _Traits>
1157 const bernoulli_distribution& __x)
1159 using __ios_base =
typename basic_ostream<_CharT, _Traits>::ios_base;
1161 const typename __ios_base::fmtflags __flags = __os.
flags();
1162 const _CharT __fill = __os.
fill();
1164 __os.
flags(__ios_base::scientific | __ios_base::left);
1170 __os.
flags(__flags);
1177 template<
typename _IntType>
1178 template<
typename _UniformRandomNumberGenerator>
1181 operator()(_UniformRandomNumberGenerator& __urng,
1182 const param_type& __param)
1186 const double __naf =
1189 const double __thr =
1191 __detail::_Adaptor<_UniformRandomNumberGenerator, double>
1196 __cand = std::floor(
std::log(1.0 - __aurng()) / __param._M_log_1_p);
1197 while (__cand >= __thr);
1199 return result_type(__cand + __naf);
1202 template<
typename _IntType>
1203 template<
typename _ForwardIterator,
1204 typename _UniformRandomNumberGenerator>
1208 _UniformRandomNumberGenerator& __urng,
1209 const param_type& __param)
1211 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
1214 const double __naf =
1217 const double __thr =
1219 __detail::_Adaptor<_UniformRandomNumberGenerator, double>
1226 __cand = std::floor(
std::log(1.0 - __aurng())
1227 / __param._M_log_1_p);
1228 while (__cand >= __thr);
1230 *__f++ = __cand + __naf;
1234 template<
typename _IntType,
1235 typename _CharT,
typename _Traits>
1238 const geometric_distribution<_IntType>& __x)
1240 using __ios_base =
typename basic_ostream<_CharT, _Traits>::ios_base;
1242 const typename __ios_base::fmtflags __flags = __os.
flags();
1243 const _CharT __fill = __os.
fill();
1245 __os.
flags(__ios_base::scientific | __ios_base::left);
1251 __os.
flags(__flags);
1257 template<
typename _IntType,
1258 typename _CharT,
typename _Traits>
1259 std::basic_istream<_CharT, _Traits>&
1264 using __ios_base =
typename basic_istream<_CharT, _Traits>::ios_base;
1266 const typename __ios_base::fmtflags __flags = __is.
flags();
1267 __is.
flags(__ios_base::skipws);
1271 __x.
param(param_type(__p));
1273 __is.
flags(__flags);
1278 template<
typename _IntType>
1279 template<
typename _UniformRandomNumberGenerator>
1280 typename negative_binomial_distribution<_IntType>::result_type
1282 operator()(_UniformRandomNumberGenerator& __urng)
1284 const double __y = _M_gd(__urng);
1288 return __poisson(__urng);
1291 template<
typename _IntType>
1292 template<
typename _UniformRandomNumberGenerator>
1295 operator()(_UniformRandomNumberGenerator& __urng,
1296 const param_type& __p)
1302 _M_gd(__urng, param_type(__p.k(), (1.0 - __p.p()) / __p.p()));
1305 return __poisson(__urng);
1308 template<
typename _IntType>
1309 template<
typename _ForwardIterator,
1310 typename _UniformRandomNumberGenerator>
1312 negative_binomial_distribution<_IntType>::
1313 __generate_impl(_ForwardIterator __f, _ForwardIterator __t,
1314 _UniformRandomNumberGenerator& __urng)
1316 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
1319 const double __y = _M_gd(__urng);
1323 *__f++ = __poisson(__urng);
1327 template<
typename _IntType>
1328 template<
typename _ForwardIterator,
1329 typename _UniformRandomNumberGenerator>
1333 _UniformRandomNumberGenerator& __urng,
1334 const param_type& __p)
1336 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
1337 typename std::gamma_distribution<result_type>::param_type
1338 __p2(__p.k(), (1.0 - __p.p()) / __p.p());
1342 const double __y = _M_gd(__urng, __p2);
1344 std::poisson_distribution<result_type> __poisson(__y);
1345 *__f++ = __poisson(__urng);
1349 template<
typename _IntType,
typename _CharT,
typename _Traits>
1350 std::basic_ostream<_CharT, _Traits>&
1351 operator<<(std::basic_ostream<_CharT, _Traits>& __os,
1354 using __ios_base =
typename basic_ostream<_CharT, _Traits>::ios_base;
1356 const typename __ios_base::fmtflags __flags = __os.
flags();
1357 const _CharT __fill = __os.
fill();
1359 const _CharT __space = __os.
widen(
' ');
1360 __os.
flags(__ios_base::scientific | __ios_base::left);
1364 __os << __x.k() << __space << __x.p()
1365 << __space << __x._M_gd;
1367 __os.
flags(__flags);
1373 template<
typename _IntType,
typename _CharT,
typename _Traits>
1374 std::basic_istream<_CharT, _Traits>&
1375 operator>>(std::basic_istream<_CharT, _Traits>& __is,
1380 using __ios_base =
typename basic_istream<_CharT, _Traits>::ios_base;
1382 const typename __ios_base::fmtflags __flags = __is.
flags();
1383 __is.
flags(__ios_base::skipws);
1387 if (__is >> __k >> __p >> __x._M_gd)
1388 __x.param(param_type(__k, __p));
1390 __is.
flags(__flags);
1395 template<
typename _IntType>
1400#if _GLIBCXX_USE_C99_MATH_FUNCS
1403 const double __m = std::floor(_M_mean);
1405 _M_lfm = std::lgamma(__m + 1);
1408 const double __pi_4 = 0.7853981633974483096156608458198757L;
1412 const double __cx = 2 * __m + _M_d;
1417 _M_cb = 2 * __cx *
std::exp(-_M_d * _M_1cx * (1 + _M_d / 2))
1435 template<
typename _IntType>
1436 template<
typename _UniformRandomNumberGenerator>
1437 typename poisson_distribution<_IntType>::result_type
1439 operator()(_UniformRandomNumberGenerator& __urng,
1442 __detail::_Adaptor<_UniformRandomNumberGenerator, double>
1444#if _GLIBCXX_USE_C99_MATH_FUNCS
1445 if (__param.mean() >= 12)
1450 const double __naf =
1452 const double __thr =
1455 const double __m = std::floor(__param.mean());
1457 const double __spi_2 = 1.2533141373155002512078826424055226L;
1458 const double __c1 = __param._M_sm * __spi_2;
1459 const double __c2 = __param._M_c2b + __c1;
1460 const double __c3 = __c2 + 1;
1461 const double __c4 = __c3 + 1;
1463 const double __178 = 0.0128205128205128205128205128205128L;
1465 const double __e178 = 1.0129030479320018583185514777512983L;
1466 const double __c5 = __c4 + __e178;
1467 const double __c = __param._M_cb + __c5;
1468 const double __2cx = 2 * (2 * __m + __param._M_d);
1470 bool __reject =
true;
1473 const double __u = __c * __aurng();
1474 const double __e = -
std::log(1.0 - __aurng());
1480 const double __n = _M_nd(__urng);
1481 const double __y = -
std::abs(__n) * __param._M_sm - 1;
1482 __x = std::floor(__y);
1483 __w = -__n * __n / 2;
1487 else if (__u <= __c2)
1489 const double __n = _M_nd(__urng);
1490 const double __y = 1 +
std::abs(__n) * __param._M_scx;
1491 __x = std::ceil(__y);
1492 __w = __y * (2 - __y) * __param._M_1cx;
1493 if (__x > __param._M_d)
1496 else if (__u <= __c3)
1500 else if (__u <= __c4)
1502 else if (__u <= __c5)
1510 const double __v = -
std::log(1.0 - __aurng());
1511 const double __y = __param._M_d
1512 + __v * __2cx / __param._M_d;
1513 __x = std::ceil(__y);
1514 __w = -__param._M_d * __param._M_1cx * (1 + __y / 2);
1517 __reject = (__w - __e - __x * __param._M_lm_thr
1518 > __param._M_lfm - std::lgamma(__x + __m + 1));
1520 __reject |= __x + __m >= __thr;
1530 double __prod = 1.0;
1534 __prod *= __aurng();
1537 while (__prod > __param._M_lm_thr);
1543 template<
typename _IntType>
1544 template<
typename _ForwardIterator,
1545 typename _UniformRandomNumberGenerator>
1549 _UniformRandomNumberGenerator& __urng,
1550 const param_type& __param)
1552 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
1558 template<
typename _IntType,
1559 typename _CharT,
typename _Traits>
1562 const poisson_distribution<_IntType>& __x)
1564 using __ios_base =
typename basic_ostream<_CharT, _Traits>::ios_base;
1566 const typename __ios_base::fmtflags __flags = __os.
flags();
1567 const _CharT __fill = __os.
fill();
1569 const _CharT __space = __os.
widen(
' ');
1570 __os.
flags(__ios_base::scientific | __ios_base::left);
1574 __os << __x.mean() << __space << __x._M_nd;
1576 __os.
flags(__flags);
1582 template<
typename _IntType,
1583 typename _CharT,
typename _Traits>
1584 std::basic_istream<_CharT, _Traits>&
1585 operator>>(std::basic_istream<_CharT, _Traits>& __is,
1586 poisson_distribution<_IntType>& __x)
1588 using param_type =
typename poisson_distribution<_IntType>::param_type;
1589 using __ios_base =
typename basic_istream<_CharT, _Traits>::ios_base;
1591 const typename __ios_base::fmtflags __flags = __is.
flags();
1592 __is.
flags(__ios_base::skipws);
1595 if (__is >> __mean >> __x._M_nd)
1598 __is.
flags(__flags);
1603 template<
typename _IntType>
1605 binomial_distribution<_IntType>::param_type::
1608 const double __p12 = _M_p <= 0.5 ? _M_p : 1.0 - _M_p;
1612#if _GLIBCXX_USE_C99_MATH_FUNCS
1613 if (_M_t * __p12 >= 8)
1616 const double __np = std::floor(_M_t * __p12);
1617 const double __pa = __np / _M_t;
1618 const double __1p = 1 - __pa;
1620 const double __pi_4 = 0.7853981633974483096156608458198757L;
1621 const double __d1x =
1623 / (81 * __pi_4 * __1p)));
1625 const double __d2x =
1627 / (__pi_4 * __pa)));
1631 const double __spi_2 = 1.2533141373155002512078826424055226L;
1632 _M_s1 =
std::sqrt(__np * __1p) * (1 + _M_d1 / (4 * __np));
1633 _M_s2 =
std::sqrt(__np * __1p) * (1 + _M_d2 / (4 * (_M_t * __1p)));
1634 _M_c = 2 * _M_d1 / __np;
1635 _M_a1 =
std::exp(_M_c) * _M_s1 * __spi_2;
1636 const double __a12 = _M_a1 + _M_s2 * __spi_2;
1637 const double __s1s = _M_s1 * _M_s1;
1638 _M_a123 = __a12 + (
std::exp(_M_d1 / (_M_t * __1p))
1640 *
std::exp(-_M_d1 * _M_d1 / (2 * __s1s)));
1641 const double __s2s = _M_s2 * _M_s2;
1642 _M_s = (_M_a123 + 2 * __s2s / _M_d2
1643 *
std::exp(-_M_d2 * _M_d2 / (2 * __s2s)));
1644 _M_lf = (std::lgamma(__np + 1)
1645 + std::lgamma(_M_t - __np + 1));
1648 _M_q = -
std::log(1 - (__p12 - __pa) / __1p);
1655 template<
typename _IntType>
1656 template<
typename _UniformRandomNumberGenerator>
1658 binomial_distribution<_IntType>::
1659 _M_waiting(_UniformRandomNumberGenerator& __urng,
1660 _IntType __t,
double __q)
1664 __detail::_Adaptor<_UniformRandomNumberGenerator, double>
1671 const double __e = -
std::log(1.0 - __aurng());
1672 __sum += __e / (__t - __x);
1675 while (__sum <= __q);
1690 template<
typename _IntType>
1691 template<
typename _UniformRandomNumberGenerator>
1694 operator()(_UniformRandomNumberGenerator& __urng,
1698 const _IntType __t = __param.t();
1699 const double __p = __param.p();
1700 const double __p12 = __p <= 0.5 ? __p : 1.0 - __p;
1701 __detail::_Adaptor<_UniformRandomNumberGenerator, double>
1704#if _GLIBCXX_USE_C99_MATH_FUNCS
1705 if (!__param._M_easy)
1710 const double __naf =
1712 const double __thr =
1715 const double __np = std::floor(__t * __p12);
1718 const double __spi_2 = 1.2533141373155002512078826424055226L;
1719 const double __a1 = __param._M_a1;
1720 const double __a12 = __a1 + __param._M_s2 * __spi_2;
1721 const double __a123 = __param._M_a123;
1722 const double __s1s = __param._M_s1 * __param._M_s1;
1723 const double __s2s = __param._M_s2 * __param._M_s2;
1728 const double __u = __param._M_s * __aurng();
1734 const double __n = _M_nd(__urng);
1735 const double __y = __param._M_s1 *
std::abs(__n);
1736 __reject = __y >= __param._M_d1;
1739 const double __e = -
std::log(1.0 - __aurng());
1740 __x = std::floor(__y);
1741 __v = -__e - __n * __n / 2 + __param._M_c;
1744 else if (__u <= __a12)
1746 const double __n = _M_nd(__urng);
1747 const double __y = __param._M_s2 *
std::abs(__n);
1748 __reject = __y >= __param._M_d2;
1751 const double __e = -
std::log(1.0 - __aurng());
1752 __x = std::floor(-__y);
1753 __v = -__e - __n * __n / 2;
1756 else if (__u <= __a123)
1758 const double __e1 = -
std::log(1.0 - __aurng());
1759 const double __e2 = -
std::log(1.0 - __aurng());
1761 const double __y = __param._M_d1
1762 + 2 * __s1s * __e1 / __param._M_d1;
1763 __x = std::floor(__y);
1764 __v = (-__e2 + __param._M_d1 * (1 / (__t - __np)
1765 -__y / (2 * __s1s)));
1770 const double __e1 = -
std::log(1.0 - __aurng());
1771 const double __e2 = -
std::log(1.0 - __aurng());
1773 const double __y = __param._M_d2
1774 + 2 * __s2s * __e1 / __param._M_d2;
1775 __x = std::floor(-__y);
1776 __v = -__e2 - __param._M_d2 * __y / (2 * __s2s);
1780 __reject = __reject || __x < -__np || __x > __t - __np;
1783 const double __lfx =
1784 std::lgamma(__np + __x + 1)
1785 + std::lgamma(__t - (__np + __x) + 1);
1786 __reject = __v > __param._M_lf - __lfx
1787 + __x * __param._M_lp1p;
1790 __reject |= __x + __np >= __thr;
1794 __x += __np + __naf;
1796 const _IntType __z = _M_waiting(__urng, __t - _IntType(__x),
1798 __ret = _IntType(__x) + __z;
1802 __ret = _M_waiting(__urng, __t, __param._M_q);
1805 __ret = __t - __ret;
1809 template<
typename _IntType>
1810 template<
typename _ForwardIterator,
1811 typename _UniformRandomNumberGenerator>
1815 _UniformRandomNumberGenerator& __urng,
1816 const param_type& __param)
1818 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
1824 template<
typename _IntType,
1825 typename _CharT,
typename _Traits>
1828 const binomial_distribution<_IntType>& __x)
1830 using __ios_base =
typename basic_ostream<_CharT, _Traits>::ios_base;
1832 const typename __ios_base::fmtflags __flags = __os.
flags();
1833 const _CharT __fill = __os.
fill();
1835 const _CharT __space = __os.
widen(
' ');
1836 __os.
flags(__ios_base::scientific | __ios_base::left);
1840 __os << __x.t() << __space << __x.p()
1841 << __space << __x._M_nd;
1843 __os.
flags(__flags);
1849 template<
typename _IntType,
1850 typename _CharT,
typename _Traits>
1851 std::basic_istream<_CharT, _Traits>&
1852 operator>>(std::basic_istream<_CharT, _Traits>& __is,
1853 binomial_distribution<_IntType>& __x)
1855 using param_type =
typename binomial_distribution<_IntType>::param_type;
1856 using __ios_base =
typename basic_istream<_CharT, _Traits>::ios_base;
1858 const typename __ios_base::fmtflags __flags = __is.
flags();
1859 __is.
flags(__ios_base::dec | __ios_base::skipws);
1863 if (__is >> __t >> __p >> __x._M_nd)
1866 __is.
flags(__flags);
1871 template<
typename _RealType>
1872 template<
typename _ForwardIterator,
1873 typename _UniformRandomNumberGenerator>
1877 _UniformRandomNumberGenerator& __urng,
1878 const param_type& __p)
1880 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
1881 __detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
1887 template<
typename _RealType,
typename _CharT,
typename _Traits>
1890 const exponential_distribution<_RealType>& __x)
1892 using __ios_base =
typename basic_ostream<_CharT, _Traits>::ios_base;
1894 const typename __ios_base::fmtflags __flags = __os.
flags();
1895 const _CharT __fill = __os.
fill();
1897 __os.
flags(__ios_base::scientific | __ios_base::left);
1901 __os << __x.lambda();
1903 __os.
flags(__flags);
1909 template<
typename _RealType,
typename _CharT,
typename _Traits>
1910 std::basic_istream<_CharT, _Traits>&
1916 using __ios_base =
typename basic_istream<_CharT, _Traits>::ios_base;
1918 const typename __ios_base::fmtflags __flags = __is.
flags();
1919 __is.
flags(__ios_base::dec | __ios_base::skipws);
1922 if (__is >> __lambda)
1923 __x.
param(param_type(__lambda));
1925 __is.
flags(__flags);
1936 template<
typename _RealType>
1937 template<
typename _UniformRandomNumberGenerator>
1940 operator()(_UniformRandomNumberGenerator& __urng,
1944 __detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
1947 if (_M_saved_available)
1949 _M_saved_available =
false;
1959 __r2 = __x * __x + __y * __y;
1961 while (__r2 > 1.0 || __r2 == 0.0);
1964 _M_saved = __x * __mult;
1965 _M_saved_available =
true;
1966 __ret = __y * __mult;
1969 __ret = __ret * __param.stddev() + __param.mean();
1973 template<
typename _RealType>
1974 template<
typename _ForwardIterator,
1975 typename _UniformRandomNumberGenerator>
1979 _UniformRandomNumberGenerator& __urng,
1980 const param_type& __param)
1982 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
1987 if (_M_saved_available)
1989 _M_saved_available =
false;
1990 *__f++ = _M_saved * __param.stddev() + __param.mean();
1996 __detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
1999 while (__f + 1 < __t)
2001 result_type __x, __y, __r2;
2006 __r2 = __x * __x + __y * __y;
2008 while (__r2 > 1.0 || __r2 == 0.0);
2011 *__f++ = __y * __mult * __param.stddev() + __param.mean();
2012 *__f++ = __x * __mult * __param.stddev() + __param.mean();
2022 __r2 = __x * __x + __y * __y;
2024 while (__r2 > 1.0 || __r2 == 0.0);
2027 _M_saved = __x * __mult;
2028 _M_saved_available =
true;
2029 *__f = __y * __mult * __param.stddev() + __param.mean();
2033 template<
typename _RealType>
2035 operator==(
const std::normal_distribution<_RealType>& __d1,
2036 const std::normal_distribution<_RealType>& __d2)
2038 if (__d1._M_param == __d2._M_param
2039 && __d1._M_saved_available == __d2._M_saved_available)
2040 return __d1._M_saved_available ? __d1._M_saved == __d2._M_saved :
true;
2045 template<
typename _RealType,
typename _CharT,
typename _Traits>
2046 std::basic_ostream<_CharT, _Traits>&
2047 operator<<(std::basic_ostream<_CharT, _Traits>& __os,
2048 const normal_distribution<_RealType>& __x)
2050 using __ios_base =
typename basic_ostream<_CharT, _Traits>::ios_base;
2052 const typename __ios_base::fmtflags __flags = __os.
flags();
2053 const _CharT __fill = __os.
fill();
2055 const _CharT __space = __os.
widen(
' ');
2056 __os.
flags(__ios_base::scientific | __ios_base::left);
2060 __os << __x.mean() << __space << __x.stddev()
2061 << __space << __x._M_saved_available;
2062 if (__x._M_saved_available)
2063 __os << __space << __x._M_saved;
2065 __os.
flags(__flags);
2071 template<
typename _RealType,
typename _CharT,
typename _Traits>
2072 std::basic_istream<_CharT, _Traits>&
2073 operator>>(std::basic_istream<_CharT, _Traits>& __is,
2074 normal_distribution<_RealType>& __x)
2076 using param_type =
typename normal_distribution<_RealType>::param_type;
2077 using __ios_base =
typename basic_istream<_CharT, _Traits>::ios_base;
2079 const typename __ios_base::fmtflags __flags = __is.
flags();
2080 __is.
flags(__ios_base::dec | __ios_base::skipws);
2082 double __mean, __stddev;
2084 if (__is >> __mean >> __stddev >> __saved_avail)
2086 if (!__saved_avail || (__is >> __x._M_saved))
2088 __x._M_saved_available = __saved_avail;
2093 __is.
flags(__flags);
2098 template<
typename _RealType>
2099 template<
typename _ForwardIterator,
2100 typename _UniformRandomNumberGenerator>
2102 lognormal_distribution<_RealType>::
2103 __generate_impl(_ForwardIterator __f, _ForwardIterator __t,
2104 _UniformRandomNumberGenerator& __urng,
2107 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
2109 *__f++ =
std::exp(__p.s() * _M_nd(__urng) + __p.m());
2112 template<
typename _RealType,
typename _CharT,
typename _Traits>
2113 std::basic_ostream<_CharT, _Traits>&
2114 operator<<(std::basic_ostream<_CharT, _Traits>& __os,
2115 const lognormal_distribution<_RealType>& __x)
2117 using __ios_base =
typename basic_ostream<_CharT, _Traits>::ios_base;
2119 const typename __ios_base::fmtflags __flags = __os.
flags();
2120 const _CharT __fill = __os.
fill();
2122 const _CharT __space = __os.
widen(
' ');
2123 __os.
flags(__ios_base::scientific | __ios_base::left);
2127 __os << __x.m() << __space << __x.s()
2128 << __space << __x._M_nd;
2130 __os.
flags(__flags);
2136 template<
typename _RealType,
typename _CharT,
typename _Traits>
2137 std::basic_istream<_CharT, _Traits>&
2138 operator>>(std::basic_istream<_CharT, _Traits>& __is,
2139 lognormal_distribution<_RealType>& __x)
2142 =
typename lognormal_distribution<_RealType>::param_type;
2143 using __ios_base =
typename basic_istream<_CharT, _Traits>::ios_base;
2145 const typename __ios_base::fmtflags __flags = __is.
flags();
2146 __is.
flags(__ios_base::dec | __ios_base::skipws);
2149 if (__is >> __m >> __s >> __x._M_nd)
2152 __is.
flags(__flags);
2156 template<
typename _RealType>
2157 template<
typename _ForwardIterator,
2158 typename _UniformRandomNumberGenerator>
2160 std::chi_squared_distribution<_RealType>::
2161 __generate_impl(_ForwardIterator __f, _ForwardIterator __t,
2162 _UniformRandomNumberGenerator& __urng)
2164 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
2166 *__f++ = 2 * _M_gd(__urng);
2169 template<
typename _RealType>
2170 template<
typename _ForwardIterator,
2171 typename _UniformRandomNumberGenerator>
2173 std::chi_squared_distribution<_RealType>::
2174 __generate_impl(_ForwardIterator __f, _ForwardIterator __t,
2175 _UniformRandomNumberGenerator& __urng,
2177 std::gamma_distribution<result_type>::param_type& __p)
2179 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
2181 *__f++ = 2 * _M_gd(__urng, __p);
2184 template<
typename _RealType,
typename _CharT,
typename _Traits>
2185 std::basic_ostream<_CharT, _Traits>&
2186 operator<<(std::basic_ostream<_CharT, _Traits>& __os,
2187 const chi_squared_distribution<_RealType>& __x)
2189 using __ios_base =
typename basic_ostream<_CharT, _Traits>::ios_base;
2191 const typename __ios_base::fmtflags __flags = __os.
flags();
2192 const _CharT __fill = __os.
fill();
2194 const _CharT __space = __os.
widen(
' ');
2195 __os.
flags(__ios_base::scientific | __ios_base::left);
2199 __os << __x.n() << __space << __x._M_gd;
2201 __os.
flags(__flags);
2207 template<
typename _RealType,
typename _CharT,
typename _Traits>
2208 std::basic_istream<_CharT, _Traits>&
2209 operator>>(std::basic_istream<_CharT, _Traits>& __is,
2210 chi_squared_distribution<_RealType>& __x)
2213 =
typename chi_squared_distribution<_RealType>::param_type;
2214 using __ios_base =
typename basic_istream<_CharT, _Traits>::ios_base;
2216 const typename __ios_base::fmtflags __flags = __is.
flags();
2217 __is.
flags(__ios_base::dec | __ios_base::skipws);
2220 if (__is >> __n >> __x._M_gd)
2223 __is.
flags(__flags);
2228 template<
typename _RealType>
2229 template<
typename _UniformRandomNumberGenerator>
2232 operator()(_UniformRandomNumberGenerator& __urng,
2235 __detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
2242 const _RealType __pi = 3.1415926535897932384626433832795029L;
2243 return __p.a() + __p.b() *
std::tan(__pi * __u);
2246 template<
typename _RealType>
2247 template<
typename _ForwardIterator,
2248 typename _UniformRandomNumberGenerator>
2252 _UniformRandomNumberGenerator& __urng,
2253 const param_type& __p)
2255 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
2256 const _RealType __pi = 3.1415926535897932384626433832795029L;
2257 __detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
2266 *__f++ = __p.a() + __p.b() *
std::tan(__pi * __u);
2270 template<
typename _RealType,
typename _CharT,
typename _Traits>
2273 const cauchy_distribution<_RealType>& __x)
2275 using __ios_base =
typename basic_ostream<_CharT, _Traits>::ios_base;
2277 const typename __ios_base::fmtflags __flags = __os.
flags();
2278 const _CharT __fill = __os.
fill();
2280 const _CharT __space = __os.
widen(
' ');
2281 __os.
flags(__ios_base::scientific | __ios_base::left);
2285 __os << __x.a() << __space << __x.b();
2287 __os.
flags(__flags);
2293 template<
typename _RealType,
typename _CharT,
typename _Traits>
2294 std::basic_istream<_CharT, _Traits>&
2299 using __ios_base =
typename basic_istream<_CharT, _Traits>::ios_base;
2301 const typename __ios_base::fmtflags __flags = __is.
flags();
2302 __is.
flags(__ios_base::dec | __ios_base::skipws);
2305 if (__is >> __a >> __b)
2306 __x.
param(param_type(__a, __b));
2308 __is.
flags(__flags);
2313 template<
typename _RealType>
2314 template<
typename _ForwardIterator,
2315 typename _UniformRandomNumberGenerator>
2319 _UniformRandomNumberGenerator& __urng)
2321 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
2323 *__f++ = ((_M_gd_x(__urng) * n()) / (_M_gd_y(__urng) * m()));
2326 template<
typename _RealType>
2327 template<
typename _ForwardIterator,
2328 typename _UniformRandomNumberGenerator>
2330 std::fisher_f_distribution<_RealType>::
2331 __generate_impl(_ForwardIterator __f, _ForwardIterator __t,
2332 _UniformRandomNumberGenerator& __urng,
2335 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
2336 typedef typename std::gamma_distribution<result_type>::param_type
2341 *__f++ = ((_M_gd_x(__urng, __p1) * n())
2342 / (_M_gd_y(__urng, __p2) * m()));
2345 template<
typename _RealType,
typename _CharT,
typename _Traits>
2346 std::basic_ostream<_CharT, _Traits>&
2347 operator<<(std::basic_ostream<_CharT, _Traits>& __os,
2348 const fisher_f_distribution<_RealType>& __x)
2350 using __ios_base =
typename basic_ostream<_CharT, _Traits>::ios_base;
2352 const typename __ios_base::fmtflags __flags = __os.
flags();
2353 const _CharT __fill = __os.
fill();
2355 const _CharT __space = __os.
widen(
' ');
2356 __os.
flags(__ios_base::scientific | __ios_base::left);
2360 __os << __x.m() << __space << __x.n()
2361 << __space << __x._M_gd_x << __space << __x._M_gd_y;
2363 __os.
flags(__flags);
2369 template<
typename _RealType,
typename _CharT,
typename _Traits>
2370 std::basic_istream<_CharT, _Traits>&
2371 operator>>(std::basic_istream<_CharT, _Traits>& __is,
2372 fisher_f_distribution<_RealType>& __x)
2375 =
typename fisher_f_distribution<_RealType>::param_type;
2376 using __ios_base =
typename basic_istream<_CharT, _Traits>::ios_base;
2378 const typename __ios_base::fmtflags __flags = __is.
flags();
2379 __is.
flags(__ios_base::dec | __ios_base::skipws);
2382 if (__is >> __m >> __n >> __x._M_gd_x >> __x._M_gd_y)
2385 __is.
flags(__flags);
2390 template<
typename _RealType>
2391 template<
typename _ForwardIterator,
2392 typename _UniformRandomNumberGenerator>
2394 std::student_t_distribution<_RealType>::
2395 __generate_impl(_ForwardIterator __f, _ForwardIterator __t,
2396 _UniformRandomNumberGenerator& __urng)
2398 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
2400 *__f++ = _M_nd(__urng) *
std::sqrt(n() / _M_gd(__urng));
2403 template<
typename _RealType>
2404 template<
typename _ForwardIterator,
2405 typename _UniformRandomNumberGenerator>
2407 std::student_t_distribution<_RealType>::
2408 __generate_impl(_ForwardIterator __f, _ForwardIterator __t,
2409 _UniformRandomNumberGenerator& __urng,
2412 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
2413 typename std::gamma_distribution<result_type>::param_type
2414 __p2(__p.n() / 2, 2);
2416 *__f++ = _M_nd(__urng) *
std::sqrt(__p.n() / _M_gd(__urng, __p2));
2419 template<
typename _RealType,
typename _CharT,
typename _Traits>
2420 std::basic_ostream<_CharT, _Traits>&
2421 operator<<(std::basic_ostream<_CharT, _Traits>& __os,
2422 const student_t_distribution<_RealType>& __x)
2424 using __ios_base =
typename basic_ostream<_CharT, _Traits>::ios_base;
2426 const typename __ios_base::fmtflags __flags = __os.
flags();
2427 const _CharT __fill = __os.
fill();
2429 const _CharT __space = __os.
widen(
' ');
2430 __os.
flags(__ios_base::scientific | __ios_base::left);
2434 __os << __x.n() << __space << __x._M_nd << __space << __x._M_gd;
2436 __os.
flags(__flags);
2442 template<
typename _RealType,
typename _CharT,
typename _Traits>
2443 std::basic_istream<_CharT, _Traits>&
2444 operator>>(std::basic_istream<_CharT, _Traits>& __is,
2445 student_t_distribution<_RealType>& __x)
2448 =
typename student_t_distribution<_RealType>::param_type;
2449 using __ios_base =
typename basic_istream<_CharT, _Traits>::ios_base;
2451 const typename __ios_base::fmtflags __flags = __is.
flags();
2452 __is.
flags(__ios_base::dec | __ios_base::skipws);
2455 if (__is >> __n >> __x._M_nd >> __x._M_gd)
2458 __is.
flags(__flags);
2463 template<
typename _RealType>
2465 gamma_distribution<_RealType>::param_type::
2468 _M_malpha = _M_alpha < 1.0 ? _M_alpha + _RealType(1.0) : _M_alpha;
2470 const _RealType __a1 = _M_malpha - _RealType(1.0) / _RealType(3.0);
2471 _M_a2 = _RealType(1.0) /
std::sqrt(_RealType(9.0) * __a1);
2479 template<
typename _RealType>
2480 template<
typename _UniformRandomNumberGenerator>
2483 operator()(_UniformRandomNumberGenerator& __urng,
2486 __detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
2491 - _RealType(1.0) / _RealType(3.0));
2497 __n = _M_nd(__urng);
2502 __v = __v * __v * __v;
2505 while (__u >
result_type(1.0) - 0.0331 * __n * __n * __n * __n
2506 && (
std::log(__u) > (0.5 * __n * __n + __a1
2509 if (__param.alpha() == __param._M_malpha)
2510 return __a1 * __v * __param.beta();
2518 * __a1 * __v * __param.beta());
2522 template<
typename _RealType>
2523 template<
typename _ForwardIterator,
2524 typename _UniformRandomNumberGenerator>
2528 _UniformRandomNumberGenerator& __urng,
2529 const param_type& __param)
2531 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
2532 __detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
2535 result_type __u, __v, __n;
2536 const result_type __a1 = (__param._M_malpha
2537 - _RealType(1.0) / _RealType(3.0));
2539 if (__param.alpha() == __param._M_malpha)
2546 __n = _M_nd(__urng);
2551 __v = __v * __v * __v;
2554 while (__u >
result_type(1.0) - 0.0331 * __n * __n * __n * __n
2555 && (
std::log(__u) > (0.5 * __n * __n + __a1
2558 *__f++ = __a1 * __v * __param.beta();
2567 __n = _M_nd(__urng);
2572 __v = __v * __v * __v;
2575 while (__u >
result_type(1.0) - 0.0331 * __n * __n * __n * __n
2576 && (
std::log(__u) > (0.5 * __n * __n + __a1
2584 * __a1 * __v * __param.beta());
2588 template<
typename _RealType,
typename _CharT,
typename _Traits>
2589 std::basic_ostream<_CharT, _Traits>&
2590 operator<<(std::basic_ostream<_CharT, _Traits>& __os,
2591 const gamma_distribution<_RealType>& __x)
2593 using __ios_base =
typename basic_ostream<_CharT, _Traits>::ios_base;
2595 const typename __ios_base::fmtflags __flags = __os.
flags();
2596 const _CharT __fill = __os.
fill();
2598 const _CharT __space = __os.
widen(
' ');
2599 __os.
flags(__ios_base::scientific | __ios_base::left);
2603 __os << __x.alpha() << __space << __x.beta()
2604 << __space << __x._M_nd;
2606 __os.
flags(__flags);
2612 template<
typename _RealType,
typename _CharT,
typename _Traits>
2613 std::basic_istream<_CharT, _Traits>&
2614 operator>>(std::basic_istream<_CharT, _Traits>& __is,
2615 gamma_distribution<_RealType>& __x)
2617 using param_type =
typename gamma_distribution<_RealType>::param_type;
2618 using __ios_base =
typename basic_istream<_CharT, _Traits>::ios_base;
2620 const typename __ios_base::fmtflags __flags = __is.
flags();
2621 __is.
flags(__ios_base::dec | __ios_base::skipws);
2623 _RealType __alpha_val, __beta_val;
2624 if (__is >> __alpha_val >> __beta_val >> __x._M_nd)
2625 __x.param(
param_type(__alpha_val, __beta_val));
2627 __is.
flags(__flags);
2632 template<
typename _RealType>
2633 template<
typename _UniformRandomNumberGenerator>
2636 operator()(_UniformRandomNumberGenerator& __urng,
2639 __detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
2645 template<
typename _RealType>
2646 template<
typename _ForwardIterator,
2647 typename _UniformRandomNumberGenerator>
2651 _UniformRandomNumberGenerator& __urng,
2652 const param_type& __p)
2654 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
2655 __detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
2664 template<
typename _RealType,
typename _CharT,
typename _Traits>
2667 const weibull_distribution<_RealType>& __x)
2669 using __ios_base =
typename basic_ostream<_CharT, _Traits>::ios_base;
2671 const typename __ios_base::fmtflags __flags = __os.
flags();
2672 const _CharT __fill = __os.
fill();
2674 const _CharT __space = __os.
widen(
' ');
2675 __os.
flags(__ios_base::scientific | __ios_base::left);
2679 __os << __x.a() << __space << __x.b();
2681 __os.
flags(__flags);
2687 template<
typename _RealType,
typename _CharT,
typename _Traits>
2688 std::basic_istream<_CharT, _Traits>&
2693 using __ios_base =
typename basic_istream<_CharT, _Traits>::ios_base;
2695 const typename __ios_base::fmtflags __flags = __is.
flags();
2696 __is.
flags(__ios_base::dec | __ios_base::skipws);
2699 if (__is >> __a >> __b)
2700 __x.
param(param_type(__a, __b));
2702 __is.
flags(__flags);
2707 template<
typename _RealType>
2708 template<
typename _UniformRandomNumberGenerator>
2711 operator()(_UniformRandomNumberGenerator& __urng,
2712 const param_type& __p)
2714 __detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
2720 template<
typename _RealType>
2721 template<
typename _ForwardIterator,
2722 typename _UniformRandomNumberGenerator>
2726 _UniformRandomNumberGenerator& __urng,
2727 const param_type& __p)
2729 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
2730 __detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
2738 template<
typename _RealType,
typename _CharT,
typename _Traits>
2741 const extreme_value_distribution<_RealType>& __x)
2743 using __ios_base =
typename basic_ostream<_CharT, _Traits>::ios_base;
2745 const typename __ios_base::fmtflags __flags = __os.
flags();
2746 const _CharT __fill = __os.
fill();
2748 const _CharT __space = __os.
widen(
' ');
2749 __os.
flags(__ios_base::scientific | __ios_base::left);
2753 __os << __x.a() << __space << __x.b();
2755 __os.
flags(__flags);
2761 template<
typename _RealType,
typename _CharT,
typename _Traits>
2762 std::basic_istream<_CharT, _Traits>&
2768 using __ios_base =
typename basic_istream<_CharT, _Traits>::ios_base;
2770 const typename __ios_base::fmtflags __flags = __is.
flags();
2771 __is.
flags(__ios_base::dec | __ios_base::skipws);
2774 if (__is >> __a >> __b)
2775 __x.
param(param_type(__a, __b));
2777 __is.
flags(__flags);
2782 template<
typename _IntType>
2784 discrete_distribution<_IntType>::param_type::
2787 if (_M_prob.size() < 2)
2794 _M_prob.end(), 0.0);
2795 __glibcxx_assert(__sum > 0);
2797 __detail::__normalize(_M_prob.begin(), _M_prob.end(), _M_prob.begin(),
2800 _M_cp.reserve(_M_prob.size());
2804 _M_cp[_M_cp.size() - 1] = 1.0;
2807 template<
typename _IntType>
2808 template<
typename _Func>
2809 discrete_distribution<_IntType>::param_type::
2810 param_type(
size_t __nw,
double __xmin,
double __xmax, _Func __fw)
2811 : _M_prob(), _M_cp()
2813 const size_t __n = __nw == 0 ? 1 : __nw;
2814 const double __delta = (__xmax - __xmin) / __n;
2816 _M_prob.reserve(__n);
2817 for (
size_t __k = 0; __k < __nw; ++__k)
2818 _M_prob.push_back(__fw(__xmin + __k * __delta + 0.5 * __delta));
2823 template<
typename _IntType>
2824 template<
typename _UniformRandomNumberGenerator>
2825 typename discrete_distribution<_IntType>::result_type
2826 discrete_distribution<_IntType>::
2827 operator()(_UniformRandomNumberGenerator& __urng,
2828 const param_type& __param)
2830 if (__param._M_cp.empty())
2831 return result_type(0);
2833 __detail::_Adaptor<_UniformRandomNumberGenerator, double>
2836 const double __p = __aurng();
2837 auto __pos = std::lower_bound(__param._M_cp.begin(),
2838 __param._M_cp.end(), __p);
2840 return __pos - __param._M_cp.begin();
2843 template<
typename _IntType>
2844 template<
typename _ForwardIterator,
2845 typename _UniformRandomNumberGenerator>
2847 discrete_distribution<_IntType>::
2848 __generate_impl(_ForwardIterator __f, _ForwardIterator __t,
2849 _UniformRandomNumberGenerator& __urng,
2850 const param_type& __param)
2852 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
2854 if (__param._M_cp.empty())
2857 *__f++ = result_type(0);
2861 __detail::_Adaptor<_UniformRandomNumberGenerator, double>
2866 const double __p = __aurng();
2867 auto __pos = std::lower_bound(__param._M_cp.begin(),
2868 __param._M_cp.end(), __p);
2870 *__f++ = __pos - __param._M_cp.begin();
2874 template<
typename _IntType,
typename _CharT,
typename _Traits>
2877 const discrete_distribution<_IntType>& __x)
2879 using __ios_base =
typename basic_ostream<_CharT, _Traits>::ios_base;
2881 const typename __ios_base::fmtflags __flags = __os.
flags();
2882 const _CharT __fill = __os.
fill();
2884 const _CharT __space = __os.
widen(
' ');
2885 __os.
flags(__ios_base::scientific | __ios_base::left);
2890 __os << __prob.
size();
2891 for (
auto __dit = __prob.
begin(); __dit != __prob.
end(); ++__dit)
2892 __os << __space << *__dit;
2894 __os.
flags(__flags);
2902 template<
typename _ValT,
typename _CharT,
typename _Traits>
2903 basic_istream<_CharT, _Traits>&
2904 __extract_params(basic_istream<_CharT, _Traits>& __is,
2905 vector<_ValT>& __vals,
size_t __n)
2907 __vals.reserve(__n);
2912 __vals.push_back(__val);
2920 template<
typename _IntType,
typename _CharT,
typename _Traits>
2923 discrete_distribution<_IntType>& __x)
2925 using __ios_base =
typename basic_istream<_CharT, _Traits>::ios_base;
2927 const typename __ios_base::fmtflags __flags = __is.
flags();
2928 __is.
flags(__ios_base::dec | __ios_base::skipws);
2934 if (__detail::__extract_params(__is, __prob_vec, __n))
2935 __x.param({__prob_vec.
begin(), __prob_vec.
end()});
2938 __is.
flags(__flags);
2943 template<
typename _RealType>
2945 piecewise_constant_distribution<_RealType>::param_type::
2948 if (_M_int.size() < 2
2949 || (_M_int.size() == 2
2950 && _M_int[0] == _RealType(0)
2951 && _M_int[1] == _RealType(1)))
2960 __glibcxx_assert(__sum > 0);
2962 __detail::__normalize(_M_den.begin(), _M_den.end(), _M_den.begin(),
2965 _M_cp.reserve(_M_den.size());
2970 _M_cp[_M_cp.size() - 1] = 1.0;
2972 for (
size_t __k = 0; __k < _M_den.size(); ++__k)
2973 _M_den[__k] /= _M_int[__k + 1] - _M_int[__k];
2976 template<
typename _RealType>
2977 template<
typename _InputIteratorB,
typename _InputIteratorW>
2978 piecewise_constant_distribution<_RealType>::param_type::
2979 param_type(_InputIteratorB __bbegin,
2980 _InputIteratorB __bend,
2981 _InputIteratorW __wbegin)
2982 : _M_int(), _M_den(), _M_cp()
2984 if (__bbegin != __bend)
2988 _M_int.push_back(*__bbegin);
2990 if (__bbegin == __bend)
2993 _M_den.push_back(*__wbegin);
3001 template<
typename _RealType>
3002 template<
typename _Func>
3003 piecewise_constant_distribution<_RealType>::param_type::
3004 param_type(initializer_list<_RealType> __bl, _Func __fw)
3005 : _M_int(), _M_den(), _M_cp()
3007 _M_int.reserve(__bl.size());
3008 for (
auto __biter = __bl.begin(); __biter != __bl.end(); ++__biter)
3009 _M_int.push_back(*__biter);
3011 _M_den.reserve(_M_int.size() - 1);
3012 for (
size_t __k = 0; __k < _M_int.size() - 1; ++__k)
3013 _M_den.push_back(__fw(0.5 * (_M_int[__k + 1] + _M_int[__k])));
3018 template<
typename _RealType>
3019 template<
typename _Func>
3020 piecewise_constant_distribution<_RealType>::param_type::
3021 param_type(
size_t __nw, _RealType __xmin, _RealType __xmax, _Func __fw)
3022 : _M_int(), _M_den(), _M_cp()
3024 const size_t __n = __nw == 0 ? 1 : __nw;
3025 const _RealType __delta = (__xmax - __xmin) / __n;
3027 _M_int.reserve(__n + 1);
3028 for (
size_t __k = 0; __k <= __nw; ++__k)
3029 _M_int.push_back(__xmin + __k * __delta);
3031 _M_den.reserve(__n);
3032 for (
size_t __k = 0; __k < __nw; ++__k)
3033 _M_den.push_back(__fw(_M_int[__k] + 0.5 * __delta));
3038 template<
typename _RealType>
3039 template<
typename _UniformRandomNumberGenerator>
3040 typename piecewise_constant_distribution<_RealType>::result_type
3041 piecewise_constant_distribution<_RealType>::
3042 operator()(_UniformRandomNumberGenerator& __urng,
3043 const param_type& __param)
3045 __detail::_Adaptor<_UniformRandomNumberGenerator, double>
3048 const double __p = __aurng();
3049 if (__param._M_cp.empty())
3052 auto __pos = std::lower_bound(__param._M_cp.begin(),
3053 __param._M_cp.end(), __p);
3054 const size_t __i = __pos - __param._M_cp.begin();
3056 const double __pref = __i > 0 ? __param._M_cp[__i - 1] : 0.0;
3058 return __param._M_int[__i] + (__p - __pref) / __param._M_den[__i];
3061 template<
typename _RealType>
3062 template<
typename _ForwardIterator,
3063 typename _UniformRandomNumberGenerator>
3065 piecewise_constant_distribution<_RealType>::
3066 __generate_impl(_ForwardIterator __f, _ForwardIterator __t,
3067 _UniformRandomNumberGenerator& __urng,
3068 const param_type& __param)
3070 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
3071 __detail::_Adaptor<_UniformRandomNumberGenerator, double>
3074 if (__param._M_cp.empty())
3083 const double __p = __aurng();
3085 auto __pos = std::lower_bound(__param._M_cp.begin(),
3086 __param._M_cp.end(), __p);
3087 const size_t __i = __pos - __param._M_cp.begin();
3089 const double __pref = __i > 0 ? __param._M_cp[__i - 1] : 0.0;
3091 *__f++ = (__param._M_int[__i]
3092 + (__p - __pref) / __param._M_den[__i]);
3096 template<
typename _RealType,
typename _CharT,
typename _Traits>
3099 const piecewise_constant_distribution<_RealType>& __x)
3101 using __ios_base =
typename basic_ostream<_CharT, _Traits>::ios_base;
3103 const typename __ios_base::fmtflags __flags = __os.
flags();
3104 const _CharT __fill = __os.
fill();
3106 const _CharT __space = __os.
widen(
' ');
3107 __os.
flags(__ios_base::scientific | __ios_base::left);
3112 __os << __int.
size() - 1;
3114 for (
auto __xit = __int.
begin(); __xit != __int.
end(); ++__xit)
3115 __os << __space << *__xit;
3118 for (
auto __dit = __den.
begin(); __dit != __den.
end(); ++__dit)
3119 __os << __space << *__dit;
3121 __os.
flags(__flags);
3127 template<
typename _RealType,
typename _CharT,
typename _Traits>
3130 piecewise_constant_distribution<_RealType>& __x)
3132 using __ios_base =
typename basic_istream<_CharT, _Traits>::ios_base;
3134 const typename __ios_base::fmtflags __flags = __is.
flags();
3135 __is.
flags(__ios_base::dec | __ios_base::skipws);
3141 if (__detail::__extract_params(__is, __int_vec, __n + 1))
3144 if (__detail::__extract_params(__is, __den_vec, __n))
3146 __x.param({ __int_vec.
begin(), __int_vec.
end(),
3147 __den_vec.
begin() });
3152 __is.
flags(__flags);
3157 template<
typename _RealType>
3159 piecewise_linear_distribution<_RealType>::param_type::
3162 if (_M_int.size() < 2
3163 || (_M_int.size() == 2
3164 && _M_int[0] == _RealType(0)
3165 && _M_int[1] == _RealType(1)
3166 && _M_den[0] == _M_den[1]))
3174 _M_cp.reserve(_M_int.size() - 1);
3175 _M_m.reserve(_M_int.size() - 1);
3176 for (
size_t __k = 0; __k < _M_int.size() - 1; ++__k)
3178 const _RealType __delta = _M_int[__k + 1] - _M_int[__k];
3179 __sum += 0.5 * (_M_den[__k + 1] + _M_den[__k]) * __delta;
3180 _M_cp.push_back(__sum);
3181 _M_m.push_back((_M_den[__k + 1] - _M_den[__k]) / __delta);
3183 __glibcxx_assert(__sum > 0);
3186 __detail::__normalize(_M_den.begin(), _M_den.end(), _M_den.begin(),
3189 __detail::__normalize(_M_cp.begin(), _M_cp.end(), _M_cp.begin(), __sum);
3191 __detail::__normalize(_M_m.begin(), _M_m.end(), _M_m.begin(), __sum);
3194 _M_cp[_M_cp.size() - 1] = 1.0;
3197 template<
typename _RealType>
3198 template<
typename _InputIteratorB,
typename _InputIteratorW>
3199 piecewise_linear_distribution<_RealType>::param_type::
3200 param_type(_InputIteratorB __bbegin,
3201 _InputIteratorB __bend,
3202 _InputIteratorW __wbegin)
3203 : _M_int(), _M_den(), _M_cp(), _M_m()
3205 for (; __bbegin != __bend; ++__bbegin, (void) ++__wbegin)
3207 _M_int.push_back(*__bbegin);
3208 _M_den.push_back(*__wbegin);
3214 template<
typename _RealType>
3215 template<
typename _Func>
3216 piecewise_linear_distribution<_RealType>::param_type::
3217 param_type(initializer_list<_RealType> __bl, _Func __fw)
3218 : _M_int(), _M_den(), _M_cp(), _M_m()
3220 _M_int.reserve(__bl.size());
3221 _M_den.reserve(__bl.size());
3222 for (
auto __biter = __bl.begin(); __biter != __bl.end(); ++__biter)
3224 _M_int.push_back(*__biter);
3225 _M_den.push_back(__fw(*__biter));
3231 template<
typename _RealType>
3232 template<
typename _Func>
3233 piecewise_linear_distribution<_RealType>::param_type::
3234 param_type(
size_t __nw, _RealType __xmin, _RealType __xmax, _Func __fw)
3235 : _M_int(), _M_den(), _M_cp(), _M_m()
3237 const size_t __n = __nw == 0 ? 1 : __nw;
3238 const _RealType __delta = (__xmax - __xmin) / __n;
3240 _M_int.reserve(__n + 1);
3241 _M_den.reserve(__n + 1);
3242 for (
size_t __k = 0; __k <= __nw; ++__k)
3244 _M_int.push_back(__xmin + __k * __delta);
3245 _M_den.push_back(__fw(_M_int[__k] + __delta));
3251 template<
typename _RealType>
3252 template<
typename _UniformRandomNumberGenerator>
3253 typename piecewise_linear_distribution<_RealType>::result_type
3254 piecewise_linear_distribution<_RealType>::
3255 operator()(_UniformRandomNumberGenerator& __urng,
3256 const param_type& __param)
3258 __detail::_Adaptor<_UniformRandomNumberGenerator, double>
3261 const double __p = __aurng();
3262 if (__param._M_cp.empty())
3265 auto __pos = std::lower_bound(__param._M_cp.begin(),
3266 __param._M_cp.end(), __p);
3267 const size_t __i = __pos - __param._M_cp.begin();
3269 const double __pref = __i > 0 ? __param._M_cp[__i - 1] : 0.0;
3271 const double __a = 0.5 * __param._M_m[__i];
3272 const double __b = __param._M_den[__i];
3273 const double __cm = __p - __pref;
3275 _RealType __x = __param._M_int[__i];
3280 const double __d = __b * __b + 4.0 * __a * __cm;
3281 __x += 0.5 * (
std::sqrt(__d) - __b) / __a;
3287 template<
typename _RealType>
3288 template<
typename _ForwardIterator,
3289 typename _UniformRandomNumberGenerator>
3291 piecewise_linear_distribution<_RealType>::
3292 __generate_impl(_ForwardIterator __f, _ForwardIterator __t,
3293 _UniformRandomNumberGenerator& __urng,
3294 const param_type& __param)
3296 __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
3299 *__f++ = this->operator()(__urng, __param);
3302 template<
typename _RealType,
typename _CharT,
typename _Traits>
3305 const piecewise_linear_distribution<_RealType>& __x)
3307 using __ios_base =
typename basic_ostream<_CharT, _Traits>::ios_base;
3309 const typename __ios_base::fmtflags __flags = __os.
flags();
3310 const _CharT __fill = __os.
fill();
3312 const _CharT __space = __os.
widen(
' ');
3313 __os.
flags(__ios_base::scientific | __ios_base::left);
3318 __os << __int.
size() - 1;
3320 for (
auto __xit = __int.
begin(); __xit != __int.
end(); ++__xit)
3321 __os << __space << *__xit;
3324 for (
auto __dit = __den.
begin(); __dit != __den.
end(); ++__dit)
3325 __os << __space << *__dit;
3327 __os.
flags(__flags);
3333 template<
typename _RealType,
typename _CharT,
typename _Traits>
3336 piecewise_linear_distribution<_RealType>& __x)
3338 using __ios_base =
typename basic_istream<_CharT, _Traits>::ios_base;
3340 const typename __ios_base::fmtflags __flags = __is.
flags();
3341 __is.
flags(__ios_base::dec | __ios_base::skipws);
3346 vector<_RealType> __int_vec;
3347 if (__detail::__extract_params(__is, __int_vec, __n + 1))
3349 vector<double> __den_vec;
3350 if (__detail::__extract_params(__is, __den_vec, __n + 1))
3352 __x.param({ __int_vec.begin(), __int_vec.end(),
3353 __den_vec.begin() });
3357 __is.
flags(__flags);
3362 template<
typename _IntType,
typename>
3365 _M_v.reserve(__il.size());
3366 for (
auto __iter = __il.begin(); __iter != __il.end(); ++__iter)
3367 _M_v.push_back(__detail::__mod<result_type,
3368 __detail::_Shift<result_type, 32>::__value>(*__iter));
3371 template<
typename _InputIterator>
3372 seed_seq::seed_seq(_InputIterator __begin, _InputIterator __end)
3374#pragma GCC diagnostic push
3375#pragma GCC diagnostic ignored "-Wc++17-extensions"
3376 if constexpr (__is_random_access_iter<_InputIterator>::value)
3378#pragma GCC diagnostic pop
3380 for (_InputIterator __iter = __begin; __iter != __end; ++__iter)
3381 _M_v.push_back(__detail::__mod<result_type,
3382 __detail::_Shift<result_type, 32>::__value>(*__iter));
3385 template<
typename _RandomAccessIterator>
3387 seed_seq::generate(_RandomAccessIterator __begin,
3388 _RandomAccessIterator __end)
3390 typedef typename iterator_traits<_RandomAccessIterator>::value_type
3393 if (__begin == __end)
3396 std::fill(__begin, __end, _Type(0x8b8b8b8bu));
3398 const size_t __n = __end - __begin;
3399 const size_t __s = _M_v.size();
3400 const size_t __t = (__n >= 623) ? 11
3405 const size_t __p = (__n - __t) / 2;
3406 const size_t __q = __p + __t;
3407 const size_t __m =
std::max(
size_t(__s + 1), __n);
3409#ifndef __UINT32_TYPE__
3412 _Up(uint_least32_t v) : _M_v(v & 0xffffffffu) { }
3414 operator uint_least32_t()
const {
return _M_v; }
3416 uint_least32_t _M_v;
3418 using uint32_t = _Up;
3423 uint32_t __r1 = 1371501266u;
3424 uint32_t __r2 = __r1 + __s;
3425 __begin[__p] += __r1;
3426 __begin[__q] = (uint32_t)__begin[__q] + __r2;
3430 for (
size_t __k = 1; __k <= __s; ++__k)
3432 const size_t __kn = __k % __n;
3433 const size_t __kpn = (__k + __p) % __n;
3434 const size_t __kqn = (__k + __q) % __n;
3435 uint32_t __arg = (__begin[__kn]
3437 ^ __begin[(__k - 1) % __n]);
3438 uint32_t __r1 = 1664525u * (__arg ^ (__arg >> 27));
3439 uint32_t __r2 = __r1 + (uint32_t)__kn + _M_v[__k - 1];
3440 __begin[__kpn] = (uint32_t)__begin[__kpn] + __r1;
3441 __begin[__kqn] = (uint32_t)__begin[__kqn] + __r2;
3442 __begin[__kn] = __r2;
3445 for (
size_t __k = __s + 1; __k < __m; ++__k)
3447 const size_t __kn = __k % __n;
3448 const size_t __kpn = (__k + __p) % __n;
3449 const size_t __kqn = (__k + __q) % __n;
3450 uint32_t __arg = (__begin[__kn]
3452 ^ __begin[(__k - 1) % __n]);
3453 uint32_t __r1 = 1664525u * (__arg ^ (__arg >> 27));
3454 uint32_t __r2 = __r1 + (uint32_t)__kn;
3455 __begin[__kpn] = (uint32_t)__begin[__kpn] + __r1;
3456 __begin[__kqn] = (uint32_t)__begin[__kqn] + __r2;
3457 __begin[__kn] = __r2;
3460 for (
size_t __k = __m; __k < __m + __n; ++__k)
3462 const size_t __kn = __k % __n;
3463 const size_t __kpn = (__k + __p) % __n;
3464 const size_t __kqn = (__k + __q) % __n;
3465 uint32_t __arg = (__begin[__kn]
3467 + __begin[(__k - 1) % __n]);
3468 uint32_t __r3 = 1566083941u * (__arg ^ (__arg >> 27));
3469 uint32_t __r4 = __r3 - __kn;
3470 __begin[__kpn] ^= __r3;
3471 __begin[__kqn] ^= __r4;
3472 __begin[__kn] = __r4;
3479#ifndef _GLIBCXX_USE_OLD_GENERATE_CANONICAL
3481#pragma GCC diagnostic push
3482#pragma GCC diagnostic ignored "-Wc++14-extensions"
3483#pragma GCC diagnostic ignored "-Wc++17-extensions"
3515 template<
typename _RealT,
typename _UInt,
size_t __d,
typename _Urbg>
3517 __generate_canonical_pow2(_Urbg& __urng)
3523 using _Rng =
decltype(_Urbg::max());
3524 const _Rng __rng_range_less_1 = _Urbg::max() - _Urbg::min();
3525 const _UInt __uint_range_less_1 = ~_UInt(0);
3527 const auto __log2_R = __builtin_popcountg(__rng_range_less_1);
3528 const auto __log2_uint_max = __builtin_popcountg(__uint_range_less_1);
3530 const unsigned __k = (__d + __log2_R - 1) / __log2_R;
3531 const unsigned __log2_Rk_max = __k * __log2_R;
3532 const unsigned __log2_Rk =
3533 __log2_uint_max < __log2_Rk_max ? __log2_uint_max : __log2_Rk_max;
3534 static_assert(__log2_Rk >= __d);
3536 constexpr _RealT __Rk = _RealT(_UInt(1) << (__log2_Rk - 1)) * 2.0;
3537#if defined(_GLIBCXX_GENERATE_CANONICAL_STRICT)
3538 const unsigned __log2_x = __log2_Rk - __d;
3540 const unsigned __log2_x = 0;
3542 const _UInt __x = _UInt(1) << __log2_x;
3543 constexpr _RealT __rd = __Rk / __x;
3548 _UInt __sum = _UInt(__urng() - _Urbg::min());
3549 for (
unsigned __i = __k - 1, __shift = 0; __i > 0; --__i)
3551 __shift += __log2_R;
3552 __sum |= _UInt(__urng() - _Urbg::min()) << __shift;
3554 const _RealT __ret = _RealT(__sum >> __log2_x) / __rd;
3555 if (__ret < _RealT(1.0))
3560 template <
typename _UInt>
3562 __gen_can_pow(_UInt __base,
size_t __exponent)
3565 while (--__exponent != 0) __prod *=
__base;
3569 template <
typename _UInt>
3571 __gen_can_rng_calls_needed(_UInt __R, _UInt __rd)
3574 for (
auto __Ri = __R; __Ri < __rd; __Ri *= __R)
3585 template<
typename _RealT,
typename _UInt,
size_t __d,
typename _Urbg>
3587 __generate_canonical_any(_Urbg& __urng)
3589 static_assert(__d < __builtin_popcountg(~_UInt(0)));
3592 const _UInt __r = 2;
3593 const _UInt __R = _UInt(_Urbg::max() - _Urbg::min()) + 1;
3594 const _UInt __rd = _UInt(1) << __d;
3595 const unsigned __k = __gen_can_rng_calls_needed(__R, __rd);
3596 const _UInt __Rk = __gen_can_pow(__R, __k);
3597 const _UInt __x = __Rk/__rd;
3601 _UInt __Ri = 1, __sum = __urng() - _Urbg::min();
3602 for (
int __i = __k - 1; __i > 0; --__i)
3605 __sum += (__urng() - _Urbg::min()) * __Ri;
3607 const _RealT __ret = _RealT(__sum / __x) / __rd;
3608 if (__ret < _RealT(1.0))
3613#if !defined(_GLIBCXX_GENERATE_CANONICAL_STRICT)
3614 template <
typename _Tp>
3615 const bool __is_rand_dist_float_v = is_floating_point<_Tp>::value;
3617 template <
typename _Tp>
const bool __is_rand_dist_float_v =
false;
3618 template <>
const bool __is_rand_dist_float_v<float> =
true;
3619 template <>
const bool __is_rand_dist_float_v<double> =
true;
3620 template <>
const bool __is_rand_dist_float_v<long double> =
true;
3624 template <
typename _Rng>
3625 constexpr bool __is_power_of_2_less_1(_Rng __range)
3626 {
return ((__range + 1) & __range) == 0; };
3628_GLIBCXX_BEGIN_INLINE_ABI_NAMESPACE(_V2)
3644 template<
typename _RealT,
size_t __digits,
3649#ifdef __glibcxx_concepts
3652 static_assert(__is_rand_dist_float_v<_RealT>,
3653 "template argument must be a floating point type");
3654 static_assert(__digits != 0 && _Urbg::max() > _Urbg::min(),
3655 "random samples with 0 bits are not meaningful");
3657 "only base-2 float types are supported");
3658#if defined(__STDCPP_FLOAT16_T__)
3659 static_assert(! is_same_v<_RealT, _Float16>,
3660 "float16_t type is not supported, consider using bfloat16_t");
3663 using _Rng =
decltype(_Urbg::max());
3665 const unsigned __d = __digits > __d_max ? __d_max : __digits;
3669 if constexpr (__is_power_of_2_less_1(_Urbg::max() - _Urbg::min()))
3671 if constexpr (__d <= 32)
3672 return __generate_canonical_pow2<_RealT, uint32_t, __d>(__urng);
3673 else if constexpr (__d <= 64)
3674 return __generate_canonical_pow2<_RealT, uint64_t, __d>(__urng);
3677#if defined(__SIZEOF_INT128__)
3679 return __extension__ __generate_canonical_pow2<
3680 _RealT,
unsigned __int128, __d>(__urng);
3682 static_assert(
false,
3683 "float precision >64 requires __int128 support");
3689 if constexpr (__d <= 32)
3690 return __generate_canonical_any<_RealT, uint64_t, __d>(__urng);
3693#if defined(__SIZEOF_INT128__)
3694 static_assert(__d <= 64,
3695 "irregular RNG with float precision >64 is not supported");
3696 return __extension__ __generate_canonical_any<
3697 _RealT,
unsigned __int128, __d>(__urng);
3699 static_assert(
false,
"irregular RNG with float precision"
3700 " >32 requires __int128 support");
3705_GLIBCXX_END_INLINE_ABI_NAMESPACE(_V2)
3707#pragma GCC diagnostic pop
3713 template<
typename _RealType,
size_t __bits,
3714 typename _UniformRandomNumberGenerator>
3716 generate_canonical(_UniformRandomNumberGenerator& __urng)
3719 "template argument must be a floating point type");
3724 const long double __r =
static_cast<long double>(__urng.max())
3725 -
static_cast<long double>(__urng.min()) + 1.0L;
3728 (__b + __log2r - 1UL) / __log2r);
3730 _RealType __sum = _RealType(0);
3731 _RealType __tmp = _RealType(1);
3732 for (
size_t __k = __m; __k != 0; --__k)
3734 __sum += _RealType(__urng() - __urng.min()) * __tmp;
3737 __ret = __sum / __tmp;
3738 if (__builtin_expect(__ret >= _RealType(1), 0))
3740# if _GLIBCXX_USE_C99_MATH_FUNCS
3741 __ret = std::nextafter(_RealType(1), _RealType(0));
3743 __ret = _RealType(1)
3752_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 _Tp __lg(_Tp __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.
Implementation details not part of the namespace std interface.
constexpr _Iterator __base(_Iterator __it)
A standard container for storing a fixed size sequence of elements.
char_type widen(char __c) const
Widens characters.
char_type fill() const
Retrieves the empty character.
Template class basic_istream.
Template class basic_ostream.
static constexpr bool is_integer
static constexpr int max_digits10
static constexpr int digits
static constexpr bool is_signed
static constexpr int radix
static constexpr _Tp max() noexcept
static constexpr _Tp epsilon() noexcept
streamsize precision() const
Flags access.
fmtflags flags() const
Access to format flags.
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.
const _RandomNumberEngine & base() const noexcept
_RandomNumberEngine::result_type result_type
Uniform continuous distribution for random numbers.
param_type param() const
Returns the parameter set of the distribution.
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 cauchy_distribution random number distribution.
param_type param() const
Returns the parameter set of the distribution.
result_type operator()(_UniformRandomNumberGenerator &__urng)
Generating functions.
A fisher_f_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.
param_type param() const
Returns the parameter set of the distribution.
A negative_binomial_distribution random number distribution.
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.
param_type param() const
Returns the parameter set of the distribution.
A weibull_distribution random number distribution.
param_type param() const
Returns the parameter set of the distribution.
result_type operator()(_UniformRandomNumberGenerator &__urng)
Generating functions.
A extreme_value_distribution random number distribution.
result_type operator()(_UniformRandomNumberGenerator &__urng)
Generating functions.
param_type param() const
Returns the parameter set of the distribution.
A standard container which offers fixed time access to individual elements in any order.
constexpr iterator end() noexcept
constexpr iterator begin() noexcept
constexpr size_type size() const noexcept
Uniform discrete distribution for random numbers. A discrete random distribution on the range with e...
param_type param() const
Returns the parameter set of the distribution.
Requirements for a uniform random bit generator.