1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
12 // template <class UIntType, size_t w, size_t n, size_t m, size_t r,
13 // UIntType a, size_t u, UIntType d, size_t s,
14 // UIntType b, size_t t, UIntType c, size_t l, UIntType f>
15 // class mersenne_twister_engine
19 // typedef UIntType result_type;
21 // // engine characteristics
22 // static constexpr size_t word_size = w;
23 // static constexpr size_t state_size = n;
24 // static constexpr size_t shift_size = m;
25 // static constexpr size_t mask_bits = r;
26 // static constexpr result_type xor_mask = a;
27 // static constexpr size_t tempering_u = u;
28 // static constexpr result_type tempering_d = d;
29 // static constexpr size_t tempering_s = s;
30 // static constexpr result_type tempering_b = b;
31 // static constexpr size_t tempering_t = t;
32 // static constexpr result_type tempering_c = c;
33 // static constexpr size_t tempering_l = l;
34 // static constexpr result_type initialization_multiplier = f;
35 // static constexpr result_type min () { return 0; }
36 // static constexpr result_type max() { return 2^w - 1; }
37 // static constexpr result_type default_seed = 5489u;
40 #include <type_traits>
44 void where(const _Tp &) {}
49 typedef std::mt19937 E;
50 static_assert((E::word_size == 32), "");
51 static_assert((E::state_size == 624), "");
52 static_assert((E::shift_size == 397), "");
53 static_assert((E::mask_bits == 31), "");
54 static_assert((E::xor_mask == 0x9908b0df), "");
55 static_assert((E::tempering_u == 11), "");
56 static_assert((E::tempering_d == 0xffffffff), "");
57 static_assert((E::tempering_s == 7), "");
58 static_assert((E::tempering_b == 0x9d2c5680), "");
59 static_assert((E::tempering_t == 15), "");
60 static_assert((E::tempering_c == 0xefc60000), "");
61 static_assert((E::tempering_l == 18), "");
62 static_assert((E::initialization_multiplier == 1812433253), "");
63 #if TEST_STD_VER >= 11
64 static_assert((E::min() == 0), "");
65 static_assert((E::max() == 0xFFFFFFFF), "");
67 assert((E::min() == 0));
68 assert((E::max() == 0xFFFFFFFF));
70 static_assert((E::default_seed == 5489u), "");
76 where(E::tempering_u);
77 where(E::tempering_d);
78 where(E::tempering_s);
79 where(E::tempering_b);
80 where(E::tempering_t);
81 where(E::tempering_c);
82 where(E::tempering_l);
83 where(E::initialization_multiplier);
84 where(E::default_seed);
90 typedef std::mt19937_64 E;
91 static_assert((E::word_size == 64), "");
92 static_assert((E::state_size == 312), "");
93 static_assert((E::shift_size == 156), "");
94 static_assert((E::mask_bits == 31), "");
95 static_assert((E::xor_mask == 0xb5026f5aa96619e9ull), "");
96 static_assert((E::tempering_u == 29), "");
97 static_assert((E::tempering_d == 0x5555555555555555ull), "");
98 static_assert((E::tempering_s == 17), "");
99 static_assert((E::tempering_b == 0x71d67fffeda60000ull), "");
100 static_assert((E::tempering_t == 37), "");
101 static_assert((E::tempering_c == 0xfff7eee000000000ull), "");
102 static_assert((E::tempering_l == 43), "");
103 static_assert((E::initialization_multiplier == 6364136223846793005ull), "");
104 #if TEST_STD_VER >= 11
105 static_assert((E::min() == 0), "");
106 static_assert((E::max() == 0xFFFFFFFFFFFFFFFFull), "");
108 assert((E::min() == 0));
109 assert((E::max() == 0xFFFFFFFFFFFFFFFFull));
111 static_assert((E::default_seed == 5489u), "");
113 where(E::state_size);
114 where(E::shift_size);
117 where(E::tempering_u);
118 where(E::tempering_d);
119 where(E::tempering_s);
120 where(E::tempering_b);
121 where(E::tempering_t);
122 where(E::tempering_c);
123 where(E::tempering_l);
124 where(E::initialization_multiplier);
125 where(E::default_seed);