30 # define UINT32_MAX ((uint32_t)-1u)
33 # define UINT32_C(value) uint_least32_t(value)
38 # pragma clang diagnostic push
39 # pragma clang diagnostic ignored "-Wold-style-cast"
40 # pragma clang diagnostic ignored "-Wunused-function"
43 # pragma GCC diagnostic push
44 # pragma GCC diagnostic ignored "-Wold-style-cast"
46 #if BOOST_COMP_MSVC || defined(BOOST_COMP_MSVC_EMULATED)
48 #pragma warning(disable: 4100)
51 #define TINYMT32_MEXP 127
52 #define TINYMT32_SH0 1
53 #define TINYMT32_SH1 10
54 #define TINYMT32_SH8 8
55 #define TINYMT32_MASK UINT32_C(0x7fffffff)
56 #define TINYMT32_MUL (1.0f / 16777216.0f)
58 #if defined(__cplusplus)
113 int32_t
const a = -((int32_t)(y & 1)) & (int32_t)random->
mat1;
114 int32_t
const b = -((int32_t)(y & 1)) & (int32_t)random->
mat2;
115 random->
status[1] ^= (uint32_t)a;
116 random->
status[2] ^= (uint32_t)b;
128 #if defined(LINEARITY_CHECK)
156 #if defined(LINEARITY_CHECK)
165 conv.u = ((t0 ^ random->
tmat) >> 9) |
UINT32_C(0x3f800000);
167 conv.u = (t0 >> 9) |
UINT32_C(0x3f800000);
186 #if defined(LINEARITY_CHECK)
195 conv.u = ((t0 ^ random->
tmat) >> 9) |
UINT32_C(0x3f800001);
197 conv.u = (t0 >> 9) |
UINT32_C(0x3f800001);
282 #if defined(__cplusplus)
296 return (x ^ (x >> 27)) *
UINT32_C(1664525);
306 return (x ^ (x >> 27)) *
UINT32_C(1566083941);
336 for (
unsigned int i = 1; i <
MIN_LOOP; i++) {
338 * (random->
status[(i - 1) & 3]
339 ^ (random->
status[(i - 1) & 3] >> 30));
342 for (
unsigned int i = 0; i <
PRE_LOOP; i++) {
356 const unsigned int lag = 1;
357 const unsigned int mid = 1;
358 const unsigned int size = 4;
362 uint32_t * st = &random->
status[0];
365 st[1] = random->
mat1;
366 st[2] = random->
mat2;
367 st[3] = random->
tmat;
369 count = (
unsigned int)key_length + 1;
374 ^ st[(size - 1) % size]);
376 r += (
unsigned int)key_length;
377 st[(mid + lag) % size] += r;
380 for (i = 1, j = 0; (j < count) && (j < (
unsigned int)key_length); j++) {
382 ^ st[(i + mid) % size]
383 ^ st[(i + size - 1) % size]);
384 st[(i + mid) % size] += r;
385 r += init_key[j] + i;
386 st[(i + mid + lag) % size] += r;
390 for (; j < count; j++) {
392 ^ st[(i + mid) % size]
393 ^ st[(i + size - 1) % size]);
394 st[(i + mid) % size] += r;
396 st[(i + mid + lag) % size] += r;
400 for (j = 0; j < size; j++) {
402 + st[(i + mid) % size]
403 + st[(i + size - 1) % size]);
404 st[(i + mid) % size] ^= r;
406 st[(i + mid + lag) % size] ^= r;
420 # pragma clang diagnostic pop
423 # pragma GCC diagnostic pop
425 #if BOOST_COMP_MSVC || defined(BOOST_COMP_MSVC_EMULATED)
426 # pragma warning(pop)
void tinymt32_init(tinymt32_t *random, uint32_t seed)
void tinymt32_init_by_array(tinymt32_t *random, uint32_t init_key[], int key_length)
static uint32_t tinymt32_temper(tinymt32_t *random)
static double tinymt32_generate_32double(tinymt32_t *random)
static float tinymt32_generate_float01(tinymt32_t *random)
static uint32_t ini_func2(uint32_t x)
static float tinymt32_temper_conv_open(tinymt32_t *random)
static void tinymt32_next_state(tinymt32_t *random)
static uint32_t tinymt32_generate_uint32(tinymt32_t *random)
static float tinymt32_generate_float12(tinymt32_t *random)
static int tinymt32_get_mexp(tinymt32_t *random)
static float tinymt32_generate_floatOO(tinymt32_t *random)
static float tinymt32_generate_floatOC(tinymt32_t *random)
static float tinymt32_generate_float(tinymt32_t *random)
static float tinymt32_temper_conv(tinymt32_t *random)
static uint32_t ini_func1(uint32_t x)
static void period_certification(tinymt32_t *random)