From a2fd89f963a7374b29f7831e67b443c3d42c6e3c Mon Sep 17 00:00:00 2001 From: Kevin Chabowski Date: Thu, 1 Aug 2013 22:53:27 +0200 Subject: Added SFMT prng. --- SFMT/html/_s_f_m_t_8h.html | 848 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 848 insertions(+) create mode 100644 SFMT/html/_s_f_m_t_8h.html (limited to 'SFMT/html/_s_f_m_t_8h.html') diff --git a/SFMT/html/_s_f_m_t_8h.html b/SFMT/html/_s_f_m_t_8h.html new file mode 100644 index 0000000..86e5740 --- /dev/null +++ b/SFMT/html/_s_f_m_t_8h.html @@ -0,0 +1,848 @@ + + + + + +SFMT: SFMT.h File Reference + + + + + + + + +
+ + +
+ + + + + + + + + + + +
+
SFMT +  1.4 +
+ +
+
+ + + + +
+
+ +
+
SFMT.h File Reference
+
+
+ +

SIMD oriented Fast Mersenne Twister(SFMT) pseudorandom number generator using C structure. +More...

+
#include <stdio.h>
+#include <assert.h>
+#include <inttypes.h>
+#include "SFMT-params.h"
+
+

Go to the source code of this file.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+Data Structures

union  W128_T
 128-bit data structure More...
struct  SFMT_T
 SFMT internal state. More...

+Defines

#define PRIu64   "llu"
#define PRIx64   "llx"

+Typedefs

typedef union W128_T w128_t
 128-bit data type
typedef struct SFMT_T sfmt_t

+Functions

void sfmt_fill_array32 (sfmt_t *sfmt, uint32_t *array, int size)
 This function generates pseudorandom 32-bit integers in the specified array[] by one call.
void sfmt_fill_array64 (sfmt_t *sfmt, uint64_t *array, int size)
 This function generates pseudorandom 64-bit integers in the specified array[] by one call.
void sfmt_init_gen_rand (sfmt_t *sfmt, uint32_t seed)
 This function initializes the internal state array with a 32-bit integer seed.
void sfmt_init_by_array (sfmt_t *sfmt, 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.
const char * sfmt_get_idstring (sfmt_t *sfmt)
 This function returns the identification string.
int sfmt_get_min_array_size32 (sfmt_t *sfmt)
 This function returns the minimum size of array used for fill_array32() function.
int sfmt_get_min_array_size64 (sfmt_t *sfmt)
 This function returns the minimum size of array used for fill_array64() function.
void sfmt_gen_rand_all (sfmt_t *sfmt)
 This function fills the internal state array with pseudorandom integers.
static uint32_t sfmt_genrand_uint32 (sfmt_t *sfmt)
 This function generates and returns 32-bit pseudorandom number.
static uint64_t sfmt_genrand_uint64 (sfmt_t *sfmt)
 This function generates and returns 64-bit pseudorandom number.
static double sfmt_to_real1 (uint32_t v)
 converts an unsigned 32-bit number to a double on [0,1]-real-interval.
static double sfmt_genrand_real1 (sfmt_t *sfmt)
 generates a random number on [0,1]-real-interval
static double sfmt_to_real2 (uint32_t v)
 converts an unsigned 32-bit integer to a double on [0,1)-real-interval.
static double sfmt_genrand_real2 (sfmt_t *sfmt)
 generates a random number on [0,1)-real-interval
static double sfmt_to_real3 (uint32_t v)
 converts an unsigned 32-bit integer to a double on (0,1)-real-interval.
static double sfmt_genrand_real3 (sfmt_t *sfmt)
 generates a random number on (0,1)-real-interval
static double sfmt_to_res53 (uint64_t v)
 converts an unsigned 32-bit integer to double on [0,1) with 53-bit resolution.
static double sfmt_genrand_res53 (sfmt_t *sfmt)
 generates a random number on [0,1) with 53-bit resolution
static double sfmt_to_res53_mix (uint32_t x, uint32_t y)
 generates a random number on [0,1) with 53-bit resolution from two 32 bit integers
static double sfmt_genrand_res53_mix (sfmt_t *sfmt)
 generates a random number on [0,1) with 53-bit resolution using two 32bit integers.
+

Detailed Description

+

SIMD oriented Fast Mersenne Twister(SFMT) pseudorandom number generator using C structure.

+
Author:
Mutsuo Saito (Hiroshima University)
+
+Makoto Matsumoto (The University of Tokyo)
+

Copyright (C) 2006, 2007 Mutsuo Saito, Makoto Matsumoto and Hiroshima University. Copyright (C) 2012 Mutsuo Saito, Makoto Matsumoto, Hiroshima University and The University of Tokyo. All rights reserved.

+

The 3-clause BSD License is applied to this software, see LICENSE.txt

+
Note:
We assume that your system has inttypes.h. If your system doesn't have inttypes.h, you have to typedef uint32_t and uint64_t, and you have to define PRIu64 and PRIx64 in this file as follows:
 typedef unsigned int uint32_t
+ typedef unsigned long long uint64_t
+ #define PRIu64 "llu"
+ #define PRIx64 "llx"
+
uint32_t must be exactly 32-bit unsigned integer type (no more, no less), and uint64_t must be exactly 64-bit unsigned integer type. PRIu64 and PRIx64 are used for printf function to print 64-bit unsigned int and 64-bit unsigned int in hexadecimal format.
+

Define Documentation

+ +
+
+ + + + +
#define PRIu64   "llu"
+
+
+ +
+
+ +
+
+ + + + +
#define PRIx64   "llx"
+
+
+ +
+
+

Typedef Documentation

+ +
+
+ + + + +
typedef struct SFMT_T sfmt_t
+
+
+ +
+
+ +
+
+ + + + +
typedef union W128_T w128_t
+
+
+ +

128-bit data type

+ +
+
+

Function Documentation

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
void sfmt_fill_array32 (sfmt_tsfmt,
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.

+
Parameters:
+ + + + +
sfmtSFMT internal state
arrayan 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.
sizethe 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.
+
+
+
Note:
memalign or posix_memalign is available to get aligned memory. Mac OSX doesn't have these functions, but malloc of OSX returns the pointer to the aligned memory block.
+ +

References gen_rand_array(), and SFMT_T::idx.

+ +
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
void sfmt_fill_array64 (sfmt_tsfmt,
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.

+
Parameters:
+ + + + +
sfmtSFMT internal state 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.
arrayan 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.
sizethe 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
+
+
+
Note:
memalign or posix_memalign is available to get aligned memory. Mac OSX doesn't have these functions, but malloc of OSX returns the pointer to the aligned memory block.
+ +

References gen_rand_array(), and SFMT_T::idx.

+ +
+
+ +
+
+ + + + + + + + +
void sfmt_gen_rand_all (sfmt_tsfmt)
+
+
+ +

This function fills the internal state array with pseudorandom integers.

+
Parameters:
+ + +
sfmtSFMT internal state
+
+
+ +

References SFMT_T::state.

+ +

Referenced by sfmt_genrand_uint32(), and sfmt_genrand_uint64().

+ +
+
+ +
+
+ + + + + + + + +
static double sfmt_genrand_real1 (sfmt_tsfmt) [inline, static]
+
+
+ +

generates a random number on [0,1]-real-interval

+
Parameters:
+ + +
sfmtSFMT internal state
+
+
+
Returns:
double on [0,1]-real-interval
+ +

References sfmt_genrand_uint32(), and sfmt_to_real1().

+ +
+
+ +
+
+ + + + + + + + +
static double sfmt_genrand_real2 (sfmt_tsfmt) [inline, static]
+
+
+ +

generates a random number on [0,1)-real-interval

+
Parameters:
+ + +
sfmtSFMT internal state
+
+
+
Returns:
double on [0,1)-real-interval
+ +

References sfmt_genrand_uint32(), and sfmt_to_real2().

+ +
+
+ +
+
+ + + + + + + + +
static double sfmt_genrand_real3 (sfmt_tsfmt) [inline, static]
+
+
+ +

generates a random number on (0,1)-real-interval

+
Parameters:
+ + +
sfmtSFMT internal state
+
+
+
Returns:
double on (0,1)-real-interval
+ +

References sfmt_genrand_uint32(), and sfmt_to_real3().

+ +
+
+ +
+
+ + + + + + + + +
static double sfmt_genrand_res53 (sfmt_tsfmt) [inline, static]
+
+
+ +

generates a random number on [0,1) with 53-bit resolution

+
Parameters:
+ + +
sfmtSFMT internal state
+
+
+
Returns:
double on [0,1) with 53-bit resolution
+ +

References sfmt_genrand_uint64(), and sfmt_to_res53().

+ +
+
+ +
+
+ + + + + + + + +
static double sfmt_genrand_res53_mix (sfmt_tsfmt) [inline, static]
+
+
+ +

generates a random number on [0,1) with 53-bit resolution using two 32bit integers.

+
Parameters:
+ + +
sfmtSFMT internal state
+
+
+
Returns:
double on [0,1) with 53-bit resolution
+ +

References sfmt_genrand_uint32(), and sfmt_to_res53_mix().

+ +
+
+ +
+
+ + + + + + + + +
static uint32_t sfmt_genrand_uint32 (sfmt_tsfmt) [inline, static]
+
+
+ +

This function generates and returns 32-bit pseudorandom number.

+

init_gen_rand or init_by_array must be called before this function.

+
Parameters:
+ + +
sfmtSFMT internal state
+
+
+
Returns:
32-bit pseudorandom number
+ +

References SFMT_T::idx, sfmt_gen_rand_all(), SFMT_T::state, and W128_T::u.

+ +

Referenced by sfmt_genrand_real1(), sfmt_genrand_real2(), sfmt_genrand_real3(), and sfmt_genrand_res53_mix().

+ +
+
+ +
+
+ + + + + + + + +
static uint64_t sfmt_genrand_uint64 (sfmt_tsfmt) [inline, static]
+
+
+ +

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.

+
Parameters:
+ + +
sfmtSFMT internal state
+
+
+
Returns:
64-bit pseudorandom number
+ +

References SFMT_T::idx, sfmt_gen_rand_all(), SFMT_T::state, W128_T::u, and W128_T::u64.

+ +

Referenced by sfmt_genrand_res53().

+ +
+
+ +
+
+ + + + + + + + +
const char* sfmt_get_idstring (sfmt_tsfmt)
+
+
+ +

This function returns the identification string.

+

The string shows the word size, the Mersenne exponent, and all parameters of this generator.

+
Parameters:
+ + +
sfmtSFMT internal state
+
+
+ +

References UNUSED_VARIABLE.

+ +
+
+ +
+
+ + + + + + + + +
int sfmt_get_min_array_size32 (sfmt_tsfmt)
+
+
+ +

This function returns the minimum size of array used for fill_array32() function.

+
Parameters:
+ + +
sfmtSFMT internal state
+
+
+
Returns:
minimum size of array used for fill_array32() function.
+ +

References UNUSED_VARIABLE.

+ +
+
+ +
+
+ + + + + + + + +
int sfmt_get_min_array_size64 (sfmt_tsfmt)
+
+
+ +

This function returns the minimum size of array used for fill_array64() function.

+
Parameters:
+ + +
sfmtSFMT internal state
+
+
+
Returns:
minimum size of array used for fill_array64() function.
+ +

References UNUSED_VARIABLE.

+ +
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
void sfmt_init_by_array (sfmt_tsfmt,
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.

+
Parameters:
+ + + + +
sfmtSFMT internal state
init_keythe array of 32-bit integers, used as a seed.
key_lengththe length of init_key.
+
+
+ +

References func1(), func2(), SFMT_T::idx, idxof(), period_certification(), SFMT_T::state, and W128_T::u.

+ +
+
+ +
+
+ + + + + + + + + + + + + + + + + + +
void sfmt_init_gen_rand (sfmt_tsfmt,
uint32_t seed 
)
+
+
+ +

This function initializes the internal state array with a 32-bit integer seed.

+
Parameters:
+ + + +
sfmtSFMT internal state
seeda 32-bit integer used as the seed.
+
+
+ +

References SFMT_T::idx, idxof(), period_certification(), SFMT_T::state, and W128_T::u.

+ +
+
+ +
+
+ + + + + + + + +
static double sfmt_to_real1 (uint32_t v) [inline, static]
+
+
+ +

converts an unsigned 32-bit number to a double on [0,1]-real-interval.

+
Parameters:
+ + +
v32-bit unsigned integer
+
+
+
Returns:
double on [0,1]-real-interval
+ +

Referenced by sfmt_genrand_real1().

+ +
+
+ +
+
+ + + + + + + + +
static double sfmt_to_real2 (uint32_t v) [inline, static]
+
+
+ +

converts an unsigned 32-bit integer to a double on [0,1)-real-interval.

+
Parameters:
+ + +
v32-bit unsigned integer
+
+
+
Returns:
double on [0,1)-real-interval
+ +

Referenced by sfmt_genrand_real2().

+ +
+
+ +
+
+ + + + + + + + +
static double sfmt_to_real3 (uint32_t v) [inline, static]
+
+
+ +

converts an unsigned 32-bit integer to a double on (0,1)-real-interval.

+
Parameters:
+ + +
v32-bit unsigned integer
+
+
+
Returns:
double on (0,1)-real-interval
+ +

Referenced by sfmt_genrand_real3().

+ +
+
+ +
+
+ + + + + + + + +
static double sfmt_to_res53 (uint64_t v) [inline, static]
+
+
+ +

converts an unsigned 32-bit integer to double on [0,1) with 53-bit resolution.

+
Parameters:
+ + +
v32-bit unsigned integer
+
+
+
Returns:
double on [0,1)-real-interval with 53-bit resolution.
+ +

Referenced by sfmt_genrand_res53(), and sfmt_to_res53_mix().

+ +
+
+ +
+
+ + + + + + + + + + + + + + + + + + +
static double sfmt_to_res53_mix (uint32_t x,
uint32_t y 
) [inline, static]
+
+
+ +

generates a random number on [0,1) with 53-bit resolution from two 32 bit integers

+ +

References sfmt_to_res53().

+ +

Referenced by sfmt_genrand_res53_mix().

+ +
+
+
+ + + + + + -- cgit v1.2.3-70-g09d2