diff options
Diffstat (limited to 'system/include/libcxx/random')
-rw-r--r-- | system/include/libcxx/random | 1013 |
1 files changed, 582 insertions, 431 deletions
diff --git a/system/include/libcxx/random b/system/include/libcxx/random index 0e0860e7..04d942bc 100644 --- a/system/include/libcxx/random +++ b/system/include/libcxx/random @@ -217,7 +217,7 @@ public: void discard(unsigned long long z); // property functions - const Engine& base() const; + const Engine& base() const noexcept; }; template<class Engine, size_t p, size_t r> @@ -269,7 +269,7 @@ public: result_type operator()(); void discard(unsigned long long z); // property functions - const Engine& base() const; + const Engine& base() const noexcept; }; template<class Engine, size_t w, class UIntType> @@ -323,7 +323,7 @@ public: void discard(unsigned long long z); // property functions - const Engine& base() const; + const Engine& base() const noexcept; }; template<class Engine, size_t k> @@ -392,7 +392,7 @@ public: result_type operator()(); // property functions - double entropy() const; + double entropy() const noexcept; // no copy functions random_device(const random_device& ) = delete; @@ -1646,7 +1646,11 @@ class piecewise_linear_distribution #include <ostream> #include <cmath> +#include <__undef_min_max> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header +#endif _LIBCPP_BEGIN_NAMESPACE_STD @@ -1655,7 +1659,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD template <class _Sseq, class _Engine> struct __is_seed_sequence { - static const bool value = + static _LIBCPP_CONSTEXPR const bool value = !is_convertible<_Sseq, typename _Engine::result_type>::value && !is_same<typename remove_cv<_Sseq>::type, _Engine>::value; }; @@ -1663,8 +1667,8 @@ struct __is_seed_sequence // linear_congruential_engine template <unsigned long long __a, unsigned long long __c, - unsigned long long __m, unsigned long long _M, - bool _MightOverflow = (__a != 0 && __m != 0 && __m-1 > (_M-__c)/__a)> + unsigned long long __m, unsigned long long _Mp, + bool _MightOverflow = (__a != 0 && __m != 0 && __m-1 > (_Mp-__c)/__a)> struct __lce_ta; // 64 @@ -1728,16 +1732,16 @@ struct __lce_ta<__a, __c, 0, (unsigned long long)(~0), false> // 32 -template <unsigned long long _A, unsigned long long _C, unsigned long long _M> -struct __lce_ta<_A, _C, _M, unsigned(~0), true> +template <unsigned long long _Ap, unsigned long long _Cp, unsigned long long _Mp> +struct __lce_ta<_Ap, _Cp, _Mp, unsigned(~0), true> { typedef unsigned result_type; _LIBCPP_INLINE_VISIBILITY static result_type next(result_type __x) { - const result_type __a = static_cast<result_type>(_A); - const result_type __c = static_cast<result_type>(_C); - const result_type __m = static_cast<result_type>(_M); + const result_type __a = static_cast<result_type>(_Ap); + const result_type __c = static_cast<result_type>(_Cp); + const result_type __m = static_cast<result_type>(_Mp); // Schrage's algorithm const result_type __q = __m / __a; const result_type __r = __m % __a; @@ -1749,15 +1753,15 @@ struct __lce_ta<_A, _C, _M, unsigned(~0), true> } }; -template <unsigned long long _A, unsigned long long _M> -struct __lce_ta<_A, 0, _M, unsigned(~0), true> +template <unsigned long long _Ap, unsigned long long _Mp> +struct __lce_ta<_Ap, 0, _Mp, unsigned(~0), true> { typedef unsigned result_type; _LIBCPP_INLINE_VISIBILITY static result_type next(result_type __x) { - const result_type __a = static_cast<result_type>(_A); - const result_type __m = static_cast<result_type>(_M); + const result_type __a = static_cast<result_type>(_Ap); + const result_type __m = static_cast<result_type>(_Mp); // Schrage's algorithm const result_type __q = __m / __a; const result_type __r = __m % __a; @@ -1768,29 +1772,29 @@ struct __lce_ta<_A, 0, _M, unsigned(~0), true> } }; -template <unsigned long long _A, unsigned long long _C, unsigned long long _M> -struct __lce_ta<_A, _C, _M, unsigned(~0), false> +template <unsigned long long _Ap, unsigned long long _Cp, unsigned long long _Mp> +struct __lce_ta<_Ap, _Cp, _Mp, unsigned(~0), false> { typedef unsigned result_type; _LIBCPP_INLINE_VISIBILITY static result_type next(result_type __x) { - const result_type __a = static_cast<result_type>(_A); - const result_type __c = static_cast<result_type>(_C); - const result_type __m = static_cast<result_type>(_M); + const result_type __a = static_cast<result_type>(_Ap); + const result_type __c = static_cast<result_type>(_Cp); + const result_type __m = static_cast<result_type>(_Mp); return (__a * __x + __c) % __m; } }; -template <unsigned long long _A, unsigned long long _C> -struct __lce_ta<_A, _C, 0, unsigned(~0), false> +template <unsigned long long _Ap, unsigned long long _Cp> +struct __lce_ta<_Ap, _Cp, 0, unsigned(~0), false> { typedef unsigned result_type; _LIBCPP_INLINE_VISIBILITY static result_type next(result_type __x) { - const result_type __a = static_cast<result_type>(_A); - const result_type __c = static_cast<result_type>(_C); + const result_type __a = static_cast<result_type>(_Ap); + const result_type __c = static_cast<result_type>(_Cp); return __a * __x + __c; } }; @@ -1809,19 +1813,20 @@ struct __lce_ta<__a, __c, __m, (unsigned short)(~0), __b> }; template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m> -class linear_congruential_engine; +class _LIBCPP_VISIBLE linear_congruential_engine; template <class _CharT, class _Traits, - class _U, _U _A, _U _C, _U _N> + class _Up, _Up _Ap, _Up _Cp, _Up _Np> +_LIBCPP_INLINE_VISIBILITY basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, - const linear_congruential_engine<_U, _A, _C, _N>&); + const linear_congruential_engine<_Up, _Ap, _Cp, _Np>&); template <class _CharT, class _Traits, - class _U, _U _A, _U _C, _U _N> + class _Up, _Up _Ap, _Up _Cp, _Up _Np> basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, - linear_congruential_engine<_U, _A, _C, _N>& __x); + linear_congruential_engine<_Up, _Ap, _Cp, _Np>& __x); template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m> class _LIBCPP_VISIBLE linear_congruential_engine @@ -1833,31 +1838,32 @@ public: private: result_type __x_; - static const result_type _M = result_type(~0); + static _LIBCPP_CONSTEXPR const result_type _Mp = result_type(~0); static_assert(__m == 0 || __a < __m, "linear_congruential_engine invalid parameters"); static_assert(__m == 0 || __c < __m, "linear_congruential_engine invalid parameters"); public: - static const result_type _Min = __c == 0u ? 1u: 0u; - static const result_type _Max = __m - 1u; + static _LIBCPP_CONSTEXPR const result_type _Min = __c == 0u ? 1u: 0u; + static _LIBCPP_CONSTEXPR const result_type _Max = __m - 1u; static_assert(_Min < _Max, "linear_congruential_engine invalid parameters"); // engine characteristics - static const/*expr*/ result_type multiplier = __a; - static const/*expr*/ result_type increment = __c; - static const/*expr*/ result_type modulus = __m; + static _LIBCPP_CONSTEXPR const result_type multiplier = __a; + static _LIBCPP_CONSTEXPR const result_type increment = __c; + static _LIBCPP_CONSTEXPR const result_type modulus = __m; _LIBCPP_INLINE_VISIBILITY - static const/*expr*/ result_type min() {return _Min;} + static _LIBCPP_CONSTEXPR result_type min() {return _Min;} _LIBCPP_INLINE_VISIBILITY - static const/*expr*/ result_type max() {return _Max;} - static const/*expr*/ result_type default_seed = 1u; + static _LIBCPP_CONSTEXPR result_type max() {return _Max;} + static _LIBCPP_CONSTEXPR const result_type default_seed = 1u; // constructors and seeding functions _LIBCPP_INLINE_VISIBILITY explicit linear_congruential_engine(result_type __s = default_seed) {seed(__s);} - template<class _Sseq> explicit linear_congruential_engine(_Sseq& __q, + template<class _Sseq> _LIBCPP_INLINE_VISIBILITY + explicit linear_congruential_engine(_Sseq& __q, typename enable_if<__is_seed_sequence<_Sseq, linear_congruential_engine>::value>::type* = 0) {seed(__q);} _LIBCPP_INLINE_VISIBILITY @@ -1879,7 +1885,7 @@ public: // generating functions _LIBCPP_INLINE_VISIBILITY result_type operator()() - {return __x_ = static_cast<result_type>(__lce_ta<__a, __c, __m, _M>::next(__x_));} + {return __x_ = static_cast<result_type>(__lce_ta<__a, __c, __m, _Mp>::next(__x_));} _LIBCPP_INLINE_VISIBILITY void discard(unsigned long long __z) {for (; __z; --__z) operator()();} @@ -1910,21 +1916,37 @@ private: void __seed(_Sseq& __q, integral_constant<unsigned, 2>); template <class _CharT, class _Traits, - class _U, _U _A, _U _C, _U _N> + class _Up, _Up _Ap, _Up _Cp, _Up _Np> friend basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, - const linear_congruential_engine<_U, _A, _C, _N>&); + const linear_congruential_engine<_Up, _Ap, _Cp, _Np>&); template <class _CharT, class _Traits, - class _U, _U _A, _U _C, _U _N> + class _Up, _Up _Ap, _Up _Cp, _Up _Np> friend basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, - linear_congruential_engine<_U, _A, _C, _N>& __x); + linear_congruential_engine<_Up, _Ap, _Cp, _Np>& __x); }; template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m> + _LIBCPP_CONSTEXPR const typename linear_congruential_engine<_UIntType, __a, __c, __m>::result_type + linear_congruential_engine<_UIntType, __a, __c, __m>::multiplier; + +template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m> + _LIBCPP_CONSTEXPR const typename linear_congruential_engine<_UIntType, __a, __c, __m>::result_type + linear_congruential_engine<_UIntType, __a, __c, __m>::increment; + +template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m> + _LIBCPP_CONSTEXPR const typename linear_congruential_engine<_UIntType, __a, __c, __m>::result_type + linear_congruential_engine<_UIntType, __a, __c, __m>::modulus; + +template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m> + _LIBCPP_CONSTEXPR const typename linear_congruential_engine<_UIntType, __a, __c, __m>::result_type + linear_congruential_engine<_UIntType, __a, __c, __m>::default_seed; + +template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m> template<class _Sseq> void linear_congruential_engine<_UIntType, __a, __c, __m>::__seed(_Sseq& __q, @@ -1985,7 +2007,7 @@ basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const linear_congruential_engine<_UIntType, __a, __c, __m>& __x) { - __save_flags<_CharT, _Traits> _(__os); + __save_flags<_CharT, _Traits> __lx(__os); __os.flags(ios_base::dec | ios_base::left); __os.fill(__os.widen(' ')); return __os << __x.__x_; @@ -1997,7 +2019,7 @@ basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, linear_congruential_engine<_UIntType, __a, __c, __m>& __x) { - __save_flags<_CharT, _Traits> _(__is); + __save_flags<_CharT, _Traits> __lx(__is); __is.flags(ios_base::dec | ios_base::skipws); _UIntType __t; __is >> __t; @@ -2016,43 +2038,44 @@ typedef minstd_rand default_random_engine; template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r, _UIntType __a, size_t __u, _UIntType __d, size_t __s, _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f> -class mersenne_twister_engine; +class _LIBCPP_VISIBLE mersenne_twister_engine; -template <class _UI, size_t _W, size_t _N, size_t _M, size_t _R, - _UI _A, size_t _U, _UI _D, size_t _S, - _UI _B, size_t _T, _UI _C, size_t _L, _UI _F> +template <class _UI, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp, + _UI _Ap, size_t _Up, _UI _Dp, size_t _Sp, + _UI _Bp, size_t _Tp, _UI _Cp, size_t _Lp, _UI _Fp> bool -operator==(const mersenne_twister_engine<_UI, _W, _N, _M, _R, _A, _U, _D, _S, - _B, _T, _C, _L, _F>& __x, - const mersenne_twister_engine<_UI, _W, _N, _M, _R, _A, _U, _D, _S, - _B, _T, _C, _L, _F>& __y); - -template <class _UI, size_t _W, size_t _N, size_t _M, size_t _R, - _UI _A, size_t _U, _UI _D, size_t _S, - _UI _B, size_t _T, _UI _C, size_t _L, _UI _F> +operator==(const mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, + _Bp, _Tp, _Cp, _Lp, _Fp>& __x, + const mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, + _Bp, _Tp, _Cp, _Lp, _Fp>& __y); + +template <class _UI, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp, + _UI _Ap, size_t _Up, _UI _Dp, size_t _Sp, + _UI _Bp, size_t _Tp, _UI _Cp, size_t _Lp, _UI _Fp> +_LIBCPP_INLINE_VISIBILITY bool -operator!=(const mersenne_twister_engine<_UI, _W, _N, _M, _R, _A, _U, _D, _S, - _B, _T, _C, _L, _F>& __x, - const mersenne_twister_engine<_UI, _W, _N, _M, _R, _A, _U, _D, _S, - _B, _T, _C, _L, _F>& __y); +operator!=(const mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, + _Bp, _Tp, _Cp, _Lp, _Fp>& __x, + const mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, + _Bp, _Tp, _Cp, _Lp, _Fp>& __y); template <class _CharT, class _Traits, - class _UI, size_t _W, size_t _N, size_t _M, size_t _R, - _UI _A, size_t _U, _UI _D, size_t _S, - _UI _B, size_t _T, _UI _C, size_t _L, _UI _F> + class _UI, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp, + _UI _Ap, size_t _Up, _UI _Dp, size_t _Sp, + _UI _Bp, size_t _Tp, _UI _Cp, size_t _Lp, _UI _Fp> basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, - const mersenne_twister_engine<_UI, _W, _N, _M, _R, _A, _U, _D, _S, - _B, _T, _C, _L, _F>& __x); + const mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, + _Bp, _Tp, _Cp, _Lp, _Fp>& __x); template <class _CharT, class _Traits, - class _UI, size_t _W, size_t _N, size_t _M, size_t _R, - _UI _A, size_t _U, _UI _D, size_t _S, - _UI _B, size_t _T, _UI _C, size_t _L, _UI _F> + class _UI, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp, + _UI _Ap, size_t _Up, _UI _Dp, size_t _Sp, + _UI _Bp, size_t _Tp, _UI _Cp, size_t _Lp, _UI _Fp> basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, - mersenne_twister_engine<_UI, _W, _N, _M, _R, _A, _U, _D, _S, - _B, _T, _C, _L, _F>& __x); + mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, + _Bp, _Tp, _Cp, _Lp, _Fp>& __x); template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r, _UIntType __a, size_t __u, _UIntType __d, size_t __s, @@ -2069,7 +2092,7 @@ private: static_assert( 0 < __m, "mersenne_twister_engine invalid parameters"); static_assert(__m <= __n, "mersenne_twister_engine invalid parameters"); - static const result_type _Dt = numeric_limits<result_type>::digits; + static _LIBCPP_CONSTEXPR const result_type _Dt = numeric_limits<result_type>::digits; static_assert(__w <= _Dt, "mersenne_twister_engine invalid parameters"); static_assert( 2 <= __w, "mersenne_twister_engine invalid parameters"); static_assert(__r <= __w, "mersenne_twister_engine invalid parameters"); @@ -2078,9 +2101,9 @@ private: static_assert(__t <= __w, "mersenne_twister_engine invalid parameters"); static_assert(__l <= __w, "mersenne_twister_engine invalid parameters"); public: - static const result_type _Min = 0; - static const result_type _Max = __w == _Dt ? result_type(~0) : - (result_type(1) << __w) - result_type(1); + static _LIBCPP_CONSTEXPR const result_type _Min = 0; + static _LIBCPP_CONSTEXPR const result_type _Max = __w == _Dt ? result_type(~0) : + (result_type(1) << __w) - result_type(1); static_assert(_Min < _Max, "mersenne_twister_engine invalid parameters"); static_assert(__a <= _Max, "mersenne_twister_engine invalid parameters"); static_assert(__b <= _Max, "mersenne_twister_engine invalid parameters"); @@ -2089,31 +2112,32 @@ public: static_assert(__f <= _Max, "mersenne_twister_engine invalid parameters"); // engine characteristics - static const/*expr*/ size_t word_size = __w; - static const/*expr*/ size_t state_size = __n; - static const/*expr*/ size_t shift_size = __m; - static const/*expr*/ size_t mask_bits = __r; - static const/*expr*/ result_type xor_mask = __a; - static const/*expr*/ size_t tempering_u = __u; - static const/*expr*/ result_type tempering_d = __d; - static const/*expr*/ size_t tempering_s = __s; - static const/*expr*/ result_type tempering_b = __b; - static const/*expr*/ size_t tempering_t = __t; - static const/*expr*/ result_type tempering_c = __c; - static const/*expr*/ size_t tempering_l = __l; - static const/*expr*/ result_type initialization_multiplier = __f; - _LIBCPP_INLINE_VISIBILITY - static const/*expr*/ result_type min() { return _Min; } - _LIBCPP_INLINE_VISIBILITY - static const/*expr*/ result_type max() { return _Max; } - static const/*expr*/ result_type default_seed = 5489u; + static _LIBCPP_CONSTEXPR const size_t word_size = __w; + static _LIBCPP_CONSTEXPR const size_t state_size = __n; + static _LIBCPP_CONSTEXPR const size_t shift_size = __m; + static _LIBCPP_CONSTEXPR const size_t mask_bits = __r; + static _LIBCPP_CONSTEXPR const result_type xor_mask = __a; + static _LIBCPP_CONSTEXPR const size_t tempering_u = __u; + static _LIBCPP_CONSTEXPR const result_type tempering_d = __d; + static _LIBCPP_CONSTEXPR const size_t tempering_s = __s; + static _LIBCPP_CONSTEXPR const result_type tempering_b = __b; + static _LIBCPP_CONSTEXPR const size_t tempering_t = __t; + static _LIBCPP_CONSTEXPR const result_type tempering_c = __c; + static _LIBCPP_CONSTEXPR const size_t tempering_l = __l; + static _LIBCPP_CONSTEXPR const result_type initialization_multiplier = __f; + _LIBCPP_INLINE_VISIBILITY + static _LIBCPP_CONSTEXPR result_type min() { return _Min; } + _LIBCPP_INLINE_VISIBILITY + static _LIBCPP_CONSTEXPR result_type max() { return _Max; } + static _LIBCPP_CONSTEXPR const result_type default_seed = 5489u; // constructors and seeding functions _LIBCPP_INLINE_VISIBILITY explicit mersenne_twister_engine(result_type __sd = default_seed) {seed(__sd);} - template<class _Sseq> explicit mersenne_twister_engine(_Sseq& __q, + template<class _Sseq> _LIBCPP_INLINE_VISIBILITY + explicit mersenne_twister_engine(_Sseq& __q, typename enable_if<__is_seed_sequence<_Sseq, mersenne_twister_engine>::value>::type* = 0) {seed(__q);} void seed(result_type __sd = default_seed); @@ -2132,45 +2156,45 @@ public: _LIBCPP_INLINE_VISIBILITY void discard(unsigned long long __z) {for (; __z; --__z) operator()();} - template <class _UI, size_t _W, size_t _N, size_t _M, size_t _R, - _UI _A, size_t _U, _UI _D, size_t _S, - _UI _B, size_t _T, _UI _C, size_t _L, _UI _F> + template <class _UI, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp, + _UI _Ap, size_t _Up, _UI _Dp, size_t _Sp, + _UI _Bp, size_t _Tp, _UI _Cp, size_t _Lp, _UI _Fp> friend bool - operator==(const mersenne_twister_engine<_UI, _W, _N, _M, _R, _A, _U, _D, _S, - _B, _T, _C, _L, _F>& __x, - const mersenne_twister_engine<_UI, _W, _N, _M, _R, _A, _U, _D, _S, - _B, _T, _C, _L, _F>& __y); - - template <class _UI, size_t _W, size_t _N, size_t _M, size_t _R, - _UI _A, size_t _U, _UI _D, size_t _S, - _UI _B, size_t _T, _UI _C, size_t _L, _UI _F> + operator==(const mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, + _Bp, _Tp, _Cp, _Lp, _Fp>& __x, + const mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, + _Bp, _Tp, _Cp, _Lp, _Fp>& __y); + + template <class _UI, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp, + _UI _Ap, size_t _Up, _UI _Dp, size_t _Sp, + _UI _Bp, size_t _Tp, _UI _Cp, size_t _Lp, _UI _Fp> friend bool - operator!=(const mersenne_twister_engine<_UI, _W, _N, _M, _R, _A, _U, _D, _S, - _B, _T, _C, _L, _F>& __x, - const mersenne_twister_engine<_UI, _W, _N, _M, _R, _A, _U, _D, _S, - _B, _T, _C, _L, _F>& __y); + operator!=(const mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, + _Bp, _Tp, _Cp, _Lp, _Fp>& __x, + const mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, + _Bp, _Tp, _Cp, _Lp, _Fp>& __y); template <class _CharT, class _Traits, - class _UI, size_t _W, size_t _N, size_t _M, size_t _R, - _UI _A, size_t _U, _UI _D, size_t _S, - _UI _B, size_t _T, _UI _C, size_t _L, _UI _F> + class _UI, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp, + _UI _Ap, size_t _Up, _UI _Dp, size_t _Sp, + _UI _Bp, size_t _Tp, _UI _Cp, size_t _Lp, _UI _Fp> friend basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, - const mersenne_twister_engine<_UI, _W, _N, _M, _R, _A, _U, _D, _S, - _B, _T, _C, _L, _F>& __x); + const mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, + _Bp, _Tp, _Cp, _Lp, _Fp>& __x); template <class _CharT, class _Traits, - class _UI, size_t _W, size_t _N, size_t _M, size_t _R, - _UI _A, size_t _U, _UI _D, size_t _S, - _UI _B, size_t _T, _UI _C, size_t _L, _UI _F> + class _UI, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp, + _UI _Ap, size_t _Up, _UI _Dp, size_t _Sp, + _UI _Bp, size_t _Tp, _UI _Cp, size_t _Lp, _UI _Fp> friend basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, - mersenne_twister_engine<_UI, _W, _N, _M, _R, _A, _U, _D, _S, - _B, _T, _C, _L, _F>& __x); + mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, + _Bp, _Tp, _Cp, _Lp, _Fp>& __x); private: template<class _Sseq> @@ -2196,7 +2220,7 @@ private: (__count >= __w), result_type >::type - __lshift(result_type __x) {return result_type(0);} + __lshift(result_type) {return result_type(0);} template <size_t __count> _LIBCPP_INLINE_VISIBILITY @@ -2216,12 +2240,96 @@ private: (__count >= _Dt), result_type >::type - __rshift(result_type __x) {return result_type(0);} + __rshift(result_type) {return result_type(0);} }; template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r, _UIntType __a, size_t __u, _UIntType __d, size_t __s, _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f> + _LIBCPP_CONSTEXPR const size_t + mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::word_size; + +template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r, + _UIntType __a, size_t __u, _UIntType __d, size_t __s, + _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f> + _LIBCPP_CONSTEXPR const size_t + mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::state_size; + +template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r, + _UIntType __a, size_t __u, _UIntType __d, size_t __s, + _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f> + _LIBCPP_CONSTEXPR const size_t + mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::shift_size; + +template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r, + _UIntType __a, size_t __u, _UIntType __d, size_t __s, + _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f> + _LIBCPP_CONSTEXPR const size_t + mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::mask_bits; + +template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r, + _UIntType __a, size_t __u, _UIntType __d, size_t __s, + _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f> + _LIBCPP_CONSTEXPR const typename mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::result_type + mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::xor_mask; + +template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r, + _UIntType __a, size_t __u, _UIntType __d, size_t __s, + _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f> + _LIBCPP_CONSTEXPR const size_t + mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_u; + +template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r, + _UIntType __a, size_t __u, _UIntType __d, size_t __s, + _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f> + _LIBCPP_CONSTEXPR const typename mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::result_type + mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_d; + +template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r, + _UIntType __a, size_t __u, _UIntType __d, size_t __s, + _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f> + _LIBCPP_CONSTEXPR const size_t + mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_s; + +template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r, + _UIntType __a, size_t __u, _UIntType __d, size_t __s, + _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f> + _LIBCPP_CONSTEXPR const typename mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::result_type + mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_b; + +template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r, + _UIntType __a, size_t __u, _UIntType __d, size_t __s, + _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f> + _LIBCPP_CONSTEXPR const size_t + mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_t; + +template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r, + _UIntType __a, size_t __u, _UIntType __d, size_t __s, + _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f> + _LIBCPP_CONSTEXPR const typename mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::result_type + mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_c; + +template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r, + _UIntType __a, size_t __u, _UIntType __d, size_t __s, + _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f> + _LIBCPP_CONSTEXPR const size_t + mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_l; + +template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r, + _UIntType __a, size_t __u, _UIntType __d, size_t __s, + _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f> + _LIBCPP_CONSTEXPR const typename mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::result_type + mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::initialization_multiplier; + +template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r, + _UIntType __a, size_t __u, _UIntType __d, size_t __s, + _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f> + _LIBCPP_CONSTEXPR const typename mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::result_type + mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::default_seed; + +template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r, + _UIntType __a, size_t __u, _UIntType __d, size_t __s, + _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f> void mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::seed(result_type __sd) @@ -2293,9 +2401,9 @@ mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, const size_t __j = (__i_ + 1) % __n; const result_type __mask = __r == _Dt ? result_type(~0) : (result_type(1) << __r) - result_type(1); - const result_type _Y = (__x_[__i_] & ~__mask) | (__x_[__j] & __mask); + const result_type _Yp = (__x_[__i_] & ~__mask) | (__x_[__j] & __mask); const size_t __k = (__i_ + __m) % __n; - __x_[__i_] = __x_[__k] ^ __rshift<1>(_Y) ^ (__a * (_Y & 1)); + __x_[__i_] = __x_[__k] ^ __rshift<1>(_Yp) ^ (__a * (_Yp & 1)); result_type __z = __x_[__i_] ^ (__rshift<__u>(__x_[__i_]) & __d); __i_ = __j; __z ^= __lshift<__s>(__z) & __b; @@ -2303,78 +2411,78 @@ mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, return __z ^ __rshift<__l>(__z); } -template <class _UI, size_t _W, size_t _N, size_t _M, size_t _R, - _UI _A, size_t _U, _UI _D, size_t _S, - _UI _B, size_t _T, _UI _C, size_t _L, _UI _F> +template <class _UI, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp, + _UI _Ap, size_t _Up, _UI _Dp, size_t _Sp, + _UI _Bp, size_t _Tp, _UI _Cp, size_t _Lp, _UI _Fp> bool -operator==(const mersenne_twister_engine<_UI, _W, _N, _M, _R, _A, _U, _D, _S, - _B, _T, _C, _L, _F>& __x, - const mersenne_twister_engine<_UI, _W, _N, _M, _R, _A, _U, _D, _S, - _B, _T, _C, _L, _F>& __y) +operator==(const mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, + _Bp, _Tp, _Cp, _Lp, _Fp>& __x, + const mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, + _Bp, _Tp, _Cp, _Lp, _Fp>& __y) { if (__x.__i_ == __y.__i_) - return _VSTD::equal(__x.__x_, __x.__x_ + _N, __y.__x_); + return _VSTD::equal(__x.__x_, __x.__x_ + _Np, __y.__x_); if (__x.__i_ == 0 || __y.__i_ == 0) { - size_t __j = _VSTD::min(_N - __x.__i_, _N - __y.__i_); + size_t __j = _VSTD::min(_Np - __x.__i_, _Np - __y.__i_); if (!_VSTD::equal(__x.__x_ + __x.__i_, __x.__x_ + __x.__i_ + __j, __y.__x_ + __y.__i_)) return false; if (__x.__i_ == 0) - return _VSTD::equal(__x.__x_ + __j, __x.__x_ + _N, __y.__x_); - return _VSTD::equal(__x.__x_, __x.__x_ + (_N - __j), __y.__x_ + __j); + return _VSTD::equal(__x.__x_ + __j, __x.__x_ + _Np, __y.__x_); + return _VSTD::equal(__x.__x_, __x.__x_ + (_Np - __j), __y.__x_ + __j); } if (__x.__i_ < __y.__i_) { - size_t __j = _N - __y.__i_; + size_t __j = _Np - __y.__i_; if (!_VSTD::equal(__x.__x_ + __x.__i_, __x.__x_ + (__x.__i_ + __j), __y.__x_ + __y.__i_)) return false; - if (!_VSTD::equal(__x.__x_ + (__x.__i_ + __j), __x.__x_ + _N, + if (!_VSTD::equal(__x.__x_ + (__x.__i_ + __j), __x.__x_ + _Np, __y.__x_)) return false; return _VSTD::equal(__x.__x_, __x.__x_ + __x.__i_, - __y.__x_ + (_N - (__x.__i_ + __j))); + __y.__x_ + (_Np - (__x.__i_ + __j))); } - size_t __j = _N - __x.__i_; + size_t __j = _Np - __x.__i_; if (!_VSTD::equal(__y.__x_ + __y.__i_, __y.__x_ + (__y.__i_ + __j), __x.__x_ + __x.__i_)) return false; - if (!_VSTD::equal(__y.__x_ + (__y.__i_ + __j), __y.__x_ + _N, + if (!_VSTD::equal(__y.__x_ + (__y.__i_ + __j), __y.__x_ + _Np, __x.__x_)) return false; return _VSTD::equal(__y.__x_, __y.__x_ + __y.__i_, - __x.__x_ + (_N - (__y.__i_ + __j))); + __x.__x_ + (_Np - (__y.__i_ + __j))); } -template <class _UI, size_t _W, size_t _N, size_t _M, size_t _R, - _UI _A, size_t _U, _UI _D, size_t _S, - _UI _B, size_t _T, _UI _C, size_t _L, _UI _F> +template <class _UI, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp, + _UI _Ap, size_t _Up, _UI _Dp, size_t _Sp, + _UI _Bp, size_t _Tp, _UI _Cp, size_t _Lp, _UI _Fp> inline _LIBCPP_INLINE_VISIBILITY bool -operator!=(const mersenne_twister_engine<_UI, _W, _N, _M, _R, _A, _U, _D, _S, - _B, _T, _C, _L, _F>& __x, - const mersenne_twister_engine<_UI, _W, _N, _M, _R, _A, _U, _D, _S, - _B, _T, _C, _L, _F>& __y) +operator!=(const mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, + _Bp, _Tp, _Cp, _Lp, _Fp>& __x, + const mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, + _Bp, _Tp, _Cp, _Lp, _Fp>& __y) { return !(__x == __y); } template <class _CharT, class _Traits, - class _UI, size_t _W, size_t _N, size_t _M, size_t _R, - _UI _A, size_t _U, _UI _D, size_t _S, - _UI _B, size_t _T, _UI _C, size_t _L, _UI _F> + class _UI, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp, + _UI _Ap, size_t _Up, _UI _Dp, size_t _Sp, + _UI _Bp, size_t _Tp, _UI _Cp, size_t _Lp, _UI _Fp> basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, - const mersenne_twister_engine<_UI, _W, _N, _M, _R, _A, _U, _D, _S, - _B, _T, _C, _L, _F>& __x) + const mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, + _Bp, _Tp, _Cp, _Lp, _Fp>& __x) { - __save_flags<_CharT, _Traits> _(__os); + __save_flags<_CharT, _Traits> __lx(__os); __os.flags(ios_base::dec | ios_base::left); _CharT __sp = __os.widen(' '); __os.fill(__sp); __os << __x.__x_[__x.__i_]; - for (size_t __j = __x.__i_ + 1; __j < _N; ++__j) + for (size_t __j = __x.__i_ + 1; __j < _Np; ++__j) __os << __sp << __x.__x_[__j]; for (size_t __j = 0; __j < __x.__i_; ++__j) __os << __sp << __x.__x_[__j]; @@ -2382,22 +2490,22 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, } template <class _CharT, class _Traits, - class _UI, size_t _W, size_t _N, size_t _M, size_t _R, - _UI _A, size_t _U, _UI _D, size_t _S, - _UI _B, size_t _T, _UI _C, size_t _L, _UI _F> + class _UI, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp, + _UI _Ap, size_t _Up, _UI _Dp, size_t _Sp, + _UI _Bp, size_t _Tp, _UI _Cp, size_t _Lp, _UI _Fp> basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, - mersenne_twister_engine<_UI, _W, _N, _M, _R, _A, _U, _D, _S, - _B, _T, _C, _L, _F>& __x) + mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, + _Bp, _Tp, _Cp, _Lp, _Fp>& __x) { - __save_flags<_CharT, _Traits> _(__is); + __save_flags<_CharT, _Traits> __lx(__is); __is.flags(ios_base::dec | ios_base::skipws); - _UI __t[_N]; - for (size_t __i = 0; __i < _N; ++__i) + _UI __t[_Np]; + for (size_t __i = 0; __i < _Np; ++__i) __is >> __t[__i]; if (!__is.fail()) { - for (size_t __i = 0; __i < _N; ++__i) + for (size_t __i = 0; __i < _Np; ++__i) __x.__x_[__i] = __t[__i]; __x.__i_ = 0; } @@ -2418,31 +2526,32 @@ typedef mersenne_twister_engine<uint_fast64_t, 64, 312, 156, 31, // subtract_with_carry_engine template<class _UIntType, size_t __w, size_t __s, size_t __r> -class subtract_with_carry_engine; +class _LIBCPP_VISIBLE subtract_with_carry_engine; -template<class _UI, size_t _W, size_t _S, size_t _R> +template<class _UI, size_t _Wp, size_t _Sp, size_t _Rp> bool operator==( - const subtract_with_carry_engine<_UI, _W, _S, _R>& __x, - const subtract_with_carry_engine<_UI, _W, _S, _R>& __y); + const subtract_with_carry_engine<_UI, _Wp, _Sp, _Rp>& __x, + const subtract_with_carry_engine<_UI, _Wp, _Sp, _Rp>& __y); -template<class _UI, size_t _W, size_t _S, size_t _R> +template<class _UI, size_t _Wp, size_t _Sp, size_t _Rp> +_LIBCPP_INLINE_VISIBILITY bool operator!=( - const subtract_with_carry_engine<_UI, _W, _S, _R>& __x, - const subtract_with_carry_engine<_UI, _W, _S, _R>& __y); + const subtract_with_carry_engin |