00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef _TR1_RANDOM
00036 #define _TR1_RANDOM 1
00037
00038 #include <cmath>
00039 #include <cstdio>
00040 #include <string>
00041 #include <iosfwd>
00042 #include <limits>
00043 #include <tr1/type_traits>
00044 #include <tr1/cmath>
00045 #include <ext/type_traits.h>
00046 #include <ext/numeric_traits.h>
00047 #include <bits/concept_check.h>
00048 #include <debug/debug.h>
00049
00050 namespace std
00051 {
00052 _GLIBCXX_BEGIN_NAMESPACE(tr1)
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065 namespace __detail
00066 {
00067 template<typename _UIntType, int __w,
00068 bool = __w < std::numeric_limits<_UIntType>::digits>
00069 struct _Shift
00070 { static const _UIntType __value = 0; };
00071
00072 template<typename _UIntType, int __w>
00073 struct _Shift<_UIntType, __w, true>
00074 { static const _UIntType __value = _UIntType(1) << __w; };
00075
00076 template<typename _Tp, _Tp __a, _Tp __c, _Tp __m, bool>
00077 struct _Mod;
00078
00079
00080
00081 template<typename _Tp, _Tp __a, _Tp __c, _Tp __m>
00082 inline _Tp
00083 __mod(_Tp __x)
00084 { return _Mod<_Tp, __a, __c, __m, __m == 0>::__calc(__x); }
00085
00086 typedef __gnu_cxx::__conditional_type<(sizeof(unsigned) == 4),
00087 unsigned, unsigned long>::__type _UInt32Type;
00088
00089
00090
00091
00092
00093 template<typename _Engine, typename _Distribution>
00094 struct _Adaptor
00095 {
00096 typedef typename _Engine::result_type _Engine_result_type;
00097 typedef typename _Distribution::input_type result_type;
00098
00099 public:
00100 _Adaptor(const _Engine& __g)
00101 : _M_g(__g) { }
00102
00103 result_type
00104 min() const
00105 {
00106 result_type __return_value = 0;
00107 if (is_integral<_Engine_result_type>::value
00108 && is_integral<result_type>::value)
00109 __return_value = _M_g.min();
00110 else if (!is_integral<result_type>::value)
00111 __return_value = result_type(0);
00112 return __return_value;
00113 }
00114
00115 result_type
00116 max() const
00117 {
00118 result_type __return_value = 0;
00119 if (is_integral<_Engine_result_type>::value
00120 && is_integral<result_type>::value)
00121 __return_value = _M_g.max();
00122 else if (!is_integral<result_type>::value)
00123 __return_value = result_type(1);
00124 return __return_value;
00125 }
00126
00127 result_type
00128 operator()();
00129
00130 private:
00131 _Engine _M_g;
00132 };
00133
00134
00135
00136
00137
00138
00139
00140
00141 template<typename _Engine, typename _Distribution>
00142 typename _Adaptor<_Engine, _Distribution>::result_type
00143 _Adaptor<_Engine, _Distribution>::
00144 operator()()
00145 {
00146 result_type __return_value = 0;
00147 if (is_integral<_Engine_result_type>::value
00148 && is_integral<result_type>::value)
00149 __return_value = _M_g();
00150 else if (is_integral<_Engine_result_type>::value
00151 && !is_integral<result_type>::value)
00152 __return_value = result_type(_M_g() - _M_g.min())
00153 / result_type(_M_g.max() - _M_g.min() + result_type(1));
00154 else if (!is_integral<_Engine_result_type>::value
00155 && !is_integral<result_type>::value)
00156 __return_value = result_type(_M_g() - _M_g.min())
00157 / result_type(_M_g.max() - _M_g.min());
00158 return __return_value;
00159 }
00160 }
00161
00162
00163
00164
00165
00166
00167
00168 template<typename _Engine, typename _Dist>
00169 class variate_generator
00170 {
00171
00172 __glibcxx_class_requires(_Engine, _CopyConstructibleConcept)
00173
00174
00175
00176 public:
00177 typedef _Engine engine_type;
00178 typedef __detail::_Adaptor<_Engine, _Dist> engine_value_type;
00179 typedef _Dist distribution_type;
00180 typedef typename _Dist::result_type result_type;
00181
00182
00183 typedef typename __gnu_cxx::__enable_if<
00184 is_arithmetic<result_type>::value, result_type>::__type _IsValidType;
00185
00186
00187
00188
00189
00190
00191
00192
00193 variate_generator(engine_type __eng, distribution_type __dist)
00194 : _M_engine(__eng), _M_dist(__dist) { }
00195
00196
00197
00198
00199 result_type
00200 operator()()
00201 { return _M_dist(_M_engine); }
00202
00203
00204
00205
00206 template<typename _Tp>
00207 result_type
00208 operator()(_Tp __value)
00209 { return _M_dist(_M_engine, __value); }
00210
00211
00212
00213
00214
00215 engine_value_type&
00216 engine()
00217 { return _M_engine; }
00218
00219
00220
00221
00222
00223 const engine_value_type&
00224 engine() const
00225 { return _M_engine; }
00226
00227
00228
00229
00230 distribution_type&
00231 distribution()
00232 { return _M_dist; }
00233
00234
00235
00236
00237 const distribution_type&
00238 distribution() const
00239 { return _M_dist; }
00240
00241
00242
00243
00244 result_type
00245 min() const
00246 { return this->distribution().min(); }
00247
00248
00249
00250
00251 result_type
00252 max() const
00253 { return this->distribution().max(); }
00254
00255 private:
00256 engine_value_type _M_engine;
00257 distribution_type _M_dist;
00258 };
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296 template<class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
00297 class linear_congruential
00298 {
00299 __glibcxx_class_requires(_UIntType, _UnsignedIntegerConcept)
00300
00301
00302 public:
00303
00304 typedef _UIntType result_type;
00305
00306
00307 static const _UIntType multiplier = __a;
00308
00309 static const _UIntType increment = __c;
00310
00311 static const _UIntType modulus = __m;
00312
00313
00314
00315
00316
00317
00318
00319 explicit
00320 linear_congruential(unsigned long __x0 = 1)
00321 { this->seed(__x0); }
00322
00323
00324
00325
00326
00327
00328
00329 template<class _Gen>
00330 linear_congruential(_Gen& __g)
00331 { this->seed(__g); }
00332
00333
00334
00335
00336
00337
00338
00339 void
00340 seed(unsigned long __s = 1);
00341
00342
00343
00344
00345
00346
00347
00348 template<class _Gen>
00349 void
00350 seed(_Gen& __g)
00351 { seed(__g, typename is_fundamental<_Gen>::type()); }
00352
00353
00354
00355
00356
00357
00358
00359 result_type
00360 min() const
00361 { return (__detail::__mod<_UIntType, 1, 0, __m>(__c) == 0) ? 1 : 0; }
00362
00363
00364
00365
00366 result_type
00367 max() const
00368 { return __m - 1; }
00369
00370
00371
00372
00373 result_type
00374 operator()();
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385 friend bool
00386 operator==(const linear_congruential& __lhs,
00387 const linear_congruential& __rhs)
00388 { return __lhs._M_x == __rhs._M_x; }
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399 friend bool
00400 operator!=(const linear_congruential& __lhs,
00401 const linear_congruential& __rhs)
00402 { return !(__lhs == __rhs); }
00403
00404
00405
00406
00407
00408
00409
00410
00411 template<class _UIntType1, _UIntType1 __a1, _UIntType1 __c1,
00412 _UIntType1 __m1,
00413 typename _CharT, typename _Traits>
00414 friend std::basic_ostream<_CharT, _Traits>&
00415 operator<<(std::basic_ostream<_CharT, _Traits>& __os,
00416 const linear_congruential<_UIntType1, __a1, __c1,
00417 __m1>& __lcr);
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432 template<class _UIntType1, _UIntType1 __a1, _UIntType1 __c1,
00433 _UIntType1 __m1,
00434 typename _CharT, typename _Traits>
00435 friend std::basic_istream<_CharT, _Traits>&
00436 operator>>(std::basic_istream<_CharT, _Traits>& __is,
00437 linear_congruential<_UIntType1, __a1, __c1, __m1>& __lcr);
00438
00439 private:
00440 template<class _Gen>
00441 void
00442 seed(_Gen& __g, true_type)
00443 { return seed(static_cast<unsigned long>(__g)); }
00444
00445 template<class _Gen>
00446 void
00447 seed(_Gen& __g, false_type);
00448
00449 _UIntType _M_x;
00450 };
00451
00452
00453
00454
00455 typedef linear_congruential<unsigned long, 16807, 0, 2147483647> minstd_rand0;
00456
00457
00458
00459
00460 typedef linear_congruential<unsigned long, 48271, 0, 2147483647> minstd_rand;
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488 template<class _UIntType, int __w, int __n, int __m, int __r,
00489 _UIntType __a, int __u, int __s, _UIntType __b, int __t,
00490 _UIntType __c, int __l>
00491 class mersenne_twister
00492 {
00493 __glibcxx_class_requires(_UIntType, _UnsignedIntegerConcept)
00494
00495 public:
00496
00497 typedef _UIntType result_type;
00498
00499
00500 static const int word_size = __w;
00501 static const int state_size = __n;
00502 static const int shift_size = __m;
00503 static const int mask_bits = __r;
00504 static const _UIntType parameter_a = __a;
00505 static const int output_u = __u;
00506 static const int output_s = __s;
00507 static const _UIntType output_b = __b;
00508 static const int output_t = __t;
00509 static const _UIntType output_c = __c;
00510 static const int output_l = __l;
00511
00512
00513 mersenne_twister()
00514 { seed(); }
00515
00516 explicit
00517 mersenne_twister(unsigned long __value)
00518 { seed(__value); }
00519
00520 template<class _Gen>
00521 mersenne_twister(_Gen& __g)
00522 { seed(__g); }
00523
00524 void
00525 seed()
00526 { seed(5489UL); }
00527
00528 void
00529 seed(unsigned long __value);
00530
00531 template<class _Gen>
00532 void
00533 seed(_Gen& __g)
00534 { seed(__g, typename is_fundamental<_Gen>::type()); }
00535
00536 result_type
00537 min() const
00538 { return 0; };
00539
00540 result_type
00541 max() const
00542 { return __detail::_Shift<_UIntType, __w>::__value - 1; }
00543
00544 result_type
00545 operator()();
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556
00557 friend bool
00558 operator==(const mersenne_twister& __lhs,
00559 const mersenne_twister& __rhs)
00560 { return std::equal(__lhs._M_x, __lhs._M_x + state_size, __rhs._M_x); }
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572 friend bool
00573 operator!=(const mersenne_twister& __lhs,
00574 const mersenne_twister& __rhs)
00575 { return !(__lhs == __rhs); }
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587 template<class _UIntType1, int __w1, int __n1, int __m1, int __r1,
00588 _UIntType1 __a1, int __u1, int __s1, _UIntType1 __b1, int __t1,
00589 _UIntType1 __c1, int __l1,
00590 typename _CharT, typename _Traits>
00591 friend std::basic_ostream<_CharT, _Traits>&
00592 operator<<(std::basic_ostream<_CharT, _Traits>& __os,
00593 const mersenne_twister<_UIntType1, __w1, __n1, __m1, __r1,
00594 __a1, __u1, __s1, __b1, __t1, __c1, __l1>& __x);
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604
00605
00606 template<class _UIntType1, int __w1, int __n1, int __m1, int __r1,
00607 _UIntType1 __a1, int __u1, int __s1, _UIntType1 __b1, int __t1,
00608 _UIntType1 __c1, int __l1,
00609 typename _CharT, typename _Traits>
00610 friend std::basic_istream<_CharT, _Traits>&
00611 operator>>(std::basic_istream<_CharT, _Traits>& __is,
00612 mersenne_twister<_UIntType1, __w1, __n1, __m1, __r1,
00613 __a1, __u1, __s1, __b1, __t1, __c1, __l1>& __x);
00614
00615 private:
00616 template<class _Gen>
00617 void
00618 seed(_Gen& __g, true_type)
00619 { return seed(static_cast<unsigned long>(__g)); }
00620
00621 template<class _Gen>
00622 void
00623 seed(_Gen& __g, false_type);
00624
00625 _UIntType _M_x[state_size];
00626 int _M_p;
00627 };
00628
00629
00630
00631
00632
00633
00634
00635
00636
00637 typedef mersenne_twister<
00638 unsigned long, 32, 624, 397, 31,
00639 0x9908b0dful, 11, 7,
00640 0x9d2c5680ul, 15,
00641 0xefc60000ul, 18
00642 > mt19937;
00643
00644
00645
00646
00647
00648
00649
00650
00651
00652
00653
00654
00655
00656
00657
00658
00659
00660
00661
00662
00663
00664
00665
00666
00667 template<typename _IntType, _IntType __m, int __s, int __r>
00668 class subtract_with_carry
00669 {
00670 __glibcxx_class_requires(_IntType, _IntegerConcept)
00671
00672 public:
00673
00674 typedef _IntType result_type;
00675
00676
00677 static const _IntType modulus = __m;
00678 static const int long_lag = __r;
00679 static const int short_lag = __s;
00680
00681
00682
00683
00684
00685 subtract_with_carry()
00686 { this->seed(); }
00687
00688
00689
00690
00691
00692 explicit
00693 subtract_with_carry(unsigned long __value)
00694 { this->seed(__value); }
00695
00696
00697
00698
00699
00700
00701
00702 template<class _Gen>
00703 subtract_with_carry(_Gen& __g)
00704 { this->seed(__g); }
00705
00706
00707
00708
00709
00710
00711
00712
00713
00714
00715
00716
00717 void
00718 seed(unsigned long __value = 19780503);
00719
00720
00721
00722
00723
00724 template<class _Gen>
00725 void
00726 seed(_Gen& __g)
00727 { seed(__g, typename is_fundamental<_Gen>::type()); }
00728
00729
00730
00731
00732
00733 result_type
00734 min() const
00735 { return 0; }
00736
00737
00738
00739
00740
00741 result_type
00742 max() const
00743 { return this->modulus - 1; }
00744
00745
00746
00747
00748 result_type
00749 operator()();
00750
00751
00752
00753
00754
00755
00756
00757
00758
00759
00760
00761 friend bool
00762 operator==(const subtract_with_carry& __lhs,
00763 const subtract_with_carry& __rhs)
00764 { return std::equal(__lhs._M_x, __lhs._M_x + long_lag, __rhs._M_x); }
00765
00766
00767
00768
00769
00770
00771
00772
00773
00774
00775
00776 friend bool
00777 operator!=(const subtract_with_carry& __lhs,
00778 const subtract_with_carry& __rhs)
00779 { return !(__lhs == __rhs); }
00780
00781
00782
00783
00784
00785
00786
00787
00788
00789
00790
00791 template<typename _IntType1, _IntType1 __m1, int __s1, int __r1,
00792 typename _CharT, typename _Traits>
00793 friend std::basic_ostream<_CharT, _Traits>&
00794 operator<<(std::basic_ostream<_CharT, _Traits>& __os,
00795 const subtract_with_carry<_IntType1, __m1, __s1,
00796 __r1>& __x);
00797
00798
00799
00800
00801
00802
00803
00804
00805
00806
00807
00808 template<typename _IntType1, _IntType1 __m1, int __s1, int __r1,
00809 typename _CharT, typename _Traits>
00810 friend std::basic_istream<_CharT, _Traits>&
00811 operator>>(std::basic_istream<_CharT, _Traits>& __is,
00812 subtract_with_carry<_IntType1, __m1, __s1, __r1>& __x);
00813
00814 private:
00815 template<class _Gen>
00816 void
00817 seed(_Gen& __g, true_type)
00818 { return seed(static_cast<unsigned long>(__g)); }
00819
00820 template<class _Gen>
00821 void
00822 seed(_Gen& __g, false_type);
00823
00824 typedef typename __gnu_cxx::__add_unsigned<_IntType>::__type _UIntType;
00825
00826 _UIntType _M_x[long_lag];
00827 _UIntType _M_carry;
00828 int _M_p;
00829 };
00830
00831
00832
00833
00834
00835
00836
00837
00838
00839
00840
00841
00842 template<typename _RealType, int __w, int __s, int __r>
00843 class subtract_with_carry_01
00844 {
00845 public:
00846
00847 typedef _RealType result_type;
00848
00849
00850 static const int word_size = __w;
00851 static const int long_lag = __r;
00852 static const int short_lag = __s;
00853
00854
00855
00856
00857
00858 subtract_with_carry_01()
00859 {
00860 this->seed();
00861 _M_initialize_npows();
00862 }
00863
00864
00865
00866
00867
00868 explicit
00869 subtract_with_carry_01(unsigned long __value)
00870 {
00871 this->seed(__value);
00872 _M_initialize_npows();
00873 }
00874
00875
00876
00877
00878
00879
00880
00881 template<class _Gen>
00882 subtract_with_carry_01(_Gen& __g)
00883 {
00884 this->seed(__g);
00885 _M_initialize_npows();
00886 }
00887
00888
00889
00890
00891 void
00892 seed(unsigned long __value = 19780503);
00893
00894
00895
00896
00897
00898 template<class _Gen>
00899 void
00900 seed(_Gen& __g)
00901 { seed(__g, typename is_fundamental<_Gen>::type()); }
00902
00903
00904
00905
00906
00907 result_type
00908 min() const
00909 { return 0.0; }
00910
00911
00912
00913
00914
00915 result_type
00916 max() const
00917 { return 1.0; }
00918
00919
00920
00921
00922 result_type
00923 operator()();
00924
00925
00926
00927
00928
00929
00930
00931
00932
00933
00934
00935
00936 friend bool
00937 operator==(const subtract_with_carry_01& __lhs,
00938 const subtract_with_carry_01& __rhs)
00939 {
00940 for (int __i = 0; __i < long_lag; ++__i)
00941 if (!std::equal(__lhs._M_x[__i], __lhs._M_x[__i] + __n,
00942 __rhs._M_x[__i]))
00943 return false;
00944 return true;
00945 }
00946
00947
00948
00949
00950
00951
00952
00953
00954
00955
00956
00957
00958
00959 friend bool
00960 operator!=(const subtract_with_carry_01& __lhs,
00961 const subtract_with_carry_01& __rhs)
00962 { return !(__lhs == __rhs); }
00963
00964
00965
00966
00967
00968
00969
00970
00971
00972
00973
00974 template<typename _RealType1, int __w1, int __s1, int __r1,
00975 typename _CharT, typename _Traits>
00976 friend std::basic_ostream<_CharT, _Traits>&
00977 operator<<(std::basic_ostream<_CharT, _Traits>& __os,
00978 const subtract_with_carry_01<_RealType1, __w1, __s1,
00979 __r1>& __x);
00980
00981
00982
00983
00984
00985
00986
00987
00988
00989
00990
00991 template<typename _RealType1, int __w1, int __s1, int __r1,
00992 typename _CharT, typename _Traits>
00993 friend std::basic_istream<_CharT, _Traits>&
00994 operator>>(std::basic_istream<_CharT, _Traits>& __is,
00995 subtract_with_carry_01<_RealType1, __w1, __s1, __r1>& __x);
00996
00997 private:
00998 template<class _Gen>
00999 void
01000 seed(_Gen& __g, true_type)
01001 { return seed(static_cast<unsigned long>(__g)); }
01002
01003 template<class _Gen>
01004 void
01005 seed(_Gen& __g, false_type);
01006
01007 void
01008 _M_initialize_npows();
01009
01010 static const int __n = (__w + 31) / 32;
01011
01012 typedef __detail::_UInt32Type _UInt32Type;
01013 _UInt32Type _M_x[long_lag][__n];
01014 _RealType _M_npows[__n];
01015 _UInt32Type _M_carry;
01016 int _M_p;
01017 };
01018
01019 typedef subtract_with_carry_01<float, 24, 10, 24> ranlux_base_01;
01020
01021
01022
01023 typedef subtract_with_carry_01<double, 48, 5, 12> ranlux64_base_01;
01024
01025
01026
01027
01028
01029
01030
01031
01032 template<class _UniformRandomNumberGenerator, int __p, int __r>
01033 class discard_block
01034 {
01035
01036
01037
01038 public:
01039
01040 typedef _UniformRandomNumberGenerator base_type;
01041
01042 typedef typename base_type::result_type result_type;
01043
01044
01045 static const int block_size = __p;
01046 static const int used_block = __r;
01047
01048
01049
01050
01051
01052
01053 discard_block()
01054 : _M_n(0) { }
01055
01056
01057
01058
01059
01060
01061
01062 explicit
01063 discard_block(const base_type& __rng)
01064 : _M_b(__rng), _M_n(0) { }
01065
01066
01067
01068
01069
01070
01071
01072 explicit
01073 discard_block(unsigned long __s)
01074 : _M_b(__s), _M_n(0) { }
01075
01076
01077
01078
01079
01080
01081 template<class _Gen>
01082 discard_block(_Gen& __g)
01083 : _M_b(__g), _M_n(0) { }
01084
01085
01086
01087
01088
01089 void seed()
01090 {
01091 _M_b.seed();
01092 _M_n = 0;
01093 }
01094
01095
01096
01097
01098
01099
01100 template<class _Gen>
01101 void seed(_Gen& __g)
01102 {
01103 _M_b.seed(__g);
01104 _M_n = 0;
01105 }
01106
01107
01108
01109
01110 const base_type&
01111 base() const
01112 { return _M_b; }
01113
01114
01115
01116
01117 result_type
01118 min() const
01119 { return _M_b.min(); }
01120
01121
01122
01123
01124 result_type
01125 max() const
01126 { return _M_b.max(); }
01127
01128
01129
01130
01131 result_type
01132 operator()();
01133
01134
01135
01136
01137
01138
01139
01140
01141
01142
01143
01144 friend bool
01145 operator==(const discard_block& __lhs, const discard_block& __rhs)
01146 { return (__lhs._M_b == __rhs._M_b) && (__lhs._M_n == __rhs._M_n); }
01147
01148
01149
01150
01151
01152
01153
01154
01155
01156
01157
01158 friend bool
01159 operator!=(const discard_block& __lhs, const discard_block& __rhs)
01160 { return !(__lhs == __rhs); }
01161
01162
01163
01164
01165
01166
01167
01168
01169
01170
01171
01172 template<class _UniformRandomNumberGenerator1, int __p1, int __r1,
01173 typename _CharT, typename _Traits>
01174 friend std::basic_ostream<_CharT, _Traits>&
01175 operator<<(std::basic_ostream<_CharT, _Traits>& __os,
01176 const discard_block<_UniformRandomNumberGenerator1,
01177 __p1, __r1>& __x);
01178
01179
01180
01181
01182
01183
01184
01185
01186
01187
01188
01189 template<class _UniformRandomNumberGenerator1, int __p1, int __r1,
01190 typename _CharT, typename _Traits>
01191 friend std::basic_istream<_CharT, _Traits>&
01192 operator>>(std::basic_istream<_CharT, _Traits>& __is,
01193 discard_block<_UniformRandomNumberGenerator1,
01194 __p1, __r1>& __x);
01195
01196 private:
01197 base_type _M_b;
01198 int _M_n;
01199 };
01200
01201
01202
01203
01204
01205 typedef discard_block<
01206 subtract_with_carry<unsigned long, (1UL << 24), 10, 24>,
01207 223,
01208 24
01209 > ranlux3;
01210
01211
01212
01213
01214 typedef discard_block<
01215 subtract_with_carry<unsigned long, (1UL << 24), 10, 24>,
01216 389,
01217 24
01218 > ranlux4;
01219
01220 typedef discard_block<
01221 subtract_with_carry_01<float, 24, 10, 24>,
01222 223,
01223 24
01224 > ranlux3_01;
01225
01226 typedef discard_block<
01227 subtract_with_carry_01<float, 24, 10, 24>,
01228 389,
01229 24
01230 > ranlux4_01;
01231
01232
01233
01234
01235
01236
01237 template<class _UniformRandomNumberGenerator1, int __s1,
01238 class _UniformRandomNumberGenerator2, int __s2>
01239 class xor_combine
01240 {
01241
01242
01243
01244
01245
01246 public:
01247
01248 typedef _UniformRandomNumberGenerator1 base1_type;
01249
01250 typedef _UniformRandomNumberGenerator2 base2_type;
01251
01252 private:
01253 typedef typename base1_type::result_type _Result_type1;
01254 typedef typename base2_type::result_type _Result_type2;
01255
01256 public:
01257
01258 typedef typename __gnu_cxx::__conditional_type<(sizeof(_Result_type1)
01259 > sizeof(_Result_type2)),
01260 _Result_type1, _Result_type2>::__type result_type;
01261
01262
01263 static const int shift1 = __s1;
01264 static const int shift2 = __s2;
01265
01266
01267 xor_combine()
01268 : _M_b1(), _M_b2()
01269 { _M_initialize_max(); }
01270
01271 xor_combine(const base1_type& __rng1, const base2_type& __rng2)
01272 : _M_b1(__rng1), _M_b2(__rng2)
01273 { _M_initialize_max(); }
01274
01275 xor_combine(unsigned long __s)
01276 : _M_b1(__s), _M_b2(__s + 1)
01277 { _M_initialize_max(); }
01278
01279 template<class _Gen>
01280 xor_combine(_Gen& __g)
01281 : _M_b1(__g), _M_b2(__g)
01282 { _M_initialize_max(); }
01283
01284 void
01285 seed()
01286 {
01287 _M_b1.seed();
01288 _M_b2.seed();
01289 }
01290
01291 template<class _Gen>
01292 void
01293 seed(_Gen& __g)
01294 {
01295 _M_b1.seed(__g);
01296 _M_b2.seed(__g);
01297 }
01298
01299 const base1_type&
01300 base1() const
01301 { return _M_b1; }
01302
01303 const base2_type&
01304 base2() const
01305 { return _M_b2; }
01306
01307 result_type
01308 min() const
01309 { return 0; }
01310
01311 result_type
01312 max() const
01313 { return _M_max; }
01314
01315
01316
01317
01318
01319 result_type
01320 operator()()
01321 {
01322 return ((result_type(_M_b1() - _M_b1.min()) << shift1)
01323 ^ (result_type(_M_b2() - _M_b2.min()) << shift2));
01324 }
01325
01326
01327
01328
01329
01330
01331
01332
01333
01334
01335
01336 friend bool
01337 operator==(const xor_combine& __lhs, const xor_combine& __rhs)
01338 {
01339 return (__lhs.base1() == __rhs.base1())
01340 && (__lhs.base2() == __rhs.base2());
01341 }
01342
01343
01344
01345
01346
01347
01348
01349
01350
01351
01352
01353 friend bool
01354 operator!=(const xor_combine& __lhs, const xor_combine& __rhs)
01355 { return !(__lhs == __rhs); }
01356
01357
01358
01359
01360
01361
01362
01363
01364
01365
01366
01367 template<class _UniformRandomNumberGenerator11, int __s11,
01368 class _UniformRandomNumberGenerator21, int __s21,
01369 typename _CharT, typename _Traits>
01370 friend std::basic_ostream<_CharT, _Traits>&
01371 operator<<(std::basic_ostream<_CharT, _Traits>& __os,
01372 const xor_combine<_UniformRandomNumberGenerator11, __s11,
01373 _UniformRandomNumberGenerator21, __s21>& __x);
01374
01375
01376
01377
01378
01379
01380
01381
01382
01383
01384
01385 template<class _UniformRandomNumberGenerator11, int __s11,
01386 class _UniformRandomNumberGenerator21, int __s21,
01387 typename _CharT, typename _Traits>
01388 friend std::basic_istream<_CharT, _Traits>&
01389 operator>>(std::basic_istream<_CharT, _Traits>& __is,
01390 xor_combine<_UniformRandomNumberGenerator11, __s11,
01391 _UniformRandomNumberGenerator21, __s21>& __x);
01392
01393 private:
01394 void
01395 _M_initialize_max();
01396
01397 result_type
01398 _M_initialize_max_aux(result_type, result_type, int);
01399
01400 base1_type _M_b1;
01401 base2_type _M_b2;
01402 result_type _M_max;
01403 };
01404
01405
01406
01407
01408
01409
01410 class random_device
01411 {
01412 public:
01413
01414 typedef unsigned int result_type;
01415
01416
01417
01418 #ifdef _GLIBCXX_USE_RANDOM_TR1
01419
01420 explicit
01421 random_device(const std::string& __token = "/dev/urandom")
01422 {
01423 if ((__token != "/dev/urandom" && __token != "/dev/random")
01424 || !(_M_file = std::fopen(__token.c_str(), "rb")))
01425 std::__throw_runtime_error(__N("random_device::"
01426 "random_device(const std::string&)"));
01427 }
01428
01429 ~random_device()
01430 { std::fclose(_M_file); }
01431
01432 #else
01433
01434 explicit
01435 random_device(const std::string& __token = "mt19937")
01436 : _M_mt(_M_strtoul(__token)) { }
01437
01438 private:
01439 static unsigned long
01440 _M_strtoul(const std::string& __str)
01441 {
01442 unsigned long __ret = 5489UL;
01443 if (__str != "mt19937")
01444 {
01445 const char* __nptr = __str.c_str();
01446 char* __endptr;
01447 __ret = std::strtoul(__nptr, &__endptr, 0);
01448 if (*__nptr == '\0' || *__endptr != '\0')
01449 std::__throw_runtime_error(__N("random_device::_M_strtoul"
01450 "(const std::string&)"));
01451 }
01452 return __ret;
01453 }
01454
01455 public:
01456
01457 #endif
01458
01459 result_type
01460 min() const
01461 { return std::numeric_limits<result_type>::min(); }
01462
01463 result_type
01464 max() const
01465 { return std::numeric_limits<result_type>::max(); }
01466
01467 double
01468 entropy() const
01469 { return 0.0; }
01470
01471 result_type
01472 operator()()
01473 {
01474 #ifdef _GLIBCXX_USE_RANDOM_TR1
01475 result_type __ret;
01476 std::fread(reinterpret_cast<void*>(&__ret), sizeof(result_type),
01477 1, _M_file);
01478 return __ret;
01479 #else
01480 return _M_mt();
01481 #endif
01482 }
01483
01484 private:
01485 random_device(const random_device&);
01486 void operator=(const random_device&);
01487
01488 #ifdef _GLIBCXX_USE_RANDOM_TR1
01489 FILE* _M_file;
01490 #else
01491 mt19937 _M_mt;
01492 #endif
01493 };
01494
01495
01496
01497
01498
01499
01500
01501
01502
01503
01504
01505
01506
01507
01508
01509
01510
01511
01512
01513
01514 template<typename _IntType = int>
01515 class uniform_int
01516 {
01517 __glibcxx_class_requires(_IntType, _IntegerConcept)
01518
01519 public:
01520
01521 typedef _IntType input_type;
01522
01523 typedef _IntType result_type;
01524
01525 public:
01526
01527
01528
01529 explicit
01530 uniform_int(_IntType __min = 0, _IntType __max = 9)
01531 : _M_min(__min), _M_max(__max)
01532 {
01533 _GLIBCXX_DEBUG_ASSERT(_M_min <= _M_max);
01534 }
01535
01536
01537
01538
01539 result_type
01540 min() const
01541 { return _M_min; }
01542
01543
01544
01545
01546 result_type
01547 max() const
01548 { return _M_max; }
01549
01550
01551
01552
01553
01554
01555 void
01556 reset() { }
01557
01558
01559
01560
01561
01562 template<typename _UniformRandomNumberGenerator>
01563 result_type
01564 operator()(_UniformRandomNumberGenerator& __urng)
01565 {
01566 typedef typename _UniformRandomNumberGenerator::result_type
01567 _UResult_type;
01568 return _M_call(__urng, _M_min, _M_max,
01569 typename is_integral<_UResult_type>::type());
01570 }
01571
01572
01573
01574
01575
01576
01577 template<typename _UniformRandomNumberGenerator>
01578 result_type
01579 operator()(_UniformRandomNumberGenerator& __urng, result_type __n)
01580 {
01581 typedef typename _UniformRandomNumberGenerator::result_type
01582 _UResult_type;
01583 return _M_call(__urng, 0, __n - 1,
01584 typename is_integral<_UResult_type>::type());
01585 }
01586
01587
01588
01589
01590
01591
01592
01593
01594
01595
01596
01597 template<typename _IntType1, typename _CharT, typename _Traits>
01598 friend std::basic_ostream<_CharT, _Traits>&
01599 operator<<(std::basic_ostream<_CharT, _Traits>& __os,
01600 const uniform_int<_IntType1>& __x);
01601
01602
01603
01604
01605
01606
01607
01608
01609
01610
01611 template<typename _IntType1, typename _CharT, typename _Traits>
01612 friend std::basic_istream<_CharT, _Traits>&
01613 operator>>(std::basic_istream<_CharT, _Traits>& __is,
01614 uniform_int<_IntType1>& __x);
01615
01616 private:
01617 template<typename _UniformRandomNumberGenerator>
01618 result_type
01619 _M_call(_UniformRandomNumberGenerator& __urng,
01620 result_type __min, result_type __max, true_type)
01621 {
01622
01623
01624 typedef typename __gnu_cxx::__add_unsigned<typename
01625 _UniformRandomNumberGenerator::result_type>::__type __utype;
01626 return result_type((__max - __min + 1.0L)
01627 * (__utype(__urng()) - __utype(__urng.min()))
01628 / (__utype(__urng.max())
01629 - __utype(__urng.min()) + 1.0L)) + __min;
01630 }
01631
01632 template<typename _UniformRandomNumberGenerator>
01633 result_type
01634 _M_call(_UniformRandomNumberGenerator& __urng,
01635 result_type __min, result_type __max, false_type)
01636 {
01637 return result_type((__urng() - __urng.min())
01638 / (__urng.max() - __urng.min())
01639 * (__max - __min + 1)) + __min;
01640 }
01641
01642 _IntType _M_min;
01643 _IntType _M_max;
01644 };
01645
01646
01647
01648
01649
01650
01651
01652
01653 class bernoulli_distribution
01654 {
01655 public:
01656 typedef int input_type;
01657 typedef bool result_type;
01658
01659 public:
01660
01661
01662
01663
01664
01665
01666 explicit
01667 bernoulli_distribution(double __p = 0.5)
01668 : _M_p(__p)
01669 {
01670 _GLIBCXX_DEBUG_ASSERT((_M_p >= 0.0) && (_M_p <= 1.0));
01671 }
01672
01673
01674
01675
01676 double
01677 p() const
01678 { return _M_p; }
01679
01680
01681
01682
01683
01684
01685 void
01686 reset() { }
01687
01688
01689
01690
01691 template<class _UniformRandomNumberGenerator>
01692 result_type
01693 operator()(_UniformRandomNumberGenerator& __urng)
01694 {
01695 if ((__urng() - __urng.min()) < _M_p * (__urng.max() - __urng.min()))
01696 return true;
01697 return false;
01698 }
01699
01700
01701
01702
01703
01704
01705
01706
01707
01708
01709
01710 template<typename _CharT, typename _Traits>
01711 friend std::basic_ostream<_CharT, _Traits>&
01712 operator<<(std::basic_ostream<_CharT, _Traits>& __os,
01713 const bernoulli_distribution& __x);
01714
01715
01716
01717
01718
01719
01720
01721
01722
01723
01724 template<typename _CharT, typename _Traits>
01725 friend std::basic_istream<_CharT, _Traits>&
01726 operator>>(std::basic_istream<_CharT, _Traits>& __is,
01727 bernoulli_distribution& __x)
01728 { return __is >> __x._M_p; }
01729
01730 private:
01731 double _M_p;
01732 };
01733
01734
01735
01736
01737
01738
01739
01740
01741
01742 template<typename _IntType = int, typename _RealType = double>
01743 class geometric_distribution
01744 {
01745 public:
01746
01747 typedef _RealType input_type;
01748 typedef _IntType result_type;
01749
01750
01751 explicit
01752 geometric_distribution(const _RealType& __p = _RealType(0.5))
01753 : _M_p(__p)
01754 {
01755 _GLIBCXX_DEBUG_ASSERT((_M_p > 0.0) && (_M_p < 1.0));
01756 _M_initialize();
01757 }
01758
01759
01760
01761
01762 _RealType
01763 p() const
01764 { return _M_p; }
01765
01766 void
01767 reset() { }
01768
01769 template<class _UniformRandomNumberGenerator>
01770 result_type
01771 operator()(_UniformRandomNumberGenerator& __urng);
01772
01773
01774
01775
01776
01777
01778
01779
01780
01781
01782
01783 template<typename _IntType1, typename _RealType1,
01784 typename _CharT, typename _Traits>
01785 friend std::basic_ostream<_CharT, _Traits>&
01786 operator<<(std::basic_ostream<_CharT, _Traits>& __os,
01787 const geometric_distribution<_IntType1, _RealType1>& __x);
01788
01789
01790
01791
01792
01793
01794
01795
01796
01797
01798 template<typename _CharT, typename _Traits>
01799 friend std::basic_istream<_CharT, _Traits>&
01800 operator>>(std::basic_istream<_CharT, _Traits>& __is,
01801 geometric_distribution& __x)
01802 {
01803 __is >> __x._M_p;
01804 __x._M_initialize();
01805 return __is;
01806 }
01807
01808 private:
01809 void
01810 _M_initialize()
01811 { _M_log_p = std::log(_M_p); }
01812
01813 _RealType _M_p;
01814 _RealType _M_log_p;
01815 };
01816
01817
01818 template<typename _RealType>
01819 class normal_distribution;
01820
01821
01822
01823
01824
01825
01826
01827
01828 template<typename _IntType = int, typename _RealType = double>
01829 class poisson_distribution
01830 {
01831 public:
01832
01833 typedef _RealType input_type;
01834 typedef _IntType result_type;
01835
01836
01837 explicit
01838 poisson_distribution(const _RealType& __mean = _RealType(1))
01839 : _M_mean(__mean), _M_nd()
01840 {
01841 _GLIBCXX_DEBUG_ASSERT(_M_mean > 0.0);
01842 _M_initialize();
01843 }
01844
01845
01846
01847
01848 _RealType
01849 mean() const
01850 { return _M_mean; }
01851
01852 void
01853 reset()
01854 { _M_nd.reset(); }
01855
01856 template<class _UniformRandomNumberGenerator>
01857 result_type
01858 operator()(_UniformRandomNumberGenerator& __urng);
01859
01860
01861
01862
01863
01864
01865
01866
01867
01868
01869
01870 template<typename _IntType1, typename _RealType1,
01871 typename _CharT, typename _Traits>
01872 friend std::basic_ostream<_CharT, _Traits>&
01873 operator<<(std::basic_ostream<_CharT, _Traits>& __os,
01874 const poisson_distribution<_IntType1, _RealType1>& __x);
01875
01876
01877
01878
01879
01880
01881
01882
01883
01884
01885 template<typename _IntType1, typename _RealType1,
01886 typename _CharT, typename _Traits>
01887 friend std::basic_istream<_CharT, _Traits>&
01888 operator>>(std::basic_istream<_CharT, _Traits>& __is,
01889 poisson_distribution<_IntType1, _RealType1>& __x);
01890
01891 private:
01892 void
01893 _M_initialize();
01894
01895
01896 normal_distribution<_RealType> _M_nd;
01897
01898 _RealType _M_mean;
01899
01900
01901 _RealType _M_lm_thr;
01902 #if _GLIBCXX_USE_C99_MATH_TR1
01903 _RealType _M_lfm, _M_sm, _M_d, _M_scx, _M_1cx, _M_c2b, _M_cb;
01904 #endif
01905 };
01906
01907
01908
01909
01910
01911
01912
01913
01914
01915 template<typename _IntType = int, typename _RealType = double>
01916 class binomial_distribution
01917 {
01918 public:
01919
01920 typedef _RealType input_type;
01921 typedef _IntType result_type;
01922
01923
01924 explicit
01925 binomial_distribution(_IntType __t = 1,
01926 const _RealType& __p = _RealType(0.5))
01927 : _M_t(__t), _M_p(__p), _M_nd()
01928 {
01929 _GLIBCXX_DEBUG_ASSERT((_M_t >= 0) && (_M_p >= 0.0) && (_M_p <= 1.0));
01930 _M_initialize();
01931 }
01932
01933
01934
01935
01936 _IntType
01937 t() const
01938 { return _M_t; }
01939
01940
01941
01942
01943 _RealType
01944 p() const
01945 { return _M_p; }
01946
01947 void
01948 reset()
01949 { _M_nd.reset(); }
01950
01951 template<class _UniformRandomNumberGenerator>
01952 result_type
01953 operator()(_UniformRandomNumberGenerator& __urng);
01954
01955
01956
01957
01958
01959
01960
01961
01962
01963
01964
01965 template<typename _IntType1, typename _RealType1,
01966 typename _CharT, typename _Traits>
01967 friend std::basic_ostream<_CharT, _Traits>&
01968 operator<<(std::basic_ostream<_CharT, _Traits>& __os,
01969 const binomial_distribution<_IntType1, _RealType1>& __x);
01970
01971
01972
01973
01974
01975
01976
01977
01978
01979
01980 template<typename _IntType1, typename _RealType1,
01981 typename _CharT, typename _Traits>
01982 friend std::basic_istream<_CharT, _Traits>&
01983 operator>>(std::basic_istream<_CharT, _Traits>& __is,
01984 binomial_distribution<_IntType1, _RealType1>& __x);
01985
01986 private:
01987 void
01988 _M_initialize();
01989
01990 template<class _UniformRandomNumberGenerator>
01991 result_type
01992 _M_waiting(_UniformRandomNumberGenerator& __urng, _IntType __t);
01993
01994
01995 normal_distribution<_RealType> _M_nd;
01996
01997 _RealType _M_q;
01998 #if _GLIBCXX_USE_C99_MATH_TR1
01999 _RealType _M_d1, _M_d2, _M_s1, _M_s2, _M_c,
02000 _M_a1, _M_a123, _M_s, _M_lf, _M_lp1p;
02001 #endif
02002 _RealType _M_p;
02003 _IntType _M_t;
02004
02005 bool _M_easy;
02006 };
02007
02008
02009
02010
02011
02012
02013
02014
02015
02016
02017
02018
02019
02020
02021
02022
02023 template<typename _RealType = double>
02024 class uniform_real
02025 {
02026 public:
02027
02028 typedef _RealType input_type;
02029 typedef _RealType result_type;
02030
02031 public:
02032
02033
02034
02035
02036
02037
02038 explicit
02039 uniform_real(_RealType __min = _RealType(0),
02040 _RealType __max = _RealType(1))
02041 : _M_min(__min), _M_max(__max)
02042 {
02043 _GLIBCXX_DEBUG_ASSERT(_M_min <= _M_max);
02044 }
02045
02046 result_type
02047 min() const
02048 { return _M_min; }
02049
02050 result_type
02051 max() const
02052 { return _M_max; }
02053
02054 void
02055 reset() { }
02056
02057 template<class _UniformRandomNumberGenerator>
02058 result_type
02059 operator()(_UniformRandomNumberGenerator& __urng)
02060 { return (__urng() * (_M_max - _M_min)) + _M_min; }
02061
02062
02063
02064
02065
02066
02067
02068
02069
02070
02071
02072 template<typename _RealType1, typename _CharT, typename _Traits>
02073 friend std::basic_ostream<_CharT, _Traits>&
02074 operator<<(std::basic_ostream<_CharT, _Traits>& __os,
02075 const uniform_real<_RealType1>& __x);
02076
02077
02078
02079
02080
02081
02082
02083
02084
02085
02086 template<typename _RealType1, typename _CharT, typename _Traits>
02087 friend std::basic_istream<_CharT, _Traits>&
02088 operator>>(std::basic_istream<_CharT, _Traits>& __is,
02089 uniform_real<_RealType1>& __x);
02090
02091 private:
02092 _RealType _M_min;
02093 _RealType _M_max;
02094 };
02095
02096
02097
02098
02099
02100
02101
02102
02103
02104
02105
02106
02107
02108
02109
02110
02111
02112 template<typename _RealType = double>
02113 class exponential_distribution
02114 {
02115 public:
02116
02117 typedef _RealType input_type;
02118 typedef _RealType result_type;
02119
02120 public:
02121
02122
02123
02124
02125 explicit
02126 exponential_distribution(const result_type& __lambda = result_type(1))
02127 : _M_lambda(__lambda)
02128 {
02129 _GLIBCXX_DEBUG_ASSERT(_M_lambda > 0);
02130 }
02131
02132
02133
02134
02135 _RealType
02136 lambda() const
02137 { return _M_lambda; }
02138
02139
02140
02141
02142
02143
02144 void
02145 reset() { }
02146
02147 template<class _UniformRandomNumberGenerator>
02148 result_type
02149 operator()(_UniformRandomNumberGenerator& __urng)
02150 { return -std::log(__urng()) / _M_lambda; }
02151
02152
02153
02154
02155
02156
02157
02158
02159
02160
02161
02162 template<typename _RealType1, typename _CharT, typename _Traits>
02163 friend std::basic_ostream<_CharT, _Traits>&
02164 operator<<(std::basic_ostream<_CharT, _Traits>& __os,
02165 const exponential_distribution<_RealType1>& __x);
02166
02167
02168
02169
02170
02171
02172
02173
02174
02175
02176
02177 template<typename _CharT, typename _Traits>
02178 friend std::basic_istream<_CharT, _Traits>&
02179 operator>>(std::basic_istream<_CharT, _Traits>& __is,
02180 exponential_distribution& __x)
02181 { return __is >> __x._M_lambda; }
02182
02183 private:
02184 result_type _M_lambda;
02185 };
02186
02187
02188
02189
02190
02191
02192
02193
02194
02195 template<typename _RealType = double>
02196 class normal_distribution
02197 {
02198 public:
02199
02200 typedef _RealType input_type;
02201 typedef _RealType result_type;
02202
02203 public:
02204
02205
02206
02207
02208 explicit
02209 normal_distribution(const result_type& __mean = result_type(0),
02210 const result_type& __sigma = result_type(1))
02211 : _M_mean(__mean), _M_sigma(__sigma), _M_saved_available(false)
02212 {
02213 _GLIBCXX_DEBUG_ASSERT(_M_sigma > 0);
02214 }
02215
02216
02217
02218
02219 _RealType
02220 mean() const
02221 { return _M_mean; }
02222
02223
02224
02225
02226 _RealType
02227 sigma() const
02228 { return _M_sigma; }
02229
02230
02231
02232
02233 void
02234 reset()
02235 { _M_saved_available = false; }
02236
02237 template<class _UniformRandomNumberGenerator>
02238 result_type
02239 operator()(_UniformRandomNumberGenerator& __urng);
02240
02241
02242
02243
02244
02245
02246
02247
02248
02249
02250
02251 template<typename _RealType1, typename _CharT, typename _Traits>
02252 friend std::basic_ostream<_CharT, _Traits>&
02253 operator<<(std::basic_ostream<_CharT, _Traits>& __os,
02254 const normal_distribution<_RealType1>& __x);
02255
02256
02257
02258
02259
02260
02261
02262
02263
02264
02265 template<typename _RealType1, typename _CharT, typename _Traits>
02266 friend std::basic_istream<_CharT, _Traits>&
02267 operator>>(std::basic_istream<_CharT, _Traits>& __is,
02268 normal_distribution<_RealType1>& __x);
02269
02270 private:
02271 result_type _M_mean;
02272 result_type _M_sigma;
02273 result_type _M_saved;
02274 bool _M_saved_available;
02275 };
02276
02277
02278
02279
02280
02281
02282
02283
02284 template<typename _RealType = double>
02285 class gamma_distribution
02286 {
02287 public:
02288
02289 typedef _RealType input_type;
02290 typedef _RealType result_type;
02291
02292 public:
02293
02294
02295
02296 explicit
02297 gamma_distribution(const result_type& __alpha_val = result_type(1))
02298 : _M_alpha(__alpha_val)
02299 {
02300 _GLIBCXX_DEBUG_ASSERT(_M_alpha > 0);
02301 _M_initialize();
02302 }
02303
02304
02305
02306
02307 _RealType
02308 alpha() const
02309 { return _M_alpha; }
02310
02311
02312
02313
02314 void
02315 reset() { }
02316
02317 template<class _UniformRandomNumberGenerator>
02318 result_type
02319 operator()(_UniformRandomNumberGenerator& __urng);
02320
02321
02322
02323
02324
02325
02326
02327
02328
02329
02330
02331 template<typename _RealType1, typename _CharT, typename _Traits>
02332 friend std::basic_ostream<_CharT, _Traits>&
02333 operator<<(std::basic_ostream<_CharT, _Traits>& __os,
02334 const gamma_distribution<_RealType1>& __x);
02335
02336
02337
02338
02339
02340
02341
02342
02343
02344
02345 template<typename _CharT, typename _Traits>
02346 friend std::basic_istream<_CharT, _Traits>&
02347 operator>>(std::basic_istream<_CharT, _Traits>& __is,
02348 gamma_distribution& __x)
02349 {
02350 __is >> __x._M_alpha;
02351 __x._M_initialize();
02352 return __is;
02353 }
02354
02355 private:
02356 void
02357 _M_initialize();
02358
02359 result_type _M_alpha;
02360
02361
02362 result_type _M_l_d;
02363 };
02364
02365
02366
02367
02368
02369 _GLIBCXX_END_NAMESPACE
02370 }
02371
02372 #include <tr1/random.tcc>
02373
02374 #endif // _TR1_RANDOM