HΦ  3.2.0
dSFMT.c File Reference

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

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "dSFMT-params.h"
#include "wrapperMPI.h"
+ Include dependency graph for dSFMT.c:

Go to the source code of this file.

Functions

static uint32_t ini_func1 (uint32_t x)
 
static uint32_t ini_func2 (uint32_t x)
 
static void gen_rand_array_c1o2 (dsfmt_t *dsfmt, w128_t *array, int size)
 
static void gen_rand_array_c0o1 (dsfmt_t *dsfmt, w128_t *array, int size)
 
static void gen_rand_array_o0c1 (dsfmt_t *dsfmt, w128_t *array, int size)
 
static void gen_rand_array_o0o1 (dsfmt_t *dsfmt, w128_t *array, int size)
 
static int idxof (int i)
 
static void initial_mask (dsfmt_t *dsfmt)
 
static void period_certification (dsfmt_t *dsfmt)
 
static void do_recursion (w128_t *r, w128_t *a, w128_t *b, w128_t *lung)
 
static void convert_c0o1 (w128_t *w)
 
static void convert_o0c1 (w128_t *w)
 
static void convert_o0o1 (w128_t *w)
 
const char * dsfmt_get_idstring (void)
 
int dsfmt_get_min_array_size (void)
 
void dsfmt_gen_rand_all (dsfmt_t *dsfmt)
 
void dsfmt_fill_array_close1_open2 (dsfmt_t *dsfmt, double array[], int size)
 
void dsfmt_fill_array_open_close (dsfmt_t *dsfmt, double array[], int size)
 
void dsfmt_fill_array_close_open (dsfmt_t *dsfmt, double array[], int size)
 
void dsfmt_fill_array_open_open (dsfmt_t *dsfmt, double array[], int size)
 
void dsfmt_chk_init_gen_rand (dsfmt_t *dsfmt, uint32_t seed, int mexp)
 
void dsfmt_chk_init_by_array (dsfmt_t *dsfmt, uint32_t init_key[], int key_length, int mexp)
 

Variables

dsfmt_t dsfmt_global_data
 
static const int dsfmt_mexp = DSFMT_MEXP
 

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,2008 Mutsuo Saito, Makoto Matsumoto and Hiroshima University. All rights reserved.

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

Definition in file dSFMT.c.

Function Documentation

◆ convert_c0o1()

static void convert_c0o1 ( w128_t *  w)
inlinestatic

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
w128bit stracture of double precision floating point numbers (I/O)

Definition at line 207 of file dSFMT.c.

Referenced by do_recursion(), and gen_rand_array_c0o1().

207  {
208  w->d[0] -= 1.0;
209  w->d[1] -= 1.0;
210 }
+ Here is the caller graph for this function:

◆ convert_o0c1()

static void convert_o0c1 ( w128_t *  w)
inlinestatic

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
w128bit stracture of double precision floating point numbers (I/O)

Definition at line 218 of file dSFMT.c.

Referenced by do_recursion(), and gen_rand_array_o0c1().

218  {
219  w->d[0] = 2.0 - w->d[0];
220  w->d[1] = 2.0 - w->d[1];
221 }
+ Here is the caller graph for this function:

◆ convert_o0o1()

static void convert_o0o1 ( w128_t *  w)
inlinestatic

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
w128bit stracture of double precision floating point numbers (I/O)

Definition at line 229 of file dSFMT.c.

Referenced by do_recursion(), and gen_rand_array_o0o1().

229  {
230  w->u[0] |= 1;
231  w->u[1] |= 1;
232  w->d[0] -= 1.0;
233  w->d[1] -= 1.0;
234 }
+ Here is the caller graph for this function:

◆ do_recursion()

static void do_recursion ( w128_t *  r,
w128_t *  a,
w128_t *  b,
w128_t *  lung 
)
inlinestatic

This function represents the recursion formula.

Parameters
routput
aa 128-bit part of the internal state array
ba 128-bit part of the internal state array
lunga 128-bit part of the internal state array This function represents the recursion formula.
routput 128-bit
aa 128-bit part of the internal state array
ba 128-bit part of the internal state array
lunga 128-bit part of the internal state array (I/O)

Definition at line 154 of file dSFMT.c.

References convert_c0o1(), convert_o0c1(), and convert_o0o1().

Referenced by dsfmt_gen_rand_all(), gen_rand_array_c0o1(), gen_rand_array_c1o2(), gen_rand_array_o0c1(), gen_rand_array_o0o1(), and idxof().

155  {
156  uint64_t t0, t1, L0, L1;
157 
158  t0 = a->u[0];
159  t1 = a->u[1];
160  L0 = lung->u[0];
161  L1 = lung->u[1];
162  lung->u[0] = (t0 << DSFMT_SL1) ^ (L1 >> 32) ^ (L1 << 32) ^ b->u[0];
163  lung->u[1] = (t1 << DSFMT_SL1) ^ (L0 >> 32) ^ (L0 << 32) ^ b->u[1];
164  r->u[0] = (lung->u[0] >> DSFMT_SR) ^ (lung->u[0] & DSFMT_MSK1) ^ t0;
165  r->u[1] = (lung->u[1] >> DSFMT_SR) ^ (lung->u[1] & DSFMT_MSK2) ^ t1;
166 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dsfmt_chk_init_by_array()

void dsfmt_chk_init_by_array ( dsfmt_t *  dsfmt,
uint32_t  init_key[],
int  key_length,
int  mexp 
)

This function initializes the internal state array, with an array of 32-bit integers used as the seeds

Parameters
dsfmtdsfmt state vector.
init_keythe array of 32-bit integers, used as a seed.
key_lengththe length of init_key.
mexpcaller's mersenne expornent

Definition at line 657 of file dSFMT.c.

References dsfmt_mexp, exitMPI(), idxof(), ini_func1(), ini_func2(), initial_mask(), and period_certification().

658  {
659  int i, j, count;
660  uint32_t r;
661  uint32_t *psfmt32;
662  int lag;
663  int mid;
664  int size = (DSFMT_N + 1) * 4; /* pulmonary */
665 
666  /* make sure caller program is compiled with the same MEXP */
667  if (mexp != dsfmt_mexp) {
668  fprintf(stderr, "DSFMT_MEXP doesn't match with dSFMT.c\n");
669  exitMPI(1);
670  }
671  if (size >= 623) {
672  lag = 11;
673  } else if (size >= 68) {
674  lag = 7;
675  } else if (size >= 39) {
676  lag = 5;
677  } else {
678  lag = 3;
679  }
680  mid = (size - lag) / 2;
681 
682  psfmt32 = &dsfmt->status[0].u32[0];
683  memset(dsfmt->status, 0x8b, sizeof(dsfmt->status));
684  if (key_length + 1 > size) {
685  count = key_length + 1;
686  } else {
687  count = size;
688  }
689  r = ini_func1(psfmt32[idxof(0)] ^ psfmt32[idxof(mid % size)]
690  ^ psfmt32[idxof((size - 1) % size)]);
691  psfmt32[idxof(mid % size)] += r;
692  r += key_length;
693  psfmt32[idxof((mid + lag) % size)] += r;
694  psfmt32[idxof(0)] = r;
695  count--;
696  for (i = 1, j = 0; (j < count) && (j < key_length); j++) {
697  r = ini_func1(psfmt32[idxof(i)]
698  ^ psfmt32[idxof((i + mid) % size)]
699  ^ psfmt32[idxof((i + size - 1) % size)]);
700  psfmt32[idxof((i + mid) % size)] += r;
701  r += init_key[j] + i;
702  psfmt32[idxof((i + mid + lag) % size)] += r;
703  psfmt32[idxof(i)] = r;
704  i = (i + 1) % size;
705  }
706  for (; j < count; j++) {
707  r = ini_func1(psfmt32[idxof(i)]
708  ^ psfmt32[idxof((i + mid) % size)]
709  ^ psfmt32[idxof((i + size - 1) % size)]);
710  psfmt32[idxof((i + mid) % size)] += r;
711  r += i;
712  psfmt32[idxof((i + mid + lag) % size)] += r;
713  psfmt32[idxof(i)] = r;
714  i = (i + 1) % size;
715  }
716  for (j = 0; j < size; j++) {
717  r = ini_func2(psfmt32[idxof(i)]
718  + psfmt32[idxof((i + mid) % size)]
719  + psfmt32[idxof((i + size - 1) % size)]);
720  psfmt32[idxof((i + mid) % size)] ^= r;
721  r -= i;
722  psfmt32[idxof((i + mid + lag) % size)] ^= r;
723  psfmt32[idxof(i)] = r;
724  i = (i + 1) % size;
725  }
726  initial_mask(dsfmt);
727  period_certification(dsfmt);
728  dsfmt->idx = DSFMT_N64;
729 #if defined(HAVE_SSE2)
730  setup_const();
731 #endif
732 }
static uint32_t ini_func1(uint32_t x)
Definition: dSFMT.c:410
static uint32_t ini_func2(uint32_t x)
Definition: dSFMT.c:420
void exitMPI(int errorcode)
MPI Abortation wrapper.
Definition: wrapperMPI.c:86
static void period_certification(dsfmt_t *dsfmt)
Definition: dSFMT.c:443
static int idxof(int i)
Definition: dSFMT.c:65
static const int dsfmt_mexp
Definition: dSFMT.c:23
static void initial_mask(dsfmt_t *dsfmt)
Definition: dSFMT.c:429
+ Here is the call graph for this function:

◆ dsfmt_chk_init_gen_rand()

void dsfmt_chk_init_gen_rand ( dsfmt_t *  dsfmt,
uint32_t  seed,
int  mexp 
)

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

Parameters
dsfmtdsfmt state vector.
seeda 32-bit integer used as the seed.
mexpcaller's mersenne expornent

Definition at line 626 of file dSFMT.c.

References dsfmt_mexp, exitMPI(), idxof(), initial_mask(), and period_certification().

626  {
627  int i;
628  uint32_t *psfmt;
629 
630  /* make sure caller program is compiled with the same MEXP */
631  if (mexp != dsfmt_mexp) {
632  fprintf(stderr, "DSFMT_MEXP doesn't match with dSFMT.c\n");
633  exitMPI(1);
634  }
635  psfmt = &dsfmt->status[0].u32[0];
636  psfmt[idxof(0)] = seed;
637  for (i = 1; i < (DSFMT_N + 1) * 4; i++) {
638  psfmt[idxof(i)] = 1812433253UL
639  * (psfmt[idxof(i - 1)] ^ (psfmt[idxof(i - 1)] >> 30)) + i;
640  }
641  initial_mask(dsfmt);
642  period_certification(dsfmt);
643  dsfmt->idx = DSFMT_N64;
644 #if defined(HAVE_SSE2)
645  setup_const();
646 #endif
647 }
void exitMPI(int errorcode)
MPI Abortation wrapper.
Definition: wrapperMPI.c:86
static void period_certification(dsfmt_t *dsfmt)
Definition: dSFMT.c:443
static int idxof(int i)
Definition: dSFMT.c:65
static const int dsfmt_mexp
Definition: dSFMT.c:23
static void initial_mask(dsfmt_t *dsfmt)
Definition: dSFMT.c:429
+ Here is the call graph for this function:

◆ dsfmt_fill_array_close1_open2()

void dsfmt_fill_array_close1_open2 ( dsfmt_t *  dsfmt,
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
dsfmtdsfmt state vector.
arrayan 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.
sizethe 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.

Definition at line 556 of file dSFMT.c.

References gen_rand_array_c1o2().

556  {
557  assert(size % 2 == 0);
558  assert(size >= DSFMT_N64);
559  gen_rand_array_c1o2(dsfmt, (w128_t *)array, size / 2);
560 }
static void gen_rand_array_c1o2(dsfmt_t *dsfmt, w128_t *array, int size)
Definition: dSFMT.c:244
+ Here is the call graph for this function:

◆ dsfmt_fill_array_close_open()

void dsfmt_fill_array_close_open ( dsfmt_t *  dsfmt,
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
arrayan array where pseudorandom numbers are filled by this function.
dsfmtdsfmt state vector.
sizethe number of pseudorandom numbers to be generated. see also
See also
fill_array_close1_open2()

Definition at line 592 of file dSFMT.c.

References gen_rand_array_c0o1().

592  {
593  assert(size % 2 == 0);
594  assert(size >= DSFMT_N64);
595  gen_rand_array_c0o1(dsfmt, (w128_t *)array, size / 2);
596 }
static void gen_rand_array_c0o1(dsfmt_t *dsfmt, w128_t *array, int size)
Definition: dSFMT.c:282
+ Here is the call graph for this function:

◆ dsfmt_fill_array_open_close()

void dsfmt_fill_array_open_close ( dsfmt_t *  dsfmt,
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
dsfmtdsfmt state vector.
arrayan array where pseudorandom numbers are filled by this function.
sizethe number of pseudorandom numbers to be generated. see also
See also
fill_array_close1_open2()

Definition at line 574 of file dSFMT.c.

References gen_rand_array_o0c1().

574  {
575  assert(size % 2 == 0);
576  assert(size >= DSFMT_N64);
577  gen_rand_array_o0c1(dsfmt, (w128_t *)array, size / 2);
578 }
static void gen_rand_array_o0c1(dsfmt_t *dsfmt, w128_t *array, int size)
Definition: dSFMT.c:368
+ Here is the call graph for this function:

◆ dsfmt_fill_array_open_open()

void dsfmt_fill_array_open_open ( dsfmt_t *  dsfmt,
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
dsfmtdsfmt state vector.
arrayan array where pseudorandom numbers are filled by this function.
sizethe number of pseudorandom numbers to be generated. see also
See also
fill_array_close1_open2()

Definition at line 610 of file dSFMT.c.

References gen_rand_array_o0o1().

610  {
611  assert(size % 2 == 0);
612  assert(size >= DSFMT_N64);
613  gen_rand_array_o0o1(dsfmt, (w128_t *)array, size / 2);
614 }
static void gen_rand_array_o0o1(dsfmt_t *dsfmt, w128_t *array, int size)
Definition: dSFMT.c:325
+ Here is the call graph for this function:

◆ dsfmt_gen_rand_all()

void dsfmt_gen_rand_all ( dsfmt_t *  dsfmt)

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

Parameters
dsfmtdsfmt state vector.

Definition at line 510 of file dSFMT.c.

References do_recursion().

510  {
511  int i;
512  w128_t lung;
513 
514  lung = dsfmt->status[DSFMT_N];
515  do_recursion(&dsfmt->status[0], &dsfmt->status[0],
516  &dsfmt->status[DSFMT_POS1], &lung);
517  for (i = 1; i < DSFMT_N - DSFMT_POS1; i++) {
518  do_recursion(&dsfmt->status[i], &dsfmt->status[i],
519  &dsfmt->status[i + DSFMT_POS1], &lung);
520  }
521  for (; i < DSFMT_N; i++) {
522  do_recursion(&dsfmt->status[i], &dsfmt->status[i],
523  &dsfmt->status[i + DSFMT_POS1 - DSFMT_N], &lung);
524  }
525  dsfmt->status[DSFMT_N] = lung;
526 }
static void do_recursion(w128_t *r, w128_t *a, w128_t *b, w128_t *lung)
Definition: dSFMT.c:154
+ Here is the call graph for this function:

◆ dsfmt_get_idstring()

const char* dsfmt_get_idstring ( void  )

This function returns the identification string. The string shows the Mersenne exponent, and all parameters of this generator.

Returns
id string.

Definition at line 492 of file dSFMT.c.

492  {
493  return DSFMT_IDSTR;
494 }

◆ dsfmt_get_min_array_size()

int dsfmt_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.

Definition at line 501 of file dSFMT.c.

501  {
502  return DSFMT_N64;
503 }

◆ gen_rand_array_c0o1()

static void gen_rand_array_c0o1 ( dsfmt_t *  dsfmt,
w128_t *  array,
int  size 
)
inlinestatic

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

Parameters
dsfmtdsfmt state vector.
arrayan 128-bit array to be filled by pseudorandom numbers.
sizenumber of 128-bit pseudorandom numbers to be generated.

Definition at line 282 of file dSFMT.c.

References convert_c0o1(), and do_recursion().

Referenced by dsfmt_fill_array_close_open().

283  {
284  int i, j;
285  w128_t lung;
286 
287  lung = dsfmt->status[DSFMT_N];
288  do_recursion(&array[0], &dsfmt->status[0], &dsfmt->status[DSFMT_POS1],
289  &lung);
290  for (i = 1; i < DSFMT_N - DSFMT_POS1; i++) {
291  do_recursion(&array[i], &dsfmt->status[i],
292  &dsfmt->status[i + DSFMT_POS1], &lung);
293  }
294  for (; i < DSFMT_N; i++) {
295  do_recursion(&array[i], &dsfmt->status[i],
296  &array[i + DSFMT_POS1 - DSFMT_N], &lung);
297  }
298  for (; i < size - DSFMT_N; i++) {
299  do_recursion(&array[i], &array[i - DSFMT_N],
300  &array[i + DSFMT_POS1 - DSFMT_N], &lung);
301  convert_c0o1(&array[i - DSFMT_N]);
302  }
303  for (j = 0; j < 2 * DSFMT_N - size; j++) {
304  dsfmt->status[j] = array[j + size - DSFMT_N];
305  }
306  for (; i < size; i++, j++) {
307  do_recursion(&array[i], &array[i - DSFMT_N],
308  &array[i + DSFMT_POS1 - DSFMT_N], &lung);
309  dsfmt->status[j] = array[i];
310  convert_c0o1(&array[i - DSFMT_N]);
311  }
312  for (i = size - DSFMT_N; i < size; i++) {
313  convert_c0o1(&array[i]);
314  }
315  dsfmt->status[DSFMT_N] = lung;
316 }
static void do_recursion(w128_t *r, w128_t *a, w128_t *b, w128_t *lung)
Definition: dSFMT.c:154
static void convert_c0o1(w128_t *w)
Definition: dSFMT.c:207
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gen_rand_array_c1o2()

static void gen_rand_array_c1o2 ( dsfmt_t *  dsfmt,
w128_t *  array,
int  size 
)
inlinestatic

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

Parameters
dsfmtdsfmt state vector.
arrayan 128-bit array to be filled by pseudorandom numbers.
sizenumber of 128-bit pseudorandom numbers to be generated.

Definition at line 244 of file dSFMT.c.

References do_recursion().

Referenced by dsfmt_fill_array_close1_open2().

245  {
246  int i, j;
247  w128_t lung;
248 
249  lung = dsfmt->status[DSFMT_N];
250  do_recursion(&array[0], &dsfmt->status[0], &dsfmt->status[DSFMT_POS1],
251  &lung);
252  for (i = 1; i < DSFMT_N - DSFMT_POS1; i++) {
253  do_recursion(&array[i], &dsfmt->status[i],
254  &dsfmt->status[i + DSFMT_POS1], &lung);
255  }
256  for (; i < DSFMT_N; i++) {
257  do_recursion(&array[i], &dsfmt->status[i],
258  &array[i + DSFMT_POS1 - DSFMT_N], &lung);
259  }
260  for (; i < size - DSFMT_N; i++) {
261  do_recursion(&array[i], &array[i - DSFMT_N],
262  &array[i + DSFMT_POS1 - DSFMT_N], &lung);
263  }
264  for (j = 0; j < 2 * DSFMT_N - size; j++) {
265  dsfmt->status[j] = array[j + size - DSFMT_N];
266  }
267  for (; i < size; i++, j++) {
268  do_recursion(&array[i], &array[i - DSFMT_N],
269  &array[i + DSFMT_POS1 - DSFMT_N], &lung);
270  dsfmt->status[j] = array[i];
271  }
272  dsfmt->status[DSFMT_N] = lung;
273 }
static void do_recursion(w128_t *r, w128_t *a, w128_t *b, w128_t *lung)
Definition: dSFMT.c:154
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gen_rand_array_o0c1()

static void gen_rand_array_o0c1 ( dsfmt_t *  dsfmt,
w128_t *  array,
int  size 
)
inlinestatic

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

Parameters
dsfmtdsfmt state vector.
arrayan 128-bit array to be filled by pseudorandom numbers.
sizenumber of 128-bit pseudorandom numbers to be generated.

Definition at line 368 of file dSFMT.c.

References convert_o0c1(), and do_recursion().

Referenced by dsfmt_fill_array_open_close().

369  {
370  int i, j;
371  w128_t lung;
372 
373  lung = dsfmt->status[DSFMT_N];
374  do_recursion(&array[0], &dsfmt->status[0], &dsfmt->status[DSFMT_POS1],
375  &lung);
376  for (i = 1; i < DSFMT_N - DSFMT_POS1; i++) {
377  do_recursion(&array[i], &dsfmt->status[i],
378  &dsfmt->status[i + DSFMT_POS1], &lung);
379  }
380  for (; i < DSFMT_N; i++) {
381  do_recursion(&array[i], &dsfmt->status[i],
382  &array[i + DSFMT_POS1 - DSFMT_N], &lung);
383  }
384  for (; i < size - DSFMT_N; i++) {
385  do_recursion(&array[i], &array[i - DSFMT_N],
386  &array[i + DSFMT_POS1 - DSFMT_N], &lung);
387  convert_o0c1(&array[i - DSFMT_N]);
388  }
389  for (j = 0; j < 2 * DSFMT_N - size; j++) {
390  dsfmt->status[j] = array[j + size - DSFMT_N];
391  }
392  for (; i < size; i++, j++) {
393  do_recursion(&array[i], &array[i - DSFMT_N],
394  &array[i + DSFMT_POS1 - DSFMT_N], &lung);
395  dsfmt->status[j] = array[i];
396  convert_o0c1(&array[i - DSFMT_N]);
397  }
398  for (i = size - DSFMT_N; i < size; i++) {
399  convert_o0c1(&array[i]);
400  }
401  dsfmt->status[DSFMT_N] = lung;
402 }
static void convert_o0c1(w128_t *w)
Definition: dSFMT.c:218
static void do_recursion(w128_t *r, w128_t *a, w128_t *b, w128_t *lung)
Definition: dSFMT.c:154
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gen_rand_array_o0o1()

static void gen_rand_array_o0o1 ( dsfmt_t *  dsfmt,
w128_t *  array,
int  size 
)
inlinestatic

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

Parameters
dsfmtdsfmt state vector.
arrayan 128-bit array to be filled by pseudorandom numbers.
sizenumber of 128-bit pseudorandom numbers to be generated.

Definition at line 325 of file dSFMT.c.

References convert_o0o1(), and do_recursion().

Referenced by dsfmt_fill_array_open_open().

326  {
327  int i, j;
328  w128_t lung;
329 
330  lung = dsfmt->status[DSFMT_N];
331  do_recursion(&array[0], &dsfmt->status[0], &dsfmt->status[DSFMT_POS1],
332  &lung);
333  for (i = 1; i < DSFMT_N - DSFMT_POS1; i++) {
334  do_recursion(&array[i], &dsfmt->status[i],
335  &dsfmt->status[i + DSFMT_POS1], &lung);
336  }
337  for (; i < DSFMT_N; i++) {
338  do_recursion(&array[i], &dsfmt->status[i],
339  &array[i + DSFMT_POS1 - DSFMT_N], &lung);
340  }
341  for (; i < size - DSFMT_N; i++) {
342  do_recursion(&array[i], &array[i - DSFMT_N],
343  &array[i + DSFMT_POS1 - DSFMT_N], &lung);
344  convert_o0o1(&array[i - DSFMT_N]);
345  }
346  for (j = 0; j < 2 * DSFMT_N - size; j++) {
347  dsfmt->status[j] = array[j + size - DSFMT_N];
348  }
349  for (; i < size; i++, j++) {
350  do_recursion(&array[i], &array[i - DSFMT_N],
351  &array[i + DSFMT_POS1 - DSFMT_N], &lung);
352  dsfmt->status[j] = array[i];
353  convert_o0o1(&array[i - DSFMT_N]);
354  }
355  for (i = size - DSFMT_N; i < size; i++) {
356  convert_o0o1(&array[i]);
357  }
358  dsfmt->status[DSFMT_N] = lung;
359 }
static void do_recursion(w128_t *r, w128_t *a, w128_t *b, w128_t *lung)
Definition: dSFMT.c:154
static void convert_o0o1(w128_t *w)
Definition: dSFMT.c:229
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ idxof()

static int idxof ( int  i)
inlinestatic

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

Definition at line 65 of file dSFMT.c.

References do_recursion().

Referenced by dsfmt_chk_init_by_array(), and dsfmt_chk_init_gen_rand().

65  {
66  return i;
67 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ini_func1()

static uint32_t ini_func1 ( uint32_t  x)
inlinestatic

This function represents a function used in the initialization by init_by_array

Parameters
x32-bit integer
Returns
32-bit integer

Definition at line 410 of file dSFMT.c.

Referenced by dsfmt_chk_init_by_array().

410  {
411  return (x ^ (x >> 27)) * (uint32_t)1664525UL;
412 }
+ Here is the caller graph for this function:

◆ ini_func2()

static uint32_t ini_func2 ( uint32_t  x)
inlinestatic

This function represents a function used in the initialization by init_by_array

Parameters
x32-bit integer
Returns
32-bit integer

Definition at line 420 of file dSFMT.c.

Referenced by dsfmt_chk_init_by_array().

420  {
421  return (x ^ (x >> 27)) * (uint32_t)1566083941UL;
422 }
+ Here is the caller graph for this function:

◆ initial_mask()

static void initial_mask ( dsfmt_t *  dsfmt)
static

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

Parameters
dsfmtdsfmt state vector.

Definition at line 429 of file dSFMT.c.

Referenced by dsfmt_chk_init_by_array(), and dsfmt_chk_init_gen_rand().

429  {
430  int i;
431  uint64_t *psfmt;
432 
433  psfmt = &dsfmt->status[0].u[0];
434  for (i = 0; i < DSFMT_N * 2; i++) {
435  psfmt[i] = (psfmt[i] & DSFMT_LOW_MASK) | DSFMT_HIGH_CONST;
436  }
437 }
+ Here is the caller graph for this function:

◆ period_certification()

static void period_certification ( dsfmt_t *  dsfmt)
static

This function certificate the period of 2^{SFMT_MEXP}-1.

Parameters
dsfmtdsfmt state vector.

Definition at line 443 of file dSFMT.c.

Referenced by dsfmt_chk_init_by_array(), and dsfmt_chk_init_gen_rand().

443  {
444  uint64_t pcv[2] = {DSFMT_PCV1, DSFMT_PCV2};
445  uint64_t tmp[2];
446  uint64_t inner;
447  int i;
448 #if (DSFMT_PCV2 & 1) != 1
449  int j;
450  uint64_t work;
451 #endif
452 
453  tmp[0] = (dsfmt->status[DSFMT_N].u[0] ^ DSFMT_FIX1);
454  tmp[1] = (dsfmt->status[DSFMT_N].u[1] ^ DSFMT_FIX2);
455 
456  inner = tmp[0] & pcv[0];
457  inner ^= tmp[1] & pcv[1];
458  for (i = 32; i > 0; i >>= 1) {
459  inner ^= inner >> i;
460  }
461  inner &= 1;
462  /* check OK */
463  if (inner == 1) {
464  return;
465  }
466  /* check NG, and modification */
467 #if (DSFMT_PCV2 & 1) == 1
468  dsfmt->status[DSFMT_N].u[1] ^= 1;
469 #else
470  for (i = 1; i >= 0; i--) {
471  work = 1;
472  for (j = 0; j < 64; j++) {
473  if ((work & pcv[i]) != 0) {
474  dsfmt->status[DSFMT_N].u[i] ^= work;
475  return;
476  }
477  work = work << 1;
478  }
479  }
480 #endif
481  return;
482 }
+ Here is the caller graph for this function:

Variable Documentation

◆ dsfmt_global_data

dsfmt_t dsfmt_global_data

dsfmt internal state vector

Definition at line 21 of file dSFMT.c.

◆ dsfmt_mexp

const int dsfmt_mexp = DSFMT_MEXP
static

dsfmt mexp for check

Definition at line 23 of file dSFMT.c.

Referenced by dsfmt_chk_init_by_array(), and dsfmt_chk_init_gen_rand().