Debian Codegraph @

headers/random

raw
1 /* Copyright (C) 2015 Povilas Kanapickas <[email protected]>
2
3 This file is part of cppreference-doc
4
5 This work is licensed under the Creative Commons Attribution-ShareAlike 3.0
6 Unported License. To view a copy of this license, visit
7 http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative
8 Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.
9
10 Permission is granted to copy, distribute and/or modify this document
11 under the terms of the GNU Free Documentation License, Version 1.3 or
12 any later version published by the Free Software Foundation; with no
13 Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
14 */
15
16 #ifndef CPPREFERENCE_RANDOM_H
17 #define CPPREFERENCE_RANDOM_H
18
19 #if CPPREFERENCE_STDVER >= 2011
20 #include <initializer_list>
21
22 namespace std {
23
24 template <
25 class UIntType,
26 UIntType a,
27 UIntType c,
28 UIntType m
29 > class linear_congruential_engine {
30 public:
31 typedef UIntType result_type;
32 static constexpr UIntType multiplier;
33 static constexpr UIntType increment;
34 static constexpr UIntType modulus;
35 static constexpr UIntType default_seed;
36
37 explicit linear_congruential_engine(result_type value = default_seed);
38
39 template<class Sseq >
40 explicit linear_congruential_engine(Sseq& s);
41
42 linear_congruential_engine(const linear_congruential_engine& other);
43
44 void seed(result_type value = default_seed);
45
46 template<class Sseq >
47 void seed(Sseq& seq);
48
49 result_type operator()();
50
51 void discard(unsigned long long z);
52
53 static constexpr result_type min();
54 static constexpr result_type max();
55 };
56
57 template<class UIntType, UIntType a, UIntType c, UIntType m >
58 bool operator==(const linear_congruential_engine<UIntType, a, c, m>& lhs,
59 const linear_congruential_engine<UIntType, a, c, m>& rhs);
60
61 template<class UIntType, UIntType a, UIntType c, UIntType m >
62 bool operator==(const linear_congruential_engine<UIntType, a, c, m>& lhs,
63 const linear_congruential_engine<UIntType, a, c, m>& rhs);
64
65 template<class CharT, class Traits, class ResultType,
66 class UIntType, UIntType a, UIntType c, UIntType m >
67 std::basic_ostream<CharT, Traits>&
68 operator<<(std::basic_ostream<CharT, Traits>& ost,
69 const linear_congruential_engine<UIntType, a, c, m>& e);
70
71 template<class CharT, class Traits, class ResultType,
72 class UIntType, UIntType a, UIntType c, UIntType m >
73 std::basic_istream<CharT, Traits>&
74 operator>>(std::basic_istream<CharT, Traits>& ist,
75 linear_congruential_engine<UIntType, a, c, m>& e);
76
77 typedef std::linear_congruential_engine<std::uint_fast32_t, 16807, 0, 2147483647> minstd_rand0;
78 typedef std::linear_congruential_engine<std::uint_fast32_t, 48271, 0, 2147483647> minstd_rand;
79
80 template <
81 class UIntType,
82 size_t w, size_t n, size_t m, size_t r,
83 UIntType a, size_t u, UIntType d, size_t s,
84 UIntType b, size_t t,
85 UIntType c, size_t l, UIntType f
86 > class mersenne_twister_engine {
87 public:
88 typedef UIntType result_type;
89 static constexpr size_t word_size;
90 static constexpr size_t state_size;
91 static constexpr size_t shift_size;
92 static constexpr size_t mask_bits;
93 static constexpr UIntType xor_mask;
94 static constexpr size_t tampering_u;
95 static constexpr UIntType tampering_d;
96 static constexpr size_t tampering_s;
97 static constexpr UIntType tampering_b;
98 static constexpr size_t tampering_t;
99 static constexpr UIntType tampering_c;
100 static constexpr size_t tampering_l;
101 static constexpr UIntType initialization_multiplier;
102
103 explicit mersenne_twister_engine(result_type value = default_seed);
104
105 template<class Sseq >
106 explicit mersenne_twister_engine(Sseq& s);
107
108 mersenne_twister_engine(const mersenne_twister_engine& other);
109
110 void seed(result_type value = default_seed);
111
112 template<class Sseq >
113 void seed(Sseq& seq);
114
115 result_type operator()();
116
117 void discard(unsigned long long z);
118
119 static constexpr result_type min();
120 static constexpr result_type max();
121 };
122
123 template<class UIntType,
124 size_t w, size_t n, size_t m, size_t r,
125 UIntType a, size_t u, UIntType d, size_t s,
126 UIntType b, size_t t,
127 UIntType c, size_t l, UIntType f >
128 bool operator==(const mersenne_twister_engine<UIntType, w, n, m, r, a, u, d, s, b, t, c, l, f>& lhs,
129 const mersenne_twister_engine<UIntType, w, n, m, r, a, u, d, s, b, t, c, l, f>& rhs);
130
131 template<class UIntType,
132 size_t w, size_t n, size_t m, size_t r,
133 UIntType a, size_t u, UIntType d, size_t s,
134 UIntType b, size_t t,
135 UIntType c, size_t l, UIntType f >
136 bool operator==(const mersenne_twister_engine<UIntType, w, n, m, r, a, u, d, s, b, t, c, l, f>& lhs,
137 const mersenne_twister_engine<UIntType, w, n, m, r, a, u, d, s, b, t, c, l, f>& rhs);
138
139 template<class CharT, class Traits, class ResultType,
140
141 class UIntType,
142 size_t w, size_t n, size_t m, size_t r,
143 UIntType a, size_t u, UIntType d, size_t s,
144 UIntType b, size_t t,
145 UIntType c, size_t l, UIntType f >
146 std::basic_ostream<CharT, Traits>&
147 operator<<(std::basic_ostream<CharT, Traits>& ost,
148 const mersenne_twister_engine<UIntType, w, n, m, r, a, u, d, s, b, t, c, l, f>& e);
149
150 template<class CharT, class Traits, class ResultType,
151
152 class UIntType,
153 size_t w, size_t n, size_t m, size_t r,
154 UIntType a, size_t u, UIntType d, size_t s,
155 UIntType b, size_t t,
156 UIntType c, size_t l, UIntType f >
157 std::basic_istream<CharT, Traits>&
158 operator>>(std::basic_istream<CharT, Traits>& ist,
159 mersenne_twister_engine<UIntType, w, n, m, r, a, u, d, s, b, t, c, l, f>& e);
160
161 typedef std::mersenne_twister_engine<std::uint_fast32_t, 32, 624, 397, 31,
162 0x9908b0df, 11,
163 0xffffffff, 7,
164 0x9d2c5680, 15,
165 0xefc60000, 18, 1812433253> mt19937;
166
167 typedef std::mersenne_twister_engine<std::uint_fast64_t, 64, 312, 156, 31,
168 0xb5026f5aa96619e9, 29,
169 0x5555555555555555, 17,
170 0x71d67fffeda60000, 37,
171 0xfff7eee000000000, 43, 6364136223846793005> mt19937_64;
172
173 template <
174 class UIntType,
175 size_t w, size_t s, size_t r
176 > class subtract_with_carry_engine {
177 public:
178 typedef UIntType result_type;
179 static constexpr size_t word_size;
180 static constexpr size_t short_lag;
181 static constexpr size_t long_lag;
182 static constexpr UIntType default_seed;
183
184 explicit subtract_with_carry_engine(result_type value = default_seed);
185
186 template<class Sseq >
187 explicit subtract_with_carry_engine(Sseq& s);
188
189 subtract_with_carry_engine(const subtract_with_carry_engine& other);
190
191 void seed(result_type value = default_seed);
192
193 template<class Sseq >
194 void seed(Sseq& seq);
195
196 result_type operator()();
197
198 void discard(unsigned long long z);
199
200 static constexpr result_type min();
201 static constexpr result_type max();
202 };
203
204 template<class UIntType, size_t w, size_t s, size_t r >
205 bool operator==(const subtract_with_carry_engine<UIntType, w, s, r>& lhs,
206 const subtract_with_carry_engine<UIntType, w, s, r>& rhs);
207
208 template<class UIntType, size_t w, size_t s, size_t r >
209 bool operator==(const subtract_with_carry_engine<UIntType, w, s, r>& lhs,
210 const subtract_with_carry_engine<UIntType, w, s, r>& rhs);
211
212 template<class CharT, class Traits, class ResultType,
213 class UIntType, size_t w, size_t s, size_t r >
214 std::basic_ostream<CharT, Traits>&
215 operator<<(std::basic_ostream<CharT, Traits>& ost,
216 const subtract_with_carry_engine<UIntType, w, s, r>& e);
217
218 template<class CharT, class Traits, class ResultType,
219 class UIntType, size_t w, size_t s, size_t r >
220 std::basic_istream<CharT, Traits>&
221 operator>>(std::basic_istream<CharT, Traits>& ist,
222 subtract_with_carry_engine<UIntType, w, s, r>& e);
223
224 typedef std::subtract_with_carry_engine<std::uint_fast32_t, 24, 10, 24> ranlux24_base;
225 typedef std::subtract_with_carry_engine<std::uint_fast64_t, 48, 5, 12> ranlex48_base;
226
227 template <
228 class Engine,
229 size_t P, size_t R
230 > class discard_block_engine {
231 public:
232 typedef typename Engine::result_type result_type;
233 static constexpr size_t block_size;
234 static constexpr size_t used_size;
235
236 discard_block_engine();
237
238 explicit discard_block_engine(result_type s);
239
240 template<class Sseq >
241 explicit discard_block_engine(Sseq& seq);
242 explicit discard_block_engine(const Engine& e);
243 explicit discard_block_engine(Engine&& e);
244
245 const Engine& base() const;
246
247 void seed();
248 void seed(result_type value);
249
250 template<class Sseq >
251 void seed(Sseq& seq);
252
253 result_type operator()();
254
255 void discard(unsigned long long z);
256
257 static constexpr result_type min();
258 static constexpr result_type max();
259 };
260
261 template<class Engine, size_t p, size_t r >
262 bool operator==(const discard_block_engine<Engine, p, r>& lhs,
263 const discard_block_engine<Engine, p, r>& rhs);
264
265 template<class Engine, size_t p, size_t r >
266 bool operator!=(const discard_block_engine<Engine, p, r>& lhs,
267 const discard_block_engine<Engine, p, r>& rhs);
268
269 template<class CharT, class Traits, class ResultType,
270 class Engine, size_t p, size_t r >
271 std::basic_ostream<CharT, Traits>&
272 operator<<(std::basic_ostream<CharT, Traits>& ost,
273 const discard_block_engine<Engine, p, r>& e);
274
275 template<class CharT, class Traits, class ResultType,
276 class Engine, size_t p, size_t r >
277 std::basic_istream<CharT, Traits>&
278 operator>>(std::basic_istream<CharT, Traits>& ist,
279 discard_block_engine<Engine, p, r>& e);
280
281 typedef std::discard_block_engine<std::ranlux24_base, 223, 23> randex24;
282 typedef std::discard_block_engine<std::ranlux48_base, 389, 11> randex48;
283
284 template <
285 class Engine,
286 std::size_t W,
287 class UIntType
288 > class independent_bits_engine {
289 public:
290 typedef typename Engine::result_type result_type;
291
292 independent_bits_engine();
293
294 explicit independent_bits_engine(result_type s);
295
296 template<class Sseq >
297 explicit independent_bits_engine(Sseq& seq);
298 explicit independent_bits_engine(const Engine& e);
299 explicit independent_bits_engine(Engine&& e);
300
301 const Engine& base() const;
302
303 void seed();
304 void seed(result_type value);
305
306 template<class Sseq >
307 void seed(Sseq& seq);
308
309 result_type operator()();
310
311 void discard(unsigned long long z);
312
313 static constexpr result_type min();
314 static constexpr result_type max();
315 };
316
317 template <
318 class Engine,
319 std::size_t K
320 > class shuffle_order_engine {
321 public:
322 typedef typename Engine::result_type result_type;
323 static constexpr size_t table_size;
324
325 shuffle_order_engine();
326
327 explicit shuffle_order_engine(result_type s);
328
329 template<class Sseq >
330 explicit shuffle_order_engine(Sseq& seq);
331 explicit shuffle_order_engine(const Engine& e);
332 explicit shuffle_order_engine(Engine&& e);
333
334 const Engine& base() const;
335
336 void seed();
337 void seed(result_type value);
338
339 template<class Sseq >
340 void seed(Sseq& seq);
341
342 result_type operator()();
343
344 void discard(unsigned long long z);
345
346 static constexpr result_type min();
347 static constexpr result_type max();
348 };
349
350 typedef std::shuffle_order_engine<std::minstd_rand0, 256> knuth_b;
351
352 class seed_seq {
353 public:
354 typedef std::uint_least32_t result_type;
355
356 seed_seq();
357 seed_seq(const seed_seq&) = delete;
358
359 template<class InputIt >
360 seed_seq(InputIt begin, InputIt end);
361
362 template<class T >
363 seed_seq(std::initializer_list<T> il);
364
365 template<class RandomIt >
366 void generate(RandomIt begin, RandomIt end);
367
368 std::size_t size() const;
369
370 template<class OutputIt >
371 void param(OutputIt dest) const;
372 };
373
374 template<class IntType = int >
375 class uniform_int_distribution {
376 public:
377 typedef IntType result_type;
378 typedef void* param_type; // TODO
379
380 explicit uniform_int_distribution(IntType a = 0,
381 IntType b = std::numeric_limits<IntType>::max());
382 explicit uniform_int_distribution(const param_type& params);
383
384 void reset();
385
386 template<class Generator >
387 result_type operator()(Generator& g);
388
389 template<class Generator >
390 result_type operator()(Generator& g, const param_type& params);
391
392 result_type a() const;
393 result_type b() const;
394
395 param_type param() const;
396 void param(const param_type& params);
397
398 result_type min() const;
399
400 result_type max() const;
401 };
402
403 template<class ResultType >
404 bool operator==(const uniform_int_distribution<ResultType>& lhs,
405 const uniform_int_distribution<ResultType>& rhs);
406
407 template<class ResultType >
408 bool operator!=(const uniform_int_distribution<ResultType>& lhs,
409 const uniform_int_distribution<ResultType>& rhs);
410
411 template<class CharT, class Traits, class ResultType >
412 std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>& ost,
413 const uniform_int_distribution<ResultType>& d);
414
415 template<class CharT, class Traits, class ResultType >
416 std::basic_istream<CharT, Traits>& operator>>(std::basic_istream<CharT, Traits>& ist,
417 uniform_int_distribution<ResultType>& d);
418
419 template<class RealType = double >
420 class uniform_real_distribution {
421 public:
422 typedef RealType result_type;
423 typedef void* param_type; // TODO
424
425 explicit uniform_real_distribution(RealType a = 0.0, RealType b = 1.0);
426 explicit uniform_real_distribution(const param_type& params);
427
428 void reset();
429
430 template<class Generator >
431 result_type operator()(Generator& g);
432
433 template<class Generator >
434 result_type operator()(Generator& g, const param_type& params);
435
436 result_type a() const;
437 result_type b() const;
438
439 param_type param() const;
440 void param(const param_type& params);
441
442 result_type min() const;
443
444 result_type max() const;
445 };
446
447 template<class ResultType >
448 bool operator==(const uniform_real_distribution<ResultType>& lhs,
449 const uniform_real_distribution<ResultType>& rhs);
450
451 template<class ResultType >
452 bool operator!=(const uniform_real_distribution<ResultType>& lhs,
453 const uniform_real_distribution<ResultType>& rhs);
454
455 template<class CharT, class Traits, class ResultType >
456 std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>& ost,
457 const uniform_real_distribution<ResultType>& d);
458
459 template<class CharT, class Traits, class ResultType >
460 std::basic_istream<CharT, Traits>& operator>>(std::basic_istream<CharT, Traits>& ist,
461 uniform_real_distribution<ResultType>& d);
462
463 template<class RealType, size_t bits, class Generator >
464 RealType generate_canonical(Generator& g);
465
466 class bernoulli_distribution {
467 public:
468 typedef bool result_type;
469 typedef void* param_type; // TODO
470
471 explicit bernoulli_distribution(double p = 0.5);
472 explicit bernoulli_distribution(const param_type& params);
473
474 void reset();
475
476 template<class Generator >
477 result_type operator()(Generator& g);
478
479 template<class Generator >
480 result_type operator()(Generator& g, const param_type& params);
481
482 double p() const;
483
484 param_type param() const;
485 void param(const param_type& params);
486
487 result_type min() const;
488 result_type max() const;
489 };
490
491 bool operator==(const bernoulli_distribution& lhs,
492 const bernoulli_distribution& rhs);
493
494 bool operator!=(const bernoulli_distribution& lhs,
495 const bernoulli_distribution& rhs);
496
497 template<class CharT, class Traits>
498 std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>& ost,
499 const bernoulli_distribution& d);
500
501 template<class CharT, class Traits>
502 std::basic_istream<CharT, Traits>& operator>>(std::basic_istream<CharT, Traits>& ist,
503 bernoulli_distribution& d);
504
505 template<class IntType = int >
506 class binomial_distribution {
507 public:
508 typedef IntType result_type;
509 typedef void* param_type; // TODO
510
511 explicit binomial_distribution(IntType t = 1, double p = 0.5);
512 explicit binomial_distribution(const param_type& params);
513
514 void reset();
515
516 template<class Generator >
517 result_type operator()(Generator& g);
518
519 template<class Generator >
520 result_type operator()(Generator& g, const param_type& params);
521
522 double p() const;
523 IntType t() const;
524
525 param_type param() const;
526 void param(const param_type& params);
527
528 result_type min() const;
529 result_type max() const;
530
531 };
532
533 template<class ResultType >
534 bool operator==(const binomial_distribution<ResultType>& lhs,
535 const binomial_distribution<ResultType>& rhs);
536
537 template<class ResultType >
538 bool operator!=(const binomial_distribution<ResultType>& lhs,
539 const binomial_distribution<ResultType>& rhs);
540
541 template<class CharT, class Traits, class ResultType >
542 std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>& ost,
543 const binomial_distribution<ResultType>& d);
544
545 template<class CharT, class Traits, class ResultType >
546 std::basic_istream<CharT, Traits>& operator>>(std::basic_istream<CharT, Traits>& ist,
547 binomial_distribution<ResultType>& d);
548
549 template<class IntType = int >
550 class negative_binomial_distribution {
551 public:
552 typedef IntType result_type;
553 typedef void* param_type; // TODO
554
555 explicit negative_binomial_distribution(IntType k = 1, double p = 0.5);
556 explicit negative_binomial_distribution(const param_type& params);
557
558 void reset();
559
560 template<class Generator >
561 result_type operator()(Generator& g);
562
563 template<class Generator >
564 result_type operator()(Generator& g, const param_type& params);
565
566 double p() const;
567 IntType k() const;
568
569 param_type param() const;
570 void param(const param_type& params);
571
572 result_type min() const;
573 result_type max() const;
574
575 };
576
577 template<class ResultType >
578 bool operator==(const negative_binomial_distribution<ResultType>& lhs,
579 const negative_binomial_distribution<ResultType>& rhs);
580
581 template<class ResultType >
582 bool operator!=(const negative_binomial_distribution<ResultType>& lhs,
583 const negative_binomial_distribution<ResultType>& rhs);
584
585 template<class CharT, class Traits, class ResultType >
586 std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>& ost,
587 const negative_binomial_distribution<ResultType>& d);
588
589 template<class CharT, class Traits, class ResultType >
590 std::basic_istream<CharT, Traits>& operator>>(std::basic_istream<CharT, Traits>& ist,
591 negative_binomial_distribution<ResultType>& d);
592
593 template<class IntType = int >
594 class geometric_distribution {
595 public:
596 typedef IntType result_type;
597 typedef void* param_type; // TODO
598
599 explicit geometric_distribution(double p = 0.5);
600 explicit geometric_distribution(const param_type& params);
601
602 void reset();
603
604 template<class Generator >
605 result_type operator()(Generator& g);
606
607 template<class Generator >
608 result_type operator()(Generator& g, const param_type& params);
609
610 double p() const;
611
612 param_type param() const;
613 void param(const param_type& params);
614
615 result_type min() const;
616 result_type max() const;
617
618 };
619
620 template<class ResultType >
621 bool operator==(const geometric_distribution<ResultType>& lhs,
622 const geometric_distribution<ResultType>& rhs);
623
624 template<class ResultType >
625 bool operator!=(const geometric_distribution<ResultType>& lhs,
626 const geometric_distribution<ResultType>& rhs);
627
628 template<class CharT, class Traits, class ResultType >
629 std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>& ost,
630 const geometric_distribution<ResultType>& d);
631
632 template<class CharT, class Traits, class ResultType >
633 std::basic_istream<CharT, Traits>& operator>>(std::basic_istream<CharT, Traits>& ist,
634 geometric_distribution<ResultType>& d);
635
636 template<class IntType = int >
637 class poisson_distribution {
638 public:
639 typedef IntType result_type;
640 typedef void* param_type; // TODO
641
642 explicit poisson_distribution(double mean = 1.0);
643 explicit poisson_distribution(const param_type& params);
644
645 void reset();
646
647 template<class Generator >
648 result_type operator()(Generator& g);
649
650 template<class Generator >
651 result_type operator()(Generator& g, const param_type& params);
652
653 double mean() const;
654
655 param_type param() const;
656 void param(const param_type& params);
657
658 result_type min() const;
659 result_type max() const;
660
661 };
662
663 template<class ResultType >
664 bool operator==(const poisson_distribution<ResultType>& lhs,
665 const poisson_distribution<ResultType>& rhs);
666
667 template<class ResultType >
668 bool operator!=(const poisson_distribution<ResultType>& lhs,
669 const poisson_distribution<ResultType>& rhs);
670
671 template<class CharT, class Traits, class ResultType >
672 std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>& ost,
673 const poisson_distribution<ResultType>& d);
674
675 template<class CharT, class Traits, class ResultType >
676 std::basic_istream<CharT, Traits>& operator>>(std::basic_istream<CharT, Traits>& ist,
677 poisson_distribution<ResultType>& d);
678
679 template<class RealType = double >
680 class exponential_distribution {
681 public:
682 typedef RealType result_type;
683 typedef void* param_type; // TODO
684
685 explicit exponential_distribution(RealType lambda = 1.0);
686 explicit exponential_distribution(const param_type& params);
687
688 void reset();
689
690 template<class Generator >
691 result_type operator()(Generator& g);
692
693 template<class Generator >
694 result_type operator()(Generator& g, const param_type& params);
695
696 result_type lambda() const;
697
698 param_type param() const;
699 void param(const param_type& params);
700
701 result_type min() const;
702 result_type max() const;
703 };
704
705 template<class ResultType >
706 bool operator==(const exponential_distribution<ResultType>& lhs,
707 const exponential_distribution<ResultType>& rhs);
708
709 template<class ResultType >
710 bool operator!=(const exponential_distribution<ResultType>& lhs,
711 const exponential_distribution<ResultType>& rhs);
712
713 template<class CharT, class Traits, class ResultType >
714 std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>& ost,
715 const exponential_distribution<ResultType>& d);
716
717 template<class CharT, class Traits, class ResultType >
718 std::basic_istream<CharT, Traits>& operator>>(std::basic_istream<CharT, Traits>& ist,
719 exponential_distribution<ResultType>& d);
720
721 template<class RealType = double >
722 class gamma_distribution {
723 public:
724 typedef RealType result_type;
725 typedef void* param_type; // TODO
726
727 explicit gamma_distribution(RealType alpha = 1.0, RealType beta = 1.0);
728 explicit gamma_distribution(const param_type& params);
729
730 void reset();
731
732 template<class Generator >
733 result_type operator()(Generator& g);
734
735 template<class Generator >
736 result_type operator()(Generator& g, const param_type& params);
737
738 result_type alpha() const;
739 result_type beta() const;
740
741 param_type param() const;
742 void param(const param_type& params);
743
744 result_type min() const;
745 result_type max() const;
746 };
747
748 template<class ResultType >
749 bool operator==(const gamma_distribution<ResultType>& lhs,
750 const gamma_distribution<ResultType>& rhs);
751
752 template<class ResultType >
753 bool operator!=(const gamma_distribution<ResultType>& lhs,
754 const gamma_distribution<ResultType>& rhs);
755
756 template<class CharT, class Traits, class ResultType >
757 std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>& ost,
758 const gamma_distribution<ResultType>& d);
759
760 template<class CharT, class Traits, class ResultType >
761 std::basic_istream<CharT, Traits>& operator>>(std::basic_istream<CharT, Traits>& ist,
762 gamma_distribution<ResultType>& d);
763
764 template<class RealType = double >
765 class weibull_distribution {
766 public:
767 typedef RealType result_type;
768 typedef void* param_type; // TODO
769
770 explicit weibull_distribution(RealType a = 1.0, RealType b = 1.0);
771 explicit weibull_distribution(const param_type& params);
772
773 void reset();
774
775 template<class Generator >
776 result_type operator()(Generator& g);
777
778 template<class Generator >
779 result_type operator()(Generator& g, const param_type& params);
780
781 result_type a() const;
782 result_type b() const;
783
784 param_type param() const;
785 void param(const param_type& params);
786
787 result_type min() const;
788 result_type max() const;
789 };
790
791 template<class ResultType >
792 bool operator==(const weibull_distribution<ResultType>& lhs,
793 const weibull_distribution<ResultType>& rhs);
794
795 template<class ResultType >
796 bool operator!=(const weibull_distribution<ResultType>& lhs,
797 const weibull_distribution<ResultType>& rhs);
798
799 template<class CharT, class Traits, class ResultType >
800 std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>& ost,
801 const weibull_distribution<ResultType>& d);
802
803 template<class CharT, class Traits, class ResultType >
804 std::basic_istream<CharT, Traits>& operator>>(std::basic_istream<CharT, Traits>& ist,
805 weibull_distribution<ResultType>& d);
806
807 template<class RealType = double >
808 class extreme_value_distribution {
809 public:
810 typedef RealType result_type;
811 typedef void* param_type; // TODO
812
813 explicit extreme_value_distribution(RealType a = 0.0, RealType b = 1.0);
814 explicit extreme_value_distribution(const param_type& params);
815
816 void reset();
817
818 template<class Generator >
819 result_type operator()(Generator& g);
820
821 template<class Generator >
822 result_type operator()(Generator& g, const param_type& params);
823
824 result_type a() const;
825 result_type b() const;
826
827 param_type param() const;
828 void param(const param_type& params);
829
830 result_type min() const;
831 result_type max() const;
832 };
833
834 template<class ResultType >
835 bool operator==(const extreme_value_distribution<ResultType>& lhs,
836 const extreme_value_distribution<ResultType>& rhs);
837
838 template<class ResultType >
839 bool operator!=(const extreme_value_distribution<ResultType>& lhs,
840 const extreme_value_distribution<ResultType>& rhs);
841
842 template<class CharT, class Traits, class ResultType >
843 std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>& ost,
844 const extreme_value_distribution<ResultType>& d);
845
846 template<class CharT, class Traits, class ResultType >
847 std::basic_istream<CharT, Traits>& operator>>(std::basic_istream<CharT, Traits>& ist,
848 extreme_value_distribution<ResultType>& d);
849
850 template<class RealType = double >
851 class normal_distribution {
852 public:
853 typedef RealType result_type;
854 typedef void* param_type; // TODO
855
856 explicit normal_distribution(RealType mean = 0.0, RealType stddev = 1.0);
857 explicit normal_distribution(const param_type& params);
858
859 void reset();
860
861 template<class Generator >
862 result_type operator()(Generator& g);
863
864 template<class Generator >
865 result_type operator()(Generator& g, const param_type& params);
866
867 result_type mean() const;
868 result_type stddev() const;
869
870 param_type param() const;
871 void param(const param_type& params);
872
873 result_type min() const;
874 result_type max() const;
875 };
876
877 template<class ResultType >
878 bool operator==(const normal_distribution<ResultType>& lhs,
879 const normal_distribution<ResultType>& rhs);
880
881 template<class ResultType >
882 bool operator!=(const normal_distribution<ResultType>& lhs,
883 const normal_distribution<ResultType>& rhs);
884
885 template<class CharT, class Traits, class ResultType >
886 std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>& ost,
887 const normal_distribution<ResultType>& d);
888
889 template<class CharT, class Traits, class ResultType >
890 std::basic_istream<CharT, Traits>& operator>>(std::basic_istream<CharT, Traits>& ist,
891 normal_distribution<ResultType>& d);
892
893 template<class RealType = double >
894 class lognormal_distribution {
895 public:
896 typedef RealType result_type;
897 typedef void* param_type; // TODO
898
899 explicit lognormal_distribution(RealType m = 0.0, RealType s = 1.0);
900 explicit lognormal_distribution(const param_type& params);
901
902 void reset();
903
904 template<class Generator >
905 result_type operator()(Generator& g);
906
907 template<class Generator >
908 result_type operator()(Generator& g, const param_type& params);
909
910 result_type m() const;
911 result_type s() const;
912
913 param_type param() const;
914 void param(const param_type& params);
915
916 result_type min() const;
917 result_type max() const;
918 };
919
920 template<class ResultType >
921 bool operator==(const lognormal_distribution<ResultType>& lhs,
922 const lognormal_distribution<ResultType>& rhs);
923
924 template<class ResultType >
925 bool operator!=(const lognormal_distribution<ResultType>& lhs,
926 const lognormal_distribution<ResultType>& rhs);
927
928 template<class CharT, class Traits, class ResultType >
929 std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>& ost,
930 const lognormal_distribution<ResultType>& d);
931
932 template<class CharT, class Traits, class ResultType >
933 std::basic_istream<CharT, Traits>& operator>>(std::basic_istream<CharT, Traits>& ist,
934 lognormal_distribution<ResultType>& d);
935
936 template<class RealType = double >
937 class chi_squared_distribution {
938 public:
939 typedef RealType result_type;
940 typedef void* param_type; // TODO
941
942 explicit chi_squared_distribution(RealType n = 1.0);
943 explicit chi_squared_distribution(const param_type& params);
944
945 void reset();
946
947 template<class Generator >
948 result_type operator()(Generator& g);
949
950 template<class Generator >
951 result_type operator()(Generator& g, const param_type& params);
952
953 result_type n() const;
954
955 param_type param() const;
956 void param(const param_type& params);
957
958 result_type min() const;
959 result_type max() const;
960 };
961
962 template<class ResultType >
963 bool operator==(const chi_squared_distribution<ResultType>& lhs,
964 const chi_squared_distribution<ResultType>& rhs);
965
966 template<class ResultType >
967 bool operator!=(const chi_squared_distribution<ResultType>& lhs,
968 const chi_squared_distribution<ResultType>& rhs);
969
970 template<class CharT, class Traits, class ResultType >
971 std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>& ost,
972 const chi_squared_distribution<ResultType>& d);
973
974 template<class CharT, class Traits, class ResultType >
975 std::basic_istream<CharT, Traits>& operator>>(std::basic_istream<CharT, Traits>& ist,
976 chi_squared_distribution<ResultType>& d);
977
978 template<class RealType = double >
979 class cauchy_distribution {
980 public:
981 typedef RealType result_type;
982 typedef void* param_type; // TODO
983
984 explicit cauchy_distribution(RealType a = 0.0, RealType b = 1.0);
985 explicit cauchy_distribution(const param_type& params);
986
987 void reset();
988
989 template<class Generator >
990 result_type operator()(Generator& g);
991
992 template<class Generator >
993 result_type operator()(Generator& g, const param_type& params);
994
995 result_type a() const;
996 result_type b() const;
997
998 param_type param() const;
999 void param(const param_type& params);
1000
1001 result_type min() const;
1002 result_type max() const;
1003 };
1004
1005 template<class ResultType >
1006 bool operator==(const cauchy_distribution<ResultType>& lhs,
1007 const cauchy_distribution<ResultType>& rhs);
1008
1009 template<class ResultType >
1010 bool operator!=(const cauchy_distribution<ResultType>& lhs,
1011 const cauchy_distribution<ResultType>& rhs);
1012
1013 template<class CharT, class Traits, class ResultType >
1014 std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>& ost,
1015 const cauchy_distribution<ResultType>& d);
1016
1017 template<class CharT, class Traits, class ResultType >
1018 std::basic_istream<CharT, Traits>& operator>>(std::basic_istream<CharT, Traits>& ist,
1019 cauchy_distribution<ResultType>& d);
1020
1021 template<class RealType = double >
1022 class fisher_f_distribution {
1023 public:
1024 typedef RealType result_type;
1025 typedef void* param_type; // TODO
1026
1027 explicit fisher_f_distribution(RealType m = 1.0, RealType n = 1.0);
1028 explicit fisher_f_distribution(const param_type& params);
1029
1030 void reset();
1031
1032 template<class Generator >
1033 result_type operator()(Generator& g);
1034
1035 template<class Generator >
1036 result_type operator()(Generator& g, const param_type& params);
1037
1038 result_type m() const;
1039 result_type n() const;
1040
1041 param_type param() const;
1042 void param(const param_type& params);
1043
1044 result_type min() const;
1045 result_type max() const;
1046 };
1047
1048 template<class ResultType >
1049 bool operator==(const fisher_f_distribution<ResultType>& lhs,
1050 const fisher_f_distribution<ResultType>& rhs);
1051
1052 template<class ResultType >
1053 bool operator!=(const fisher_f_distribution<ResultType>& lhs,
1054 const fisher_f_distribution<ResultType>& rhs);
1055
1056 template<class CharT, class Traits, class ResultType >
1057 std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>& ost,
1058 const fisher_f_distribution<ResultType>& d);
1059
1060 template<class CharT, class Traits, class ResultType >
1061 std::basic_istream<CharT, Traits>& operator>>(std::basic_istream<CharT, Traits>& ist,
1062 fisher_f_distribution<ResultType>& d);
1063
1064 template<class RealType = double >
1065 class student_t_distribution {
1066 public:
1067 typedef RealType result_type;
1068 typedef void* param_type; // TODO
1069
1070 explicit student_t_distribution(RealType n = 1.0);
1071 explicit student_t_distribution(const param_type& params);
1072
1073 void reset();
1074
1075 template<class Generator >
1076 result_type operator()(Generator& g);
1077
1078 template<class Generator >
1079 result_type operator()(Generator& g, const param_type& params);
1080
1081 result_type n() const;
1082
1083 param_type param() const;
1084 void param(const param_type& params);
1085
1086 result_type min() const;
1087 result_type max() const;
1088 };
1089
1090 template<class ResultType >
1091 bool operator==(const student_t_distribution<ResultType>& lhs,
1092 const student_t_distribution<ResultType>& rhs);
1093
1094 template<class ResultType >
1095 bool operator!=(const student_t_distribution<ResultType>& lhs,
1096 const student_t_distribution<ResultType>& rhs);
1097
1098 template<class CharT, class Traits, class ResultType >
1099 std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>& ost,
1100 const student_t_distribution<ResultType>& d);
1101
1102 template<class CharT, class Traits, class ResultType >
1103 std::basic_istream<CharT, Traits>& operator>>(std::basic_istream<CharT, Traits>& ist,
1104 student_t_distribution<ResultType>& d);
1105
1106 template<class IntType = int >
1107 class discrete_distribution {
1108 public:
1109 typedef IntType result_type;
1110 typedef void* param_type; // TODO
1111
1112 discrete_distribution();
1113
1114 template<class InputIt >
1115 discrete_distribution(InputIt first, InputIt last);
1116
1117 discrete_distribution(std::initializer_list<double> weights);
1118
1119 template<class UnaryOperation >
1120 discrete_distribution(std::size_t count, double xmin, double xmax,
1121 UnaryOperation unary_op);
1122
1123 explicit discrete_distribution(const param_type& params);
1124
1125 void reset();
1126
1127 template<class Generator >
1128 result_type operator()(Generator& g);
1129
1130 template<class Generator >
1131 result_type operator()(Generator& g, const param_type& params);
1132
1133 std::vector<double> probabilities() const;
1134
1135 param_type param() const;
1136 void param(const param_type& params);
1137
1138 result_type min() const;
1139 result_type max() const;
1140
1141 };
1142
1143 template<class ResultType >
1144 bool operator==(const discrete_distribution<ResultType>& lhs,
1145 const discrete_distribution<ResultType>& rhs);
1146
1147 template<class ResultType >
1148 bool operator!=(const discrete_distribution<ResultType>& lhs,
1149 const discrete_distribution<ResultType>& rhs);
1150
1151 template<class CharT, class Traits, class ResultType >
1152 std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>& ost,
1153 const discrete_distribution<ResultType>& d);
1154
1155 template<class CharT, class Traits, class ResultType >
1156 std::basic_istream<CharT, Traits>& operator>>(std::basic_istream<CharT, Traits>& ist,
1157 discrete_distribution<ResultType>& d);
1158
1159 template<class RealType = double >
1160 class piecewise_constant_distribution {
1161 public:
1162 typedef RealType result_type;
1163 typedef void* param_type; // TODO
1164
1165 piecewise_constant_distribution();
1166
1167 template<class InputIt1, class InputIt2 >
1168 piecewise_constant_distribution(InputIt1 first_i, InputIt1 last_i,
1169 InputIt2 first_w);
1170
1171 template<class UnaryOperation >
1172 piecewise_constant_distribution(std::initializer_list<RealType> bl,
1173 UnaryOperation fw);
1174
1175 template<class UnaryOperation >
1176 piecewise_constant_distribution(std::size_t nw,
1177 RealType xmin, RealType xmax,
1178 UnaryOperation fw);
1179
1180 explicit piecewise_constant_distribution(const param_type& parm);
1181
1182 void reset();
1183
1184 template<class Generator >
1185 result_type operator()(Generator& g);
1186
1187 template<class Generator >
1188 result_type operator()(Generator& g, const param_type& params);
1189
1190 std::vector<RealType> intervals() const;
1191 std::vector<RealType> densities() const;
1192
1193 param_type param() const;
1194 void param(const param_type& params);
1195
1196 result_type min() const;
1197 result_type max() const;
1198 };
1199
1200 template<class ResultType >
1201 bool operator==(const piecewise_constant_distribution<ResultType>& lhs,
1202 const piecewise_constant_distribution<ResultType>& rhs);
1203
1204 template<class ResultType >
1205 bool operator!=(const piecewise_constant_distribution<ResultType>& lhs,
1206 const piecewise_constant_distribution<ResultType>& rhs);
1207
1208 template<class CharT, class Traits, class ResultType >
1209 std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>& ost,
1210 const piecewise_constant_distribution<ResultType>& d);
1211
1212 template<class CharT, class Traits, class ResultType >
1213 std::basic_istream<CharT, Traits>& operator>>(std::basic_istream<CharT, Traits>& ist,
1214 piecewise_constant_distribution<ResultType>& d);
1215
1216 template<class RealType = double >
1217 class piecewise_linear_distribution {
1218 public:
1219 typedef RealType result_type;
1220 typedef void* param_type; // TODO
1221
1222 piecewise_linear_distribution();
1223
1224 template<class InputIt1, class InputIt2 >
1225 piecewise_linear_distribution(InputIt1 first_i, InputIt1 last_i,
1226 InputIt2 first_w);
1227
1228 template<class UnaryOperation >
1229 piecewise_linear_distribution(std::initializer_list<RealType> ilist,
1230 UnaryOperation fw);
1231
1232 template<class UnaryOperation >
1233 piecewise_linear_distribution(std::size_t nw,
1234 RealType xmin, RealType xmax,
1235 UnaryOperation fw);
1236
1237 explicit piecewise_linear_distribution(const param_type& parm);
1238
1239 void reset();
1240
1241 template<class Generator >
1242 result_type operator()(Generator& g);
1243
1244 template<class Generator >
1245 result_type operator()(Generator& g, const param_type& params);
1246
1247 std::vector<RealType> intervals() const;
1248 std::vector<RealType> densities() const;
1249
1250 param_type param() const;
1251 void param(const param_type& params);
1252
1253 result_type min() const;
1254 result_type max() const;
1255 };
1256
1257 template<class ResultType >
1258 bool operator==(const piecewise_linear_distribution<ResultType>& lhs,
1259 const piecewise_linear_distribution<ResultType>& rhs);
1260
1261 template<class ResultType >
1262 bool operator!=(const piecewise_linear_distribution<ResultType>& lhs,
1263 const piecewise_linear_distribution<ResultType>& rhs);
1264
1265 template<class CharT, class Traits, class ResultType >
1266 std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>& ost,
1267 const piecewise_linear_distribution<ResultType>& d);
1268
1269 template<class CharT, class Traits, class ResultType >
1270 std::basic_istream<CharT, Traits>& operator>>(std::basic_istream<CharT, Traits>& ist,
1271 piecewise_linear_distribution<ResultType>& d);
1272
1273
1274 class random_device {
1275 public:
1276 typedef unsigned int result_type;
1277
1278 // actually the default value is impl-defined
1279 explicit random_device(const std::string& token = "");
1280
1281 random_device(const random_device&) = delete;
1282 random_device& operator=(const random_device&) = delete;
1283
1284 result_type operator()();
1285 double entropy() const;
1286 static constexpr result_type min();
1287 static constexpr result_type max();
1288 };
1289 } // namespace std
1290
1291 #endif // CPPREFERENCE_STDVER >= 2011
1292
1293 #endif // CPPREFERENCE_RANDOM_H