sfmt19937.h File Reference

SIMD oriented Fast Mersenne Twister(SFMT) pseudorandom number generator. More...

#include <stdio.h>
#include <inttypes.h>

Go to the source code of this file.

Defines

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

Functions

INLINE uint32_t gen_rand32 (void)
 This function generates and returns 32-bit pseudorandom number.
INLINE uint64_t gen_rand64 (void)
 This function generates and returns 64-bit pseudorandom number.
INLINE void fill_array32 (uint32_t array[], int size)
 This function generates pseudorandom 32-bit integers in the specified array[] by one call.
INLINE 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.
static INLINE double genrand_real1 (void)
static INLINE double genrand_real2 (void)
static INLINE double genrand_real3 (void)
static INLINE double genrand_res53 (void)


Detailed Description

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

Author:
Mutsuo Saito (Hiroshima University)

Makoto Matsumoto (Hiroshima University)

Date:
2007-01-10
Copyright (C) 2006 Mutsuo Saito, Makoto Matsumoto and Hiroshima University. All rights reserved.

The new 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 like this:
 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"


Function Documentation

INLINE 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.

Parameters:
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 624.
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 a memory block aligned multiple of 16.

INLINE 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.

Parameters:
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 312.
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 memory block aligned multiple of 16.

INLINE 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.

Returns:
32-bit pseudorandom number

INLINE 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.

Returns:
64-bit pseudorandom number

static INLINE double genrand_real1 ( void   )  [static]

static INLINE double genrand_real2 ( void   )  [static]

static INLINE double genrand_real3 ( void   )  [static]

static INLINE double genrand_res53 ( void   )  [static]

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.

Parameters:
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.

Parameters:
seed a 32-bit integer used as the seed.


Generated on Wed Jan 10 14:49:36 2007 for SFMT19937 by  doxygen 1.4.7