16 #if !defined(RANDOMLIB_RANDOMALGORITHM_HPP)
17 #define RANDOMLIB_RANDOMALGORITHM_HPP 1
22 #if defined(HAVE_SSE2) && HAVE_SSE2
23 #include <emmintrin.h>
26 #if (defined(HAVE_SSE2) && HAVE_SSE2) && (defined(HAVE_ALTIVEC) && HAVE_ALTIVEC)
27 #error "HAVE_SSE2 and HAVE_ALTIVEC should not both be defined"
32 # pragma warning (push)
33 # pragma warning (disable: 4310)
84 static const unsigned width = engine_t::width;
93 M = width == 32 ? 397 : 156,
97 R = ((P + width - 1)/width) * width - P
99 static const engine_type mask = engine_t::mask;
103 static const engine_type magic =
104 width == 32 ? 0x9908b0dfULL : 0xb5026f5aa96619e9ULL;
108 static const engine_type upper = mask << R & mask;
112 static const engine_type lower = ~upper & mask;
119 static const unsigned version = 0x456e4d54UL + (engine_t::width/32 - 1);
124 N = (P + width - 1)/width
134 static void Transition(
long long count,
internal_type statev[])
throw();
142 static engine_type Generate(engine_type y)
throw();
151 static void NormalizeState(engine_type state[])
throw();
167 static std::string
Name() throw() {
168 return "MT19937<Random_u" + std::string(width == 32 ?
"32" :
"64") +
">";
176 y ^= y << 7 & engine_type(0x9d2c5680UL);
177 y ^= y << 15 & engine_type(0xefc60000UL);
187 y ^= y >> 29 & engine_type(0x5555555555555555ULL);
188 y ^= y << 17 & engine_type(0x71d67fffeda60000ULL);
189 y ^= y << 37 & engine_type(0xfff7eee000000000ULL);
239 #if defined(HAVE_SSE2) && HAVE_SSE2
241 #elif defined(HAVE_ALTIVEC) && HAVE_ALTIVEC
257 static const unsigned width = engine_t::width;
266 N128 = (P + 128 - 1)/128,
280 #if (defined(HAVE_SSE2) && HAVE_SSE2) || (defined(HAVE_ALTIVEC) && HAVE_ALTIVEC)
290 static const engine_type
291 magic0 = width == 32 ? 0x1fffefULL : 0x1ecb7f001fffefULL;
292 static const engine_type
293 magic1 = width == 32 ? 0x1ecb7fULL : 0x1ffff6001affffULL;
294 static const engine_type
295 magic2 = width == 32 ? 0x1affffULL : 0ULL;
296 static const engine_type
297 magic3 = width == 32 ? 0x1ffff6ULL : 0ULL;
302 static const engine_type mask18 = engine_type(0xfffc0000fffc0000ULL);
306 static const engine_type PARITY0 = 1U;
307 static const engine_type PARITY1 = width == 32 ? 0U : 0x13c9e68400000000ULL;
308 static const engine_type PARITY2 = 0U;
309 static const engine_type PARITY3 = width == 32 ? 0x13c9e684UL : 0U;
313 static const unsigned PARITY_LSB = 0;
314 static const engine_type mask = engine_t::mask;
321 static const unsigned version = 0x456e534dUL + (engine_t::width/32 - 1);
336 static void Transition(
long long count, internal_type statev[])
346 static engine_type
Generate(engine_type y)
throw() {
return y; }
355 static void NormalizeState(engine_type state[])
throw();
372 static std::string
Name() throw() {
373 return "SFMT19937<Random_u" +
374 std::string(width == 32 ?
"32" :
"64") +
">";
380 #if defined(_MSC_VER)
381 # pragma warning (pop)
384 #endif // RANDOMLIB_RANDOMALGORITHM_HPP
static std::string Name()
static std::string Name()
engine_t::type internal_type
Class to hold bit-width and unsigned type.
The MT19937 random number engine.
The SFMT random number engine.
static engine_type Generate(engine_type y)
engine_t::type internal_type
Class to hold bit-width and unsigned type.
static engine_type Generate(engine_type y)