dSFMT.c File Reference

double precision SIMD-oriented Fast Mersenne Twister (dSFMT) based on IEEE 754 format. More...

#include <string.h>
#include <assert.h>
#include "dSFMT.h"
#include "dSFMT-params.h"

Data Structures

union  W128_T
 128-bit data structure More...

Typedefs

typedef W128_T w128_t
 128-bit data type

Functions

static void lshift128 (w128_t *out, const w128_t *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 double precision floating point pseudorandom numbers of the IEEE 754 format.
static void gen_rand_array (w128_t array[], int size)
 This function fills the user-specified array with double precision floating point pseudorandom numbers of the IEEE 754 format.
static uint32_t ini_func1 (uint32_t x)
 This function represents a function used in the initialization by init_by_array.
static uint32_t ini_func2 (uint32_t x)
 This function represents a function used in the initialization by init_by_array.
static void convert_co (w128_t array[], int size)
 This function converts the double precision floating point numbers which distribute uniformly in the range [1, 2) to those which distribute uniformly in the range [0, 1).
static void convert_oc (w128_t array[], int size)
 This function converts the double precision floating point numbers which distribute uniformly in the range [1, 2) to those which distribute uniformly in the range (0, 1].
static void convert_oo (w128_t array[], int size)
 This function converts the double precision floating point numbers which distribute uniformly in the range [1, 2) to those which distribute uniformly in the range (0, 1).
static int sfmt_idxof (int i)
 This function simulate a 32-bit array index overlapped to 64-bit array of LITTLE ENDIAN in BIG ENDIAN machine.
static void initial_mask (void)
 This function initializes the internal state array to fit the IEEE 754 format.
static void period_certification ()
 This function certificate the period of 2^{SFMT_MEXP}-1.
static void do_recursion (w128_t *r, w128_t *a, w128_t *b, w128_t *c, w128_t *lung)
 This function represents the recursion formula.
char * get_idstring (void)
 This function returns the identification string.
int get_min_array_size (void)
 This function returns the minimum size of array used for fill_array functions.
double genrand_close1_open2 (void)
 This function generates and returns double precision pseudorandom number which distributes uniformly in the range [1, 2).
void fill_array_close1_open2 (double array[], int size)
 This function generates double precision floating point pseudorandom numbers which distribute in the range [1, 2) to the specified array[] by one call.
void fill_array_open_close (double array[], int size)
 This function generates double precision floating point pseudorandom numbers which distribute in the range (0, 1] to the specified array[] by one call.
void fill_array_close_open (double array[], int size)
 This function generates double precision floating point pseudorandom numbers which distribute in the range [0, 1) to the specified array[] by one call.
void fill_array_open_open (double array[], int size)
 This function generates double precision floating point pseudorandom numbers which distribute in the range (0, 1) to 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 [SFMT_N+1]
 the 128-bit internal state array
static double * psfmt64 = &sfmt[0].d[0]
 the double pointer to the 128-bit internal state array
static int sfmt_idx
 index counter to the internal state array as double
static int is_sfmt_initialized = 0
 a flag: it is 0 if and only if the internal state is not yet initialized.
static uint64_t sfmt_pcv [2] = {SFMT_PCV1, SFMT_PCV2}
 a period certification vector which certificate the period of 2^{SFMT_MEXP}-1.


Detailed Description

double precision SIMD-oriented Fast Mersenne Twister (dSFMT) based on IEEE 754 format.

Author:
Mutsuo Saito (Hiroshima University)

Makoto Matsumoto (Hiroshima University)

Copyright (C) 2007 Mutsuo Saito, Makoto Matsumoto and Hiroshima University. All rights reserved.

The new BSD License is applied to this software, see LICENSE.txt


Typedef Documentation

typedef union W128_T w128_t

128-bit data type


Function Documentation

static void convert_co ( w128_t  array[],
int  size 
) [inline, static]

This function converts the double precision floating point numbers which distribute uniformly in the range [1, 2) to those which distribute uniformly in the range [0, 1).

Parameters:
array array of double precision floating point numbers
size size of the array

static void convert_oc ( w128_t  array[],
int  size 
) [inline, static]

This function converts the double precision floating point numbers which distribute uniformly in the range [1, 2) to those which distribute uniformly in the range (0, 1].

Parameters:
array array of double precision floating point numbers
size size of the array

static void convert_oo ( w128_t  array[],
int  size 
) [inline, static]

This function converts the double precision floating point numbers which distribute uniformly in the range [1, 2) to those which distribute uniformly in the range (0, 1).

Parameters:
array array of double precision floating point numbers
size size of the array

static void do_recursion ( w128_t r,
w128_t a,
w128_t b,
w128_t c,
w128_t lung 
) [inline, static]

This function represents the recursion formula.

Parameters:
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
lung a 128-bit part of the internal state array

void fill_array_close1_open2 ( double  array[],
int  size 
)

This function generates double precision floating point pseudorandom numbers which distribute in the range [1, 2) to the specified array[] by one call.

The number of pseudorandom numbers is specified by the argument size, which must be at least (SFMT_MEXP / 128) * 2 and a multiple of two. The function get_min_array_size() returns this minimum size. The generation by this function is much faster than the following fill_array_xxx functions.

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 genrand_xxx functions, without initialization.

Parameters:
array an array where pseudorandom numbers 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 (SFMT_MEXP / 128) * 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.

void fill_array_close_open ( double  array[],
int  size 
)

This function generates double precision floating point pseudorandom numbers which distribute in the range [0, 1) to the specified array[] by one call.

This function is the same as fill_array_close1_open2() except the distribution range.

Parameters:
array an array where pseudorandom numbers are filled by this function.
size the number of pseudorandom numbers to be generated. see also
See also:
fill_array_close1_open2()

void fill_array_open_close ( double  array[],
int  size 
)

This function generates double precision floating point pseudorandom numbers which distribute in the range (0, 1] to the specified array[] by one call.

This function is the same as fill_array_close1_open2() except the distribution range.

Parameters:
array an array where pseudorandom numbers are filled by this function.
size the number of pseudorandom numbers to be generated. see also
See also:
fill_array_close1_open2()

void fill_array_open_open ( double  array[],
int  size 
)

This function generates double precision floating point pseudorandom numbers which distribute in the range (0, 1) to the specified array[] by one call.

This function is the same as fill_array_close1_open2() except the distribution range.

Parameters:
array an array where pseudorandom numbers are filled by this function.
size the number of pseudorandom numbers to be generated. see also
See also:
fill_array_close1_open2()

static void gen_rand_all ( void   )  [inline, static]

This function fills the internal state array with double precision floating point pseudorandom numbers of the IEEE 754 format.

static void gen_rand_array ( w128_t  array[],
int  size 
) [inline, static]

This function fills the user-specified array with double precision floating point pseudorandom numbers of the IEEE 754 format.

Parameters:
array an 128-bit array to be filled by pseudorandom numbers.
size number of 128-bit pseudorandom numbers to be generated.

double genrand_close1_open2 ( void   )  [inline]

This function generates and returns double precision pseudorandom number which distributes uniformly in the range [1, 2).

This is the primitive and faster than generating numbers in other ranges. init_gen_rand() or init_by_array() must be called before this function.

Returns:
double precision floating point pseudorandom number

char* get_idstring ( void   ) 

This function returns the identification string.

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

Returns:
id string.

int get_min_array_size ( void   ) 

This function returns the minimum size of array used for fill_array functions.

Returns:
minimum size of array used for fill_array functions.

static uint32_t ini_func1 ( uint32_t  x  )  [inline, static]

This function represents a function used in the initialization by init_by_array.

Parameters:
x 32-bit integer
Returns:
32-bit integer

static uint32_t ini_func2 ( uint32_t  x  )  [inline, static]

This function represents a function used in the initialization by init_by_array.

Parameters:
x 32-bit integer
Returns:
32-bit integer

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.

void initial_mask ( void   )  [static]

This function initializes the internal state array to fit the IEEE 754 format.

static void lshift128 ( w128_t out,
const w128_t in,
int  shift 
) [inline, static]

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.

Parameters:
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^{SFMT_MEXP}-1.

static int sfmt_idxof ( int  i  )  [inline, static]

This function simulate a 32-bit array index overlapped to 64-bit array of LITTLE ENDIAN in BIG ENDIAN machine.


Variable Documentation

int is_sfmt_initialized = 0 [static]

a flag: it is 0 if and only if the internal state is not yet initialized.

double* psfmt64 = &sfmt[0].d[0] [static]

the double pointer to the 128-bit internal state array

w128_t sfmt[SFMT_N+1] [static]

the 128-bit internal state array

int sfmt_idx [static]

index counter to the internal state array as double

uint64_t sfmt_pcv[2] = {SFMT_PCV1, SFMT_PCV2} [static]

a period certification vector which certificate the period of 2^{SFMT_MEXP}-1.


Generated on Wed Mar 21 14:21:35 2007 for dSFMT by  doxygen 1.4.7