1 // Random number extensions -*- C++ -*-
 
    3 // Copyright (C) 2012-2014 Free Software Foundation, Inc.
 
    5 // This file is part of the GNU ISO C++ Library.  This library is free
 
    6 // software; you can redistribute it and/or modify it under the
 
    7 // terms of the GNU General Public License as published by the
 
    8 // Free Software Foundation; either version 3, or (at your option)
 
   11 // This library is distributed in the hope that it will be useful,
 
   12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
 
   13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
   14 // GNU General Public License for more details.
 
   16 // Under Section 7 of GPL version 3, you are granted additional
 
   17 // permissions described in the GCC Runtime Library Exception, version
 
   18 // 3.1, as published by the Free Software Foundation.
 
   20 // You should have received a copy of the GNU General Public License and
 
   21 // a copy of the GCC Runtime Library Exception along with this program;
 
   22 // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 
   23 // <http://www.gnu.org/licenses/>.
 
   25 /** @file ext/random.tcc
 
   26  *  This is an internal header file, included by other library headers.
 
   27  *  Do not attempt to use it directly. @headername{ext/random}
 
   30 #ifndef _EXT_RANDOM_TCC
 
   31 #define _EXT_RANDOM_TCC 1
 
   33 #pragma GCC system_header
 
   35 namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
 
   37 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   39 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
 
   41   template<typename _UIntType, size_t __m,
 
   42       size_t __pos1, size_t __sl1, size_t __sl2,
 
   43       size_t __sr1, size_t __sr2,
 
   44       uint32_t __msk1, uint32_t __msk2,
 
   45       uint32_t __msk3, uint32_t __msk4,
 
   46       uint32_t __parity1, uint32_t __parity2,
 
   47       uint32_t __parity3, uint32_t __parity4>
 
   48     void simd_fast_mersenne_twister_engine<_UIntType, __m,
 
   49                       __pos1, __sl1, __sl2, __sr1, __sr2,
 
   50                       __msk1, __msk2, __msk3, __msk4,
 
   51                       __parity1, __parity2, __parity3,
 
   53     seed(_UIntType __seed)
 
   55       _M_state32[0] = static_cast<uint32_t>(__seed);
 
   56       for (size_t __i = 1; __i < _M_nstate32; ++__i)
 
   57    _M_state32[__i] = (1812433253UL
 
   58               * (_M_state32[__i - 1] ^ (_M_state32[__i - 1] >> 30))
 
   61       _M_period_certification();
 
   67     inline uint32_t _Func1(uint32_t __x)
 
   69       return (__x ^ (__x >> 27)) * UINT32_C(1664525);
 
   72     inline uint32_t _Func2(uint32_t __x)
 
   74       return (__x ^ (__x >> 27)) * UINT32_C(1566083941);
 
   80   template<typename _UIntType, size_t __m,
 
   81       size_t __pos1, size_t __sl1, size_t __sl2,
 
   82       size_t __sr1, size_t __sr2,
 
   83       uint32_t __msk1, uint32_t __msk2,
 
   84       uint32_t __msk3, uint32_t __msk4,
 
   85       uint32_t __parity1, uint32_t __parity2,
 
   86       uint32_t __parity3, uint32_t __parity4>
 
   87     template<typename _Sseq>
 
   88       typename std::enable_if<std::is_class<_Sseq>::value>::type
 
   89       simd_fast_mersenne_twister_engine<_UIntType, __m,
 
   90                    __pos1, __sl1, __sl2, __sr1, __sr2,
 
   91                    __msk1, __msk2, __msk3, __msk4,
 
   92                    __parity1, __parity2, __parity3,
 
   98    if (_M_nstate32 >= 623)
 
  100    else if (_M_nstate32 >= 68)
 
  102    else if (_M_nstate32 >= 39)
 
  106    const size_t __mid = (_M_nstate32 - __lag) / 2;
 
  108    std::fill(_M_state32, _M_state32 + _M_nstate32, UINT32_C(0x8b8b8b8b));
 
  109    uint32_t __arr[_M_nstate32];
 
  110    __q.generate(__arr + 0, __arr + _M_nstate32);
 
  112    uint32_t __r = _Func1(_M_state32[0] ^ _M_state32[__mid]
 
  113                  ^ _M_state32[_M_nstate32  - 1]);
 
  114    _M_state32[__mid] += __r;
 
  116    _M_state32[__mid + __lag] += __r;
 
  119    for (size_t __i = 1, __j = 0; __j < _M_nstate32; ++__j)
 
  121        __r = _Func1(_M_state32[__i]
 
  122             ^ _M_state32[(__i + __mid) % _M_nstate32]
 
  123             ^ _M_state32[(__i + _M_nstate32 - 1) % _M_nstate32]);
 
  124        _M_state32[(__i + __mid) % _M_nstate32] += __r;
 
  125        __r += __arr[__j] + __i;
 
  126        _M_state32[(__i + __mid + __lag) % _M_nstate32] += __r;
 
  127        _M_state32[__i] = __r;
 
  128        __i = (__i + 1) % _M_nstate32;
 
  130    for (size_t __j = 0; __j < _M_nstate32; ++__j)
 
  132        const size_t __i = (__j + 1) % _M_nstate32;
 
  133        __r = _Func2(_M_state32[__i]
 
  134             + _M_state32[(__i + __mid) % _M_nstate32]
 
  135             + _M_state32[(__i + _M_nstate32 - 1) % _M_nstate32]);
 
  136        _M_state32[(__i + __mid) % _M_nstate32] ^= __r;
 
  138        _M_state32[(__i + __mid + __lag) % _M_nstate32] ^= __r;
 
  139        _M_state32[__i] = __r;
 
  143    _M_period_certification();
 
  147   template<typename _UIntType, size_t __m,
 
  148       size_t __pos1, size_t __sl1, size_t __sl2,
 
  149       size_t __sr1, size_t __sr2,
 
  150       uint32_t __msk1, uint32_t __msk2,
 
  151       uint32_t __msk3, uint32_t __msk4,
 
  152       uint32_t __parity1, uint32_t __parity2,
 
  153       uint32_t __parity3, uint32_t __parity4>
 
  154     void simd_fast_mersenne_twister_engine<_UIntType, __m,
 
  155                       __pos1, __sl1, __sl2, __sr1, __sr2,
 
  156                       __msk1, __msk2, __msk3, __msk4,
 
  157                       __parity1, __parity2, __parity3,
 
  159     _M_period_certification(void)
 
  161       static const uint32_t __parity[4] = { __parity1, __parity2,
 
  162                        __parity3, __parity4 };
 
  163       uint32_t __inner = 0;
 
  164       for (size_t __i = 0; __i < 4; ++__i)
 
  165    if (__parity[__i] != 0)
 
  166      __inner ^= _M_state32[__i] & __parity[__i];
 
  168       if (__builtin_parity(__inner) & 1)
 
  170       for (size_t __i = 0; __i < 4; ++__i)
 
  171    if (__parity[__i] != 0)
 
  173        _M_state32[__i] ^= 1 << (__builtin_ffs(__parity[__i]) - 1);
 
  176       __builtin_unreachable();
 
  180   template<typename _UIntType, size_t __m,
 
  181       size_t __pos1, size_t __sl1, size_t __sl2,
 
  182       size_t __sr1, size_t __sr2,
 
  183       uint32_t __msk1, uint32_t __msk2,
 
  184       uint32_t __msk3, uint32_t __msk4,
 
  185       uint32_t __parity1, uint32_t __parity2,
 
  186       uint32_t __parity3, uint32_t __parity4>
 
  187     void simd_fast_mersenne_twister_engine<_UIntType, __m,
 
  188                       __pos1, __sl1, __sl2, __sr1, __sr2,
 
  189                       __msk1, __msk2, __msk3, __msk4,
 
  190                       __parity1, __parity2, __parity3,
 
  192     discard(unsigned long long __z)
 
  194       while (__z > state_size - _M_pos)
 
  196      __z -= state_size - _M_pos;
 
  205 #ifndef  _GLIBCXX_OPT_HAVE_RANDOM_SFMT_GEN_READ
 
  209     template<size_t __shift>
 
  210       inline void __rshift(uint32_t *__out, const uint32_t *__in)
 
  212    uint64_t __th = ((static_cast<uint64_t>(__in[3]) << 32)
 
  213             | static_cast<uint64_t>(__in[2]));
 
  214    uint64_t __tl = ((static_cast<uint64_t>(__in[1]) << 32)
 
  215             | static_cast<uint64_t>(__in[0]));
 
  217    uint64_t __oh = __th >> (__shift * 8);
 
  218    uint64_t __ol = __tl >> (__shift * 8);
 
  219    __ol |= __th << (64 - __shift * 8);
 
  220    __out[1] = static_cast<uint32_t>(__ol >> 32);
 
  221    __out[0] = static_cast<uint32_t>(__ol);
 
  222    __out[3] = static_cast<uint32_t>(__oh >> 32);
 
  223    __out[2] = static_cast<uint32_t>(__oh);
 
  227     template<size_t __shift>
 
  228       inline void __lshift(uint32_t *__out, const uint32_t *__in)
 
  230    uint64_t __th = ((static_cast<uint64_t>(__in[3]) << 32)
 
  231             | static_cast<uint64_t>(__in[2]));
 
  232    uint64_t __tl = ((static_cast<uint64_t>(__in[1]) << 32)
 
  233             | static_cast<uint64_t>(__in[0]));
 
  235    uint64_t __oh = __th << (__shift * 8);
 
  236    uint64_t __ol = __tl << (__shift * 8);
 
  237    __oh |= __tl >> (64 - __shift * 8);
 
  238    __out[1] = static_cast<uint32_t>(__ol >> 32);
 
  239    __out[0] = static_cast<uint32_t>(__ol);
 
  240    __out[3] = static_cast<uint32_t>(__oh >> 32);
 
  241    __out[2] = static_cast<uint32_t>(__oh);
 
  245     template<size_t __sl1, size_t __sl2, size_t __sr1, size_t __sr2,
 
  246         uint32_t __msk1, uint32_t __msk2, uint32_t __msk3, uint32_t __msk4>
 
  247       inline void __recursion(uint32_t *__r,
 
  248                  const uint32_t *__a, const uint32_t *__b,
 
  249                  const uint32_t *__c, const uint32_t *__d)
 
  254    __lshift<__sl2>(__x, __a);
 
  255    __rshift<__sr2>(__y, __c);
 
  256    __r[0] = (__a[0] ^ __x[0] ^ ((__b[0] >> __sr1) & __msk1)
 
  257          ^ __y[0] ^ (__d[0] << __sl1));
 
  258    __r[1] = (__a[1] ^ __x[1] ^ ((__b[1] >> __sr1) & __msk2)
 
  259          ^ __y[1] ^ (__d[1] << __sl1));
 
  260    __r[2] = (__a[2] ^ __x[2] ^ ((__b[2] >> __sr1) & __msk3)
 
  261          ^ __y[2] ^ (__d[2] << __sl1));
 
  262    __r[3] = (__a[3] ^ __x[3] ^ ((__b[3] >> __sr1) & __msk4)
 
  263          ^ __y[3] ^ (__d[3] << __sl1));
 
  269   template<typename _UIntType, size_t __m,
 
  270       size_t __pos1, size_t __sl1, size_t __sl2,
 
  271       size_t __sr1, size_t __sr2,
 
  272       uint32_t __msk1, uint32_t __msk2,
 
  273       uint32_t __msk3, uint32_t __msk4,
 
  274       uint32_t __parity1, uint32_t __parity2,
 
  275       uint32_t __parity3, uint32_t __parity4>
 
  276     void simd_fast_mersenne_twister_engine<_UIntType, __m,
 
  277                       __pos1, __sl1, __sl2, __sr1, __sr2,
 
  278                       __msk1, __msk2, __msk3, __msk4,
 
  279                       __parity1, __parity2, __parity3,
 
  283       const uint32_t *__r1 = &_M_state32[_M_nstate32 - 8];
 
  284       const uint32_t *__r2 = &_M_state32[_M_nstate32 - 4];
 
  285       static constexpr size_t __pos1_32 = __pos1 * 4;
 
  288       for (__i = 0; __i < _M_nstate32 - __pos1_32; __i += 4)
 
  290      __recursion<__sl1, __sl2, __sr1, __sr2,
 
  291              __msk1, __msk2, __msk3, __msk4>
 
  292        (&_M_state32[__i], &_M_state32[__i],
 
  293         &_M_state32[__i + __pos1_32], __r1, __r2);
 
  295      __r2 = &_M_state32[__i];
 
  298       for (; __i < _M_nstate32; __i += 4)
 
  300      __recursion<__sl1, __sl2, __sr1, __sr2,
 
  301              __msk1, __msk2, __msk3, __msk4>
 
  302        (&_M_state32[__i], &_M_state32[__i],
 
  303         &_M_state32[__i + __pos1_32 - _M_nstate32], __r1, __r2);
 
  305      __r2 = &_M_state32[__i];
 
  313 #ifndef _GLIBCXX_OPT_HAVE_RANDOM_SFMT_OPERATOREQUAL
 
  314   template<typename _UIntType, size_t __m,
 
  315       size_t __pos1, size_t __sl1, size_t __sl2,
 
  316       size_t __sr1, size_t __sr2,
 
  317       uint32_t __msk1, uint32_t __msk2,
 
  318       uint32_t __msk3, uint32_t __msk4,
 
  319       uint32_t __parity1, uint32_t __parity2,
 
  320       uint32_t __parity3, uint32_t __parity4>
 
  322     operator==(const __gnu_cxx::simd_fast_mersenne_twister_engine<_UIntType,
 
  323           __m, __pos1, __sl1, __sl2, __sr1, __sr2,
 
  324           __msk1, __msk2, __msk3, __msk4,
 
  325           __parity1, __parity2, __parity3, __parity4>& __lhs,
 
  326           const __gnu_cxx::simd_fast_mersenne_twister_engine<_UIntType,
 
  327           __m, __pos1, __sl1, __sl2, __sr1, __sr2,
 
  328           __msk1, __msk2, __msk3, __msk4,
 
  329           __parity1, __parity2, __parity3, __parity4>& __rhs)
 
  331       typedef __gnu_cxx::simd_fast_mersenne_twister_engine<_UIntType,
 
  332           __m, __pos1, __sl1, __sl2, __sr1, __sr2,
 
  333           __msk1, __msk2, __msk3, __msk4,
 
  334           __parity1, __parity2, __parity3, __parity4> __engine;
 
  335       return (std::equal(__lhs._M_stateT,
 
  336             __lhs._M_stateT + __engine::state_size,
 
  338          && __lhs._M_pos == __rhs._M_pos);
 
  342   template<typename _UIntType, size_t __m,
 
  343       size_t __pos1, size_t __sl1, size_t __sl2,
 
  344       size_t __sr1, size_t __sr2,
 
  345       uint32_t __msk1, uint32_t __msk2,
 
  346       uint32_t __msk3, uint32_t __msk4,
 
  347       uint32_t __parity1, uint32_t __parity2,
 
  348       uint32_t __parity3, uint32_t __parity4,
 
  349       typename _CharT, typename _Traits>
 
  350     std::basic_ostream<_CharT, _Traits>&
 
  351     operator<<(std::basic_ostream<_CharT, _Traits>& __os,
 
  352           const __gnu_cxx::simd_fast_mersenne_twister_engine<_UIntType,
 
  353           __m, __pos1, __sl1, __sl2, __sr1, __sr2,
 
  354           __msk1, __msk2, __msk3, __msk4,
 
  355           __parity1, __parity2, __parity3, __parity4>& __x)
 
  357       typedef std::basic_ostream<_CharT, _Traits> __ostream_type;
 
  358       typedef typename __ostream_type::ios_base __ios_base;
 
  360       const typename __ios_base::fmtflags __flags = __os.flags();
 
  361       const _CharT __fill = __os.fill();
 
  362       const _CharT __space = __os.widen(' ');
 
  363       __os.flags(__ios_base::dec | __ios_base::fixed | __ios_base::left);
 
  366       for (size_t __i = 0; __i < __x._M_nstate32; ++__i)
 
  367    __os << __x._M_state32[__i] << __space;
 
  376   template<typename _UIntType, size_t __m,
 
  377       size_t __pos1, size_t __sl1, size_t __sl2,
 
  378       size_t __sr1, size_t __sr2,
 
  379       uint32_t __msk1, uint32_t __msk2,
 
  380       uint32_t __msk3, uint32_t __msk4,
 
  381       uint32_t __parity1, uint32_t __parity2,
 
  382       uint32_t __parity3, uint32_t __parity4,
 
  383       typename _CharT, typename _Traits>
 
  384     std::basic_istream<_CharT, _Traits>&
 
  385     operator>>(std::basic_istream<_CharT, _Traits>& __is,
 
  386           __gnu_cxx::simd_fast_mersenne_twister_engine<_UIntType,
 
  387           __m, __pos1, __sl1, __sl2, __sr1, __sr2,
 
  388           __msk1, __msk2, __msk3, __msk4,
 
  389           __parity1, __parity2, __parity3, __parity4>& __x)
 
  391       typedef std::basic_istream<_CharT, _Traits> __istream_type;
 
  392       typedef typename __istream_type::ios_base __ios_base;
 
  394       const typename __ios_base::fmtflags __flags = __is.flags();
 
  395       __is.flags(__ios_base::dec | __ios_base::skipws);
 
  397       for (size_t __i = 0; __i < __x._M_nstate32; ++__i)
 
  398    __is >> __x._M_state32[__i];
 
  405 #endif // __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
 
  408    * Iteration method due to M.D. J<o:>hnk.
 
  410    * M.D. J<o:>hnk, Erzeugung von betaverteilten und gammaverteilten
 
  411    * Zufallszahlen, Metrika, Volume 8, 1964
 
  413   template<typename _RealType>
 
  414     template<typename _UniformRandomNumberGenerator>
 
  415       typename beta_distribution<_RealType>::result_type
 
  416       beta_distribution<_RealType>::
 
  417       operator()(_UniformRandomNumberGenerator& __urng,
 
  418         const param_type& __param)
 
  420    std::__detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
 
  423    result_type __x, __y;
 
  426        __x = std::exp(std::log(__aurng()) / __param.alpha());
 
  427        __y = std::exp(std::log(__aurng()) / __param.beta());
 
  429    while (__x + __y > result_type(1));
 
  431    return __x / (__x + __y);
 
  434   template<typename _RealType>
 
  435     template<typename _OutputIterator,
 
  436         typename _UniformRandomNumberGenerator>
 
  438       beta_distribution<_RealType>::
 
  439       __generate_impl(_OutputIterator __f, _OutputIterator __t,
 
  440              _UniformRandomNumberGenerator& __urng,
 
  441              const param_type& __param)
 
  443    __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator>)
 
  445    std::__detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
 
  450        result_type __x, __y;
 
  453        __x = std::exp(std::log(__aurng()) / __param.alpha());
 
  454        __y = std::exp(std::log(__aurng()) / __param.beta());
 
  456        while (__x + __y > result_type(1));
 
  458        *__f++ = __x / (__x + __y);
 
  462   template<typename _RealType, typename _CharT, typename _Traits>
 
  463     std::basic_ostream<_CharT, _Traits>&
 
  464     operator<<(std::basic_ostream<_CharT, _Traits>& __os,
 
  465           const __gnu_cxx::beta_distribution<_RealType>& __x)
 
  467       typedef std::basic_ostream<_CharT, _Traits>  __ostream_type;
 
  468       typedef typename __ostream_type::ios_base    __ios_base;
 
  470       const typename __ios_base::fmtflags __flags = __os.flags();
 
  471       const _CharT __fill = __os.fill();
 
  472       const std::streamsize __precision = __os.precision();
 
  473       const _CharT __space = __os.widen(' ');
 
  474       __os.flags(__ios_base::scientific | __ios_base::left);
 
  476       __os.precision(std::numeric_limits<_RealType>::max_digits10);
 
  478       __os << __x.alpha() << __space << __x.beta();
 
  482       __os.precision(__precision);
 
  486   template<typename _RealType, typename _CharT, typename _Traits>
 
  487     std::basic_istream<_CharT, _Traits>&
 
  488     operator>>(std::basic_istream<_CharT, _Traits>& __is,
 
  489           __gnu_cxx::beta_distribution<_RealType>& __x)
 
  491       typedef std::basic_istream<_CharT, _Traits>  __istream_type;
 
  492       typedef typename __istream_type::ios_base    __ios_base;
 
  494       const typename __ios_base::fmtflags __flags = __is.flags();
 
  495       __is.flags(__ios_base::dec | __ios_base::skipws);
 
  497       _RealType __alpha_val, __beta_val;
 
  498       __is >> __alpha_val >> __beta_val;
 
  499       __x.param(typename __gnu_cxx::beta_distribution<_RealType>::
 
  500        param_type(__alpha_val, __beta_val));
 
  507   template<std::size_t _Dimen, typename _RealType>
 
  508     template<typename _InputIterator1, typename _InputIterator2>
 
  510       normal_mv_distribution<_Dimen, _RealType>::param_type::
 
  511       _M_init_full(_InputIterator1 __meanbegin, _InputIterator1 __meanend,
 
  512           _InputIterator2 __varcovbegin, _InputIterator2 __varcovend)
 
  514    __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
 
  515    __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
 
  516    std::fill(std::copy(__meanbegin, __meanend, _M_mean.begin()),
 
  517          _M_mean.end(), _RealType(0));
 
  519    // Perform the Cholesky decomposition
 
  520    auto __w = _M_t.begin();
 
  521    for (size_t __j = 0; __j < _Dimen; ++__j)
 
  523        _RealType __sum = _RealType(0);
 
  525        auto __slitbegin = __w;
 
  526        auto __cit = _M_t.begin();
 
  527        for (size_t __i = 0; __i < __j; ++__i)
 
  529        auto __slit = __slitbegin;
 
  530        _RealType __s = *__varcovbegin++;
 
  531        for (size_t __k = 0; __k < __i; ++__k)
 
  532          __s -= *__slit++ * *__cit++;
 
  534        *__w++ = __s /= *__cit++;
 
  538        __sum = *__varcovbegin - __sum;
 
  539        if (__builtin_expect(__sum <= _RealType(0), 0))
 
  540          std::__throw_runtime_error(__N("normal_mv_distribution::"
 
  541                         "param_type::_M_init_full"));
 
  542        *__w++ = std::sqrt(__sum);
 
  544        std::advance(__varcovbegin, _Dimen - __j);
 
  548   template<std::size_t _Dimen, typename _RealType>
 
  549     template<typename _InputIterator1, typename _InputIterator2>
 
  551       normal_mv_distribution<_Dimen, _RealType>::param_type::
 
  552       _M_init_lower(_InputIterator1 __meanbegin, _InputIterator1 __meanend,
 
  553            _InputIterator2 __varcovbegin, _InputIterator2 __varcovend)
 
  555    __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
 
  556    __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
 
  557    std::fill(std::copy(__meanbegin, __meanend, _M_mean.begin()),
 
  558          _M_mean.end(), _RealType(0));
 
  560    // Perform the Cholesky decomposition
 
  561    auto __w = _M_t.begin();
 
  562    for (size_t __j = 0; __j < _Dimen; ++__j)
 
  564        _RealType __sum = _RealType(0);
 
  566        auto __slitbegin = __w;
 
  567        auto __cit = _M_t.begin();
 
  568        for (size_t __i = 0; __i < __j; ++__i)
 
  570        auto __slit = __slitbegin;
 
  571        _RealType __s = *__varcovbegin++;
 
  572        for (size_t __k = 0; __k < __i; ++__k)
 
  573          __s -= *__slit++ * *__cit++;
 
  575        *__w++ = __s /= *__cit++;
 
  579        __sum = *__varcovbegin++ - __sum;
 
  580        if (__builtin_expect(__sum <= _RealType(0), 0))
 
  581          std::__throw_runtime_error(__N("normal_mv_distribution::"
 
  582                         "param_type::_M_init_full"));
 
  583        *__w++ = std::sqrt(__sum);
 
  587   template<std::size_t _Dimen, typename _RealType>
 
  588     template<typename _InputIterator1, typename _InputIterator2>
 
  590       normal_mv_distribution<_Dimen, _RealType>::param_type::
 
  591       _M_init_diagonal(_InputIterator1 __meanbegin, _InputIterator1 __meanend,
 
  592               _InputIterator2 __varbegin, _InputIterator2 __varend)
 
  594    __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
 
  595    __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
 
  596    std::fill(std::copy(__meanbegin, __meanend, _M_mean.begin()),
 
  597          _M_mean.end(), _RealType(0));
 
  599    auto __w = _M_t.begin();
 
  601    while (__varbegin != __varend)
 
  603        std::fill_n(__w, __step, _RealType(0));
 
  605        if (__builtin_expect(*__varbegin < _RealType(0), 0))
 
  606          std::__throw_runtime_error(__N("normal_mv_distribution::"
 
  607                         "param_type::_M_init_diagonal"));
 
  608        *__w++ = std::sqrt(*__varbegin++);
 
  612   template<std::size_t _Dimen, typename _RealType>
 
  613     template<typename _UniformRandomNumberGenerator>
 
  614       typename normal_mv_distribution<_Dimen, _RealType>::result_type
 
  615       normal_mv_distribution<_Dimen, _RealType>::
 
  616       operator()(_UniformRandomNumberGenerator& __urng,
 
  617         const param_type& __param)
 
  621    _M_nd.__generate(__ret.begin(), __ret.end(), __urng);
 
  623    auto __t_it = __param._M_t.crbegin();
 
  624    for (size_t __i = _Dimen; __i > 0; --__i)
 
  626        _RealType __sum = _RealType(0);
 
  627        for (size_t __j = __i; __j > 0; --__j)
 
  628          __sum += __ret[__j - 1] * *__t_it++;
 
  629        __ret[__i - 1] = __sum;
 
  635   template<std::size_t _Dimen, typename _RealType>
 
  636     template<typename _ForwardIterator, typename _UniformRandomNumberGenerator>
 
  638       normal_mv_distribution<_Dimen, _RealType>::
 
  639       __generate_impl(_ForwardIterator __f, _ForwardIterator __t,
 
  640              _UniformRandomNumberGenerator& __urng,
 
  641              const param_type& __param)
 
  643    __glibcxx_function_requires(_Mutable_ForwardIteratorConcept<
 
  646      *__f++ = this->operator()(__urng, __param);
 
  649   template<size_t _Dimen, typename _RealType>
 
  651     operator==(const __gnu_cxx::normal_mv_distribution<_Dimen, _RealType>&
 
  653           const __gnu_cxx::normal_mv_distribution<_Dimen, _RealType>&
 
  656       return __d1._M_param == __d2._M_param && __d1._M_nd == __d2._M_nd;
 
  659   template<size_t _Dimen, typename _RealType, typename _CharT, typename _Traits>
 
  660     std::basic_ostream<_CharT, _Traits>&
 
  661     operator<<(std::basic_ostream<_CharT, _Traits>& __os,
 
  662           const __gnu_cxx::normal_mv_distribution<_Dimen, _RealType>& __x)
 
  664       typedef std::basic_ostream<_CharT, _Traits>  __ostream_type;
 
  665       typedef typename __ostream_type::ios_base    __ios_base;
 
  667       const typename __ios_base::fmtflags __flags = __os.flags();
 
  668       const _CharT __fill = __os.fill();
 
  669       const std::streamsize __precision = __os.precision();
 
  670       const _CharT __space = __os.widen(' ');
 
  671       __os.flags(__ios_base::scientific | __ios_base::left);
 
  673       __os.precision(std::numeric_limits<_RealType>::max_digits10);
 
  675       auto __mean = __x._M_param.mean();
 
  676       for (auto __it : __mean)
 
  677    __os << __it << __space;
 
  678       auto __t = __x._M_param.varcov();
 
  679       for (auto __it : __t)
 
  680    __os << __it << __space;
 
  686       __os.precision(__precision);
 
  690   template<size_t _Dimen, typename _RealType, typename _CharT, typename _Traits>
 
  691     std::basic_istream<_CharT, _Traits>&
 
  692     operator>>(std::basic_istream<_CharT, _Traits>& __is,
 
  693           __gnu_cxx::normal_mv_distribution<_Dimen, _RealType>& __x)
 
  695       typedef std::basic_istream<_CharT, _Traits>  __istream_type;
 
  696       typedef typename __istream_type::ios_base    __ios_base;
 
  698       const typename __ios_base::fmtflags __flags = __is.flags();
 
  699       __is.flags(__ios_base::dec | __ios_base::skipws);
 
  701       std::array<_RealType, _Dimen> __mean;
 
  702       for (auto& __it : __mean)
 
  704       std::array<_RealType, _Dimen * (_Dimen + 1) / 2> __varcov;
 
  705       for (auto& __it : __varcov)
 
  710       __x.param(typename normal_mv_distribution<_Dimen, _RealType>::
 
  711        param_type(__mean.begin(), __mean.end(),
 
  712               __varcov.begin(), __varcov.end()));
 
  719   template<typename _RealType>
 
  720     template<typename _OutputIterator,
 
  721         typename _UniformRandomNumberGenerator>
 
  723       rice_distribution<_RealType>::
 
  724       __generate_impl(_OutputIterator __f, _OutputIterator __t,
 
  725              _UniformRandomNumberGenerator& __urng,
 
  726              const param_type& __p)
 
  728    __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator>)
 
  732        typename std::normal_distribution<result_type>::param_type
 
  733          __px(__p.nu(), __p.sigma()), __py(result_type(0), __p.sigma());
 
  734        result_type __x = this->_M_ndx(__px, __urng);
 
  735        result_type __y = this->_M_ndy(__py, __urng);
 
  736 #if _GLIBCXX_USE_C99_MATH_TR1
 
  737        *__f++ = std::hypot(__x, __y);
 
  739        *__f++ = std::sqrt(__x * __x + __y * __y);
 
  744   template<typename _RealType, typename _CharT, typename _Traits>
 
  745     std::basic_ostream<_CharT, _Traits>&
 
  746     operator<<(std::basic_ostream<_CharT, _Traits>& __os,
 
  747           const rice_distribution<_RealType>& __x)
 
  749       typedef std::basic_ostream<_CharT, _Traits>  __ostream_type;
 
  750       typedef typename __ostream_type::ios_base    __ios_base;
 
  752       const typename __ios_base::fmtflags __flags = __os.flags();
 
  753       const _CharT __fill = __os.fill();
 
  754       const std::streamsize __precision = __os.precision();
 
  755       const _CharT __space = __os.widen(' ');
 
  756       __os.flags(__ios_base::scientific | __ios_base::left);
 
  758       __os.precision(std::numeric_limits<_RealType>::max_digits10);
 
  760       __os << __x.nu() << __space << __x.sigma();
 
  761       __os << __space << __x._M_ndx;
 
  762       __os << __space << __x._M_ndy;
 
  766       __os.precision(__precision);
 
  770   template<typename _RealType, typename _CharT, typename _Traits>
 
  771     std::basic_istream<_CharT, _Traits>&
 
  772     operator>>(std::basic_istream<_CharT, _Traits>& __is,
 
  773           rice_distribution<_RealType>& __x)
 
  775       typedef std::basic_istream<_CharT, _Traits>  __istream_type;
 
  776       typedef typename __istream_type::ios_base    __ios_base;
 
  778       const typename __ios_base::fmtflags __flags = __is.flags();
 
  779       __is.flags(__ios_base::dec | __ios_base::skipws);
 
  781       _RealType __nu_val, __sigma_val;
 
  782       __is >> __nu_val >> __sigma_val;
 
  785       __x.param(typename rice_distribution<_RealType>::
 
  786        param_type(__nu_val, __sigma_val));
 
  793   template<typename _RealType>
 
  794     template<typename _OutputIterator,
 
  795         typename _UniformRandomNumberGenerator>
 
  797       nakagami_distribution<_RealType>::
 
  798       __generate_impl(_OutputIterator __f, _OutputIterator __t,
 
  799              _UniformRandomNumberGenerator& __urng,
 
  800              const param_type& __p)
 
  802    __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator>)
 
  804    typename std::gamma_distribution<result_type>::param_type
 
  805      __pg(__p.mu(), __p.omega() / __p.mu());
 
  807      *__f++ = std::sqrt(this->_M_gd(__pg, __urng));
 
  810   template<typename _RealType, typename _CharT, typename _Traits>
 
  811     std::basic_ostream<_CharT, _Traits>&
 
  812     operator<<(std::basic_ostream<_CharT, _Traits>& __os,
 
  813           const nakagami_distribution<_RealType>& __x)
 
  815       typedef std::basic_ostream<_CharT, _Traits>  __ostream_type;
 
  816       typedef typename __ostream_type::ios_base    __ios_base;
 
  818       const typename __ios_base::fmtflags __flags = __os.flags();
 
  819       const _CharT __fill = __os.fill();
 
  820       const std::streamsize __precision = __os.precision();
 
  821       const _CharT __space = __os.widen(' ');
 
  822       __os.flags(__ios_base::scientific | __ios_base::left);
 
  824       __os.precision(std::numeric_limits<_RealType>::max_digits10);
 
  826       __os << __x.mu() << __space << __x.omega();
 
  827       __os << __space << __x._M_gd;
 
  831       __os.precision(__precision);
 
  835   template<typename _RealType, typename _CharT, typename _Traits>
 
  836     std::basic_istream<_CharT, _Traits>&
 
  837     operator>>(std::basic_istream<_CharT, _Traits>& __is,
 
  838           nakagami_distribution<_RealType>& __x)
 
  840       typedef std::basic_istream<_CharT, _Traits>  __istream_type;
 
  841       typedef typename __istream_type::ios_base    __ios_base;
 
  843       const typename __ios_base::fmtflags __flags = __is.flags();
 
  844       __is.flags(__ios_base::dec | __ios_base::skipws);
 
  846       _RealType __mu_val, __omega_val;
 
  847       __is >> __mu_val >> __omega_val;
 
  849       __x.param(typename nakagami_distribution<_RealType>::
 
  850        param_type(__mu_val, __omega_val));
 
  857   template<typename _RealType>
 
  858     template<typename _OutputIterator,
 
  859         typename _UniformRandomNumberGenerator>
 
  861       pareto_distribution<_RealType>::
 
  862       __generate_impl(_OutputIterator __f, _OutputIterator __t,
 
  863              _UniformRandomNumberGenerator& __urng,
 
  864              const param_type& __p)
 
  866    __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator>)
 
  868    result_type __mu_val = __p.mu();
 
  869    result_type __malphinv = -result_type(1) / __p.alpha();
 
  871      *__f++ = __mu_val * std::pow(this->_M_ud(__urng), __malphinv);
 
  874   template<typename _RealType, typename _CharT, typename _Traits>
 
  875     std::basic_ostream<_CharT, _Traits>&
 
  876     operator<<(std::basic_ostream<_CharT, _Traits>& __os,
 
  877           const pareto_distribution<_RealType>& __x)
 
  879       typedef std::basic_ostream<_CharT, _Traits>  __ostream_type;
 
  880       typedef typename __ostream_type::ios_base    __ios_base;
 
  882       const typename __ios_base::fmtflags __flags = __os.flags();
 
  883       const _CharT __fill = __os.fill();
 
  884       const std::streamsize __precision = __os.precision();
 
  885       const _CharT __space = __os.widen(' ');
 
  886       __os.flags(__ios_base::scientific | __ios_base::left);
 
  888       __os.precision(std::numeric_limits<_RealType>::max_digits10);
 
  890       __os << __x.alpha() << __space << __x.mu();
 
  891       __os << __space << __x._M_ud;
 
  895       __os.precision(__precision);
 
  899   template<typename _RealType, typename _CharT, typename _Traits>
 
  900     std::basic_istream<_CharT, _Traits>&
 
  901     operator>>(std::basic_istream<_CharT, _Traits>& __is,
 
  902           pareto_distribution<_RealType>& __x)
 
  904       typedef std::basic_istream<_CharT, _Traits>  __istream_type;
 
  905       typedef typename __istream_type::ios_base    __ios_base;
 
  907       const typename __ios_base::fmtflags __flags = __is.flags();
 
  908       __is.flags(__ios_base::dec | __ios_base::skipws);
 
  910       _RealType __alpha_val, __mu_val;
 
  911       __is >> __alpha_val >> __mu_val;
 
  913       __x.param(typename pareto_distribution<_RealType>::
 
  914        param_type(__alpha_val, __mu_val));
 
  921   template<typename _RealType>
 
  922     template<typename _UniformRandomNumberGenerator>
 
  923       typename k_distribution<_RealType>::result_type
 
  924       k_distribution<_RealType>::
 
  925       operator()(_UniformRandomNumberGenerator& __urng)
 
  927    result_type __x = this->_M_gd1(__urng);
 
  928    result_type __y = this->_M_gd2(__urng);
 
  929    return std::sqrt(__x * __y);
 
  932   template<typename _RealType>
 
  933     template<typename _UniformRandomNumberGenerator>
 
  934       typename k_distribution<_RealType>::result_type
 
  935       k_distribution<_RealType>::
 
  936       operator()(_UniformRandomNumberGenerator& __urng,
 
  937         const param_type& __p)
 
  939    typename std::gamma_distribution<result_type>::param_type
 
  940      __p1(__p.lambda(), result_type(1) / __p.lambda()),
 
  941      __p2(__p.nu(), __p.mu() / __p.nu());
 
  942    result_type __x = this->_M_gd1(__p1, __urng);
 
  943    result_type __y = this->_M_gd2(__p2, __urng);
 
  944    return std::sqrt(__x * __y);
 
  947   template<typename _RealType>
 
  948     template<typename _OutputIterator,
 
  949         typename _UniformRandomNumberGenerator>
 
  951       k_distribution<_RealType>::
 
  952       __generate_impl(_OutputIterator __f, _OutputIterator __t,
 
  953              _UniformRandomNumberGenerator& __urng,
 
  954              const param_type& __p)
 
  956    __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator>)
 
  958    typename std::gamma_distribution<result_type>::param_type
 
  959      __p1(__p.lambda(), result_type(1) / __p.lambda()),
 
  960      __p2(__p.nu(), __p.mu() / __p.nu());
 
  963        result_type __x = this->_M_gd1(__p1, __urng);
 
  964        result_type __y = this->_M_gd2(__p2, __urng);
 
  965        *__f++ = std::sqrt(__x * __y);
 
  969   template<typename _RealType, typename _CharT, typename _Traits>
 
  970     std::basic_ostream<_CharT, _Traits>&
 
  971     operator<<(std::basic_ostream<_CharT, _Traits>& __os,
 
  972           const k_distribution<_RealType>& __x)
 
  974       typedef std::basic_ostream<_CharT, _Traits>  __ostream_type;
 
  975       typedef typename __ostream_type::ios_base    __ios_base;
 
  977       const typename __ios_base::fmtflags __flags = __os.flags();
 
  978       const _CharT __fill = __os.fill();
 
  979       const std::streamsize __precision = __os.precision();
 
  980       const _CharT __space = __os.widen(' ');
 
  981       __os.flags(__ios_base::scientific | __ios_base::left);
 
  983       __os.precision(std::numeric_limits<_RealType>::max_digits10);
 
  985       __os << __x.lambda() << __space << __x.mu() << __space << __x.nu();
 
  986       __os << __space << __x._M_gd1;
 
  987       __os << __space << __x._M_gd2;
 
  991       __os.precision(__precision);
 
  995   template<typename _RealType, typename _CharT, typename _Traits>
 
  996     std::basic_istream<_CharT, _Traits>&
 
  997     operator>>(std::basic_istream<_CharT, _Traits>& __is,
 
  998           k_distribution<_RealType>& __x)
 
 1000       typedef std::basic_istream<_CharT, _Traits>  __istream_type;
 
 1001       typedef typename __istream_type::ios_base    __ios_base;
 
 1003       const typename __ios_base::fmtflags __flags = __is.flags();
 
 1004       __is.flags(__ios_base::dec | __ios_base::skipws);
 
 1006       _RealType __lambda_val, __mu_val, __nu_val;
 
 1007       __is >> __lambda_val >> __mu_val >> __nu_val;
 
 1010       __x.param(typename k_distribution<_RealType>::
 
 1011        param_type(__lambda_val, __mu_val, __nu_val));
 
 1013       __is.flags(__flags);
 
 1018   template<typename _RealType>
 
 1019     template<typename _OutputIterator,
 
 1020         typename _UniformRandomNumberGenerator>
 
 1022       arcsine_distribution<_RealType>::
 
 1023       __generate_impl(_OutputIterator __f, _OutputIterator __t,
 
 1024              _UniformRandomNumberGenerator& __urng,
 
 1025              const param_type& __p)
 
 1027    __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator>)
 
 1029    result_type __dif = __p.b() - __p.a();
 
 1030    result_type __sum = __p.a() + __p.b();
 
 1033        result_type __x = std::sin(this->_M_ud(__urng));
 
 1034        *__f++ = (__x * __dif + __sum) / result_type(2);
 
 1038   template<typename _RealType, typename _CharT, typename _Traits>
 
 1039     std::basic_ostream<_CharT, _Traits>&
 
 1040     operator<<(std::basic_ostream<_CharT, _Traits>& __os,
 
 1041           const arcsine_distribution<_RealType>& __x)
 
 1043       typedef std::basic_ostream<_CharT, _Traits>  __ostream_type;
 
 1044       typedef typename __ostream_type::ios_base    __ios_base;
 
 1046       const typename __ios_base::fmtflags __flags = __os.flags();
 
 1047       const _CharT __fill = __os.fill();
 
 1048       const std::streamsize __precision = __os.precision();
 
 1049       const _CharT __space = __os.widen(' ');
 
 1050       __os.flags(__ios_base::scientific | __ios_base::left);
 
 1052       __os.precision(std::numeric_limits<_RealType>::max_digits10);
 
 1054       __os << __x.a() << __space << __x.b();
 
 1055       __os << __space << __x._M_ud;
 
 1057       __os.flags(__flags);
 
 1059       __os.precision(__precision);
 
 1063   template<typename _RealType, typename _CharT, typename _Traits>
 
 1064     std::basic_istream<_CharT, _Traits>&
 
 1065     operator>>(std::basic_istream<_CharT, _Traits>& __is,
 
 1066           arcsine_distribution<_RealType>& __x)
 
 1068       typedef std::basic_istream<_CharT, _Traits>  __istream_type;
 
 1069       typedef typename __istream_type::ios_base    __ios_base;
 
 1071       const typename __ios_base::fmtflags __flags = __is.flags();
 
 1072       __is.flags(__ios_base::dec | __ios_base::skipws);
 
 1077       __x.param(typename arcsine_distribution<_RealType>::
 
 1078        param_type(__a, __b));
 
 1080       __is.flags(__flags);
 
 1085   template<typename _RealType>
 
 1086     template<typename _UniformRandomNumberGenerator>
 
 1087       typename hoyt_distribution<_RealType>::result_type
 
 1088       hoyt_distribution<_RealType>::
 
 1089       operator()(_UniformRandomNumberGenerator& __urng)
 
 1091    result_type __x = this->_M_ad(__urng);
 
 1092    result_type __y = this->_M_ed(__urng);
 
 1093    return (result_type(2) * this->q()
 
 1094          / (result_type(1) + this->q() * this->q()))
 
 1095           * std::sqrt(this->omega() * __x * __y);
 
 1098   template<typename _RealType>
 
 1099     template<typename _UniformRandomNumberGenerator>
 
 1100       typename hoyt_distribution<_RealType>::result_type
 
 1101       hoyt_distribution<_RealType>::
 
 1102       operator()(_UniformRandomNumberGenerator& __urng,
 
 1103         const param_type& __p)
 
 1105    result_type __q2 = __p.q() * __p.q();
 
 1106    result_type __num = result_type(0.5L) * (result_type(1) + __q2);
 
 1107    typename __gnu_cxx::arcsine_distribution<result_type>::param_type
 
 1108      __pa(__num, __num / __q2);
 
 1109    result_type __x = this->_M_ad(__pa, __urng);
 
 1110    result_type __y = this->_M_ed(__urng);
 
 1111    return (result_type(2) * __p.q() / (result_type(1) + __q2))
 
 1112           * std::sqrt(__p.omega() * __x * __y);
 
 1115   template<typename _RealType>
 
 1116     template<typename _OutputIterator,
 
 1117         typename _UniformRandomNumberGenerator>
 
 1119       hoyt_distribution<_RealType>::
 
 1120       __generate_impl(_OutputIterator __f, _OutputIterator __t,
 
 1121              _UniformRandomNumberGenerator& __urng,
 
 1122              const param_type& __p)
 
 1124    __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator>)
 
 1126    result_type __2q = result_type(2) * __p.q();
 
 1127    result_type __q2 = __p.q() * __p.q();
 
 1128    result_type __q2p1 = result_type(1) + __q2;
 
 1129    result_type __num = result_type(0.5L) * __q2p1;
 
 1130    result_type __omega = __p.omega();
 
 1131    typename __gnu_cxx::arcsine_distribution<result_type>::param_type
 
 1132      __pa(__num, __num / __q2);
 
 1135        result_type __x = this->_M_ad(__pa, __urng);
 
 1136        result_type __y = this->_M_ed(__urng);
 
 1137        *__f++ = (__2q / __q2p1) * std::sqrt(__omega * __x * __y);
 
 1141   template<typename _RealType, typename _CharT, typename _Traits>
 
 1142     std::basic_ostream<_CharT, _Traits>&
 
 1143     operator<<(std::basic_ostream<_CharT, _Traits>& __os,
 
 1144           const hoyt_distribution<_RealType>& __x)
 
 1146       typedef std::basic_ostream<_CharT, _Traits>  __ostream_type;
 
 1147       typedef typename __ostream_type::ios_base    __ios_base;
 
 1149       const typename __ios_base::fmtflags __flags = __os.flags();
 
 1150       const _CharT __fill = __os.fill();
 
 1151       const std::streamsize __precision = __os.precision();
 
 1152       const _CharT __space = __os.widen(' ');
 
 1153       __os.flags(__ios_base::scientific | __ios_base::left);
 
 1155       __os.precision(std::numeric_limits<_RealType>::max_digits10);
 
 1157       __os << __x.q() << __space << __x.omega();
 
 1158       __os << __space << __x._M_ad;
 
 1159       __os << __space << __x._M_ed;
 
 1161       __os.flags(__flags);
 
 1163       __os.precision(__precision);
 
 1167   template<typename _RealType, typename _CharT, typename _Traits>
 
 1168     std::basic_istream<_CharT, _Traits>&
 
 1169     operator>>(std::basic_istream<_CharT, _Traits>& __is,
 
 1170           hoyt_distribution<_RealType>& __x)
 
 1172       typedef std::basic_istream<_CharT, _Traits>  __istream_type;
 
 1173       typedef typename __istream_type::ios_base    __ios_base;
 
 1175       const typename __ios_base::fmtflags __flags = __is.flags();
 
 1176       __is.flags(__ios_base::dec | __ios_base::skipws);
 
 1178       _RealType __q, __omega;
 
 1179       __is >> __q >> __omega;
 
 1182       __x.param(typename hoyt_distribution<_RealType>::
 
 1183        param_type(__q, __omega));
 
 1185       __is.flags(__flags);
 
 1190   template<typename _RealType>
 
 1191     template<typename _OutputIterator,
 
 1192         typename _UniformRandomNumberGenerator>
 
 1194       triangular_distribution<_RealType>::
 
 1195       __generate_impl(_OutputIterator __f, _OutputIterator __t,
 
 1196              _UniformRandomNumberGenerator& __urng,
 
 1197              const param_type& __param)
 
 1199    __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator>)
 
 1202      *__f++ = this->operator()(__urng, __param);
 
 1205   template<typename _RealType, typename _CharT, typename _Traits>
 
 1206     std::basic_ostream<_CharT, _Traits>&
 
 1207     operator<<(std::basic_ostream<_CharT, _Traits>& __os,
 
 1208           const __gnu_cxx::triangular_distribution<_RealType>& __x)
 
 1210       typedef std::basic_ostream<_CharT, _Traits>  __ostream_type;
 
 1211       typedef typename __ostream_type::ios_base    __ios_base;
 
 1213       const typename __ios_base::fmtflags __flags = __os.flags();
 
 1214       const _CharT __fill = __os.fill();
 
 1215       const std::streamsize __precision = __os.precision();
 
 1216       const _CharT __space = __os.widen(' ');
 
 1217       __os.flags(__ios_base::scientific | __ios_base::left);
 
 1219       __os.precision(std::numeric_limits<_RealType>::max_digits10);
 
 1221       __os << __x.a() << __space << __x.b() << __space << __x.c();
 
 1223       __os.flags(__flags);
 
 1225       __os.precision(__precision);
 
 1229   template<typename _RealType, typename _CharT, typename _Traits>
 
 1230     std::basic_istream<_CharT, _Traits>&
 
 1231     operator>>(std::basic_istream<_CharT, _Traits>& __is,
 
 1232           __gnu_cxx::triangular_distribution<_RealType>& __x)
 
 1234       typedef std::basic_istream<_CharT, _Traits>  __istream_type;
 
 1235       typedef typename __istream_type::ios_base    __ios_base;
 
 1237       const typename __ios_base::fmtflags __flags = __is.flags();
 
 1238       __is.flags(__ios_base::dec | __ios_base::skipws);
 
 1240       _RealType __a, __b, __c;
 
 1241       __is >> __a >> __b >> __c;
 
 1242       __x.param(typename __gnu_cxx::triangular_distribution<_RealType>::
 
 1243        param_type(__a, __b, __c));
 
 1245       __is.flags(__flags);
 
 1250   template<typename _RealType>
 
 1251     template<typename _OutputIterator,
 
 1252         typename _UniformRandomNumberGenerator>
 
 1254       von_mises_distribution<_RealType>::
 
 1255       __generate_impl(_OutputIterator __f, _OutputIterator __t,
 
 1256              _UniformRandomNumberGenerator& __urng,
 
 1257              const param_type& __param)
 
 1259    __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator>)
 
 1262      *__f++ = this->operator()(__urng, __param);
 
 1265   template<typename _RealType, typename _CharT, typename _Traits>
 
 1266     std::basic_ostream<_CharT, _Traits>&
 
 1267     operator<<(std::basic_ostream<_CharT, _Traits>& __os,
 
 1268           const __gnu_cxx::von_mises_distribution<_RealType>& __x)
 
 1270       typedef std::basic_ostream<_CharT, _Traits>  __ostream_type;
 
 1271       typedef typename __ostream_type::ios_base    __ios_base;
 
 1273       const typename __ios_base::fmtflags __flags = __os.flags();
 
 1274       const _CharT __fill = __os.fill();
 
 1275       const std::streamsize __precision = __os.precision();
 
 1276       const _CharT __space = __os.widen(' ');
 
 1277       __os.flags(__ios_base::scientific | __ios_base::left);
 
 1279       __os.precision(std::numeric_limits<_RealType>::max_digits10);
 
 1281       __os << __x.mu() << __space << __x.kappa();
 
 1283       __os.flags(__flags);
 
 1285       __os.precision(__precision);
 
 1289   template<typename _RealType, typename _CharT, typename _Traits>
 
 1290     std::basic_istream<_CharT, _Traits>&
 
 1291     operator>>(std::basic_istream<_CharT, _Traits>& __is,
 
 1292           __gnu_cxx::von_mises_distribution<_RealType>& __x)
 
 1294       typedef std::basic_istream<_CharT, _Traits>  __istream_type;
 
 1295       typedef typename __istream_type::ios_base    __ios_base;
 
 1297       const typename __ios_base::fmtflags __flags = __is.flags();
 
 1298       __is.flags(__ios_base::dec | __ios_base::skipws);
 
 1300       _RealType __mu, __kappa;
 
 1301       __is >> __mu >> __kappa;
 
 1302       __x.param(typename __gnu_cxx::von_mises_distribution<_RealType>::
 
 1303        param_type(__mu, __kappa));
 
 1305       __is.flags(__flags);
 
 1310   template<typename _UIntType>
 
 1311     template<typename _UniformRandomNumberGenerator>
 
 1312       typename hypergeometric_distribution<_UIntType>::result_type
 
 1313       hypergeometric_distribution<_UIntType>::
 
 1314       operator()(_UniformRandomNumberGenerator& __urng,
 
 1315         const param_type& __param)
 
 1317    std::__detail::_Adaptor<_UniformRandomNumberGenerator, double>
 
 1320    result_type __a = __param.successful_size();
 
 1321    result_type __b = __param.total_size();
 
 1322    result_type __k = 0;
 
 1324    if (__param.total_draws() < __param.total_size() / 2) 
 
 1326        for (result_type __i = 0; __i < __param.total_draws(); ++__i)
 
 1328        if (__b * __aurng() < __a)
 
 1331            if (__k == __param.successful_size())
 
 1341        for (result_type __i = 0; __i < __param.unsuccessful_size(); ++__i)
 
 1343        if (__b * __aurng() < __a)
 
 1346            if (__k == __param.successful_size())
 
 1347              return __param.successful_size() - __k;
 
 1352        return __param.successful_size() - __k;
 
 1356   template<typename _UIntType>
 
 1357     template<typename _OutputIterator,
 
 1358         typename _UniformRandomNumberGenerator>
 
 1360       hypergeometric_distribution<_UIntType>::
 
 1361       __generate_impl(_OutputIterator __f, _OutputIterator __t,
 
 1362              _UniformRandomNumberGenerator& __urng,
 
 1363              const param_type& __param)
 
 1365    __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator>)
 
 1368      *__f++ = this->operator()(__urng);
 
 1371   template<typename _UIntType, typename _CharT, typename _Traits>
 
 1372     std::basic_ostream<_CharT, _Traits>&
 
 1373     operator<<(std::basic_ostream<_CharT, _Traits>& __os,
 
 1374           const __gnu_cxx::hypergeometric_distribution<_UIntType>& __x)
 
 1376       typedef std::basic_ostream<_CharT, _Traits>  __ostream_type;
 
 1377       typedef typename __ostream_type::ios_base    __ios_base;
 
 1379       const typename __ios_base::fmtflags __flags = __os.flags();
 
 1380       const _CharT __fill = __os.fill();
 
 1381       const std::streamsize __precision = __os.precision();
 
 1382       const _CharT __space = __os.widen(' ');
 
 1383       __os.flags(__ios_base::scientific | __ios_base::left);
 
 1385       __os.precision(std::numeric_limits<_UIntType>::max_digits10);
 
 1387       __os << __x.total_size() << __space << __x.successful_size() << __space
 
 1388       << __x.total_draws();
 
 1390       __os.flags(__flags);
 
 1392       __os.precision(__precision);
 
 1396   template<typename _UIntType, typename _CharT, typename _Traits>
 
 1397     std::basic_istream<_CharT, _Traits>&
 
 1398     operator>>(std::basic_istream<_CharT, _Traits>& __is,
 
 1399           __gnu_cxx::hypergeometric_distribution<_UIntType>& __x)
 
 1401       typedef std::basic_istream<_CharT, _Traits>  __istream_type;
 
 1402       typedef typename __istream_type::ios_base    __ios_base;
 
 1404       const typename __ios_base::fmtflags __flags = __is.flags();
 
 1405       __is.flags(__ios_base::dec | __ios_base::skipws);
 
 1407       _UIntType __total_size, __successful_size, __total_draws;
 
 1408       __is >> __total_size >> __successful_size >> __total_draws;
 
 1409       __x.param(typename __gnu_cxx::hypergeometric_distribution<_UIntType>::
 
 1410        param_type(__total_size, __successful_size, __total_draws));
 
 1412       __is.flags(__flags);
 
 1416 _GLIBCXX_END_NAMESPACE_VERSION
 
 1420 #endif // _EXT_RANDOM_TCC