libstdc++: random.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31#ifndef _RANDOM_H
32#define _RANDOM_H 1
33
36
37namespace std _GLIBCXX_VISIBILITY(default)
38{
39_GLIBCXX_BEGIN_NAMESPACE_VERSION
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58 template<typename _RealType, size_t __bits,
59 typename _UniformRandomNumberGenerator>
60 _RealType
62
63
64
65 namespace __detail
66 {
67#pragma GCC diagnostic push
68#pragma GCC diagnostic ignored "-Wc++17-extensions"
69
70 template<typename _UIntType, size_t __w,
71 bool = __w < static_cast<size_t>
73 struct _Shift
74 { static constexpr _UIntType __value = 0; };
75
76 template<typename _UIntType, size_t __w>
77 struct _Shift<_UIntType, __w, true>
78 { static constexpr _UIntType __value = _UIntType(1) << __w; };
79
80 template<int __s,
81 int __which = ((__s <= __CHAR_BIT__ * sizeof (int))
82 + (__s <= __CHAR_BIT__ * sizeof (long))
83 + (__s <= __CHAR_BIT__ * sizeof (long long))
84
85 + (__s <= 128))>
86 struct _Select_uint_least_t
87 {
88 static_assert(__which < 0,
89 "sorry, would be too much trouble for a slow result");
90 };
91
92 template<int __s>
93 struct _Select_uint_least_t<__s, 4>
94 { using type = unsigned int; };
95
96 template<int __s>
97 struct _Select_uint_least_t<__s, 3>
98 { using type = unsigned long; };
99
100 template<int __s>
101 struct _Select_uint_least_t<__s, 2>
102 { using type = unsigned long long; };
103
104#if __SIZEOF_INT128__ > __SIZEOF_LONG_LONG__
105 template<int __s>
106 struct _Select_uint_least_t<__s, 1>
107 { __extension__ using type = unsigned __int128; };
108#elif __has_builtin(__builtin_add_overflow) \
109 && __has_builtin(__builtin_sub_overflow) \
110 && defined __UINT64_TYPE__
111 template<int __s>
112 struct _Select_uint_least_t<__s, 1>
113 {
114
115
116 struct type
117 {
118 explicit
119 type(uint64_t __a) noexcept : _M_lo(__a), _M_hi(0) { }
120
121
122 friend type
123 operator*(type __l, uint64_t __x) noexcept
124 {
125
126
127
128
129 constexpr uint64_t __mask = 0xffffffff;
130 uint64_t __ll[2] = { __l._M_lo >> 32, __l._M_lo & __mask };
131 uint64_t __xx[2] = { __x >> 32, __x & __mask };
132 uint64_t __l0x0 = __ll[0] * __xx[0];
133 uint64_t __l0x1 = __ll[0] * __xx[1];
134 uint64_t __l1x0 = __ll[1] * __xx[0];
135 uint64_t __l1x1 = __ll[1] * __xx[1];
136
137
138 uint64_t __mid
139 = (__l0x1 & __mask) + (__l1x0 & __mask) + (__l1x1 >> 32);
140 __l._M_hi = __l0x0 + (__l0x1 >> 32) + (__l1x0 >> 32) + (__mid >> 32);
141 __l._M_lo = (__mid << 32) + (__l1x1 & __mask);
142 return __l;
143 }
144
145 friend type
146 operator+(type __l, uint64_t __c) noexcept
147 {
148 __l._M_hi += __builtin_add_overflow(__l._M_lo, __c, &__l._M_lo);
149 return __l;
150 }
151
152 friend type
153 operator%(type __l, uint64_t __m) noexcept
154 {
155 if (__builtin_expect(__l._M_hi == 0, 0))
156 {
157 __l._M_lo %= __m;
158 return __l;
159 }
160
161 int __shift = __builtin_clzll(__m) + 64
162 - __builtin_clzll(__l._M_hi);
163 type __x(0);
164 if (__shift >= 64)
165 {
166 __x._M_hi = __m << (__shift - 64);
167 __x._M_lo = 0;
168 }
169 else
170 {
171 __x._M_hi = __m >> (64 - __shift);
172 __x._M_lo = __m << __shift;
173 }
174
175 while (__l._M_hi != 0 || __l._M_lo >= __m)
176 {
177 if (__x <= __l)
178 {
179 __l._M_hi -= __x._M_hi;
180 __l._M_hi -= __builtin_sub_overflow(__l._M_lo, __x._M_lo,
181 &__l._M_lo);
182 }
183 __x._M_lo = (__x._M_lo >> 1) | (__x._M_hi << 63);
184 __x._M_hi >>= 1;
185 }
186 return __l;
187 }
188
189
190 explicit operator uint64_t() const noexcept
191 { return _M_lo; }
192
193 friend bool operator<(const type& __l, const type& __r) noexcept
194 {
195 if (__l._M_hi < __r._M_hi)
196 return true;
197 else if (__l._M_hi == __r._M_hi)
198 return __l._M_lo < __r._M_lo;
199 else
200 return false;
201 }
202
203 friend bool operator<=(const type& __l, const type& __r) noexcept
204 { return !(__r < __l); }
205
206 uint64_t _M_lo;
207 uint64_t _M_hi;
208 };
209 };
210#endif
211
212
213 template<typename _Tp, _Tp __m, _Tp __a, _Tp __c,
214 bool __big_enough = (!(__m & (__m - 1))
215 || (_Tp(-1) - __c) / __a >= __m - 1),
216 bool __schrage_ok = __m % __a < __m / __a>
217 struct _Mod
218 {
219 static _Tp
220 __calc(_Tp __x)
221 {
222 using _Tp2
223 = typename _Select_uint_least_t<std::__lg(__a)
225 return static_cast<_Tp>((_Tp2(__a) * __x + __c) % __m);
226 }
227 };
228
229
230 template<typename _Tp, _Tp __m, _Tp __a, _Tp __c>
231 struct _Mod<_Tp, __m, __a, __c, false, true>
232 {
233 static _Tp
234 __calc(_Tp __x);
235 };
236
237
238
239
240 template<typename _Tp, _Tp __m, _Tp __a, _Tp __c, bool __s>
241 struct _Mod<_Tp, __m, __a, __c, true, __s>
242 {
243 static _Tp
244 __calc(_Tp __x)
245 {
246 _Tp __res = __a * __x + __c;
247 if (__m)
248 __res %= __m;
249 return __res;
250 }
251 };
252
253 template<typename _Tp, _Tp __m, _Tp __a = 1, _Tp __c = 0>
254 inline _Tp
255 __mod(_Tp __x)
256 {
257 if constexpr (__a == 0)
258 return __c;
259 else
260 return _Mod<_Tp, __m, __a, __c>::__calc(__x);
261 }
262
263
264
265
266
267 template<typename _Engine, typename _DInputType>
268 struct _Adaptor
269 {
271 "template argument must be a floating point type");
272
273 public:
274 _Adaptor(_Engine& __g)
275 : _M_g(__g) { }
276
277 _DInputType
278 min() const
279 { return _DInputType(0); }
280
281 _DInputType
282 max() const
283 { return _DInputType(1); }
284
285
286
287
288
289
290 _DInputType
291 operator()()
292 {
295 _Engine>(_M_g);
296 }
297
298 private:
299 _Engine& _M_g;
300 };
301
302
303
304
305
306
307 template<typename _Sseq>
308 using __seed_seq_generate_t = decltype(
309 std::declval<_Sseq&>().generate(std::declval<uint_least32_t*>(),
310 std::declval<uint_least32_t*>()));
311
312 template<typename _Sseq, typename _Engine, typename _Res,
313 typename _GenerateCheck = __seed_seq_generate_t<_Sseq>>
314 using _If_seed_seq_for = _Require<
315 __not_<is_same<__remove_cvref_t<_Sseq>, _Engine>>,
316 is_unsigned<typename _Sseq::result_type>,
317 __not_<is_convertible<_Sseq, _Res>>
318 >;
319
320#pragma GCC diagnostic pop
321 }
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365 template<typename _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
367 {
369 "result_type must be an unsigned integral type");
370 static_assert(__m == 0u || (__a < __m && __c < __m),
371 "template argument substituting __m out of bounds");
372
373 template<typename _Sseq>
374 using _If_seed_seq
376 _UIntType>;
377
378 public:
379
381
382
384
386
388 static constexpr result_type default_seed = 1u;
389
390
391
392
393
395 { }
396
397
398
399
400
401
402
403
404 explicit
406 { seed(__s); }
407
408
409
410
411
412
413
414 template<typename _Sseq, typename = _If_seed_seq<_Sseq>>
415 explicit
417 { seed(__q); }
418
419
420
421
422
423
424
425 void
427
428
429
430
431
432
433
434
435 template<typename _Sseq>
436 _If_seed_seq<_Sseq>
438
439
440
441
442
443
444
447 { return __c == 0u ? 1u : 0u; }
448
449
450
451
454 { return __m - 1u; }
455
456
457
458
459 void
461 {
462 for (; __z != 0ULL; --__z)
463 (*this)();
464 }
465
466
467
468
471 {
472 _M_x = __detail::__mod<_UIntType, __m, __a, __c>(_M_x);
473 return _M_x;
474 }
475
476
477
478
479
480
481
482
483
484
485
486
487 friend bool
490 { return __lhs._M_x == __rhs._M_x; }
491
492
493
494
495
496
497
498
499
500 template<typename _UIntType1, _UIntType1 __a1, _UIntType1 __c1,
501 _UIntType1 __m1, typename _CharT, typename _Traits>
505 __a1, __c1, __m1>& __lcr);
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520 template<typename _UIntType1, _UIntType1 __a1, _UIntType1 __c1,
521 _UIntType1 __m1, typename _CharT, typename _Traits>
525 __c1, __m1>& __lcr);
526
527 private:
528 _UIntType _M_x;
529 };
530
531#if __cpp_impl_three_way_comparison < 201907L
532
533
534
535
536
537
538
539
540
541
542
543 template<typename _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
544 inline bool
546 __c, __m>& __lhs,
548 __c, __m>& __rhs)
549 { return !(__lhs == __rhs); }
550#endif
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583 template<typename _UIntType, size_t __w,
584 size_t __n, size_t __m, size_t __r,
585 _UIntType __a, size_t __u, _UIntType __d, size_t __s,
586 _UIntType __b, size_t __t,
587 _UIntType __c, size_t __l, _UIntType __f>
589 {
591 "result_type must be an unsigned integral type");
592 static_assert(1u <= __m && __m <= __n,
593 "template argument substituting __m out of bounds");
594 static_assert(__r <= __w, "template argument substituting "
595 "__r out of bound");
596 static_assert(__u <= __w, "template argument substituting "
597 "__u out of bound");
598 static_assert(__s <= __w, "template argument substituting "
599 "__s out of bound");
600 static_assert(__t <= __w, "template argument substituting "
601 "__t out of bound");
602 static_assert(__l <= __w, "template argument substituting "
603 "__l out of bound");
604 static_assert(__w <= std::numeric_limits<_UIntType>::digits,
605 "template argument substituting __w out of bound");
606 static_assert(__a <= (__detail::_Shift<_UIntType, __w>::__value - 1),
607 "template argument substituting __a out of bound");
608 static_assert(__b <= (__detail::_Shift<_UIntType, __w>::__value - 1),
609 "template argument substituting __b out of bound");
610 static_assert(__c <= (__detail::_Shift<_UIntType, __w>::__value - 1),
611 "template argument substituting __c out of bound");
612 static_assert(__d <= (__detail::_Shift<_UIntType, __w>::__value - 1),
613 "template argument substituting __d out of bound");
614 static_assert(__f <= (__detail::_Shift<_UIntType, __w>::__value - 1),
615 "template argument substituting __f out of bound");
616
617 template<typename _Sseq>
618 using _If_seed_seq
620 _UIntType>;
621
622 public:
623
625
626
627 static constexpr size_t word_size = __w;
628 static constexpr size_t state_size = __n;
629 static constexpr size_t shift_size = __m;
630 static constexpr size_t mask_bits = __r;
631 static constexpr result_type xor_mask = __a;
632 static constexpr size_t tempering_u = __u;
633 static constexpr result_type tempering_d = __d;
634 static constexpr size_t tempering_s = __s;
635 static constexpr result_type tempering_b = __b;
636 static constexpr size_t tempering_t = __t;
637 static constexpr result_type tempering_c = __c;
638 static constexpr size_t tempering_l = __l;
639 static constexpr result_type initialization_multiplier = __f;
640 static constexpr result_type default_seed = 5489u;
641
642
643
645
646 explicit
648 { seed(__sd); }
649
650
651
652
653
654
655
656 template<typename _Sseq, typename = _If_seed_seq<_Sseq>>
657 explicit
659 { seed(__q); }
660
661 void
663
664 template<typename _Sseq>
665 _If_seed_seq<_Sseq>
666 seed(_Sseq& __q);
667
668
669
670
673 { return 0; }
674
675
676
677
680 { return __detail::_Shift<_UIntType, __w>::__value - 1; }
681
682
683
684
685 void
686 discard(unsigned long long __z);
687
689 operator()();
690
691
692
693
694
695
696
697
698
699
700
701
702
703 friend bool
706 { return (std::equal(__lhs._M_x, __lhs._M_x + state_size, __rhs._M_x)
707 && __lhs._M_p == __rhs._M_p); }
708
709
710
711
712
713
714
715
716
717
718
719
720
721 template<typename _UIntType1,
722 size_t __w1, size_t __n1,
723 size_t __m1, size_t __r1,
724 _UIntType1 __a1, size_t __u1,
725 _UIntType1 __d1, size_t __s1,
726 _UIntType1 __b1, size_t __t1,
727 _UIntType1 __c1, size_t __l1, _UIntType1 __f1,
728 typename _CharT, typename _Traits>
732 __m1, __r1, __a1, __u1, __d1, __s1, __b1, __t1, __c1,
733 __l1, __f1>& __x);
734
735
736
737
738
739
740
741
742
743
744
745
746
747 template<typename _UIntType1,
748 size_t __w1, size_t __n1,
749 size_t __m1, size_t __r1,
750 _UIntType1 __a1, size_t __u1,
751 _UIntType1 __d1, size_t __s1,
752 _UIntType1 __b1, size_t __t1,
753 _UIntType1 __c1, size_t __l1, _UIntType1 __f1,
754 typename _CharT, typename _Traits>
758 __r1, __a1, __u1, __d1, __s1, __b1, __t1, __c1,
759 __l1, __f1>& __x);
760
761 private:
762 void _M_gen_rand();
763
764 _UIntType _M_x[state_size];
765 size_t _M_p;
766 };
767
768#if __cpp_impl_three_way_comparison < 201907L
769
770
771
772
773
774
775
776
777
778
779
780
781 template<typename _UIntType, size_t __w,
782 size_t __n, size_t __m, size_t __r,
783 _UIntType __a, size_t __u, _UIntType __d, size_t __s,
784 _UIntType __b, size_t __t,
785 _UIntType __c, size_t __l, _UIntType __f>
786 inline bool
788 __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>& __lhs,
790 __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>& __rhs)
791 { return !(__lhs == __rhs); }
792#endif
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812 template<typename _UIntType, size_t __w, size_t __s, size_t __r>
814 {
816 "result_type must be an unsigned integral type");
817 static_assert(0u < __s && __s < __r,
818 "0 < s < r");
819 static_assert(0u < __w && __w <= std::numeric_limits<_UIntType>::digits,
820 "template argument substituting __w out of bounds");
821
822 template<typename _Sseq>
823 using _If_seed_seq
825 _UIntType>;
826
827 public:
828
830
831
832 static constexpr size_t word_size = __w;
833 static constexpr size_t short_lag = __s;
834 static constexpr size_t long_lag = __r;
835 static constexpr uint_least32_t default_seed = 19780503u;
836
838 { }
839
840
841
842
843
844 explicit
846 { seed(__sd); }
847
848
849
850
851
852
853
854 template<typename _Sseq, typename = _If_seed_seq<_Sseq>>
855 explicit
857 { seed(__q); }
858
859
860
861
862
863
864
865
866
867
868
869
870
871 void
873
874
875
876
877
878 template<typename _Sseq>
879 _If_seed_seq<_Sseq>
881
882
883
884
885
888 { return 0; }
889
890
891
892
893
896 { return __detail::_Shift<_UIntType, __w>::__value - 1; }
897
898
899
900
901 void
903 {
904 for (; __z != 0ULL; --__z)
905 (*this)();
906 }
907
908
909
910
913
914
915
916
917
918
919
920
921
922
923
924
925
926 friend bool
929 { return (std::equal(__lhs._M_x, __lhs._M_x + long_lag, __rhs._M_x)
930 && __lhs._M_carry == __rhs._M_carry
931 && __lhs._M_p == __rhs._M_p); }
932
933
934
935
936
937
938
939
940
941
942
943
944
945 template<typename _UIntType1, size_t __w1, size_t __s1, size_t __r1,
946 typename _CharT, typename _Traits>
950 __s1, __r1>& __x);
951
952
953
954
955
956
957
958
959
960
961
962
963
964 template<typename _UIntType1, size_t __w1, size_t __s1, size_t __r1,
965 typename _CharT, typename _Traits>
969 __s1, __r1>& __x);
970
971 private:
972
973 _UIntType _M_x[long_lag];
974 _UIntType _M_carry;
975 size_t _M_p;
976 };
977
978#if __cpp_impl_three_way_comparison < 201907L
979
980
981
982
983
984
985
986
987
988
989
990
991 template<typename _UIntType, size_t __w, size_t __s, size_t __r>
992 inline bool
994 __s, __r>& __lhs,
996 __s, __r>& __rhs)
997 { return !(__lhs == __rhs); }
998#endif
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009 template<typename _RandomNumberEngine, size_t __p, size_t __r>
1011 {
1012 static_assert(1 <= __r && __r <= __p,
1013 "template argument substituting __r out of bounds");
1014
1015 public:
1016
1017 typedef typename _RandomNumberEngine::result_type result_type;
1018
1019 template<typename _Sseq>
1020 using _If_seed_seq
1023
1024
1025 static constexpr size_t block_size = __p;
1026 static constexpr size_t used_block = __r;
1027
1028
1029
1030
1031
1032
1034 : _M_b(), _M_n(0) { }
1035
1036
1037
1038
1039
1040
1041
1042 explicit
1044 : _M_b(__rng), _M_n(0) { }
1045
1046
1047
1048
1049
1050
1051
1052 explicit
1054 : _M_b(std::move(__rng)), _M_n(0) { }
1055
1056
1057
1058
1059
1060
1061
1062 explicit
1064 : _M_b(__s), _M_n(0) { }
1065
1066
1067
1068
1069
1070
1071 template<typename _Sseq, typename = _If_seed_seq<_Sseq>>
1072 explicit
1074 : _M_b(__q), _M_n(0)
1075 { }
1076
1077
1078
1079
1080
1081 void
1083 {
1084 _M_b.seed();
1085 _M_n = 0;
1086 }
1087
1088
1089
1090
1091
1092 void
1094 {
1095 _M_b.seed(__s);
1096 _M_n = 0;
1097 }
1098
1099
1100
1101
1102
1103
1104 template<typename _Sseq>
1105 _If_seed_seq<_Sseq>
1107 {
1108 _M_b.seed(__q);
1109 _M_n = 0;
1110 }
1111
1112
1113
1114
1115
1116 const _RandomNumberEngine&
1118 { return _M_b; }
1119
1120
1121
1122
1125 { return _RandomNumberEngine::min(); }
1126
1127
1128
1129
1132 { return _RandomNumberEngine::max(); }
1133
1134
1135
1136
1137 void
1139 {
1140 for (; __z != 0ULL; --__z)
1141 (*this)();
1142 }
1143
1144
1145
1146
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161 friend bool
1164 { return __lhs._M_b == __rhs._M_b && __lhs._M_n == __rhs._M_n; }
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177 template<typename _RandomNumberEngine1, size_t __p1, size_t __r1,
1178 typename _CharT, typename _Traits>
1182 __p1, __r1>& __x);
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195 template<typename _RandomNumberEngine1, size_t __p1, size_t __r1,
1196 typename _CharT, typename _Traits>
1200 __p1, __r1>& __x);
1201
1202 private:
1203 _RandomNumberEngine _M_b;
1204 size_t _M_n;
1205 };
1206
1207#if __cpp_impl_three_way_comparison < 201907L
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219 template<typename _RandomNumberEngine, size_t __p, size_t __r>
1220 inline bool
1222 __r>& __lhs,
1224 __r>& __rhs)
1225 { return !(__lhs == __rhs); }
1226#endif
1227
1228
1229
1230
1231
1232
1233
1234
1235 template<typename _RandomNumberEngine, size_t __w, typename _UIntType>
1237 {
1239 "result_type must be an unsigned integral type");
1240 static_assert(0u < __w && __w <= std::numeric_limits<_UIntType>::digits,
1241 "template argument substituting __w out of bounds");
1242
1243 template<typename _Sseq>
1244 using _If_seed_seq
1246 _UIntType>;
1247
1248 public:
1249
1251
1252
1253
1254
1255
1256
1258 : _M_b() { }
1259
1260
1261
1262
1263
1264
1265
1266 explicit
1268 : _M_b(__rng) { }
1269
1270
1271
1272
1273
1274
1275
1276 explicit
1278 : _M_b(std::move(__rng)) { }
1279
1280
1281
1282
1283
1284
1285
1286 explicit
1288 : _M_b(__s) { }
1289
1290
1291
1292
1293
1294
1295 template<typename _Sseq, typename = _If_seed_seq<_Sseq>>
1296 explicit
1298 : _M_b(__q)
1299 { }
1300
1301
1302
1303
1304
1305 void
1307 { _M_b.seed(); }
1308
1309
1310
1311
1312
1313 void
1315 { _M_b.seed(__s); }
1316
1317
1318
1319
1320
1321
1322 template<typename _Sseq>
1323 _If_seed_seq<_Sseq>
1325 { _M_b.seed(__q); }
1326
1327
1328
1329
1330
1331 const _RandomNumberEngine&
1333 { return _M_b; }
1334
1335
1336
1337
1340 { return 0U; }
1341
1342
1343
1344
1347 { return __detail::_Shift<_UIntType, __w>::__value - 1; }
1348
1349
1350
1351
1352 void
1354 {
1355 for (; __z != 0ULL; --__z)
1356 (*this)();
1357 }
1358
1359
1360
1361
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377 friend bool
1380 { return __lhs._M_b == __rhs._M_b; }
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394 template<typename _CharT, typename _Traits>
1398 __w, _UIntType>& __x)
1399 {
1400 __is >> __x._M_b;
1401 return __is;
1402 }
1403
1404 private:
1405 _RandomNumberEngine _M_b;
1406 };
1407
1408#if __cpp_impl_three_way_comparison < 201907L
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421 template<typename _RandomNumberEngine, size_t __w, typename _UIntType>
1422 inline bool
1424 _UIntType>& __lhs,
1426 _UIntType>& __rhs)
1427 { return !(__lhs == __rhs); }
1428#endif
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440 template<typename _RandomNumberEngine, size_t __w, typename _UIntType,
1441 typename _CharT, typename _Traits>
1445 __w, _UIntType>& __x)
1446 {
1447 __os << __x.base();
1448 return __os;
1449 }
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462 template<typename _RandomNumberEngine, size_t __k>
1464 {
1465 static_assert(1u <= __k, "template argument substituting "
1466 "__k out of bound");
1467
1468 public:
1469
1470 typedef typename _RandomNumberEngine::result_type result_type;
1471
1472 template<typename _Sseq>
1473 using _If_seed_seq
1476
1477 static constexpr size_t table_size = __k;
1478
1479
1480
1481
1482
1483
1485 : _M_b()
1486 { _M_initialize(); }
1487
1488
1489
1490
1491
1492
1493
1494 explicit
1496 : _M_b(__rng)
1497 { _M_initialize(); }
1498
1499
1500
1501
1502
1503
1504
1505 explicit
1508 { _M_initialize(); }
1509
1510
1511
1512
1513
1514
1515
1516 explicit
1518 : _M_b(__s)
1519 { _M_initialize(); }
1520
1521
1522
1523
1524
1525
1526 template<typename _Sseq, typename = _If_seed_seq<_Sseq>>
1527 explicit
1529 : _M_b(__q)
1530 { _M_initialize(); }
1531
1532
1533
1534
1535
1536 void
1538 {
1539 _M_b.seed();
1540 _M_initialize();
1541 }
1542
1543
1544
1545
1546
1547 void
1549 {
1550 _M_b.seed(__s);
1551 _M_initialize();
1552 }
1553
1554
1555
1556
1557
1558
1559 template<typename _Sseq>
1560 _If_seed_seq<_Sseq>
1562 {
1563 _M_b.seed(__q);
1564 _M_initialize();
1565 }
1566
1567
1568
1569
1570 const _RandomNumberEngine&
1572 { return _M_b; }
1573
1574
1575
1576
1579 { return _RandomNumberEngine::min(); }
1580
1581
1582
1583
1586 { return _RandomNumberEngine::max(); }
1587
1588
1589
1590
1591 void
1593 {
1594 for (; __z != 0ULL; --__z)
1595 (*this)();
1596 }
1597
1598
1599
1600
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615 friend bool
1618 { return (__lhs._M_b == __rhs._M_b
1619 && std::equal(__lhs._M_v, __lhs._M_v + __k, __rhs._M_v)
1620 && __lhs._M_y == __rhs._M_y); }
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633 template<typename _RandomNumberEngine1, size_t __k1,
1634 typename _CharT, typename _Traits>
1638 __k1>& __x);
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651 template<typename _RandomNumberEngine1, size_t __k1,
1652 typename _CharT, typename _Traits>
1656
1657 private:
1658 void _M_initialize()
1659 {
1660 for (size_t __i = 0; __i < __k; ++__i)
1661 _M_v[__i] = _M_b();
1662 _M_y = _M_b();
1663 }
1664
1665 _RandomNumberEngine _M_b;
1668 };
1669
1670#if __cpp_impl_three_way_comparison < 201907L
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682 template<typename _RandomNumberEngine, size_t __k>
1683 inline bool
1685 __k>& __lhs,
1687 __k>& __rhs)
1688 { return !(__lhs == __rhs); }
1689#endif
1690
1691
1692
1693
1694 typedef linear_congruential_engine<uint_fast32_t, 16807UL, 0UL, 2147483647UL>
1696
1697
1698
1699
1702
1703
1704
1705
1706
1707
1708
1709
1710
1712 uint_fast32_t,
1713 32, 624, 397, 31,
1714 0x9908b0dfUL, 11,
1715 0xffffffffUL, 7,
1716 0x9d2c5680UL, 15,
1717 0xefc60000UL, 18, 1812433253UL> mt19937;
1718
1719
1720
1721
1723 uint_fast64_t,
1724 64, 312, 156, 31,
1725 0xb5026f5aa96619e9ULL, 29,
1726 0x5555555555555555ULL, 17,
1727 0x71d67fffeda60000ULL, 37,
1728 0xfff7eee000000000ULL, 43,
1730
1733
1736
1738
1740
1742
1744
1745
1746
1747
1748
1749
1750
1751
1753 {
1754 public:
1755
1757
1758
1759
1761
1762 explicit
1764
1765 ~random_device()
1766 { _M_fini(); }
1767
1769 min()
1771
1773 max()
1775
1776 double
1777 entropy() const noexcept
1778 { return this->_M_getentropy(); }
1779
1781 operator()()
1782 { return this->_M_getval(); }
1783
1784
1785 random_device(const random_device&) = delete;
1786 void operator=(const random_device&) = delete;
1787
1788 private:
1789
1790 void _M_init(const std::string& __token);
1791 void _M_init_pretr1(const std::string& __token);
1792 void _M_fini();
1793
1796 double _M_getentropy() const noexcept;
1797
1798 void _M_init(const char*, size_t);
1799
1800 __extension__ union
1801 {
1802 struct
1803 {
1804 void* _M_file;
1806 int _M_fd;
1807 };
1809 };
1810 };
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828#if __cpp_impl_three_way_comparison < 201907L
1829
1830
1831
1832
1833 template<typename _IntType>
1834 inline bool
1837 { return !(__d1 == __d2); }
1838#endif
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850 template<typename _IntType, typename _CharT, typename _Traits>
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864 template<typename _IntType, typename _CharT, typename _Traits>
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880 template<typename _RealType = double>
1882 {
1884 "result_type must be a floating point type");
1885
1886 public:
1887
1889
1890
1892 {
1894
1896
1897 explicit
1898 param_type(_RealType __a, _RealType __b = _RealType(1))
1899 : _M_a(__a), _M_b(__b)
1900 {
1901 __glibcxx_assert(_M_a <= _M_b);
1902 }
1903
1905 a() const
1906 { return _M_a; }
1907
1909 b() const
1910 { return _M_b; }
1911
1912 friend bool
1914 { return __p1._M_a == __p2._M_a && __p1._M_b == __p2._M_b; }
1915
1916#if __cpp_impl_three_way_comparison < 201907L
1917 friend bool
1919 { return !(__p1 == __p2); }
1920#endif
1921
1922 private:
1923 _RealType _M_a;
1924 _RealType _M_b;
1925 };
1926
1927 public:
1928
1929
1930
1931
1932
1934
1935
1936
1937
1938
1939
1940
1941 explicit
1943 : _M_param(__a, __b)
1944 { }
1945
1946 explicit
1948 : _M_param(__p)
1949 { }
1950
1951
1952
1953
1954
1955
1956 void
1958
1960 a() const
1961 { return _M_param.a(); }
1962
1964 b() const
1965 { return _M_param.b(); }
1966
1967
1968
1969
1970 param_type
1972 { return _M_param; }
1973
1974
1975
1976
1977
1978 void
1980 { _M_param = __param; }
1981
1982
1983
1984
1987 { return this->a(); }
1988
1989
1990
1991
1994 { return this->b(); }
1995
1996
1997
1998
1999 template<typename _UniformRandomNumberGenerator>
2002 { return this->operator()(__urng, _M_param); }
2003
2004 template<typename _UniformRandomNumberGenerator>
2006 operator()(_UniformRandomNumberGenerator& __urng,
2007 const param_type& __p)
2008 {
2009 __detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
2010 __aurng(__urng);
2011 return (__aurng() * (__p.b() - __p.a())) + __p.a();
2012 }
2013
2014 template<typename _ForwardIterator,
2015 typename _UniformRandomNumberGenerator>
2016 void
2017 __generate(_ForwardIterator __f, _ForwardIterator __t,
2018 _UniformRandomNumberGenerator& __urng)
2019 { this->__generate(__f, __t, __urng, _M_param); }
2020
2021 template<typename _ForwardIterator,
2022 typename _UniformRandomNumberGenerator>
2023 void
2024 __generate(_ForwardIterator __f, _ForwardIterator __t,
2025 _UniformRandomNumberGenerator& __urng,
2026 const param_type& __p)
2027 { this->__generate_impl(__f, __t, __urng, __p); }
2028
2029 template<typename _UniformRandomNumberGenerator>
2030 void
2032 _UniformRandomNumberGenerator& __urng,
2033 const param_type& __p)
2034 { this->__generate_impl(__f, __t, __urng, __p); }
2035
2036
2037
2038
2039
2040 friend bool
2043 { return __d1._M_param == __d2._M_param; }
2044
2045 private:
2046 template<typename _ForwardIterator,
2047 typename _UniformRandomNumberGenerator>
2048 void
2049 __generate_impl(_ForwardIterator __f, _ForwardIterator __t,
2050 _UniformRandomNumberGenerator& __urng,
2051 const param_type& __p);
2052
2053 param_type _M_param;
2054 };
2055
2056#if __cpp_impl_three_way_comparison < 201907L
2057
2058
2059
2060
2061 template<typename _IntType>
2062 inline bool
2065 { return !(__d1 == __d2); }
2066#endif
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078 template<typename _RealType, typename _CharT, typename _Traits>
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092 template<typename _RealType, typename _CharT, typename _Traits>
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117 template<typename _RealType = double>
2119 {
2121 "result_type must be a floating point type");
2122
2123 public:
2124
2126
2127
2129 {
2131
2133
2134 explicit
2135 param_type(_RealType __mean, _RealType __stddev = _RealType(1))
2136 : _M_mean(__mean), _M_stddev(__stddev)
2137 {
2138 __glibcxx_assert(_M_stddev > _RealType(0));
2139 }
2140
2141 _RealType
2142 mean() const
2143 { return _M_mean; }
2144
2145 _RealType
2146 stddev() const
2147 { return _M_stddev; }
2148
2149 friend bool
2151 { return (__p1._M_mean == __p2._M_mean
2152 && __p1._M_stddev == __p2._M_stddev); }
2153
2154#if __cpp_impl_three_way_comparison < 201907L
2155 friend bool
2157 { return !(__p1 == __p2); }
2158#endif
2159
2160 private:
2161 _RealType _M_mean;
2162 _RealType _M_stddev;
2163 };
2164
2165 public:
2167
2168
2169
2170
2171
2172 explicit
2175 : _M_param(__mean, __stddev)
2176 { }
2177
2178 explicit
2180 : _M_param(__p)
2181 { }
2182
2183
2184
2185
2186 void
2188 { _M_saved_available = false; }
2189
2190
2191
2192
2193 _RealType
2195 { return _M_param.mean(); }
2196
2197
2198
2199
2200 _RealType
2202 { return _M_param.stddev(); }
2203
2204
2205
2206
2207 param_type
2209 { return _M_param; }
2210
2211
2212
2213
2214
2215 void
2217 { _M_param = __param; }
2218
2219
2220
2221
2225
2226
2227
2228
2232
2233
2234
2235
2236 template<typename _UniformRandomNumberGenerator>
2239 { return this->operator()(__urng, _M_param); }
2240
2241 template<typename _UniformRandomNumberGenerator>
2243 operator()(_UniformRandomNumberGenerator& __urng,
2244 const param_type& __p);
2245
2246 template<typename _ForwardIterator,
2247 typename _UniformRandomNumberGenerator>
2248 void
2249 __generate(_ForwardIterator __f, _ForwardIterator __t,
2250 _UniformRandomNumberGenerator& __urng)
2251 { this->__generate(__f, __t, __urng, _M_param); }
2252
2253 template<typename _ForwardIterator,
2254 typename _UniformRandomNumberGenerator>
2255 void
2256 __generate(_ForwardIterator __f, _ForwardIterator __t,
2257 _UniformRandomNumberGenerator& __urng,
2258 const param_type& __p)
2259 { this->__generate_impl(__f, __t, __urng, __p); }
2260
2261 template<typename _UniformRandomNumberGenerator>
2262 void
2264 _UniformRandomNumberGenerator& __urng,
2265 const param_type& __p)
2266 { this->__generate_impl(__f, __t, __urng, __p); }
2267
2268
2269
2270
2271
2272
2273 template<typename _RealType1>
2274 friend bool
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288 template<typename _RealType1, typename _CharT, typename _Traits>
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303 template<typename _RealType1, typename _CharT, typename _Traits>
2307
2308 private:
2309 template<typename _ForwardIterator,
2310 typename _UniformRandomNumberGenerator>
2311 void
2312 __generate_impl(_ForwardIterator __f, _ForwardIterator __t,
2313 _UniformRandomNumberGenerator& __urng,
2315
2318 bool _M_saved_available = false;
2319 };
2320
2321#if __cpp_impl_three_way_comparison < 201907L
2322
2323
2324
2325 template<typename _RealType>
2326 inline bool
2329 { return !(__d1 == __d2); }
2330#endif
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344 template<typename _RealType = double>
2346 {
2348 "result_type must be a floating point type");
2349
2350 public:
2351
2353
2354
2356 {
2358
2360
2361 explicit
2362 param_type(_RealType __m, _RealType __s = _RealType(1))
2363 : _M_m(__m), _M_s(__s)
2364 { }
2365
2366 _RealType
2367 m() const
2368 { return _M_m; }
2369
2370 _RealType
2371 s() const
2372 { return _M_s; }
2373
2374 friend bool
2376 { return __p1._M_m == __p2._M_m && __p1._M_s == __p2._M_s; }
2377
2378#if __cpp_impl_three_way_comparison < 201907L
2379 friend bool
2381 { return !(__p1 == __p2); }
2382#endif
2383
2384 private:
2385 _RealType _M_m;
2386 _RealType _M_s;
2387 };
2388
2390
2391 explicit
2393 : _M_param(__m, __s), _M_nd()
2394 { }
2395
2396 explicit
2397 lognormal_distribution(const param_type& __p)
2398 : _M_param(__p), _M_nd()
2399 { }
2400
2401
2402
2403
2404 void
2406 { _M_nd.reset(); }
2407
2408
2409
2410
2411 _RealType
2412 m() const
2413 { return _M_param.m(); }
2414
2415 _RealType
2416 s() const
2417 { return _M_param.s(); }
2418
2419
2420
2421
2422 param_type
2424 { return _M_param; }
2425
2426
2427
2428
2429
2430 void
2432 { _M_param = __param; }
2433
2434
2435
2436
2440
2441
2442
2443
2447
2448
2449
2450
2451 template<typename _UniformRandomNumberGenerator>
2454 { return this->operator()(__urng, _M_param); }
2455
2456 template<typename _UniformRandomNumberGenerator>
2458 operator()(_UniformRandomNumberGenerator& __urng,
2459 const param_type& __p)
2460 { return std::exp(__p.s() * _M_nd(__urng) + __p.m()); }
2461
2462 template<typename _ForwardIterator,
2463 typename _UniformRandomNumberGenerator>
2464 void
2465 __generate(_ForwardIterator __f, _ForwardIterator __t,
2466 _UniformRandomNumberGenerator& __urng)
2467 { this->__generate(__f, __t, __urng, _M_param); }
2468
2469 template<typename _ForwardIterator,
2470 typename _UniformRandomNumberGenerator>
2471 void
2472 __generate(_ForwardIterator __f, _ForwardIterator __t,
2473 _UniformRandomNumberGenerator& __urng,
2474 const param_type& __p)
2475 { this->__generate_impl(__f, __t, __urng, __p); }
2476
2477 template<typename _UniformRandomNumberGenerator>
2478 void
2480 _UniformRandomNumberGenerator& __urng,
2481 const param_type& __p)
2482 { this->__generate_impl(__f, __t, __urng, __p); }
2483
2484
2485
2486
2487
2488
2489 friend bool
2492 { return (__d1._M_param == __d2._M_param
2493 && __d1._M_nd == __d2._M_nd); }
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505 template<typename _RealType1, typename _CharT, typename _Traits>
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520 template<typename _RealType1, typename _CharT, typename _Traits>
2524
2525 private:
2526 template<typename _ForwardIterator,
2527 typename _UniformRandomNumberGenerator>
2528 void
2529 __generate_impl(_ForwardIterator __f, _ForwardIterator __t,
2530 _UniformRandomNumberGenerator& __urng,
2532
2534
2536 };
2537
2538#if __cpp_impl_three_way_comparison < 201907L
2539
2540
2541
2542 template<typename _RealType>
2543 inline bool
2546 { return !(__d1 == __d2); }
2547#endif
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569 template<typename _RealType = double>
2571 {
2573 "result_type must be a floating point type");
2574
2575 public:
2576
2578
2579
2581 {
2584
2586
2587 explicit
2588 param_type(_RealType __alpha_val, _RealType __beta_val = _RealType(1))
2589 : _M_alpha(__alpha_val), _M_beta(__beta_val)
2590 {
2591 __glibcxx_assert(_M_alpha > _RealType(0));
2592 _M_initialize();
2593 }
2594
2595 _RealType
2596 alpha() const
2597 { return _M_alpha; }
2598
2599 _RealType
2600 beta() const
2601 { return _M_beta; }
2602
2603 friend bool
2605 { return (__p1._M_alpha == __p2._M_alpha
2606 && __p1._M_beta == __p2._M_beta); }
2607
2608#if __cpp_impl_three_way_comparison < 201907L
2609 friend bool
2611 { return !(__p1 == __p2); }
2612#endif
2613
2614 private:
2615 void
2616 _M_initialize();
2617
2618 _RealType _M_alpha;
2619 _RealType _M_beta;
2620
2621 _RealType _M_malpha, _M_a2;
2622 };
2623
2624 public:
2625
2626
2627
2629
2630
2631
2632
2633
2634 explicit
2636 _RealType __beta_val = _RealType(1))
2637 : _M_param(__alpha_val, __beta_val), _M_nd()
2638 { }
2639
2640 explicit
2642 : _M_param(__p), _M_nd()
2643 { }
2644
2645
2646
2647
2648 void
2650 { _M_nd.reset(); }
2651
2652
2653
2654
2655 _RealType
2657 { return _M_param.alpha(); }
2658
2659
2660
2661
2662 _RealType
2664 { return _M_param.beta(); }
2665
2666
2667
2668
2669 param_type
2671 { return _M_param; }
2672
2673
2674
2675
2676
2677 void
2679 { _M_param = __param; }
2680
2681
2682
2683
2687
2688
2689
2690
2694
2695
2696
2697
2698 template<typename _UniformRandomNumberGenerator>
2701 { return this->operator()(__urng, _M_param); }
2702
2703 template<typename _UniformRandomNumberGenerator>
2705 operator()(_UniformRandomNumberGenerator& __urng,
2706 const param_type& __p);
2707
2708 template<typename _ForwardIterator,
2709 typename _UniformRandomNumberGenerator>
2710 void
2711 __generate(_ForwardIterator __f, _ForwardIterator __t,
2712 _UniformRandomNumberGenerator& __urng)
2713 { this->__generate(__f, __t, __urng, _M_param); }
2714
2715 template<typename _ForwardIterator,
2716 typename _UniformRandomNumberGenerator>
2717 void
2718 __generate(_ForwardIterator __f, _ForwardIterator __t,
2719 _UniformRandomNumberGenerator& __urng,
2720 const param_type& __p)
2721 { this->__generate_impl(__f, __t, __urng, __p); }
2722
2723 template<typename _UniformRandomNumberGenerator>
2724 void
2726 _UniformRandomNumberGenerator& __urng,
2727 const param_type& __p)
2728 { this->__generate_impl(__f, __t, __urng, __p); }
2729
2730
2731
2732
2733
2734
2735 friend bool
2738 { return (__d1._M_param == __d2._M_param
2739 && __d1._M_nd == __d2._M_nd); }
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751 template<typename _RealType1, typename _CharT, typename _Traits>
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765 template<typename _RealType1, typename _CharT, typename _Traits>
2769
2770 private:
2771 template<typename _ForwardIterator,
2772 typename _UniformRandomNumberGenerator>
2773 void
2774 __generate_impl(_ForwardIterator __f, _ForwardIterator __t,
2775 _UniformRandomNumberGenerator& __urng,
2777
2779
2781 };
2782
2783#if __cpp_impl_three_way_comparison < 201907L
2784
2785
2786
2787 template<typename _RealType>
2788 inline bool
2791 { return !(__d1 == __d2); }
2792#endif
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811 template<typename _RealType = double>
2813 {
2815 "result_type must be a floating point type");
2816
2817 public:
2818
2820
2821
2823 {
2825
2827
2828 explicit
2830 : _M_n(__n)
2831 { }
2832
2833 _RealType
2834 n() const
2835 { return _M_n; }
2836
2837 friend bool
2839 { return __p1._M_n == __p2._M_n; }
2840
2841#if __cpp_impl_three_way_comparison < 201907L
2842 friend bool
2844 { return !(__p1 == __p2); }
2845#endif
2846
2847 private:
2848 _RealType _M_n;
2849 };
2850
2852
2853 explicit
2855 : _M_param(__n), _M_gd(__n / 2)
2856 { }
2857
2858 explicit
2859 chi_squared_distribution(const param_type& __p)
2860 : _M_param(__p), _M_gd(__p.n() / 2)
2861 { }
2862
2863
2864
2865
2866 void
2868 { _M_gd.reset(); }
2869
2870
2871
2872
2873 _RealType
2874 n() const
2875 { return _M_param.n(); }
2876
2877
2878
2879
2880 param_type
2882 { return _M_param; }
2883
2884
2885
2886
2887
2888 void
2890 {
2891 _M_param = __param;
2895 }
2896
2897
2898
2899
2903
2904
2905
2906
2910
2911
2912
2913
2914 template<typename _UniformRandomNumberGenerator>
2917 { return 2 * _M_gd(__urng); }
2918
2919 template<typename _UniformRandomNumberGenerator>
2921 operator()(_UniformRandomNumberGenerator& __urng,
2922 const param_type& __p)
2923 {
2925 param_type;
2926 return 2 * _M_gd(__urng, param_type(__p.n() / 2));
2927 }
2928
2929 template<typename _ForwardIterator,
2930 typename _UniformRandomNumberGenerator>
2931 void
2932 __generate(_ForwardIterator __f, _ForwardIterator __t,
2933 _UniformRandomNumberGenerator& __urng)
2934 { this->__generate_impl(__f, __t, __urng); }
2935
2936 template<typename _ForwardIterator,
2937 typename _UniformRandomNumberGenerator>
2938 void
2939 __generate(_ForwardIterator __f, _ForwardIterator __t,
2940 _UniformRandomNumberGenerator& __urng,
2941 const param_type& __p)
2943 __p2(__p.n() / 2);
2944 this->__generate_impl(__f, __t, __urng, __p2); }
2945
2946 template<typename _UniformRandomNumberGenerator>
2947 void
2949 _UniformRandomNumberGenerator& __urng)
2950 { this->__generate_impl(__f, __t, __urng); }
2951
2952 template<typename _UniformRandomNumberGenerator>
2953 void
2955 _UniformRandomNumberGenerator& __urng,
2956 const param_type& __p)
2958 __p2(__p.n() / 2);
2959 this->__generate_impl(__f, __t, __urng, __p2); }
2960
2961
2962
2963
2964
2965
2966 friend bool
2969 { return __d1._M_param == __d2._M_param && __d1._M_gd == __d2._M_gd; }
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981 template<typename _RealType1, typename _CharT, typename _Traits>
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996 template<typename _RealType1, typename _CharT, typename _Traits>
3000
3001 private:
3002 template<typename _ForwardIterator,
3003 typename _UniformRandomNumberGenerator>
3004 void
3005 __generate_impl(_ForwardIterator __f, _ForwardIterator __t,
3006 _UniformRandomNumberGenerator& __urng);
3007
3008 template<typename _ForwardIterator,
3009 typename _UniformRandomNumberGenerator>
3010 void
3011 __generate_impl(_ForwardIterator __f, _ForwardIterator __t,
3012 _UniformRandomNumberGenerator& __urng,
3013 const typename
3015
3017
3019 };
3020
3021#if __cpp_impl_three_way_comparison < 201907L
3022
3023
3024
3025 template<typename _RealType>
3026 inline bool
3029 { return !(__d1 == __d2); }
3030#endif
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041 template<typename _RealType = double>
3043 {
3045 "result_type must be a floating point type");
3046
3047 public:
3048
3050
3051
3053 {
3055
3057
3058 explicit
3059 param_type(_RealType __a, _RealType __b = _RealType(1))
3060 : _M_a(__a), _M_b(__b)
3061 { }
3062
3063 _RealType
3064 a() const
3065 { return _M_a; }
3066
3067 _RealType
3068 b() const
3069 { return _M_b; }
3070
3071 friend bool
3073 { return __p1._M_a == __p2._M_a && __p1._M_b == __p2._M_b; }
3074
3075#if __cpp_impl_three_way_comparison < 201907L
3076 friend bool
3078 { return !(__p1 == __p2); }
3079#endif
3080
3081 private:
3082 _RealType _M_a;
3083 _RealType _M_b;
3084 };
3085
3087
3088 explicit
3090 : _M_param(__a, __b)
3091 { }
3092
3093 explicit
3094 cauchy_distribution(const param_type& __p)
3095 : _M_param(__p)
3096 { }
3097
3098
3099
3100
3101 void
3103 { }
3104
3105
3106
3107
3108 _RealType
3109 a() const
3110 { return _M_param.a(); }
3111
3112 _RealType
3113 b() const
3114 { return _M_param.b(); }
3115
3116
3117
3118
3119 param_type
3121 { return _M_param; }
3122
3123
3124
3125
3126
3127 void
3129 { _M_param = __param; }
3130
3131
3132
3133
3137
3138
3139
3140
3144
3145
3146
3147
3148 template<typename _UniformRandomNumberGenerator>
3151 { return this->operator()(__urng, _M_param); }
3152
3153 template<typename _UniformRandomNumberGenerator>
3155 operator()(_UniformRandomNumberGenerator& __urng,
3156 const param_type& __p);
3157
3158 template<typename _ForwardIterator,
3159 typename _UniformRandomNumberGenerator>
3160 void
3161 __generate(_ForwardIterator __f, _ForwardIterator __t,
3162 _UniformRandomNumberGenerator& __urng)
3163 { this->__generate(__f, __t, __urng, _M_param); }
3164
3165 template<typename _ForwardIterator,
3166 typename _UniformRandomNumberGenerator>
3167 void
3168 __generate(_ForwardIterator __f, _ForwardIterator __t,
3169 _UniformRandomNumberGenerator& __urng,
3170 const param_type& __p)
3171 { this->__generate_impl(__f, __t, __urng, __p); }
3172
3173 template<typename _UniformRandomNumberGenerator>
3174 void
3176 _UniformRandomNumberGenerator& __urng,
3177 const param_type& __p)
3178 { this->__generate_impl(__f, __t, __urng, __p); }
3179
3180
3181
3182
3183
3184 friend bool
3187 { return __d1._M_param == __d2._M_param; }
3188
3189 private:
3190 template<typename _ForwardIterator,
3191 typename _UniformRandomNumberGenerator>
3192 void
3193 __generate_impl(_ForwardIterator __f, _ForwardIterator __t,
3194 _UniformRandomNumberGenerator& __urng,
3195 const param_type& __p);
3196
3197 param_type _M_param;
3198 };
3199
3200#if __cpp_impl_three_way_comparison < 201907L
3201
3202
3203
3204
3205 template<typename _RealType>
3206 inline bool
3209 { return !(__d1 == __d2); }
3210#endif
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222 template<typename _RealType, typename _CharT, typename _Traits>
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237 template<typename _RealType, typename _CharT, typename _Traits>
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256 template<typename _RealType = double>
3258 {
3260 "result_type must be a floating point type");
3261
3262 public:
3263
3265
3266
3268 {
3270
3272
3273 explicit
3274 param_type(_RealType __m, _RealType __n = _RealType(1))
3275 : _M_m(__m), _M_n(__n)
3276 { }
3277
3278 _RealType
3279 m() const
3280 { return _M_m; }
3281
3282 _RealType
3283 n() const
3284 { return _M_n; }
3285
3286 friend bool
3288 { return __p1._M_m == __p2._M_m && __p1._M_n == __p2._M_n; }
3289
3290#if __cpp_impl_three_way_comparison < 201907L
3291 friend bool
3293 { return !(__p1 == __p2); }
3294#endif
3295
3296 private:
3297 _RealType _M_m;
3298 _RealType _M_n;
3299 };
3300
3302
3303 explicit
3305 _RealType __n = _RealType(1))
3306 : _M_param(__m, __n), _M_gd_x(__m / 2), _M_gd_y(__n / 2)
3307 { }
3308
3309 explicit
3310 fisher_f_distribution(const param_type& __p)
3311 : _M_param(__p), _M_gd_x(__p.m() / 2), _M_gd_y(__p.n() / 2)
3312 { }
3313
3314
3315
3316
3317 void
3319 {
3320 _M_gd_x.reset();
3321 _M_gd_y.reset();
3322 }
3323
3324
3325
3326
3327 _RealType
3328 m() const
3329 { return _M_param.m(); }
3330
3331 _RealType
3332 n() const
3333 { return _M_param.n(); }
3334
3335
3336
3337
3338 param_type
3340 { return _M_param; }
3341
3342
3343
3344
3345
3346 void
3348 { _M_param = __param; }
3349
3350
3351
3352
3356
3357
3358
3359
3363
3364
3365
3366
3367 template<typename _UniformRandomNumberGenerator>
3370 { return (_M_gd_x(__urng) * n()) / (_M_gd_y(__urng) * m()); }
3371
3372 template<typename _UniformRandomNumberGenerator>
3374 operator()(_UniformRandomNumberGenerator& __urng,
3375 const param_type& __p)
3376 {
3378 param_type;
3379 return ((_M_gd_x(__urng, param_type(__p.m() / 2)) * n())
3380 / (_M_gd_y(__urng, param_type(__p.n() / 2)) * m()));
3381 }
3382
3383 template<typename _ForwardIterator,
3384 typename _UniformRandomNumberGenerator>
3385 void
3386 __generate(_ForwardIterator __f, _ForwardIterator __t,
3387 _UniformRandomNumberGenerator& __urng)
3388 { this->__generate_impl(__f, __t, __urng); }
3389
3390 template<typename _ForwardIterator,
3391 typename _UniformRandomNumberGenerator>
3392 void
3393 __generate(_ForwardIterator __f, _ForwardIterator __t,
3394 _UniformRandomNumberGenerator& __urng,
3395 const param_type& __p)
3396 { this->__generate_impl(__f, __t, __urng, __p); }
3397
3398 template<typename _UniformRandomNumberGenerator>
3399 void
3401 _UniformRandomNumberGenerator& __urng)
3402 { this->__generate_impl(__f, __t, __urng); }
3403
3404 template<typename _UniformRandomNumberGenerator>
3405 void
3407 _UniformRandomNumberGenerator& __urng,
3408 const param_type& __p)
3409 { this->__generate_impl(__f, __t, __urng, __p); }
3410
3411
3412
3413
3414
3415
3416 friend bool
3419 { return (__d1._M_param == __d2._M_param
3420 && __d1._M_gd_x == __d2._M_gd_x
3421 && __d1._M_gd_y == __d2._M_gd_y); }
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433 template<typename _RealType1, typename _CharT, typename _Traits>
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448 template<typename _RealType1, typename _CharT, typename _Traits>
3452
3453 private:
3454 template<typename _ForwardIterator,
3455 typename _UniformRandomNumberGenerator>
3456 void
3457 __generate_impl(_ForwardIterator __f, _ForwardIterator __t,
3458 _UniformRandomNumberGenerator& __urng);
3459
3460 template<typename _ForwardIterator,
3461 typename _UniformRandomNumberGenerator>
3462 void
3463 __generate_impl(_ForwardIterator __f, _ForwardIterator __t,
3464 _UniformRandomNumberGenerator& __urng,
3466
3468
3470 };
3471
3472#if __cpp_impl_three_way_comparison < 201907L
3473
3474
3475
3476 template<typename _RealType>
3477 inline bool
3480 { return !(__d1 == __d2); }
3481#endif
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495 template<typename _RealType = double>
3497 {
3499 "result_type must be a floating point type");
3500
3501 public:
3502
3504
3505
3507 {
3509
3511
3512 explicit
3514 : _M_n(__n)
3515 { }
3516
3517 _RealType
3518 n() const
3519 { return _M_n; }
3520
3521 friend bool
3523 { return __p1._M_n == __p2._M_n; }
3524
3525#if __cpp_impl_three_way_comparison < 201907L
3526 friend bool
3528 { return !(__p1 == __p2); }
3529#endif
3530
3531 private:
3532 _RealType _M_n;
3533 };
3534
3536
3537 explicit
3539 : _M_param(__n), _M_nd(), _M_gd(__n / 2, 2)
3540 { }
3541
3542 explicit
3543 student_t_distribution(const param_type& __p)
3544 : _M_param(__p), _M_nd(), _M_gd(__p.n() / 2, 2)
3545 { }
3546
3547
3548
3549
3550 void
3552 {
3555 }
3556
3557
3558
3559
3560 _RealType
3561 n() const
3562 { return _M_param.n(); }
3563
3564
3565
3566
3567 param_type
3569 { return _M_param; }
3570
3571
3572
3573
3574
3575 void
3577 { _M_param = __param; }
3578
3579
3580
3581
3585
3586
3587
3588
3592
3593
3594
3595
3596 template<typename _UniformRandomNumberGenerator>
3599 { return _M_nd(__urng) * std::sqrt(n() / _M_gd(__urng)); }
3600
3601 template<typename _UniformRandomNumberGenerator>
3603 operator()(_UniformRandomNumberGenerator& __urng,
3604 const param_type& __p)
3605 {
3607 param_type;
3608
3609 const result_type __g = _M_gd(__urng, param_type(__p.n() / 2, 2));
3610 return _M_nd(__urng) * std::sqrt(__p.n() / __g);
3611 }
3612
3613 template<typename _ForwardIterator,
3614 typename _UniformRandomNumberGenerator>
3615 void
3616 __generate(_ForwardIterator __f, _ForwardIterator __t,
3617 _UniformRandomNumberGenerator& __urng)
3618 { this->__generate_impl(__f, __t, __urng); }
3619
3620 template<typename _ForwardIterator,
3621 typename _UniformRandomNumberGenerator>
3622 void
3623 __generate(_ForwardIterator __f, _ForwardIterator __t,
3624 _UniformRandomNumberGenerator& __urng,
3625 const param_type& __p)
3626 { this->__generate_impl(__f, __t, __urng, __p); }
3627
3628 template<typename _UniformRandomNumberGenerator>
3629 void
3631 _UniformRandomNumberGenerator& __urng)
3632 { this->__generate_impl(__f, __t, __urng); }
3633
3634 template<typename _UniformRandomNumberGenerator>
3635 void
3637 _UniformRandomNumberGenerator& __urng,
3638 const param_type& __p)
3639 { this->__generate_impl(__f, __t, __urng, __p); }
3640
3641
3642
3643
3644
3645
3646 friend bool
3649 { return (__d1._M_param == __d2._M_param
3650 && __d1._M_nd == __d2._M_nd && __d1._M_gd == __d2._M_gd); }
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662 template<typename _RealType1, typename _CharT, typename _Traits>
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677 template<typename _RealType1, typename _CharT, typename _Traits>
3681
3682 private:
3683 template<typename _ForwardIterator,
3684 typename _UniformRandomNumberGenerator>
3685 void
3686 __generate_impl(_ForwardIterator __f, _ForwardIterator __t,
3687 _UniformRandomNumberGenerator& __urng);
3688 template<typename _ForwardIterator,
3689 typename _UniformRandomNumberGenerator>
3690 void
3691 __generate_impl(_ForwardIterator __f, _ForwardIterator __t,
3692 _UniformRandomNumberGenerator& __urng,
3694
3696
3699 };
3700
3701#if __cpp_impl_three_way_comparison < 201907L
3702
3703
3704
3705 template<typename _RealType>
3706 inline bool
3709 { return !(__d1 == __d2); }
3710#endif
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3730 {
3731 public:
3732
3734
3735
3737 {
3739
3741
3742 explicit
3744 : _M_p(__p)
3745 {
3746 __glibcxx_assert((_M_p >= 0.0) && (_M_p <= 1.0));
3747 }
3748
3749 double
3750 p() const
3751 { return _M_p; }
3752
3753 friend bool
3755 { return __p1._M_p == __p2._M_p; }
3756
3757#if __cpp_impl_three_way_comparison < 201907L
3758 friend bool
3760 { return !(__p1 == __p2); }
3761#endif
3762
3763 private:
3764 double _M_p;
3765 };
3766
3767 public:
3768
3769
3770
3772
3773
3774
3775
3776
3777
3778
3779 explicit
3781 : _M_param(__p)
3782 { }
3783
3784 explicit
3786 : _M_param(__p)
3787 { }
3788
3789
3790
3791
3792
3793
3794 void
3796
3797
3798
3799
3800 double
3802 { return _M_param.p(); }
3803
3804
3805
3806
3807 param_type
3809 { return _M_param; }
3810
3811
3812
3813
3814
3815 void
3817 { _M_param = __param; }
3818
3819
3820
3821
3825
3826
3827
3828
3832
3833
3834
3835
3836 template<typename _UniformRandomNumberGenerator>
3839 { return this->operator()(__urng, _M_param); }
3840
3841 template<typename _UniformRandomNumberGenerator>
3843 operator()(_UniformRandomNumberGenerator& __urng,
3844 const param_type& __p)
3845 {
3846 __detail::_Adaptor<_UniformRandomNumberGenerator, double>
3847 __aurng(__urng);
3848 if ((__aurng() - __aurng.min())
3849 < __p.p() * (__aurng.max() - __aurng.min()))
3850 return true;
3851 return false;
3852 }
3853
3854 template<typename _ForwardIterator,
3855 typename _UniformRandomNumberGenerator>
3856 void
3857 __generate(_ForwardIterator __f, _ForwardIterator __t,
3858 _UniformRandomNumberGenerator& __urng)
3859 { this->__generate(__f, __t, __urng, _M_param); }
3860
3861 template<typename _ForwardIterator,
3862 typename _UniformRandomNumberGenerator>
3863 void
3864 __generate(_ForwardIterator __f, _ForwardIterator __t,
3865 _UniformRandomNumberGenerator& __urng, const param_type& __p)
3866 { this->__generate_impl(__f, __t, __urng, __p); }
3867
3868 template<typename _UniformRandomNumberGenerator>
3869 void
3871 _UniformRandomNumberGenerator& __urng,
3872 const param_type& __p)
3873 { this->__generate_impl(__f, __t, __urng, __p); }
3874
3875
3876
3877
3878
3879 friend bool
3882 { return __d1._M_param == __d2._M_param; }
3883
3884 private:
3885 template<typename _ForwardIterator,
3886 typename _UniformRandomNumberGenerator>
3887 void
3888 __generate_impl(_ForwardIterator __f, _ForwardIterator __t,
3889 _UniformRandomNumberGenerator& __urng,
3890 const param_type& __p);
3891
3892 param_type _M_param;
3893 };
3894
3895#if __cpp_impl_three_way_comparison < 201907L
3896
3897
3898
3899
3900 inline bool
3903 { return !(__d1 == __d2); }
3904#endif
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916 template<typename _CharT, typename _Traits>
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930 template<typename _CharT, typename _Traits>
3934 {
3935 double __p;
3936 if (__is >> __p)
3938 return __is;
3939 }
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952 template<typename _IntType = int>
3954 {
3956 "result_type must be an integral type");
3957
3958 public:
3959
3961
3962
3964 {
3967
3969
3970 explicit
3971 param_type(_IntType __t, double __p = 0.5)
3972 : _M_t(__t), _M_p(__p)
3973 {
3974 __glibcxx_assert((_M_t >= _IntType(0))
3975 && (_M_p >= 0.0)
3976 && (_M_p <= 1.0));
3977 _M_initialize();
3978 }
3979
3980 _IntType
3981 t() const
3982 { return _M_t; }
3983
3984 double
3985 p() const
3986 { return _M_p; }
3987
3988 friend bool
3990 { return __p1._M_t == __p2._M_t && __p1._M_p == __p2._M_p; }
3991
3992#if __cpp_impl_three_way_comparison < 201907L
3993 friend bool
3995 { return !(__p1 == __p2); }
3996#endif
3997
3998 private:
3999 void
4000 _M_initialize();
4001
4002 _IntType _M_t;
4003 double _M_p;
4004
4005 double _M_q;
4006#if _GLIBCXX_USE_C99_MATH_FUNCS
4007 double _M_d1, _M_d2, _M_s1, _M_s2, _M_c,
4008 _M_a1, _M_a123, _M_s, _M_lf, _M_lp1p;
4009#endif
4010 bool _M_easy;
4011 };
4012
4013
4014
4016
4017 explicit
4019 : _M_param(__t, __p), _M_nd()
4020 { }
4021
4022 explicit
4023 binomial_distribution(const param_type& __p)
4024 : _M_param(__p), _M_nd()
4025 { }
4026
4027
4028
4029
4030 void
4032 { _M_nd.reset(); }
4033
4034
4035
4036
4037 _IntType
4039 { return _M_param.t(); }
4040
4041
4042
4043
4044 double
4046 { return _M_param.p(); }
4047
4048
4049
4050
4051 param_type
4053 { return _M_param; }
4054
4055
4056
4057
4058
4059 void
4061 { _M_param = __param; }
4062
4063
4064
4065
4068 { return 0; }
4069
4070
4071
4072
4075 { return _M_param.t(); }
4076
4077
4078
4079
4080 template<typename _UniformRandomNumberGenerator>
4083 { return this->operator()(__urng, _M_param); }
4084
4085 template<typename _UniformRandomNumberGenerator>
4087 operator()(_UniformRandomNumberGenerator& __urng,
4088 const param_type& __p);
4089
4090 template<typename _ForwardIterator,
4091 typename _UniformRandomNumberGenerator>
4092 void
4093 __generate(_ForwardIterator __f, _ForwardIterator __t,
4094 _UniformRandomNumberGenerator& __urng)
4095 { this->__generate(__f, __t, __urng, _M_param); }
4096
4097 template<typename _ForwardIterator,
4098 typename _UniformRandomNumberGenerator>
4099 void
4100 __generate(_ForwardIterator __f, _ForwardIterator __t,
4101 _UniformRandomNumberGenerator& __urng,
4102 const param_type& __p)
4103 { this->__generate_impl(__f, __t, __urng, __p); }
4104
4105 template<typename _UniformRandomNumberGenerator>
4106 void
4108 _UniformRandomNumberGenerator& __urng,
4109 const param_type& __p)
4110 { this->__generate_impl(__f, __t, __urng, __p); }
4111
4112
4113
4114
4115
4116
4117 friend bool
4120#ifdef _GLIBCXX_USE_C99_MATH_FUNCS
4121 { return __d1._M_param == __d2._M_param && __d1._M_nd == __d2._M_nd; }
4122#else
4123 { return __d1._M_param == __d2._M_param; }
4124#endif
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136 template<typename _IntType1,
4137 typename _CharT, typename _Traits>
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152 template<typename _IntType1,
4153 typename _CharT, typename _Traits>
4157
4158 private:
4159 template<typename _ForwardIterator,
4160 typename _UniformRandomNumberGenerator>
4161 void
4162 __generate_impl(_ForwardIterator __f, _ForwardIterator __t,
4163 _UniformRandomNumberGenerator& __urng,
4165
4166 template<typename _UniformRandomNumberGenerator>
4168 _M_waiting(_UniformRandomNumberGenerator& __urng,
4169 _IntType __t, double __q);
4170
4172
4173
4175 };
4176
4177#if __cpp_impl_three_way_comparison < 201907L
4178
4179
4180
4181 template<typename _IntType>
4182 inline bool
4185 { return !(__d1 == __d2); }
4186#endif
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198 template<typename _IntType = int>
4200 {
4202 "result_type must be an integral type");
4203
4204 public:
4205
4207
4208
4210 {
4213
4215
4216 explicit
4218 : _M_p(__p)
4219 {
4220 __glibcxx_assert((_M_p > 0.0) && (_M_p < 1.0));
4221 _M_initialize();
4222 }
4223
4224 double
4225 p() const
4226 { return _M_p; }
4227
4228 friend bool
4230 { return __p1._M_p == __p2._M_p; }
4231
4232#if __cpp_impl_three_way_comparison < 201907L
4233 friend bool
4235 { return !(__p1 == __p2); }
4236#endif
4237
4238 private:
4239 void
4240 _M_initialize()
4241 { _M_log_1_p = std::log(1.0 - _M_p); }
4242
4243 double _M_p;
4244
4245 double _M_log_1_p;
4246 };
4247
4248
4249
4251
4252 explicit
4254 : _M_param(__p)
4255 { }
4256
4257 explicit
4258 geometric_distribution(const param_type& __p)
4259 : _M_param(__p)
4260 { }
4261
4262
4263
4264
4265
4266
4267 void
4269
4270
4271
4272
4273 double
4275 { return _M_param.p(); }
4276
4277
4278
4279
4280 param_type
4282 { return _M_param; }
4283
4284
4285
4286
4287
4288 void
4290 { _M_param = __param; }
4291
4292
4293
4294
4297 { return 0; }
4298
4299
4300
4301
4305
4306
4307
4308
4309 template<typename _UniformRandomNumberGenerator>
4312 { return this->operator()(__urng, _M_param); }
4313
4314 template<typename _UniformRandomNumberGenerator>
4316 operator()(_UniformRandomNumberGenerator& __urng,
4317 const param_type& __p);
4318
4319 template<typename _ForwardIterator,
4320 typename _UniformRandomNumberGenerator>
4321 void
4322 __generate(_ForwardIterator __f, _ForwardIterator __t,
4323 _UniformRandomNumberGenerator& __urng)
4324 { this->__generate(__f, __t, __urng, _M_param); }
4325
4326 template<typename _ForwardIterator,
4327 typename _UniformRandomNumberGenerator>
4328 void
4329 __generate(_ForwardIterator __f, _ForwardIterator __t,
4330 _UniformRandomNumberGenerator& __urng,
4331 const param_type& __p)
4332 { this->__generate_impl(__f, __t, __urng, __p); }
4333
4334 template<typename _UniformRandomNumberGenerator>
4335 void
4337 _UniformRandomNumberGenerator& __urng,
4338 const param_type& __p)
4339 { this->__generate_impl(__f, __t, __urng, __p); }
4340
4341
4342
4343
4344
4345 friend bool
4348 { return __d1._M_param == __d2._M_param; }
4349
4350 private:
4351 template<typename _ForwardIterator,
4352 typename _UniformRandomNumberGenerator>
4353 void
4354 __generate_impl(_ForwardIterator __f, _ForwardIterator __t,
4355 _UniformRandomNumberGenerator& __urng,
4356 const param_type& __p);
4357
4358 param_type _M_param;
4359 };
4360
4361#if __cpp_impl_three_way_comparison < 201907L
4362
4363
4364
4365
4366 template<typename _IntType>
4367 inline bool
4370 { return !(__d1 == __d2); }
4371#endif
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383 template<typename _IntType,
4384 typename _CharT, typename _Traits>
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398 template<typename _IntType,
4399 typename _CharT, typename _Traits>
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415 template<typename _IntType = int>
4417 {
4419 "result_type must be an integral type");
4420
4421 public:
4422
4424
4425
4427 {
4429
4431
4432 explicit
4433 param_type(_IntType __k, double __p = 0.5)
4434 : _M_k(__k), _M_p(__p)
4435 {
4436 __glibcxx_assert((_M_k > 0) && (_M_p > 0.0) && (_M_p <= 1.0));
4437 }
4438
4439 _IntType
4440 k() const
4441 { return _M_k; }
4442
4443 double
4444 p() const
4445 { return _M_p; }
4446
4447 friend bool
4449 { return __p1._M_k == __p2._M_k && __p1._M_p == __p2._M_p; }
4450
4451#if __cpp_impl_three_way_comparison < 201907L
4452 friend bool
4454 { return !(__p1 == __p2); }
4455#endif
4456
4457 private:
4458 _IntType _M_k;
4459 double _M_p;
4460 };
4461
4463
4464 explicit
4466 : _M_param(__k, __p), _M_gd(__k, (1.0 - __p) / __p)
4467 { }
4468
4469 explicit
4470 negative_binomial_distribution(const param_type& __p)
4471 : _M_param(__p), _M_gd(__p.k(), (1.0 - __p.p()) / __p.p())
4472 { }
4473
4474
4475
4476
4477 void
4479 { _M_gd.reset(); }
4480
4481
4482
4483
4484 _IntType
4486 { return _M_param.k(); }
4487
4488
4489
4490
4491 double
4493 { return _M_param.p(); }
4494
4495
4496
4497
4498 param_type
4500 { return _M_param; }
4501
4502
4503
4504
4505
4506 void
4508 { _M_param = __param; }
4509
4510
4511
4512
4516
4517
4518
4519
4523
4524
4525
4526
4527 template<typename _UniformRandomNumberGenerator>
4529 operator()(_UniformRandomNumberGenerator& __urng);
4530
4531 template<typename _UniformRandomNumberGenerator>
4533 operator()(_UniformRandomNumberGenerator& __urng,
4534 const param_type& __p);
4535
4536 template<typename _ForwardIterator,
4537 typename _UniformRandomNumberGenerator>
4538 void
4539 __generate(_ForwardIterator __f, _ForwardIterator __t,
4540 _UniformRandomNumberGenerator& __urng)
4541 { this->__generate_impl(__f, __t, __urng); }
4542
4543 template<typename _ForwardIterator,
4544 typename _UniformRandomNumberGenerator>
4545 void
4546 __generate(_ForwardIterator __f, _ForwardIterator __t,
4547 _UniformRandomNumberGenerator& __urng,
4548 const param_type& __p)
4549 { this->__generate_impl(__f, __t, __urng, __p); }
4550
4551 template<typename _UniformRandomNumberGenerator>
4552 void
4554 _UniformRandomNumberGenerator& __urng)
4555 { this->__generate_impl(__f, __t, __urng); }
4556
4557 template<typename _UniformRandomNumberGenerator>
4558 void
4560 _UniformRandomNumberGenerator& __urng,
4561 const param_type& __p)
4562 { this->__generate_impl(__f, __t, __urng, __p); }
4563
4564
4565
4566
4567
4568
4569 friend bool
4572 { return __d1._M_param == __d2._M_param && __d1._M_gd == __d2._M_gd; }
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585 template<typename _IntType1, typename _CharT, typename _Traits>
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600 template<typename _IntType1, typename _CharT, typename _Traits>
4604
4605 private:
4606 template<typename _ForwardIterator,
4607 typename _UniformRandomNumberGenerator>
4608 void
4609 __generate_impl(_ForwardIterator __f, _ForwardIterator __t,
4610 _UniformRandomNumberGenerator& __urng);
4611 template<typename _ForwardIterator,
4612 typename _UniformRandomNumberGenerator>
4613 void
4614 __generate_impl(_ForwardIterator __f, _ForwardIterator __t,
4615 _UniformRandomNumberGenerator& __urng,
4617
4619
4621 };
4622
4623#if __cpp_impl_three_way_comparison < 201907L
4624
4625
4626
4627 template<typename _IntType>
4628 inline bool
4631 { return !(__d1 == __d2); }
4632#endif
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652 template<typename _IntType = int>
4654 {
4656 "result_type must be an integral type");
4657
4658 public:
4659
4661
4662
4664 {
4667
4669
4670 explicit
4672 : _M_mean(__mean)
4673 {
4674 __glibcxx_assert(_M_mean > 0.0);
4675 _M_initialize();
4676 }
4677
4678 double
4679 mean() const
4680 { return _M_mean; }
4681
4682 friend bool
4684 { return __p1._M_mean == __p2._M_mean; }
4685
4686#if __cpp_impl_three_way_comparison < 201907L
4687 friend bool
4689 { return !(__p1 == __p2); }
4690#endif
4691
4692 private:
4693
4694 void
4695 _M_initialize();
4696
4697 double _M_mean;
4698
4699 double _M_lm_thr;
4700#if _GLIBCXX_USE_C99_MATH_FUNCS
4701 double _M_lfm, _M_sm, _M_d, _M_scx, _M_1cx, _M_c2b, _M_cb;
4702#endif
4703 };
4704
4705
4706
4708
4709 explicit
4711 : _M_param(__mean), _M_nd()
4712 { }
4713
4714 explicit
4715 poisson_distribution(const param_type& __p)
4716 : _M_param(__p), _M_nd()
4717 { }
4718
4719
4720
4721
4722 void
4724 { _M_nd.reset(); }
4725
4726
4727
4728
4729 double
4731 { return _M_param.mean(); }
4732
4733
4734
4735
4736 param_type
4738 { return _M_param; }
4739
4740
4741
4742
4743
4744 void
4746 { _M_param = __param; }
4747
4748
4749
4750
4753 { return 0; }
4754
4755
4756
4757
4761
4762
4763
4764
4765 template<typename _UniformRandomNumberGenerator>
4768 { return this->operator()(__urng, _M_param); }
4769
4770 template<typename _UniformRandomNumberGenerator>
4772 operator()(_UniformRandomNumberGenerator& __urng,
4773 const param_type& __p);
4774
4775 template<typename _ForwardIterator,
4776 typename _UniformRandomNumberGenerator>
4777 void
4778 __generate(_ForwardIterator __f, _ForwardIterator __t,
4779 _UniformRandomNumberGenerator& __urng)
4780 { this->__generate(__f, __t, __urng, _M_param); }
4781
4782 template<typename _ForwardIterator,
4783 typename _UniformRandomNumberGenerator>
4784 void
4785 __generate(_ForwardIterator __f, _ForwardIterator __t,
4786 _UniformRandomNumberGenerator& __urng,
4787 const param_type& __p)
4788 { this->__generate_impl(__f, __t, __urng, __p); }
4789
4790 template<typename _UniformRandomNumberGenerator>
4791 void
4793 _UniformRandomNumberGenerator& __urng,
4794 const param_type& __p)
4795 { this->__generate_impl(__f, __t, __urng, __p); }
4796
4797
4798
4799
4800
4801
4802 friend bool
4805#ifdef _GLIBCXX_USE_C99_MATH_FUNCS
4806 { return __d1._M_param == __d2._M_param && __d1._M_nd == __d2._M_nd; }
4807#else
4808 { return __d1._M_param == __d2._M_param; }
4809#endif
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821 template<typename _IntType1, typename _CharT, typename _Traits>
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836 template<typename _IntType1, typename _CharT, typename _Traits>
4840
4841 private:
4842 template<typename _ForwardIterator,
4843 typename _UniformRandomNumberGenerator>
4844 void
4845 __generate_impl(_ForwardIterator __f, _ForwardIterator __t,
4846 _UniformRandomNumberGenerator& __urng,
4848
4850
4851
4853 };
4854
4855#if __cpp_impl_three_way_comparison < 201907L
4856
4857
4858
4859 template<typename _IntType>
4860 inline bool
4863 { return !(__d1 == __d2); }
4864#endif
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884 template<typename _RealType = double>
4886 {
4888 "result_type must be a floating point type");
4889
4890 public:
4891
4893
4894
4896 {
4898
4900
4901 explicit
4903 : _M_lambda(__lambda)
4904 {
4905 __glibcxx_assert(_M_lambda > _RealType(0));
4906 }
4907
4908 _RealType
4909 lambda() const
4910 { return _M_lambda; }
4911
4912 friend bool
4914 { return __p1._M_lambda == __p2._M_lambda; }
4915
4916#if __cpp_impl_three_way_comparison < 201907L
4917 friend bool
4919 { return !(__p1 == __p2); }
4920#endif
4921
4922 private:
4923 _RealType _M_lambda;
4924 };
4925
4926 public:
4927
4928
4929
4930
4932
4933
4934
4935
4936
4937 explicit
4939 : _M_param(__lambda)
4940 { }
4941
4942 explicit
4944 : _M_param(__p)
4945 { }
4946
4947
4948
4949
4950
4951
4952 void
4954
4955
4956
4957
4958 _RealType
4960 { return _M_param.lambda(); }
4961
4962
4963
4964
4965 param_type
4967 { return _M_param; }
4968
4969
4970
4971
4972
4973 void
4975 { _M_param = __param; }
4976
4977
4978
4979
4983
4984
4985
4986
4990
4991
4992
4993
4994 template<typename _UniformRandomNumberGenerator>
4997 { return this->operator()(__urng, _M_param); }
4998
4999 template<typename _UniformRandomNumberGenerator>
5001 operator()(_UniformRandomNumberGenerator& __urng,
5002 const param_type& __p)
5003 {
5004 __detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
5005 __aurng(__urng);
5007 }
5008
5009 template<typename _ForwardIterator,
5010 typename _UniformRandomNumberGenerator>
5011 void
5012 __generate(_ForwardIterator __f, _ForwardIterator __t,
5013 _UniformRandomNumberGenerator& __urng)
5014 { this->__generate(__f, __t, __urng, _M_param); }
5015
5016 template<typename _ForwardIterator,
5017 typename _UniformRandomNumberGenerator>
5018 void
5019 __generate(_ForwardIterator __f, _ForwardIterator __t,
5020 _UniformRandomNumberGenerator& __urng,
5021 const param_type& __p)
5022 { this->__generate_impl(__f, __t, __urng, __p); }
5023
5024 template<typename _UniformRandomNumberGenerator>
5025 void
5027 _UniformRandomNumberGenerator& __urng,
5028 const param_type& __p)
5029 { this->__generate_impl(__f, __t, __urng, __p); }
5030
5031
5032
5033
5034
5035 friend bool
5038 { return __d1._M_param == __d2._M_param; }
5039
5040 private:
5041 template<typename _ForwardIterator,
5042 typename _UniformRandomNumberGenerator>
5043 void
5044 __generate_impl(_ForwardIterator __f, _ForwardIterator __t,
5045 _UniformRandomNumberGenerator& __urng,
5046 const param_type& __p);
5047
5048 param_type _M_param;
5049 };
5050
5051#if __cpp_impl_three_way_comparison < 201907L
5052
5053
5054
5055
5056 template<typename _RealType>
5057 inline bool
5060 { return !(__d1 == __d2); }
5061#endif
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073 template<typename _RealType, typename _CharT, typename _Traits>
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088 template<typename _RealType, typename _CharT, typename _Traits>
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106 template<typename _RealType = double>
5108 {
5110 "result_type must be a floating point type");
5111
5112 public:
5113
5115
5116
5118 {
5120
5122
5123 explicit
5124 param_type(_RealType __a, _RealType __b = _RealType(1.0))
5125 : _M_a(__a), _M_b(__b)
5126 { }
5127
5128 _RealType
5129 a() const
5130 { return _M_a; }
5131
5132 _RealType
5133 b() const
5134 { return _M_b; }
5135
5136 friend bool
5138 { return __p1._M_a == __p2._M_a && __p1._M_b == __p2._M_b; }
5139
5140#if __cpp_impl_three_way_comparison < 201907L
5141 friend bool
5143 { return !(__p1 == __p2); }
5144#endif
5145
5146 private:
5147 _RealType _M_a;
5148 _RealType _M_b;
5149 };
5150
5152
5153 explicit
5155 : _M_param(__a, __b)
5156 { }
5157
5158 explicit
5159 weibull_distribution(const param_type& __p)
5160 : _M_param(__p)
5161 { }
5162
5163
5164
5165
5166 void
5168 { }
5169
5170
5171
5172
5173 _RealType
5175 { return _M_param.a(); }
5176
5177
5178
5179
5180 _RealType
5182 { return _M_param.b(); }
5183
5184
5185
5186
5187 param_type
5189 { return _M_param; }
5190
5191
5192
5193
5194
5195 void
5197 { _M_param = __param; }
5198
5199
5200
5201
5205
5206
5207
5208
5212
5213
5214
5215
5216 template<typename _UniformRandomNumberGenerator>
5219 { return this->operator()(__urng, _M_param); }
5220
5221 template<typename _UniformRandomNumberGenerator>
5223 operator()(_UniformRandomNumberGenerator& __urng,
5224 const param_type& __p);
5225
5226 template<typename _ForwardIterator,
5227 typename _UniformRandomNumberGenerator>
5228 void
5229 __generate(_ForwardIterator __f, _ForwardIterator __t,
5230 _UniformRandomNumberGenerator& __urng)
5231 { this->__generate(__f, __t, __urng, _M_param); }
5232
5233 template<typename _ForwardIterator,
5234 typename _UniformRandomNumberGenerator>
5235 void
5236 __generate(_ForwardIterator __f, _ForwardIterator __t,
5237 _UniformRandomNumberGenerator& __urng,
5238 const param_type& __p)
5239 { this->__generate_impl(__f, __t, __urng, __p); }
5240
5241 template<typename _UniformRandomNumberGenerator>
5242 void
5244 _UniformRandomNumberGenerator& __urng,
5245 const param_type& __p)
5246 { this->__generate_impl(__f, __t, __urng, __p); }
5247
5248
5249
5250
5251
5252 friend bool
5255 { return __d1._M_param == __d2._M_param; }
5256
5257 private:
5258 template<typename _ForwardIterator,
5259 typename _UniformRandomNumberGenerator>
5260 void
5261 __generate_impl(_ForwardIterator __f, _ForwardIterator __t,
5262 _UniformRandomNumberGenerator& __urng,
5263 const param_type& __p);
5264
5265 param_type _M_param;
5266 };
5267
5268#if __cpp_impl_three_way_comparison < 201907L
5269
5270
5271
5272
5273 template<typename _RealType>
5274 inline bool
5277 { return !(__d1 == __d2); }
5278#endif
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290 template<typename _RealType, typename _CharT, typename _Traits>
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305 template<typename _RealType, typename _CharT, typename _Traits>
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323 template<typename _RealType = double>
5325 {
5327 "result_type must be a floating point type");
5328
5329 public:
5330
5332
5333
5335 {
5337
5339
5340 explicit
5341 param_type(_RealType __a, _RealType __b = _RealType(1.0))
5342 : _M_a(__a), _M_b(__b)
5343 { }
5344
5345 _RealType
5346 a() const
5347 { return _M_a; }
5348
5349 _RealType
5350 b() const
5351 { return _M_b; }
5352
5353 friend bool
5355 { return __p1._M_a == __p2._M_a && __p1._M_b == __p2._M_b; }
5356
5357#if __cpp_impl_three_way_comparison < 201907L
5358 friend bool
5360 { return !(__p1 == __p2); }
5361#endif
5362
5363 private:
5364 _RealType _M_a;
5365 _RealType _M_b;
5366 };
5367
5369
5370 explicit
5372 : _M_param(__a, __b)
5373 { }
5374
5375 explicit
5376 extreme_value_distribution(const param_type& __p)
5377 : _M_param(__p)
5378 { }
5379
5380
5381
5382
5383 void
5385 { }
5386
5387
5388
5389
5390 _RealType
5392 { return _M_param.a(); }
5393
5394
5395
5396
5397 _RealType
5399 { return _M_param.b(); }
5400
5401
5402
5403
5404 param_type
5406 { return _M_param; }
5407
5408
5409
5410
5411
5412 void
5414 { _M_param = __param; }
5415
5416
5417
5418
5422
5423
5424
5425
5429
5430
5431
5432
5433 template<typename _UniformRandomNumberGenerator>
5436 { return this->operator()(__urng, _M_param); }
5437
5438 template<typename _UniformRandomNumberGenerator>
5440 operator()(_UniformRandomNumberGenerator& __urng,
5441 const param_type& __p);
5442
5443 template<typename _ForwardIterator,
5444 typename _UniformRandomNumberGenerator>
5445 void
5446 __generate(_ForwardIterator __f, _ForwardIterator __t,
5447 _UniformRandomNumberGenerator& __urng)
5448 { this->__generate(__f, __t, __urng, _M_param); }
5449
5450 template<typename _ForwardIterator,
5451 typename _UniformRandomNumberGenerator>
5452 void
5453 __generate(_ForwardIterator __f, _ForwardIterator __t,
5454 _UniformRandomNumberGenerator& __urng,
5455 const param_type& __p)
5456 { this->__generate_impl(__f, __t, __urng, __p); }
5457
5458 template<typename _UniformRandomNumberGenerator>
5459 void
5461 _UniformRandomNumberGenerator& __urng,
5462 const param_type& __p)
5463 { this->__generate_impl(__f, __t, __urng, __p); }
5464
5465
5466
5467
5468
5469 friend bool
5472 { return __d1._M_param == __d2._M_param; }
5473
5474 private:
5475 template<typename _ForwardIterator,
5476 typename _UniformRandomNumberGenerator>
5477 void
5478 __generate_impl(_ForwardIterator __f, _ForwardIterator __t,
5479 _UniformRandomNumberGenerator& __urng,
5480 const param_type& __p);
5481
5482 param_type _M_param;
5483 };
5484
5485#if __cpp_impl_three_way_comparison < 201907L
5486
5487
5488
5489
5490 template<typename _RealType>
5491 inline bool
5494 { return !(__d1 == __d2); }
5495#endif
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507 template<typename _RealType, typename _CharT, typename _Traits>
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522 template<typename _RealType, typename _CharT, typename _Traits>
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545 template<typename _IntType = int>
5547 {
5549 "result_type must be an integral type");
5550
5551 public:
5552
5554
5555
5557 {
5560
5562 : _M_prob(), _M_cp()
5563 { }
5564
5565 template<typename _InputIterator>
5567 _InputIterator __wend)
5568 : _M_prob(__wbegin, __wend), _M_cp()
5569 { _M_initialize(); }
5570
5572 : _M_prob(__wil.begin(), __wil.end()), _M_cp()
5573 { _M_initialize(); }
5574
5575 template<typename _Func>
5576 param_type(size_t __nw, double __xmin, double __xmax,
5577 _Func __fw);
5578
5579
5582
5584 probabilities() const
5586
5587 friend bool
5589 { return __p1._M_prob == __p2._M_prob; }
5590
5591#if __cpp_impl_three_way_comparison < 201907L
5592 friend bool
5594 { return !(__p1 == __p2); }
5595#endif
5596
5597 private:
5598 void
5599 _M_initialize();
5600
5603 };
5604
5606 : _M_param()
5607 { }
5608
5609 template<typename _InputIterator>
5611 _InputIterator __wend)
5612 : _M_param(__wbegin, __wend)
5613 { }
5614
5615 discrete_distribution(initializer_list __wl)
5616 : _M_param(__wl)
5617 { }
5618
5619 template<typename _Func>
5620 discrete_distribution(size_t __nw, double __xmin, double __xmax,
5621 _Func __fw)
5622 : _M_param(__nw, __xmin, __xmax, __fw)
5623 { }
5624
5625 explicit
5626 discrete_distribution(const param_type& __p)
5627 : _M_param(__p)
5628 { }
5629
5630
5631
5632
5633 void
5635 { }
5636
5637
5638
5639
5642 {
5643 return _M_param._M_prob.empty()
5645 }
5646
5647
5648
5649
5650 param_type
5652 { return _M_param; }
5653
5654
5655
5656
5657
5658 void
5660 { _M_param = __param; }
5661
5662
5663
5664
5668
5669
5670
5671
5674 {
5675 return _M_param._M_prob.empty()
5677 }
5678
5679
5680
5681
5682 template<typename _UniformRandomNumberGenerator>
5685 { return this->operator()(__urng, _M_param); }
5686
5687 template<typename _UniformRandomNumberGenerator>
5689 operator()(_UniformRandomNumberGenerator& __urng,
5690 const param_type& __p);
5691
5692 template<typename _ForwardIterator,
5693 typename _UniformRandomNumberGenerator>
5694 void
5695 __generate(_ForwardIterator __f, _ForwardIterator __t,
5696 _UniformRandomNumberGenerator& __urng)
5697 { this->__generate(__f, __t, __urng, _M_param); }
5698
5699 template<typename _ForwardIterator,
5700 typename _UniformRandomNumberGenerator>
5701 void
5702 __generate(_ForwardIterator __f, _ForwardIterator __t,
5703 _UniformRandomNumberGenerator& __urng,
5704 const param_type& __p)
5705 { this->__generate_impl(__f, __t, __urng, __p); }
5706
5707 template<typename _UniformRandomNumberGenerator>
5708 void
5710 _UniformRandomNumberGenerator& __urng,
5711 const param_type& __p)
5712 { this->__generate_impl(__f, __t, __urng, __p); }
5713
5714
5715
5716
5717
5718 friend bool
5721 { return __d1._M_param == __d2._M_param; }
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733 template<typename _IntType1, typename _CharT, typename _Traits>
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749 template<typename _IntType1, typename _CharT, typename _Traits>
5753
5754 private:
5755 template<typename _ForwardIterator,
5756 typename _UniformRandomNumberGenerator>
5757 void
5758 __generate_impl(_ForwardIterator __f, _ForwardIterator __t,
5759 _UniformRandomNumberGenerator& __urng,
5761
5763 };
5764
5765#if __cpp_impl_three_way_comparison < 201907L
5766
5767
5768
5769
5770 template<typename _IntType>
5771 inline bool
5774 { return !(__d1 == __d2); }
5775#endif
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793 template<typename _RealType = double>
5795 {
5797 "result_type must be a floating point type");
5798
5799 public:
5800
5802
5803
5805 {
5808
5810 : _M_int(), _M_den(), _M_cp()
5811 { }
5812
5813 template<typename _InputIteratorB, typename _InputIteratorW>
5814 param_type(_InputIteratorB __bfirst,
5815 _InputIteratorB __bend,
5816 _InputIteratorW __wbegin);
5817
5818 template<typename _Func>
5820
5821 template<typename _Func>
5822 param_type(size_t __nw, _RealType __xmin, _RealType __xmax,
5823 _Func __fw);
5824
5825
5828
5830 intervals() const
5831 {
5832 if (_M_int.empty())
5833 {
5835 __tmp[1] = _RealType(1);
5836 return __tmp;
5837 }
5838 else
5839 return _M_int;
5840 }
5841
5843 densities() const
5845
5846 friend bool
5848 { return __p1._M_int == __p2._M_int && __p1._M_den == __p2._M_den; }
5849
5850#if __cpp_impl_three_way_comparison < 201907L
5851 friend bool
5853 { return !(__p1 == __p2); }
5854#endif
5855
5856 private:
5857 void
5858 _M_initialize();
5859
5863 };
5864
5866 : _M_param()
5867 { }
5868
5869 template<typename _InputIteratorB, typename _InputIteratorW>
5871 _InputIteratorB __bend,
5872 _InputIteratorW __wbegin)
5873 : _M_param(__bfirst, __bend, __wbegin)
5874 { }
5875
5876 template<typename _Func>
5877 piecewise_constant_distribution(initializer_list<_RealType> __bl,
5878 _Func __fw)
5879 : _M_param(__bl, __fw)
5880 { }
5881
5882 template<typename _Func>
5883 piecewise_constant_distribution(size_t __nw,
5884 _RealType __xmin, _RealType __xmax,
5885 _Func __fw)
5886 : _M_param(__nw, __xmin, __xmax, __fw)
5887 { }
5888
5889 explicit
5890 piecewise_constant_distribution(const param_type& __p)
5891 : _M_param(__p)
5892 { }
5893
5894
5895
5896
5897 void
5899 { }
5900
5901
5902
5903
5906 {
5907 if (_M_param._M_int.empty())
5908 {
5910 __tmp[1] = _RealType(1);
5911 return __tmp;
5912 }
5913 else
5914 return _M_param._M_int;
5915 }
5916
5917
5918
5919
5922 {
5923 return _M_param._M_den.empty()
5925 }
5926
5927
5928
5929
5930 param_type
5932 { return _M_param; }
5933
5934
5935
5936
5937
5938 void
5940 { _M_param = __param; }
5941
5942
5943
5944
5947 {
5948 return _M_param._M_int.empty()
5950 }
5951
5952
5953
5954
5957 {
5958 return _M_param._M_int.empty()
5960 }
5961
5962
5963
5964
5965 template<typename _UniformRandomNumberGenerator>
5968 { return this->operator()(__urng, _M_param); }
5969
5970 template<typename _UniformRandomNumberGenerator>
5972 operator()(_UniformRandomNumberGenerator& __urng,
5973 const param_type& __p);
5974
5975 template<typename _ForwardIterator,
5976 typename _UniformRandomNumberGenerator>
5977 void
5978 __generate(_ForwardIterator __f, _ForwardIterator __t,
5979 _UniformRandomNumberGenerator& __urng)
5980 { this->__generate(__f, __t, __urng, _M_param); }
5981
5982 template<typename _ForwardIterator,
5983 typename _UniformRandomNumberGenerator>
5984 void
5985 __generate(_ForwardIterator __f, _ForwardIterator __t,
5986 _UniformRandomNumberGenerator& __urng,
5987 const param_type& __p)
5988 { this->__generate_impl(__f, __t, __urng, __p); }
5989
5990 template<typename _UniformRandomNumberGenerator>
5991 void
5993 _UniformRandomNumberGenerator& __urng,
5994 const param_type& __p)
5995 { this->__generate_impl(__f, __t, __urng, __p); }
5996
5997
5998
5999
6000
6001 friend bool
6004 { return __d1._M_param == __d2._M_param; }
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017 template<typename _RealType1, typename _CharT, typename _Traits>
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033 template<typename _RealType1, typename _CharT, typename _Traits>
6037
6038 private:
6039 template<typename _ForwardIterator,
6040 typename _UniformRandomNumberGenerator>
6041 void
6042 __generate_impl(_ForwardIterator __f, _ForwardIterator __t,
6043 _UniformRandomNumberGenerator& __urng,
6045
6047 };
6048
6049#if __cpp_impl_three_way_comparison < 201907L
6050
6051
6052
6053
6054 template<typename _RealType>
6055 inline bool
6058 { return !(__d1 == __d2); }
6059#endif
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073 template<typename _RealType = double>
6075 {
6077 "result_type must be a floating point type");
6078
6079 public:
6080
6082
6083
6085 {
6088
6090 : _M_int(), _M_den(), _M_cp(), _M_m()
6091 { }
6092
6093 template<typename _InputIteratorB, typename _InputIteratorW>
6094 param_type(_InputIteratorB __bfirst,
6095 _InputIteratorB __bend,
6096 _InputIteratorW __wbegin);
6097
6098 template<typename _Func>
6100
6101 template<typename _Func>
6102 param_type(size_t __nw, _RealType __xmin, _RealType __xmax,
6103 _Func __fw);
6104
6105
6108
6110 intervals() const
6111 {
6112 if (_M_int.empty())
6113 {
6115 __tmp[1] = _RealType(1);
6116 return __tmp;
6117 }
6118 else
6119 return _M_int;
6120 }
6121
6123 densities() const
6125
6126 friend bool
6128 { return __p1._M_int == __p2._M_int && __p1._M_den == __p2._M_den; }
6129
6130#if __cpp_impl_three_way_comparison < 201907L
6131 friend bool
6133 { return !(__p1 == __p2); }
6134#endif
6135
6136 private:
6137 void
6138 _M_initialize();
6139
6144 };
6145
6147 : _M_param()
6148 { }
6149
6150 template<typename _InputIteratorB, typename _InputIteratorW>
6152 _InputIteratorB __bend,
6153 _InputIteratorW __wbegin)
6154 : _M_param(__bfirst, __bend, __wbegin)
6155 { }
6156
6157 template<typename _Func>
6158 piecewise_linear_distribution(initializer_list<_RealType> __bl,
6159 _Func __fw)
6160 : _M_param(__bl, __fw)
6161 { }
6162
6163 template<typename _Func>
6164 piecewise_linear_distribution(size_t __nw,
6165 _RealType __xmin, _RealType __xmax,
6166 _Func __fw)
6167 : _M_param(__nw, __xmin, __xmax, __fw)
6168 { }
6169
6170 explicit
6171 piecewise_linear_distribution(const param_type& __p)
6172 : _M_param(__p)
6173 { }
6174
6175
6176
6177
6178 void
6180 { }
6181
6182
6183
6184
6187 {
6188 if (_M_param._M_int.empty())
6189 {
6191 __tmp[1] = _RealType(1);
6192 return __tmp;
6193 }
6194 else
6195 return _M_param._M_int;
6196 }
6197
6198
6199
6200
6201
6204 {
6205 return _M_param._M_den.empty()
6207 }
6208
6209
6210
6211
6212 param_type
6214 { return _M_param; }
6215
6216
6217
6218
6219
6220 void
6222 { _M_param = __param; }
6223
6224
6225
6226
6229 {
6230 return _M_param._M_int.empty()
6232 }
6233
6234
6235
6236
6239 {
6240 return _M_param._M_int.empty()
6242 }
6243
6244
6245
6246
6247 template<typename _UniformRandomNumberGenerator>
6250 { return this->operator()(__urng, _M_param); }
6251
6252 template<typename _UniformRandomNumberGenerator>
6254 operator()(_UniformRandomNumberGenerator& __urng,
6255 const param_type& __p);
6256
6257 template<typename _ForwardIterator,
6258 typename _UniformRandomNumberGenerator>
6259 void
6260 __generate(_ForwardIterator __f, _ForwardIterator __t,
6261 _UniformRandomNumberGenerator& __urng)
6262 { this->__generate(__f, __t, __urng, _M_param); }
6263
6264 template<typename _ForwardIterator,
6265 typename _UniformRandomNumberGenerator>
6266 void
6267 __generate(_ForwardIterator __f, _ForwardIterator __t,
6268 _UniformRandomNumberGenerator& __urng,
6269 const param_type& __p)
6270 { this->__generate_impl(__f, __t, __urng, __p); }
6271
6272 template<typename _UniformRandomNumberGenerator>
6273 void
6275 _UniformRandomNumberGenerator& __urng,
6276 const param_type& __p)
6277 { this->__generate_impl(__f, __t, __urng, __p); }
6278
6279
6280
6281
6282
6283 friend bool
6286 { return __d1._M_param == __d2._M_param; }
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299 template<typename _RealType1, typename _CharT, typename _Traits>
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315 template<typename _RealType1, typename _CharT, typename _Traits>
6319
6320 private:
6321 template<typename _ForwardIterator,
6322 typename _UniformRandomNumberGenerator>
6323 void
6324 __generate_impl(_ForwardIterator __f, _ForwardIterator __t,
6325 _UniformRandomNumberGenerator& __urng,
6327
6329 };
6330
6331#if __cpp_impl_three_way_comparison < 201907L
6332
6333
6334
6335
6336 template<typename _RealType>
6337 inline bool
6340 { return !(__d1 == __d2); }
6341#endif
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6361 {
6362 public:
6363
6365
6366
6368 : _M_v()
6369 { }
6370
6371 template<typename _IntType, typename = _Require<is_integral<_IntType>>>
6373
6374 template<typename _InputIterator>
6375 seed_seq(_InputIterator __begin, _InputIterator __end);
6376
6377
6378 template<typename _RandomAccessIterator>
6379 void
6380 generate(_RandomAccessIterator __begin, _RandomAccessIterator __end);
6381
6382
6383 size_t size() const noexcept
6384 { return _M_v.size(); }
6385
6386 template<typename _OutputIterator>
6387 void
6388 param(_OutputIterator __dest) const
6389 { std::copy(_M_v.begin(), _M_v.end(), __dest); }
6390
6391
6394
6395 private:
6397 };
6398
6399
6400
6401
6402
6403_GLIBCXX_END_NAMESPACE_VERSION
6404}
6405
6406#endif
constexpr bool operator<=(const duration< _Rep1, _Period1 > &__lhs, const duration< _Rep2, _Period2 > &__rhs)
constexpr duration< __common_rep_t< _Rep1, __disable_if_is_duration< _Rep2 > >, _Period > operator%(const duration< _Rep1, _Period > &__d, const _Rep2 &__s)
constexpr bool operator<(const duration< _Rep1, _Period1 > &__lhs, const duration< _Rep2, _Period2 > &__rhs)
constexpr complex< _Tp > operator*(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x times y.
complex< _Tp > log(const complex< _Tp > &)
Return complex natural logarithm of z.
constexpr complex< _Tp > operator+(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x plus y.
complex< _Tp > exp(const complex< _Tp > &)
Return complex base e exponential of z.
complex< _Tp > sqrt(const complex< _Tp > &)
Return complex square root of z.
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
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...
linear_congruential_engine< uint_fast32_t, 48271UL, 0UL, 2147483647UL > minstd_rand
linear_congruential_engine< uint_fast32_t, 16807UL, 0UL, 2147483647UL > minstd_rand0
mersenne_twister_engine< uint_fast32_t, 32, 624, 397, 31, 0x9908b0dfUL, 11, 0xffffffffUL, 7, 0x9d2c5680UL, 15, 0xefc60000UL, 18, 1812433253UL > mt19937
mersenne_twister_engine< uint_fast64_t, 64, 312, 156, 31, 0xb5026f5aa96619e9ULL, 29, 0x5555555555555555ULL, 17, 0x71d67fffeda60000ULL, 37, 0xfff7eee000000000ULL, 43, 6364136223846793005ULL > mt19937_64
ISO C++ entities toplevel namespace is std.
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.
Template class basic_istream.
Template class basic_ostream.
Properties of fundamental types.
static constexpr _Tp max() noexcept
static constexpr _Tp lowest() noexcept
static constexpr _Tp min() noexcept
A model of a linear congruential random number generator.
friend std::basic_istream< _CharT, _Traits > & operator>>(std::basic_istream< _CharT, _Traits > &__is, std::linear_congruential_engine< _UIntType1, __a1, __c1, __m1 > &__lcr)
Sets the state of the engine by reading its textual representation from __is.
linear_congruential_engine(result_type __s)
Constructs a linear_congruential_engine random number generator engine with seed __s....
linear_congruential_engine(_Sseq &__q)
Constructs a linear_congruential_engine random number generator engine seeded from the seed sequence ...
static constexpr result_type min()
Gets the smallest possible value in the output range.
static constexpr result_type multiplier
void discard(unsigned long long __z)
Discard a sequence of random numbers.
linear_congruential_engine()
Constructs a linear_congruential_engine random number generator engine with seed 1.
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
_If_seed_seq< _Sseq > seed(_Sseq &__q)
Reseeds the linear_congruential_engine random number generator engine sequence using values from the ...
friend bool operator==(const linear_congruential_engine &__lhs, const linear_congruential_engine &__rhs)
Compares two linear congruential random number generator objects of the same type for equality.
friend std::basic_ostream< _CharT, _Traits > & operator<<(std::basic_ostream< _CharT, _Traits > &__os, const std::linear_congruential_engine< _UIntType1, __a1, __c1, __m1 > &__lcr)
Writes the textual representation of the state x(i) of x to __os.
result_type operator()()
Gets the next random number in the sequence.
static constexpr result_type max()
Gets the largest possible value in the output range.
void discard(unsigned long long __z)
Discard a sequence of random numbers.
mersenne_twister_engine(_Sseq &__q)
Constructs a mersenne_twister_engine random number generator engine seeded from the seed sequence __q...
friend std::basic_istream< _CharT, _Traits > & operator>>(std::basic_istream< _CharT, _Traits > &__is, std::mersenne_twister_engine< _UIntType1, __w1, __n1, __m1, __r1, __a1, __u1, __d1, __s1, __b1, __t1, __c1, __l1, __f1 > &__x)
Extracts the current state of a % mersenne_twister_engine random number generator engine __x from the...
static constexpr result_type max()
Gets the largest possible value in the output range.
friend bool operator==(const mersenne_twister_engine &__lhs, const mersenne_twister_engine &__rhs)
Compares two % mersenne_twister_engine random number generator objects of the same type for equality.
friend std::basic_ostream< _CharT, _Traits > & operator<<(std::basic_ostream< _CharT, _Traits > &__os, const std::mersenne_twister_engine< _UIntType1, __w1, __n1, __m1, __r1, __a1, __u1, __d1, __s1, __b1, __t1, __c1, __l1, __f1 > &__x)
Inserts the current state of a % mersenne_twister_engine random number generator engine __x into the ...
static constexpr result_type min()
Gets the smallest possible value in the output range.
The Marsaglia-Zaman generator.
void seed(result_type __sd=0u)
Seeds the initial state of the random number generator.
friend std::basic_ostream< _CharT, _Traits > & operator<<(std::basic_ostream< _CharT, _Traits > &__os, const std::subtract_with_carry_engine< _UIntType1, __w1, __s1, __r1 > &__x)
Inserts the current state of a % subtract_with_carry_engine random number generator engine __x into t...
subtract_with_carry_engine(result_type __sd)
Constructs an explicitly seeded subtract_with_carry_engine random number generator.
void discard(unsigned long long __z)
Discard a sequence of random numbers.
result_type operator()()
Gets the next random number in the sequence.
_If_seed_seq< _Sseq > seed(_Sseq &__q)
Seeds the initial state of the % subtract_with_carry_engine random number generator.
static constexpr result_type min()
Gets the inclusive minimum value of the range of random integers returned by this generator.
friend std::basic_istream< _CharT, _Traits > & operator>>(std::basic_istream< _CharT, _Traits > &__is, std::subtract_with_carry_engine< _UIntType1, __w1, __s1, __r1 > &__x)
Extracts the current state of a % subtract_with_carry_engine random number generator engine __x from ...
friend bool operator==(const subtract_with_carry_engine &__lhs, const subtract_with_carry_engine &__rhs)
Compares two % subtract_with_carry_engine random number generator objects of the same type for equali...
subtract_with_carry_engine(_Sseq &__q)
Constructs a subtract_with_carry_engine random number engine seeded from the seed sequence __q.
static constexpr result_type max()
Gets the inclusive maximum value of the range of random integers returned by this generator.
void seed(result_type __s)
Reseeds the discard_block_engine object with the default seed for the underlying base class generator...
static constexpr result_type min()
Gets the minimum value in the generated random number range.
friend std::basic_ostream< _CharT, _Traits > & operator<<(std::basic_ostream< _CharT, _Traits > &__os, const std::discard_block_engine< _RandomNumberEngine1, __p1, __r1 > &__x)
Inserts the current state of a discard_block_engine random number generator engine __x into the outpu...
const _RandomNumberEngine & base() const noexcept
Gets a const reference to the underlying generator engine object.
void seed()
Reseeds the discard_block_engine object with the default seed for the underlying base class generator...
_If_seed_seq< _Sseq > seed(_Sseq &__q)
Reseeds the discard_block_engine object with the given seed sequence.
discard_block_engine(const _RandomNumberEngine &__rng)
Copy constructs a discard_block_engine engine.
void discard(unsigned long long __z)
Discard a sequence of random numbers.
discard_block_engine(_RandomNumberEngine &&__rng)
Move constructs a discard_block_engine engine.
friend std::basic_istream< _CharT, _Traits > & operator>>(std::basic_istream< _CharT, _Traits > &__is, std::discard_block_engine< _RandomNumberEngine1, __p1, __r1 > &__x)
Extracts the current state of a % subtract_with_carry_engine random number generator engine __x from ...
static constexpr result_type max()
Gets the maximum value in the generated random number range.
discard_block_engine()
Constructs a default discard_block_engine engine.
friend bool operator==(const discard_block_engine &__lhs, const discard_block_engine &__rhs)
Compares two discard_block_engine random number generator objects of the same type for equality.
discard_block_engine(_Sseq &__q)
Generator construct a discard_block_engine engine.
result_type operator()()
Gets the next value in the generated random number sequence.
discard_block_engine(result_type __s)
Seed constructs a discard_block_engine engine.
_RandomNumberEngine::result_type result_type
_If_seed_seq< _Sseq > seed(_Sseq &__q)
Reseeds the independent_bits_engine object with the given seed sequence.
independent_bits_engine(_Sseq &__q)
Generator construct a independent_bits_engine engine.
independent_bits_engine(const _RandomNumberEngine &__rng)
Copy constructs a independent_bits_engine engine.
static constexpr result_type min()
Gets the minimum value in the generated random number range.
result_type operator()()
Gets the next value in the generated random number sequence.
void seed()
Reseeds the independent_bits_engine object with the default seed for the underlying base class genera...
void discard(unsigned long long __z)
Discard a sequence of random numbers.
void seed(result_type __s)
Reseeds the independent_bits_engine object with the default seed for the underlying base class genera...
friend std::basic_istream< _CharT, _Traits > & operator>>(std::basic_istream< _CharT, _Traits > &__is, std::independent_bits_engine< _RandomNumberEngine, __w, _UIntType > &__x)
Extracts the current state of a % subtract_with_carry_engine random number generator engine __x from ...
friend bool operator==(const independent_bits_engine &__lhs, const independent_bits_engine &__rhs)
Compares two independent_bits_engine random number generator objects of the same type for equality.
static constexpr result_type max()
Gets the maximum value in the generated random number range.
independent_bits_engine()
Constructs a default independent_bits_engine engine.
const _RandomNumberEngine & base() const noexcept
Gets a const reference to the underlying generator engine object.
independent_bits_engine(result_type __s)
Seed constructs a independent_bits_engine engine.
independent_bits_engine(_RandomNumberEngine &&__rng)
Move constructs a independent_bits_engine engine.
Produces random numbers by reordering random numbers from some base engine.
_If_seed_seq< _Sseq > seed(_Sseq &__q)
Reseeds the shuffle_order_engine object with the given seed sequence.
static constexpr result_type min()
shuffle_order_engine()
Constructs a default shuffle_order_engine engine.
static constexpr result_type max()
shuffle_order_engine(const _RandomNumberEngine &__rng)
Copy constructs a shuffle_order_engine engine.
shuffle_order_engine(_Sseq &__q)
Generator construct a shuffle_order_engine engine.
const _RandomNumberEngine & base() const noexcept
shuffle_order_engine(_RandomNumberEngine &&__rng)
Move constructs a shuffle_order_engine engine.
void seed()
Reseeds the shuffle_order_engine object with the default seed for the underlying base class generator...
shuffle_order_engine(result_type __s)
Seed constructs a shuffle_order_engine engine.
_RandomNumberEngine::result_type result_type
friend bool operator==(const shuffle_order_engine &__lhs, const shuffle_order_engine &__rhs)
void discard(unsigned long long __z)
void seed(result_type __s)
Reseeds the shuffle_order_engine object with the default seed for the underlying base class generator...
friend std::basic_ostream< _CharT, _Traits > & operator<<(std::basic_ostream< _CharT, _Traits > &__os, const std::shuffle_order_engine< _RandomNumberEngine1, __k1 > &__x)
Inserts the current state of a shuffle_order_engine random number generator engine __x into the outpu...
friend std::basic_istream< _CharT, _Traits > & operator>>(std::basic_istream< _CharT, _Traits > &__is, std::shuffle_order_engine< _RandomNumberEngine1, __k1 > &__x)
Extracts the current state of a % subtract_with_carry_engine random number generator engine __x from ...
Uniform continuous distribution for random numbers.
param_type param() const
Returns the parameter set of the distribution.
void reset()
Resets the distribution state.
uniform_real_distribution(_RealType __a, _RealType __b=_RealType(1))
Constructs a uniform_real_distribution object.
result_type min() const
Returns the inclusive lower bound of the distribution range.
friend bool operator==(const uniform_real_distribution &__d1, const uniform_real_distribution &__d2)
Return true if two uniform real distributions have the same parameters.
result_type max() const
Returns the inclusive upper bound of the distribution range.
uniform_real_distribution()
Constructs a uniform_real_distribution object.
result_type operator()(_UniformRandomNumberGenerator &__urng)
Generating functions.
void param(const param_type &__param)
Sets the parameter set of the distribution.
A normal continuous distribution for random numbers.
_RealType stddev() const
Returns the standard deviation of the distribution.
param_type param() const
Returns the parameter set of the distribution.
void reset()
Resets the distribution state.
friend std::basic_istream< _CharT, _Traits > & operator>>(std::basic_istream< _CharT, _Traits > &__is, std::normal_distribution< _RealType1 > &__x)
Extracts a normal_distribution random number distribution __x from the input stream __is.
void param(const param_type &__param)
Sets the parameter set of the distribution.
result_type min() const
Returns the greatest lower bound value of the distribution.
_RealType mean() const
Returns the mean of the distribution.
friend std::basic_ostream< _CharT, _Traits > & operator<<(std::basic_ostream< _CharT, _Traits > &__os, const std::normal_distribution< _RealType1 > &__x)
Inserts a normal_distribution random number distribution __x into the output stream __os.
normal_distribution(result_type __mean, result_type __stddev=result_type(1))
result_type max() const
Returns the least upper bound value of the distribution.
result_type operator()(_UniformRandomNumberGenerator &__urng)
Generating functions.
friend bool operator==(const std::normal_distribution< _RealType1 > &__d1, const std::normal_distribution< _RealType1 > &__d2)
Return true if two normal distributions have the same parameters and the sequences that would be gene...
A lognormal_distribution random number distribution.
friend bool operator==(const lognormal_distribution &__d1, const lognormal_distribution &__d2)
Return true if two lognormal distributions have the same parameters and the sequences that would be g...
param_type param() const
Returns the parameter set of the distribution.
friend std::basic_istream< _CharT, _Traits > & operator>>(std::basic_istream< _CharT, _Traits > &__is, std::lognormal_distribution< _RealType1 > &__x)
Extracts a lognormal_distribution random number distribution __x from the input stream __is.
result_type min() const
Returns the greatest lower bound value of the distribution.
friend std::basic_ostream< _CharT, _Traits > & operator<<(std::basic_ostream< _CharT, _Traits > &__os, const std::lognormal_distribution< _RealType1 > &__x)
Inserts a lognormal_distribution random number distribution __x into the output stream __os.
void param(const param_type &__param)
Sets the parameter set of the distribution.
result_type max() const
Returns the least upper bound value of the distribution.
result_type operator()(_UniformRandomNumberGenerator &__urng)
Generating functions.
A gamma continuous distribution for random numbers.
gamma_distribution(_RealType __alpha_val, _RealType __beta_val=_RealType(1))
Constructs a gamma distribution with parameters and .
void reset()
Resets the distribution state.
friend std::basic_ostream< _CharT, _Traits > & operator<<(std::basic_ostream< _CharT, _Traits > &__os, const std::gamma_distribution< _RealType1 > &__x)
Inserts a gamma_distribution random number distribution __x into the output stream __os.
result_type operator()(_UniformRandomNumberGenerator &__urng)
Generating functions.
result_type min() const
Returns the greatest lower bound value of the distribution.
_RealType alpha() const
Returns the of the distribution.
gamma_distribution()
Constructs a gamma distribution with parameters 1 and 1.
friend bool operator==(const gamma_distribution &__d1, const gamma_distribution &__d2)
Return true if two gamma distributions have the same parameters and the sequences that would be gener...
void param(const param_type &__param)
Sets the parameter set of the distribution.
_RealType beta() const
Returns the of the distribution.
friend std::basic_istream< _CharT, _Traits > & operator>>(std::basic_istream< _CharT, _Traits > &__is, std::gamma_distribution< _RealType1 > &__x)
Extracts a gamma_distribution random number distribution __x from the input stream __is.
param_type param() const
Returns the parameter set of the distribution.
result_type max() const
Returns the least upper bound value of the distribution.
A chi_squared_distribution random number distribution.
result_type operator()(_UniformRandomNumberGenerator &__urng)
Generating functions.
param_type param() const
Returns the parameter set of the distribution.
friend bool operator==(const chi_squared_distribution &__d1, const chi_squared_distribution &__d2)
Return true if two Chi-squared distributions have the same parameters and the sequences that would be...
result_type min() const
Returns the greatest lower bound value of the distribution.
friend std::basic_ostream< _CharT, _Traits > & operator<<(std::basic_ostream< _CharT, _Traits > &__os, const std::chi_squared_distribution< _RealType1 > &__x)
Inserts a chi_squared_distribution random number distribution __x into the output stream __os.
void reset()
Resets the distribution state.
void param(const param_type &__param)
Sets the parameter set of the distribution.
result_type max() const
Returns the least upper bound value of the distribution.
friend std::basic_istream< _CharT, _Traits > & operator>>(std::basic_istream< _CharT, _Traits > &__is, std::chi_squared_distribution< _RealType1 > &__x)
Extracts a chi_squared_distribution random number distribution __x from the input stream __is.
A cauchy_distribution random number distribution.
result_type min() const
Returns the greatest lower bound value of the distribution.
friend bool operator==(const cauchy_distribution &__d1, const cauchy_distribution &__d2)
Return true if two Cauchy distributions have the same parameters.
void reset()
Resets the distribution state.
param_type param() const
Returns the parameter set of the distribution.
result_type operator()(_UniformRandomNumberGenerator &__urng)
Generating functions.
result_type max() const
Returns the least upper bound value of the distribution.
void param(const param_type &__param)
Sets the parameter set of the distribution.
A fisher_f_distribution random number distribution.
void param(const param_type &__param)
Sets the parameter set of the distribution.
result_type max() const
Returns the least upper bound value of the distribution.
void reset()
Resets the distribution state.
param_type param() const
Returns the parameter set of the distribution.
friend bool operator==(const fisher_f_distribution &__d1, const fisher_f_distribution &__d2)
Return true if two Fisher f distributions have the same parameters and the sequences that would be ge...
result_type min() const
Returns the greatest lower bound value of the distribution.
result_type operator()(_UniformRandomNumberGenerator &__urng)
Generating functions.
friend std::basic_ostream< _CharT, _Traits > & operator<<(std::basic_ostream< _CharT, _Traits > &__os, const std::fisher_f_distribution< _RealType1 > &__x)
Inserts a fisher_f_distribution random number distribution __x into the output stream __os.
friend std::basic_istream< _CharT, _Traits > & operator>>(std::basic_istream< _CharT, _Traits > &__is, std::fisher_f_distribution< _RealType1 > &__x)
Extracts a fisher_f_distribution random number distribution __x from the input stream __is.
A student_t_distribution random number distribution.
void param(const param_type &__param)
Sets the parameter set of the distribution.
result_type max() const
Returns the least upper bound value of the distribution.
result_type min() const
Returns the greatest lower bound value of the distribution.
void reset()
Resets the distribution state.
friend bool operator==(const student_t_distribution &__d1, const student_t_distribution &__d2)
Return true if two Student t distributions have the same parameters and the sequences that would be g...
result_type operator()(_UniformRandomNumberGenerator &__urng)
Generating functions.
friend std::basic_ostream< _CharT, _Traits > & operator<<(std::basic_ostream< _CharT, _Traits > &__os, const std::student_t_distribution< _RealType1 > &__x)
Inserts a student_t_distribution random number distribution __x into the output stream __os.
friend std::basic_istream< _CharT, _Traits > & operator>>(std::basic_istream< _CharT, _Traits > &__is, std::student_t_distribution< _RealType1 > &__x)
Extracts a student_t_distribution random number distribution __x from the input stream __is.
param_type param() const
Returns the parameter set of the distribution.
A Bernoulli random number distribution.
void reset()
Resets the distribution state.
result_type max() const
Returns the least upper bound value of the distribution.
friend bool operator==(const bernoulli_distribution &__d1, const bernoulli_distribution &__d2)
Return true if two Bernoulli distributions have the same parameters.
param_type param() const
Returns the parameter set of the distribution.
bernoulli_distribution()
Constructs a Bernoulli distribution with likelihood 0.5.
bernoulli_distribution(double __p)
Constructs a Bernoulli distribution with likelihood p.
result_type min() const
Returns the greatest lower bound value of the distribution.
double p() const
Returns the p parameter of the distribution.
void param(const param_type &__param)
Sets the parameter set of the distribution.
result_type operator()(_UniformRandomNumberGenerator &__urng)
Generating functions.
A discrete binomial random number distribution.
result_type min() const
Returns the greatest lower bound value of the distribution.
result_type max() const
Returns the least upper bound value of the distribution.
void param(const param_type &__param)
Sets the parameter set of the distribution.
result_type operator()(_UniformRandomNumberGenerator &__urng)
Generating functions.
friend bool operator==(const binomial_distribution &__d1, const binomial_distribution &__d2)
Return true if two binomial distributions have the same parameters and the sequences that would be ge...
param_type param() const
Returns the parameter set of the distribution.
friend std::basic_istream< _CharT, _Traits > & operator>>(std::basic_istream< _CharT, _Traits > &__is, std::binomial_distribution< _IntType1 > &__x)
Extracts a binomial_distribution random number distribution __x from the input stream __is.
_IntType t() const
Returns the distribution t parameter.
friend std::basic_ostream< _CharT, _Traits > & operator<<(std::basic_ostream< _CharT, _Traits > &__os, const std::binomial_distribution< _IntType1 > &__x)
Inserts a binomial_distribution random number distribution __x into the output stream __os.
void reset()
Resets the distribution state.
double p() const
Returns the distribution p parameter.
A discrete geometric random number distribution.
double p() const
Returns the distribution parameter p.
result_type operator()(_UniformRandomNumberGenerator &__urng)
Generating functions.
result_type max() const
Returns the least upper bound value of the distribution.
friend bool operator==(const geometric_distribution &__d1, const geometric_distribution &__d2)
Return true if two geometric distributions have the same parameters.
param_type param() const
Returns the parameter set of the distribution.
void param(const param_type &__param)
Sets the parameter set of the distribution.
void reset()
Resets the distribution state.
result_type min() const
Returns the greatest lower bound value of the distribution.
A negative_binomial_distribution random number distribution.
friend std::basic_ostream< _CharT, _Traits > & operator<<(std::basic_ostream< _CharT, _Traits > &__os, const std::negative_binomial_distribution< _IntType1 > &__x)
Inserts a negative_binomial_distribution random number distribution __x into the output stream __os.
result_type operator()(_UniformRandomNumberGenerator &__urng)
Generating functions.
friend std::basic_istream< _CharT, _Traits > & operator>>(std::basic_istream< _CharT, _Traits > &__is, std::negative_binomial_distribution< _IntType1 > &__x)
Extracts a negative_binomial_distribution random number distribution __x from the input stream __is.
void param(const param_type &__param)
Sets the parameter set of the distribution.
result_type min() const
Returns the greatest lower bound value of the distribution.
result_type max() const
Returns the least upper bound value of the distribution.
double p() const
Return the parameter of the distribution.
friend bool operator==(const negative_binomial_distribution &__d1, const negative_binomial_distribution &__d2)
Return true if two negative binomial distributions have the same parameters and the sequences that wo...
param_type param() const
Returns the parameter set of the distribution.
_IntType k() const
Return the parameter of the distribution.
void reset()
Resets the distribution state.
A discrete Poisson random number distribution.
void reset()
Resets the distribution state.
result_type operator()(_UniformRandomNumberGenerator &__urng)
Generating functions.
double mean() const
Returns the distribution parameter mean.
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...
result_type max() const
Returns the least upper bound value of the distribution.
void param(const param_type &__param)
Sets the parameter set of the distribution.
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.
param_type param() const
Returns the parameter set of the distribution.
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.
result_type min() const
Returns the greatest lower bound value of the distribution.
An exponential continuous distribution for random numbers.
_RealType lambda() const
Returns the inverse scale parameter of the distribution.
exponential_distribution()
Constructs an exponential distribution with inverse scale parameter 1.0.
exponential_distribution(_RealType __lambda)
Constructs an exponential distribution with inverse scale parameter .
result_type operator()(_UniformRandomNumberGenerator &__urng)
Generating functions.
void reset()
Resets the distribution state.
result_type min() const
Returns the greatest lower bound value of the distribution.
param_type param() const
Returns the parameter set of the distribution.
result_type max() const
Returns the least upper bound value of the distribution.
void param(const param_type &__param)
Sets the parameter set of the distribution.
friend bool operator==(const exponential_distribution &__d1, const exponential_distribution &__d2)
Return true if two exponential distributions have the same parameters.
A weibull_distribution random number distribution.
param_type param() const
Returns the parameter set of the distribution.
result_type min() const
Returns the greatest lower bound value of the distribution.
void reset()
Resets the distribution state.
result_type operator()(_UniformRandomNumberGenerator &__urng)
Generating functions.
friend bool operator==(const weibull_distribution &__d1, const weibull_distribution &__d2)
Return true if two Weibull distributions have the same parameters.
void param(const param_type &__param)
Sets the parameter set of the distribution.
_RealType b() const
Return the parameter of the distribution.
result_type max() const
Returns the least upper bound value of the distribution.
_RealType a() const
Return the parameter of the distribution.
A extreme_value_distribution random number distribution.
void reset()
Resets the distribution state.
_RealType b() const
Return the parameter of the distribution.
result_type operator()(_UniformRandomNumberGenerator &__urng)
Generating functions.
void param(const param_type &__param)
Sets the parameter set of the distribution.
result_type min() const
Returns the greatest lower bound value of the distribution.
result_type max() const
Returns the least upper bound value of the distribution.
_RealType a() const
Return the parameter of the distribution.
friend bool operator==(const extreme_value_distribution &__d1, const extreme_value_distribution &__d2)
Return true if two extreme value distributions have the same parameters.
param_type param() const
Returns the parameter set of the distribution.
A discrete_distribution random number distribution.
friend std::basic_ostream< _CharT, _Traits > & operator<<(std::basic_ostream< _CharT, _Traits > &__os, const std::discrete_distribution< _IntType1 > &__x)
Inserts a discrete_distribution random number distribution __x into the output stream __os.
result_type min() const
Returns the greatest lower bound value of the distribution.
friend std::basic_istream< _CharT, _Traits > & operator>>(std::basic_istream< _CharT, _Traits > &__is, std::discrete_distribution< _IntType1 > &__x)
Extracts a discrete_distribution random number distribution __x from the input stream __is.
result_type max() const
Returns the least upper bound value of the distribution.
void reset()
Resets the distribution state.
param_type param() const
Returns the parameter set of the distribution.
friend bool operator==(const discrete_distribution &__d1, const discrete_distribution &__d2)
Return true if two discrete distributions have the same parameters.
std::vector< double > probabilities() const
Returns the probabilities of the distribution.
result_type operator()(_UniformRandomNumberGenerator &__urng)
Generating functions.
void param(const param_type &__param)
Sets the parameter set of the distribution.
A piecewise_constant_distribution random number distribution.
std::vector< double > densities() const
Returns a vector of the probability densities.
void param(const param_type &__param)
Sets the parameter set of the distribution.
result_type min() const
Returns the greatest lower bound value of the distribution.
result_type max() const
Returns the least upper bound value of the distribution.
void reset()
Resets the distribution state.
friend std::basic_ostream< _CharT, _Traits > & operator<<(std::basic_ostream< _CharT, _Traits > &__os, const std::piecewise_constant_distribution< _RealType1 > &__x)
Inserts a piecewise_constant_distribution random number distribution __x into the output stream __os.
param_type param() const
Returns the parameter set of the distribution.
friend bool operator==(const piecewise_constant_distribution &__d1, const piecewise_constant_distribution &__d2)
Return true if two piecewise constant distributions have the same parameters.
result_type operator()(_UniformRandomNumberGenerator &__urng)
Generating functions.
friend std::basic_istream< _CharT, _Traits > & operator>>(std::basic_istream< _CharT, _Traits > &__is, std::piecewise_constant_distribution< _RealType1 > &__x)
Extracts a piecewise_constant_distribution random number distribution __x from the input stream __is.
std::vector< _RealType > intervals() const
Returns a vector of the intervals.
A piecewise_linear_distribution random number distribution.
result_type operator()(_UniformRandomNumberGenerator &__urng)
Generating functions.
result_type max() const
Returns the least upper bound value of the distribution.
friend std::basic_istream< _CharT, _Traits > & operator>>(std::basic_istream< _CharT, _Traits > &__is, std::piecewise_linear_distribution< _RealType1 > &__x)
Extracts a piecewise_linear_distribution random number distribution __x from the input stream __is.
std::vector< _RealType > intervals() const
Return the intervals of the distribution.
param_type param() const
Returns the parameter set of the distribution.
friend bool operator==(const piecewise_linear_distribution &__d1, const piecewise_linear_distribution &__d2)
Return true if two piecewise linear distributions have the same parameters.
void param(const param_type &__param)
Sets the parameter set of the distribution.
result_type min() const
Returns the greatest lower bound value of the distribution.
std::vector< double > densities() const
Return a vector of the probability densities of the distribution.
friend std::basic_ostream< _CharT, _Traits > & operator<<(std::basic_ostream< _CharT, _Traits > &__os, const std::piecewise_linear_distribution< _RealType1 > &__x)
Inserts a piecewise_linear_distribution random number distribution __x into the output stream __os.
The seed_seq class generates sequences of seeds for random number generators.
uint_least32_t result_type
One of the math functors.
A standard container which offers fixed time access to individual elements in any order.
constexpr iterator end() noexcept
constexpr iterator begin() noexcept
constexpr reference front() noexcept
constexpr bool empty() const noexcept
constexpr size_type size() const noexcept
constexpr reference back() noexcept
Uniform discrete distribution for random numbers. A discrete random distribution on the range with e...