Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-03 08:14:00

0001 //===----------------------------------------------------------------------===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef _LIBCPP___RANDOM_MERSENNE_TWISTER_ENGINE_H
0010 #define _LIBCPP___RANDOM_MERSENNE_TWISTER_ENGINE_H
0011 
0012 #include <__algorithm/equal.h>
0013 #include <__algorithm/min.h>
0014 #include <__config>
0015 #include <__cstddef/size_t.h>
0016 #include <__random/is_seed_sequence.h>
0017 #include <__type_traits/enable_if.h>
0018 #include <cstdint>
0019 #include <iosfwd>
0020 #include <limits>
0021 
0022 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0023 #  pragma GCC system_header
0024 #endif
0025 
0026 _LIBCPP_PUSH_MACROS
0027 #include <__undef_macros>
0028 
0029 _LIBCPP_BEGIN_NAMESPACE_STD
0030 
0031 template <class _UIntType,
0032           size_t __w,
0033           size_t __n,
0034           size_t __m,
0035           size_t __r,
0036           _UIntType __a,
0037           size_t __u,
0038           _UIntType __d,
0039           size_t __s,
0040           _UIntType __b,
0041           size_t __t,
0042           _UIntType __c,
0043           size_t __l,
0044           _UIntType __f>
0045 class _LIBCPP_TEMPLATE_VIS mersenne_twister_engine;
0046 
0047 template <class _UInt,
0048           size_t _Wp,
0049           size_t _Np,
0050           size_t _Mp,
0051           size_t _Rp,
0052           _UInt _Ap,
0053           size_t _Up,
0054           _UInt _Dp,
0055           size_t _Sp,
0056           _UInt _Bp,
0057           size_t _Tp,
0058           _UInt _Cp,
0059           size_t _Lp,
0060           _UInt _Fp>
0061 _LIBCPP_HIDE_FROM_ABI bool
0062 operator==(const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __x,
0063            const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __y);
0064 
0065 template <class _UInt,
0066           size_t _Wp,
0067           size_t _Np,
0068           size_t _Mp,
0069           size_t _Rp,
0070           _UInt _Ap,
0071           size_t _Up,
0072           _UInt _Dp,
0073           size_t _Sp,
0074           _UInt _Bp,
0075           size_t _Tp,
0076           _UInt _Cp,
0077           size_t _Lp,
0078           _UInt _Fp>
0079 _LIBCPP_HIDE_FROM_ABI bool
0080 operator!=(const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __x,
0081            const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __y);
0082 
0083 template <class _CharT,
0084           class _Traits,
0085           class _UInt,
0086           size_t _Wp,
0087           size_t _Np,
0088           size_t _Mp,
0089           size_t _Rp,
0090           _UInt _Ap,
0091           size_t _Up,
0092           _UInt _Dp,
0093           size_t _Sp,
0094           _UInt _Bp,
0095           size_t _Tp,
0096           _UInt _Cp,
0097           size_t _Lp,
0098           _UInt _Fp>
0099 _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
0100 operator<<(basic_ostream<_CharT, _Traits>& __os,
0101            const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __x);
0102 
0103 template <class _CharT,
0104           class _Traits,
0105           class _UInt,
0106           size_t _Wp,
0107           size_t _Np,
0108           size_t _Mp,
0109           size_t _Rp,
0110           _UInt _Ap,
0111           size_t _Up,
0112           _UInt _Dp,
0113           size_t _Sp,
0114           _UInt _Bp,
0115           size_t _Tp,
0116           _UInt _Cp,
0117           size_t _Lp,
0118           _UInt _Fp>
0119 _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
0120 operator>>(basic_istream<_CharT, _Traits>& __is,
0121            mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __x);
0122 
0123 template <class _UIntType,
0124           size_t __w,
0125           size_t __n,
0126           size_t __m,
0127           size_t __r,
0128           _UIntType __a,
0129           size_t __u,
0130           _UIntType __d,
0131           size_t __s,
0132           _UIntType __b,
0133           size_t __t,
0134           _UIntType __c,
0135           size_t __l,
0136           _UIntType __f>
0137 class _LIBCPP_TEMPLATE_VIS mersenne_twister_engine {
0138 public:
0139   // types
0140   typedef _UIntType result_type;
0141 
0142 private:
0143   result_type __x_[__n];
0144   size_t __i_;
0145 
0146   static_assert(0 < __m, "mersenne_twister_engine invalid parameters");
0147   static_assert(__m <= __n, "mersenne_twister_engine invalid parameters");
0148   static _LIBCPP_CONSTEXPR const result_type _Dt = numeric_limits<result_type>::digits;
0149   static_assert(__w <= _Dt, "mersenne_twister_engine invalid parameters");
0150   static_assert(2 <= __w, "mersenne_twister_engine invalid parameters");
0151   static_assert(__r <= __w, "mersenne_twister_engine invalid parameters");
0152   static_assert(__u <= __w, "mersenne_twister_engine invalid parameters");
0153   static_assert(__s <= __w, "mersenne_twister_engine invalid parameters");
0154   static_assert(__t <= __w, "mersenne_twister_engine invalid parameters");
0155   static_assert(__l <= __w, "mersenne_twister_engine invalid parameters");
0156 
0157 public:
0158   static _LIBCPP_CONSTEXPR const result_type _Min = 0;
0159   static _LIBCPP_CONSTEXPR const result_type _Max =
0160       __w == _Dt ? result_type(~0) : (result_type(1) << __w) - result_type(1);
0161   static_assert(_Min < _Max, "mersenne_twister_engine invalid parameters");
0162   static_assert(__a <= _Max, "mersenne_twister_engine invalid parameters");
0163   static_assert(__b <= _Max, "mersenne_twister_engine invalid parameters");
0164   static_assert(__c <= _Max, "mersenne_twister_engine invalid parameters");
0165   static_assert(__d <= _Max, "mersenne_twister_engine invalid parameters");
0166   static_assert(__f <= _Max, "mersenne_twister_engine invalid parameters");
0167 
0168   // engine characteristics
0169   static inline _LIBCPP_CONSTEXPR const size_t word_size                      = __w;
0170   static inline _LIBCPP_CONSTEXPR const size_t state_size                     = __n;
0171   static inline _LIBCPP_CONSTEXPR const size_t shift_size                     = __m;
0172   static inline _LIBCPP_CONSTEXPR const size_t mask_bits                      = __r;
0173   static inline _LIBCPP_CONSTEXPR const result_type xor_mask                  = __a;
0174   static inline _LIBCPP_CONSTEXPR const size_t tempering_u                    = __u;
0175   static inline _LIBCPP_CONSTEXPR const result_type tempering_d               = __d;
0176   static inline _LIBCPP_CONSTEXPR const size_t tempering_s                    = __s;
0177   static inline _LIBCPP_CONSTEXPR const result_type tempering_b               = __b;
0178   static inline _LIBCPP_CONSTEXPR const size_t tempering_t                    = __t;
0179   static inline _LIBCPP_CONSTEXPR const result_type tempering_c               = __c;
0180   static inline _LIBCPP_CONSTEXPR const size_t tempering_l                    = __l;
0181   static inline _LIBCPP_CONSTEXPR const result_type initialization_multiplier = __f;
0182   _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type min() { return _Min; }
0183   _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type max() { return _Max; }
0184   static inline _LIBCPP_CONSTEXPR const result_type default_seed = 5489u;
0185 
0186   // constructors and seeding functions
0187 #ifndef _LIBCPP_CXX03_LANG
0188   _LIBCPP_HIDE_FROM_ABI mersenne_twister_engine() : mersenne_twister_engine(default_seed) {}
0189   _LIBCPP_HIDE_FROM_ABI explicit mersenne_twister_engine(result_type __sd) { seed(__sd); }
0190 #else
0191   _LIBCPP_HIDE_FROM_ABI explicit mersenne_twister_engine(result_type __sd = default_seed) { seed(__sd); }
0192 #endif
0193   template <class _Sseq, __enable_if_t<__is_seed_sequence<_Sseq, mersenne_twister_engine>::value, int> = 0>
0194   _LIBCPP_HIDE_FROM_ABI explicit mersenne_twister_engine(_Sseq& __q) {
0195     seed(__q);
0196   }
0197   _LIBCPP_HIDE_FROM_ABI void seed(result_type __sd = default_seed);
0198   template <class _Sseq, __enable_if_t<__is_seed_sequence<_Sseq, mersenne_twister_engine>::value, int> = 0>
0199   _LIBCPP_HIDE_FROM_ABI void seed(_Sseq& __q) {
0200     __seed(__q, integral_constant<unsigned, 1 + (__w - 1) / 32>());
0201   }
0202 
0203   // generating functions
0204   _LIBCPP_HIDE_FROM_ABI result_type operator()();
0205   _LIBCPP_HIDE_FROM_ABI void discard(unsigned long long __z) {
0206     for (; __z; --__z)
0207       operator()();
0208   }
0209 
0210   template <class _UInt,
0211             size_t _Wp,
0212             size_t _Np,
0213             size_t _Mp,
0214             size_t _Rp,
0215             _UInt _Ap,
0216             size_t _Up,
0217             _UInt _Dp,
0218             size_t _Sp,
0219             _UInt _Bp,
0220             size_t _Tp,
0221             _UInt _Cp,
0222             size_t _Lp,
0223             _UInt _Fp>
0224   friend bool operator==(
0225       const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __x,
0226       const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __y);
0227 
0228   template <class _UInt,
0229             size_t _Wp,
0230             size_t _Np,
0231             size_t _Mp,
0232             size_t _Rp,
0233             _UInt _Ap,
0234             size_t _Up,
0235             _UInt _Dp,
0236             size_t _Sp,
0237             _UInt _Bp,
0238             size_t _Tp,
0239             _UInt _Cp,
0240             size_t _Lp,
0241             _UInt _Fp>
0242   friend bool operator!=(
0243       const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __x,
0244       const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __y);
0245 
0246   template <class _CharT,
0247             class _Traits,
0248             class _UInt,
0249             size_t _Wp,
0250             size_t _Np,
0251             size_t _Mp,
0252             size_t _Rp,
0253             _UInt _Ap,
0254             size_t _Up,
0255             _UInt _Dp,
0256             size_t _Sp,
0257             _UInt _Bp,
0258             size_t _Tp,
0259             _UInt _Cp,
0260             size_t _Lp,
0261             _UInt _Fp>
0262   friend basic_ostream<_CharT, _Traits>& operator<<(
0263       basic_ostream<_CharT, _Traits>& __os,
0264       const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __x);
0265 
0266   template <class _CharT,
0267             class _Traits,
0268             class _UInt,
0269             size_t _Wp,
0270             size_t _Np,
0271             size_t _Mp,
0272             size_t _Rp,
0273             _UInt _Ap,
0274             size_t _Up,
0275             _UInt _Dp,
0276             size_t _Sp,
0277             _UInt _Bp,
0278             size_t _Tp,
0279             _UInt _Cp,
0280             size_t _Lp,
0281             _UInt _Fp>
0282   friend basic_istream<_CharT, _Traits>&
0283   operator>>(basic_istream<_CharT, _Traits>& __is,
0284              mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __x);
0285 
0286 private:
0287   template <class _Sseq>
0288   _LIBCPP_HIDE_FROM_ABI void __seed(_Sseq& __q, integral_constant<unsigned, 1>);
0289   template <class _Sseq>
0290   _LIBCPP_HIDE_FROM_ABI void __seed(_Sseq& __q, integral_constant<unsigned, 2>);
0291 
0292   template <size_t __count,
0293             __enable_if_t<__count< __w, int> = 0> _LIBCPP_HIDE_FROM_ABI static result_type __lshift(result_type __x) {
0294     return (__x << __count) & _Max;
0295   }
0296 
0297   template <size_t __count, __enable_if_t<(__count >= __w), int> = 0>
0298   _LIBCPP_HIDE_FROM_ABI static result_type __lshift(result_type) {
0299     return result_type(0);
0300   }
0301 
0302   template <size_t __count,
0303             __enable_if_t<__count< _Dt, int> = 0> _LIBCPP_HIDE_FROM_ABI static result_type __rshift(result_type __x) {
0304     return __x >> __count;
0305   }
0306 
0307   template <size_t __count, __enable_if_t<(__count >= _Dt), int> = 0>
0308   _LIBCPP_HIDE_FROM_ABI static result_type __rshift(result_type) {
0309     return result_type(0);
0310   }
0311 };
0312 
0313 template <class _UIntType,
0314           size_t __w,
0315           size_t __n,
0316           size_t __m,
0317           size_t __r,
0318           _UIntType __a,
0319           size_t __u,
0320           _UIntType __d,
0321           size_t __s,
0322           _UIntType __b,
0323           size_t __t,
0324           _UIntType __c,
0325           size_t __l,
0326           _UIntType __f>
0327 void mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::seed(
0328     result_type __sd) _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK { // __w >= 2
0329   __x_[0] = __sd & _Max;
0330   for (size_t __i = 1; __i < __n; ++__i)
0331     __x_[__i] = (__f * (__x_[__i - 1] ^ __rshift<__w - 2>(__x_[__i - 1])) + __i) & _Max;
0332   __i_ = 0;
0333 }
0334 
0335 template <class _UIntType,
0336           size_t __w,
0337           size_t __n,
0338           size_t __m,
0339           size_t __r,
0340           _UIntType __a,
0341           size_t __u,
0342           _UIntType __d,
0343           size_t __s,
0344           _UIntType __b,
0345           size_t __t,
0346           _UIntType __c,
0347           size_t __l,
0348           _UIntType __f>
0349 template <class _Sseq>
0350 void mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::__seed(
0351     _Sseq& __q, integral_constant<unsigned, 1>) {
0352   const unsigned __k = 1;
0353   uint32_t __ar[__n * __k];
0354   __q.generate(__ar, __ar + __n * __k);
0355   for (size_t __i = 0; __i < __n; ++__i)
0356     __x_[__i] = static_cast<result_type>(__ar[__i] & _Max);
0357   const result_type __mask = __r == _Dt ? result_type(~0) : (result_type(1) << __r) - result_type(1);
0358   __i_                     = 0;
0359   if ((__x_[0] & ~__mask) == 0) {
0360     for (size_t __i = 1; __i < __n; ++__i)
0361       if (__x_[__i] != 0)
0362         return;
0363     __x_[0] = result_type(1) << (__w - 1);
0364   }
0365 }
0366 
0367 template <class _UIntType,
0368           size_t __w,
0369           size_t __n,
0370           size_t __m,
0371           size_t __r,
0372           _UIntType __a,
0373           size_t __u,
0374           _UIntType __d,
0375           size_t __s,
0376           _UIntType __b,
0377           size_t __t,
0378           _UIntType __c,
0379           size_t __l,
0380           _UIntType __f>
0381 template <class _Sseq>
0382 void mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::__seed(
0383     _Sseq& __q, integral_constant<unsigned, 2>) {
0384   const unsigned __k = 2;
0385   uint32_t __ar[__n * __k];
0386   __q.generate(__ar, __ar + __n * __k);
0387   for (size_t __i = 0; __i < __n; ++__i)
0388     __x_[__i] = static_cast<result_type>((__ar[2 * __i] + ((uint64_t)__ar[2 * __i + 1] << 32)) & _Max);
0389   const result_type __mask = __r == _Dt ? result_type(~0) : (result_type(1) << __r) - result_type(1);
0390   __i_                     = 0;
0391   if ((__x_[0] & ~__mask) == 0) {
0392     for (size_t __i = 1; __i < __n; ++__i)
0393       if (__x_[__i] != 0)
0394         return;
0395     __x_[0] = result_type(1) << (__w - 1);
0396   }
0397 }
0398 
0399 template <class _UIntType,
0400           size_t __w,
0401           size_t __n,
0402           size_t __m,
0403           size_t __r,
0404           _UIntType __a,
0405           size_t __u,
0406           _UIntType __d,
0407           size_t __s,
0408           _UIntType __b,
0409           size_t __t,
0410           _UIntType __c,
0411           size_t __l,
0412           _UIntType __f>
0413 _UIntType
0414 mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::operator()() {
0415   const size_t __j         = (__i_ + 1) % __n;
0416   const result_type __mask = __r == _Dt ? result_type(~0) : (result_type(1) << __r) - result_type(1);
0417   const result_type __yp   = (__x_[__i_] & ~__mask) | (__x_[__j] & __mask);
0418   const size_t __k         = (__i_ + __m) % __n;
0419   __x_[__i_]               = __x_[__k] ^ __rshift<1>(__yp) ^ (__a * (__yp & 1));
0420   result_type __z          = __x_[__i_] ^ (__rshift<__u>(__x_[__i_]) & __d);
0421   __i_                     = __j;
0422   __z ^= __lshift<__s>(__z) & __b;
0423   __z ^= __lshift<__t>(__z) & __c;
0424   return __z ^ __rshift<__l>(__z);
0425 }
0426 
0427 template <class _UInt,
0428           size_t _Wp,
0429           size_t _Np,
0430           size_t _Mp,
0431           size_t _Rp,
0432           _UInt _Ap,
0433           size_t _Up,
0434           _UInt _Dp,
0435           size_t _Sp,
0436           _UInt _Bp,
0437           size_t _Tp,
0438           _UInt _Cp,
0439           size_t _Lp,
0440           _UInt _Fp>
0441 _LIBCPP_HIDE_FROM_ABI bool
0442 operator==(const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __x,
0443            const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __y) {
0444   if (__x.__i_ == __y.__i_)
0445     return std::equal(__x.__x_, __x.__x_ + _Np, __y.__x_);
0446   if (__x.__i_ == 0 || __y.__i_ == 0) {
0447     size_t __j = std::min(_Np - __x.__i_, _Np - __y.__i_);
0448     if (!std::equal(__x.__x_ + __x.__i_, __x.__x_ + __x.__i_ + __j, __y.__x_ + __y.__i_))
0449       return false;
0450     if (__x.__i_ == 0)
0451       return std::equal(__x.__x_ + __j, __x.__x_ + _Np, __y.__x_);
0452     return std::equal(__x.__x_, __x.__x_ + (_Np - __j), __y.__x_ + __j);
0453   }
0454   if (__x.__i_ < __y.__i_) {
0455     size_t __j = _Np - __y.__i_;
0456     if (!std::equal(__x.__x_ + __x.__i_, __x.__x_ + (__x.__i_ + __j), __y.__x_ + __y.__i_))
0457       return false;
0458     if (!std::equal(__x.__x_ + (__x.__i_ + __j), __x.__x_ + _Np, __y.__x_))
0459       return false;
0460     return std::equal(__x.__x_, __x.__x_ + __x.__i_, __y.__x_ + (_Np - (__x.__i_ + __j)));
0461   }
0462   size_t __j = _Np - __x.__i_;
0463   if (!std::equal(__y.__x_ + __y.__i_, __y.__x_ + (__y.__i_ + __j), __x.__x_ + __x.__i_))
0464     return false;
0465   if (!std::equal(__y.__x_ + (__y.__i_ + __j), __y.__x_ + _Np, __x.__x_))
0466     return false;
0467   return std::equal(__y.__x_, __y.__x_ + __y.__i_, __x.__x_ + (_Np - (__y.__i_ + __j)));
0468 }
0469 
0470 template <class _UInt,
0471           size_t _Wp,
0472           size_t _Np,
0473           size_t _Mp,
0474           size_t _Rp,
0475           _UInt _Ap,
0476           size_t _Up,
0477           _UInt _Dp,
0478           size_t _Sp,
0479           _UInt _Bp,
0480           size_t _Tp,
0481           _UInt _Cp,
0482           size_t _Lp,
0483           _UInt _Fp>
0484 inline _LIBCPP_HIDE_FROM_ABI bool
0485 operator!=(const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __x,
0486            const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __y) {
0487   return !(__x == __y);
0488 }
0489 
0490 template <class _CharT,
0491           class _Traits,
0492           class _UInt,
0493           size_t _Wp,
0494           size_t _Np,
0495           size_t _Mp,
0496           size_t _Rp,
0497           _UInt _Ap,
0498           size_t _Up,
0499           _UInt _Dp,
0500           size_t _Sp,
0501           _UInt _Bp,
0502           size_t _Tp,
0503           _UInt _Cp,
0504           size_t _Lp,
0505           _UInt _Fp>
0506 _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
0507 operator<<(basic_ostream<_CharT, _Traits>& __os,
0508            const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __x) {
0509   __save_flags<_CharT, _Traits> __lx(__os);
0510   typedef basic_ostream<_CharT, _Traits> _Ostream;
0511   __os.flags(_Ostream::dec | _Ostream::left);
0512   _CharT __sp = __os.widen(' ');
0513   __os.fill(__sp);
0514   __os << __x.__x_[__x.__i_];
0515   for (size_t __j = __x.__i_ + 1; __j < _Np; ++__j)
0516     __os << __sp << __x.__x_[__j];
0517   for (size_t __j = 0; __j < __x.__i_; ++__j)
0518     __os << __sp << __x.__x_[__j];
0519   return __os;
0520 }
0521 
0522 template <class _CharT,
0523           class _Traits,
0524           class _UInt,
0525           size_t _Wp,
0526           size_t _Np,
0527           size_t _Mp,
0528           size_t _Rp,
0529           _UInt _Ap,
0530           size_t _Up,
0531           _UInt _Dp,
0532           size_t _Sp,
0533           _UInt _Bp,
0534           size_t _Tp,
0535           _UInt _Cp,
0536           size_t _Lp,
0537           _UInt _Fp>
0538 _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
0539 operator>>(basic_istream<_CharT, _Traits>& __is,
0540            mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __x) {
0541   __save_flags<_CharT, _Traits> __lx(__is);
0542   typedef basic_istream<_CharT, _Traits> _Istream;
0543   __is.flags(_Istream::dec | _Istream::skipws);
0544   _UInt __t[_Np];
0545   for (size_t __i = 0; __i < _Np; ++__i)
0546     __is >> __t[__i];
0547   if (!__is.fail()) {
0548     for (size_t __i = 0; __i < _Np; ++__i)
0549       __x.__x_[__i] = __t[__i];
0550     __x.__i_ = 0;
0551   }
0552   return __is;
0553 }
0554 
0555 typedef mersenne_twister_engine<
0556     uint_fast32_t,
0557     32,
0558     624,
0559     397,
0560     31,
0561     0x9908b0df,
0562     11,
0563     0xffffffff,
0564     7,
0565     0x9d2c5680,
0566     15,
0567     0xefc60000,
0568     18,
0569     1812433253>
0570     mt19937;
0571 typedef mersenne_twister_engine<
0572     uint_fast64_t,
0573     64,
0574     312,
0575     156,
0576     31,
0577     0xb5026f5aa96619e9ULL,
0578     29,
0579     0x5555555555555555ULL,
0580     17,
0581     0x71d67fffeda60000ULL,
0582     37,
0583     0xfff7eee000000000ULL,
0584     43,
0585     6364136223846793005ULL>
0586     mt19937_64;
0587 
0588 _LIBCPP_END_NAMESPACE_STD
0589 
0590 _LIBCPP_POP_MACROS
0591 
0592 #endif // _LIBCPP___RANDOM_MERSENNE_TWISTER_ENGINE_H