#include <string.h>
#include <assert.h>
#include "SFMT.h"
#include "SFMT-params.h"
Data Structures | |
struct | W128_T |
128-bit data structure More... | |
Typedefs | |
typedef W128_T | w128_t |
128-bit data type | |
Functions | |
static int | idxof (int i) |
This function simulate a 64-bit index of LITTLE ENDIAN in BIG ENDIAN machine. | |
static void | rshift128 (w128_t *out, w128_t const *in, int shift) |
This function simulates SIMD 128-bit right shift by the standard C. | |
static void | lshift128 (w128_t *out, w128_t const *in, int shift) |
This function simulates SIMD 128-bit left shift by the standard C. | |
static void | gen_rand_all (void) |
This function fills the internal state array with pseudorandom integers. | |
static void | gen_rand_array (w128_t *array, int size) |
This function fills the user-specified array with pseudorandom integers. | |
static uint32_t | func1 (uint32_t x) |
This function represents a function used in the initialization by init_by_array. | |
static uint32_t | func2 (uint32_t x) |
This function represents a function used in the initialization by init_by_array. | |
static void | period_certification (void) |
This function certificate the period of 2^{MEXP}. | |
static void | do_recursion (w128_t *r, w128_t *a, w128_t *b, w128_t *c, w128_t *d) |
This function represents the recursion formula. | |
const char * | get_idstring (void) |
This function returns the identification string. | |
int | get_min_array_size32 (void) |
This function returns the minimum size of array used for fill_array32() function. | |
int | get_min_array_size64 (void) |
This function returns the minimum size of array used for fill_array64() function. | |
uint32_t | gen_rand32 (void) |
This function generates and returns 32-bit pseudorandom number. | |
uint64_t | gen_rand64 (void) |
This function generates and returns 64-bit pseudorandom number. | |
void | fill_array32 (uint32_t *array, int size) |
This function generates pseudorandom 32-bit integers in the specified array[] by one call. | |
void | fill_array64 (uint64_t *array, int size) |
This function generates pseudorandom 64-bit integers in the specified array[] by one call. | |
void | init_gen_rand (uint32_t seed) |
This function initializes the internal state array with a 32-bit integer seed. | |
void | init_by_array (uint32_t *init_key, int key_length) |
This function initializes the internal state array, with an array of 32-bit integers used as the seeds. | |
Variables | |
static w128_t | sfmt [N] |
the 128-bit internal state array | |
static uint32_t * | psfmt32 = &sfmt[0].u[0] |
the 32bit integer pointer to the 128-bit internal state array | |
static uint64_t * | psfmt64 = (uint64_t *)&sfmt[0].u[0] |
the 64bit integer pointer to the 128-bit internal state array | |
static int | idx |
index counter to the 32-bit internal state array | |
static int | initialized = 0 |
a flag: it is 0 if and only if the internal state is not yet initialized. | |
static uint32_t | parity [4] = {PARITY1, PARITY2, PARITY3, PARITY4} |
a parity check vector which certificate the period of 2^{MEXP} |
Makoto Matsumoto (Hiroshima University)
The new BSD License is applied to this software, see LICENSE.txt
static void do_recursion | ( | w128_t * | r, | |
w128_t * | a, | |||
w128_t * | b, | |||
w128_t * | c, | |||
w128_t * | d | |||
) | [inline, static] |
This function represents the recursion formula.
r | output | |
a | a 128-bit part of the internal state array | |
b | a 128-bit part of the internal state array | |
c | a 128-bit part of the internal state array | |
d | a 128-bit part of the internal state array |
void fill_array32 | ( | uint32_t * | array, | |
int | size | |||
) |
This function generates pseudorandom 32-bit integers in the specified array[] by one call.
The number of pseudorandom integers is specified by the argument size, which must be at least 624 and a multiple of four. The generation by this function is much faster than the following gen_rand function.
For initialization, init_gen_rand or init_by_array must be called before the first call of this function. This function can not be used after calling gen_rand function, without initialization.
array | an array where pseudorandom 32-bit integers are filled by this function. The pointer to the array must be "aligned" (namely, must be a multiple of 16) in the SIMD version, since it refers to the address of a 128-bit integer. In the standard C version, the pointer is arbitrary. | |
size | the number of 32-bit pseudorandom integers to be generated. size must be a multiple of 4, and greater than or equal to (MEXP / 128 + 1) * 4. |
void fill_array64 | ( | uint64_t * | array, | |
int | size | |||
) |
This function generates pseudorandom 64-bit integers in the specified array[] by one call.
The number of pseudorandom integers is specified by the argument size, which must be at least 312 and a multiple of two. The generation by this function is much faster than the following gen_rand function.
For initialization, init_gen_rand or init_by_array must be called before the first call of this function. This function can not be used after calling gen_rand function, without initialization.
array | an array where pseudorandom 64-bit integers are filled by this function. The pointer to the array must be "aligned" (namely, must be a multiple of 16) in the SIMD version, since it refers to the address of a 128-bit integer. In the standard C version, the pointer is arbitrary. | |
size | the number of 64-bit pseudorandom integers to be generated. size must be a multiple of 2, and greater than or equal to (MEXP / 128 + 1) * 2 |
static uint32_t func1 | ( | uint32_t | x | ) | [inline, static] |
This function represents a function used in the initialization by init_by_array.
x | 32-bit integer |
static uint32_t func2 | ( | uint32_t | x | ) | [inline, static] |
This function represents a function used in the initialization by init_by_array.
x | 32-bit integer |
uint32_t gen_rand32 | ( | void | ) |
This function generates and returns 32-bit pseudorandom number.
init_gen_rand or init_by_array must be called before this function.
uint64_t gen_rand64 | ( | void | ) |
This function generates and returns 64-bit pseudorandom number.
init_gen_rand or init_by_array must be called before this function. The function gen_rand64 should not be called after gen_rand32, unless an initialization is again executed.
static void gen_rand_all | ( | void | ) | [inline, static] |
This function fills the internal state array with pseudorandom integers.
static void gen_rand_array | ( | w128_t * | array, | |
int | size | |||
) | [inline, static] |
This function fills the user-specified array with pseudorandom integers.
array | an 128-bit array to be filled by pseudorandom numbers. | |
size | number of 128-bit pseudorandom numbers to be generated. |
const char* get_idstring | ( | void | ) |
This function returns the identification string.
The string shows the word size, the Mersenne exponent, and all parameters of this generator.
int get_min_array_size32 | ( | void | ) |
This function returns the minimum size of array used for fill_array32() function.
int get_min_array_size64 | ( | void | ) |
This function returns the minimum size of array used for fill_array64() function.
static int idxof | ( | int | i | ) | [inline, static] |
This function simulate a 64-bit index of LITTLE ENDIAN in BIG ENDIAN machine.
void init_by_array | ( | uint32_t * | init_key, | |
int | key_length | |||
) |
This function initializes the internal state array, with an array of 32-bit integers used as the seeds.
init_key | the array of 32-bit integers, used as a seed. | |
key_length | the length of init_key. |
void init_gen_rand | ( | uint32_t | seed | ) |
This function initializes the internal state array with a 32-bit integer seed.
seed | a 32-bit integer used as the seed. |
This function simulates SIMD 128-bit left shift by the standard C.
The 128-bit integer given in in is shifted by (shift * 8) bits. This function simulates the LITTLE ENDIAN SIMD.
out | the output of this function | |
in | the 128-bit data to be shifted | |
shift | the shift value |
static void period_certification | ( | void | ) | [static] |
This function certificate the period of 2^{MEXP}.
This function simulates SIMD 128-bit right shift by the standard C.
The 128-bit integer given in in is shifted by (shift * 8) bits. This function simulates the LITTLE ENDIAN SIMD.
out | the output of this function | |
in | the 128-bit data to be shifted | |
shift | the shift value |
int idx [static] |
index counter to the 32-bit internal state array
int initialized = 0 [static] |
a flag: it is 0 if and only if the internal state is not yet initialized.
uint32_t parity[4] = {PARITY1, PARITY2, PARITY3, PARITY4} [static] |
a parity check vector which certificate the period of 2^{MEXP}
the 32bit integer pointer to the 128-bit internal state array
the 64bit integer pointer to the 128-bit internal state array