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 typedef typename __gnu_cxx::__add_unsigned<typename
01623 _UniformRandomNumberGenerator::result_type>::__type __utype;
01624 return result_type(__utype(__urng()) % (__max - __min + 1)) + __min;
01625 }
01626
01627 template<typename _UniformRandomNumberGenerator>
01628 result_type
01629 _M_call(_UniformRandomNumberGenerator& __urng,
01630 result_type __min, result_type __max, false_type)
01631 {
01632 return result_type((__urng() - __urng.min())
01633 / (__urng.max() - __urng.min())
01634 * (__max - __min + 1)) + __min;
01635 }
01636
01637 _IntType _M_min;
01638 _IntType _M_max;
01639 };
01640
01641
01642
01643
01644
01645
01646
01647
01648 class bernoulli_distribution
01649 {
01650 public:
01651 typedef int input_type;
01652 typedef bool result_type;
01653
01654 public:
01655
01656
01657
01658
01659
01660
01661 explicit
01662 bernoulli_distribution(double __p = 0.5)
01663 : _M_p(__p)
01664 {
01665 _GLIBCXX_DEBUG_ASSERT((_M_p >= 0.0) && (_M_p <= 1.0));
01666 }
01667
01668
01669
01670
01671 double
01672 p() const
01673 { return _M_p; }
01674
01675
01676
01677
01678
01679
01680 void
01681 reset() { }
01682
01683
01684
01685
01686 template<class _UniformRandomNumberGenerator>
01687 result_type
01688 operator()(_UniformRandomNumberGenerator& __urng)
01689 {
01690 if ((__urng() - __urng.min()) < _M_p * (__urng.max() - __urng.min()))
01691 return true;
01692 return false;
01693 }
01694
01695
01696
01697
01698
01699
01700
01701
01702
01703
01704
01705 template<typename _CharT, typename _Traits>
01706 friend std::basic_ostream<_CharT, _Traits>&
01707 operator<<(std::basic_ostream<_CharT, _Traits>& __os,
01708 const bernoulli_distribution& __x);
01709
01710
01711
01712
01713
01714
01715
01716
01717
01718
01719 template<typename _CharT, typename _Traits>
01720 friend std::basic_istream<_CharT, _Traits>&
01721 operator>>(std::basic_istream<_CharT, _Traits>& __is,
01722 bernoulli_distribution& __x)
01723 { return __is >> __x._M_p; }
01724
01725 private:
01726 double _M_p;
01727 };
01728
01729
01730
01731
01732
01733
01734
01735
01736
01737 template<typename _IntType = int, typename _RealType = double>
01738 class geometric_distribution
01739 {
01740 public:
01741
01742 typedef _RealType input_type;
01743 typedef _IntType result_type;
01744
01745
01746 explicit
01747 geometric_distribution(const _RealType& __p = _RealType(0.5))
01748 : _M_p(__p)
01749 {
01750 _GLIBCXX_DEBUG_ASSERT((_M_p > 0.0) && (_M_p < 1.0));
01751 _M_initialize();
01752 }
01753
01754
01755
01756
01757 _RealType
01758 p() const
01759 { return _M_p; }
01760
01761 void
01762 reset() { }
01763
01764 template<class _UniformRandomNumberGenerator>
01765 result_type
01766 operator()(_UniformRandomNumberGenerator& __urng);
01767
01768
01769
01770
01771
01772
01773
01774
01775
01776
01777
01778 template<typename _IntType1, typename _RealType1,
01779 typename _CharT, typename _Traits>
01780 friend std::basic_ostream<_CharT, _Traits>&
01781 operator<<(std::basic_ostream<_CharT, _Traits>& __os,
01782 const geometric_distribution<_IntType1, _RealType1>& __x);
01783
01784
01785
01786
01787
01788
01789
01790
01791
01792
01793 template<typename _CharT, typename _Traits>
01794 friend std::basic_istream<_CharT, _Traits>&
01795 operator>>(std::basic_istream<_CharT, _Traits>& __is,
01796 geometric_distribution& __x)
01797 {
01798 __is >> __x._M_p;
01799 __x._M_initialize();
01800 return __is;
01801 }
01802
01803 private:
01804 void
01805 _M_initialize()
01806 { _M_log_p = std::log(_M_p); }
01807
01808 _RealType _M_p;
01809 _RealType _M_log_p;
01810 };
01811
01812
01813 template<typename _RealType>
01814 class normal_distribution;
01815
01816
01817
01818
01819
01820
01821
01822
01823 template<typename _IntType = int, typename _RealType = double>
01824 class poisson_distribution
01825 {
01826 public:
01827
01828 typedef _RealType input_type;
01829 typedef _IntType result_type;
01830
01831
01832 explicit
01833 poisson_distribution(const _RealType& __mean = _RealType(1))
01834 : _M_mean(__mean), _M_nd()
01835 {
01836 _GLIBCXX_DEBUG_ASSERT(_M_mean > 0.0);
01837 _M_initialize();
01838 }
01839
01840
01841
01842
01843 _RealType
01844 mean() const
01845 { return _M_mean; }
01846
01847 void
01848 reset()
01849 { _M_nd.reset(); }
01850
01851 template<class _UniformRandomNumberGenerator>
01852 result_type
01853 operator()(_UniformRandomNumberGenerator& __urng);
01854
01855
01856
01857
01858
01859
01860
01861
01862
01863
01864
01865 template<typename _IntType1, typename _RealType1,
01866 typename _CharT, typename _Traits>
01867 friend std::basic_ostream<_CharT, _Traits>&
01868 operator<<(std::basic_ostream<_CharT, _Traits>& __os,
01869 const poisson_distribution<_IntType1, _RealType1>& __x);
01870
01871
01872
01873
01874
01875
01876
01877
01878
01879
01880 template<typename _IntType1, typename _RealType1,
01881 typename _CharT, typename _Traits>
01882 friend std::basic_istream<_CharT, _Traits>&
01883 operator>>(std::basic_istream<_CharT, _Traits>& __is,
01884 poisson_distribution<_IntType1, _RealType1>& __x);
01885
01886 private:
01887 void
01888 _M_initialize();
01889
01890
01891 normal_distribution<_RealType> _M_nd;
01892
01893 _RealType _M_mean;
01894
01895
01896 _RealType _M_lm_thr;
01897 #if _GLIBCXX_USE_C99_MATH_TR1
01898 _RealType _M_lfm, _M_sm, _M_d, _M_scx, _M_1cx, _M_c2b, _M_cb;
01899 #endif
01900 };
01901
01902
01903
01904
01905
01906
01907
01908
01909
01910 template<typename _IntType = int, typename _RealType = double>
01911 class binomial_distribution
01912 {
01913 public:
01914
01915 typedef _RealType input_type;
01916 typedef _IntType result_type;
01917
01918
01919 explicit
01920 binomial_distribution(_IntType __t = 1,
01921 const _RealType& __p = _RealType(0.5))
01922 : _M_t(__t), _M_p(__p), _M_nd()
01923 {
01924 _GLIBCXX_DEBUG_ASSERT((_M_t >= 0) && (_M_p >= 0.0) && (_M_p <= 1.0));
01925 _M_initialize();
01926 }
01927
01928
01929
01930
01931 _IntType
01932 t() const
01933 { return _M_t; }
01934
01935
01936
01937
01938 _RealType
01939 p() const
01940 { return _M_p; }
01941
01942 void
01943 reset()
01944 { _M_nd.reset(); }
01945
01946 template<class _UniformRandomNumberGenerator>
01947 result_type
01948 operator()(_UniformRandomNumberGenerator& __urng);
01949
01950
01951
01952
01953
01954
01955
01956
01957
01958
01959
01960 template<typename _IntType1, typename _RealType1,
01961 typename _CharT, typename _Traits>
01962 friend std::basic_ostream<_CharT, _Traits>&
01963 operator<<(std::basic_ostream<_CharT, _Traits>& __os,
01964 const binomial_distribution<_IntType1, _RealType1>& __x);
01965
01966
01967
01968
01969
01970
01971
01972
01973
01974
01975 template<typename _IntType1, typename _RealType1,
01976 typename _CharT, typename _Traits>
01977 friend std::basic_istream<_CharT, _Traits>&
01978 operator>>(std::basic_istream<_CharT, _Traits>& __is,
01979 binomial_distribution<_IntType1, _RealType1>& __x);
01980
01981 private:
01982 void
01983 _M_initialize();
01984
01985 template<class _UniformRandomNumberGenerator>
01986 result_type
01987 _M_waiting(_UniformRandomNumberGenerator& __urng, _IntType __t);
01988
01989
01990 normal_distribution<_RealType> _M_nd;
01991
01992 _RealType _M_q;
01993 #if _GLIBCXX_USE_C99_MATH_TR1
01994 _RealType _M_d1, _M_d2, _M_s1, _M_s2, _M_c,
01995 _M_a1, _M_a123, _M_s, _M_lf, _M_lp1p;
01996 #endif
01997 _RealType _M_p;
01998 _IntType _M_t;
01999
02000 bool _M_easy;
02001 };
02002
02003
02004
02005
02006
02007
02008
02009
02010
02011
02012
02013
02014
02015
02016
02017
02018 template<typename _RealType = double>
02019 class uniform_real
02020 {
02021 public:
02022
02023 typedef _RealType input_type;
02024 typedef _RealType result_type;
02025
02026 public:
02027
02028
02029
02030
02031
02032
02033 explicit
02034 uniform_real(_RealType __min = _RealType(0),
02035 _RealType __max = _RealType(1))
02036 : _M_min(__min), _M_max(__max)
02037 {
02038 _GLIBCXX_DEBUG_ASSERT(_M_min <= _M_max);
02039 }
02040
02041 result_type
02042 min() const
02043 { return _M_min; }
02044
02045 result_type
02046 max() const
02047 { return _M_max; }
02048
02049 void
02050 reset() { }
02051
02052 template<class _UniformRandomNumberGenerator>
02053 result_type
02054 operator()(_UniformRandomNumberGenerator& __urng)
02055 { return (__urng() * (_M_max - _M_min)) + _M_min; }
02056
02057
02058
02059
02060
02061
02062
02063
02064
02065
02066
02067 template<typename _RealType1, typename _CharT, typename _Traits>
02068 friend std::basic_ostream<_CharT, _Traits>&
02069 operator<<(std::basic_ostream<_CharT, _Traits>& __os,
02070 const uniform_real<_RealType1>& __x);
02071
02072
02073
02074
02075
02076
02077
02078
02079
02080
02081 template<typename _RealType1, typename _CharT, typename _Traits>
02082 friend std::basic_istream<_CharT, _Traits>&
02083 operator>>(std::basic_istream<_CharT, _Traits>& __is,
02084 uniform_real<_RealType1>& __x);
02085
02086 private:
02087 _RealType _M_min;
02088 _RealType _M_max;
02089 };
02090
02091
02092
02093
02094
02095
02096
02097
02098
02099
02100
02101
02102
02103
02104
02105
02106
02107 template<typename _RealType = double>
02108 class exponential_distribution
02109 {
02110 public:
02111
02112 typedef _RealType input_type;
02113 typedef _RealType result_type;
02114
02115 public:
02116
02117
02118
02119
02120 explicit
02121 exponential_distribution(const result_type& __lambda = result_type(1))
02122 : _M_lambda(__lambda)
02123 {
02124 _GLIBCXX_DEBUG_ASSERT(_M_lambda > 0);
02125 }
02126
02127
02128
02129
02130 _RealType
02131 lambda() const
02132 { return _M_lambda; }
02133
02134
02135
02136
02137
02138
02139 void
02140 reset() { }
02141
02142 template<class _UniformRandomNumberGenerator>
02143 result_type
02144 operator()(_UniformRandomNumberGenerator& __urng)
02145 { return -std::log(__urng()) / _M_lambda; }
02146
02147
02148
02149
02150
02151
02152
02153
02154
02155
02156
02157 template<typename _RealType1, typename _CharT, typename _Traits>
02158 friend std::basic_ostream<_CharT, _Traits>&
02159 operator<<(std::basic_ostream<_CharT, _Traits>& __os,
02160 const exponential_distribution<_RealType1>& __x);
02161
02162
02163
02164
02165
02166
02167
02168
02169
02170
02171
02172 template<typename _CharT, typename _Traits>
02173 friend std::basic_istream<_CharT, _Traits>&
02174 operator>>(std::basic_istream<_CharT, _Traits>& __is,
02175 exponential_distribution& __x)
02176 { return __is >> __x._M_lambda; }
02177
02178 private:
02179 result_type _M_lambda;
02180 };
02181
02182
02183
02184
02185
02186
02187
02188
02189
02190 template<typename _RealType = double>
02191 class normal_distribution
02192 {
02193 public:
02194
02195 typedef _RealType input_type;
02196 typedef _RealType result_type;
02197
02198 public:
02199
02200
02201
02202
02203 explicit
02204 normal_distribution(const result_type& __mean = result_type(0),
02205 const result_type& __sigma = result_type(1))
02206 : _M_mean(__mean), _M_sigma(__sigma), _M_saved_available(false)
02207 {
02208 _GLIBCXX_DEBUG_ASSERT(_M_sigma > 0);
02209 }
02210
02211
02212
02213
02214 _RealType
02215 mean() const
02216 { return _M_mean; }
02217
02218
02219
02220
02221 _RealType
02222 sigma() const
02223 { return _M_sigma; }
02224
02225
02226
02227
02228 void
02229 reset()
02230 { _M_saved_available = false; }
02231
02232 template<class _UniformRandomNumberGenerator>
02233 result_type
02234 operator()(_UniformRandomNumberGenerator& __urng);
02235
02236
02237
02238
02239
02240
02241
02242
02243
02244
02245
02246 template<typename _RealType1, typename _CharT, typename _Traits>
02247 friend std::basic_ostream<_CharT, _Traits>&
02248 operator<<(std::basic_ostream<_CharT, _Traits>& __os,
02249 const normal_distribution<_RealType1>& __x);
02250
02251
02252
02253
02254
02255
02256
02257
02258
02259
02260 template<typename _RealType1, typename _CharT, typename _Traits>
02261 friend std::basic_istream<_CharT, _Traits>&
02262 operator>>(std::basic_istream<_CharT, _Traits>& __is,
02263 normal_distribution<_RealType1>& __x);
02264
02265 private:
02266 result_type _M_mean;
02267 result_type _M_sigma;
02268 result_type _M_saved;
02269 bool _M_saved_available;
02270 };
02271
02272
02273
02274
02275
02276
02277
02278
02279 template<typename _RealType = double>
02280 class gamma_distribution
02281 {
02282 public:
02283
02284 typedef _RealType input_type;
02285 typedef _RealType result_type;
02286
02287 public:
02288
02289
02290
02291 explicit
02292 gamma_distribution(const result_type& __alpha_val = result_type(1))
02293 : _M_alpha(__alpha_val)
02294 {
02295 _GLIBCXX_DEBUG_ASSERT(_M_alpha > 0);
02296 _M_initialize();
02297 }
02298
02299
02300
02301
02302 _RealType
02303 alpha() const
02304 { return _M_alpha; }
02305
02306
02307
02308
02309 void
02310 reset() { }
02311
02312 template<class _UniformRandomNumberGenerator>
02313 result_type
02314 operator()(_UniformRandomNumberGenerator& __urng);
02315
02316
02317
02318
02319
02320
02321
02322
02323
02324
02325
02326 template<typename _RealType1, typename _CharT, typename _Traits>
02327 friend std::basic_ostream<_CharT, _Traits>&
02328 operator<<(std::basic_ostream<_CharT, _Traits>& __os,
02329 const gamma_distribution<_RealType1>& __x);
02330
02331
02332
02333
02334
02335
02336
02337
02338
02339
02340 template<typename _CharT, typename _Traits>
02341 friend std::basic_istream<_CharT, _Traits>&
02342 operator>>(std::basic_istream<_CharT, _Traits>& __is,
02343 gamma_distribution& __x)
02344 {
02345 __is >> __x._M_alpha;
02346 __x._M_initialize();
02347 return __is;
02348 }
02349
02350 private:
02351 void
02352 _M_initialize();
02353
02354 result_type _M_alpha;
02355
02356
02357 result_type _M_l_d;
02358 };
02359
02360
02361
02362
02363
02364 _GLIBCXX_END_NAMESPACE
02365 }
02366
02367 #include <tr1/random.tcc>
02368
02369 #endif // _TR1_RANDOM