mt19937ar.h File Reference

Go to the source code of this file.

Functions

double genrand_real1 (void)
 
double genrand_real2 (void)
 
double genrand_real3 (void)
 
double genrand_res53 (void)
 
void init_by_array (unsigned long init_key[], int key_length)
 
void init_genrand (unsigned long s)
 

Function Documentation

◆ genrand_real1()

double genrand_real1 ( void  )

Definition at line 150 of file mt19937ar.c.

151 {
152  return genrand_int32()*(1.0/4294967295.0);
153  /* divided by 2^32-1 */
154 }

References genrand_int32().

Referenced by generateMeasurementOutcome().

◆ genrand_real2()

double genrand_real2 ( void  )

Definition at line 157 of file mt19937ar.c.

158 {
159  return genrand_int32()*(1.0/4294967296.0);
160  /* divided by 2^32 */
161 }

References genrand_int32().

◆ genrand_real3()

double genrand_real3 ( void  )

Definition at line 164 of file mt19937ar.c.

165 {
166  return (((double)genrand_int32()) + 0.5)*(1.0/4294967296.0);
167  /* divided by 2^32 */
168 }

References genrand_int32().

◆ genrand_res53()

double genrand_res53 ( void  )

Definition at line 171 of file mt19937ar.c.

172 {
173  unsigned long a=genrand_int32()>>5, b=genrand_int32()>>6;
174  return(a*67108864.0+b)*(1.0/9007199254740992.0);
175 }

References genrand_int32().

◆ init_by_array()

void init_by_array ( unsigned long  init_key[],
int  key_length 
)

Definition at line 80 of file mt19937ar.c.

81 {
82  int i, j, k;
83  init_genrand(19650218UL);
84  i=1; j=0;
85  k = (N>key_length ? N : key_length);
86  for (; k; k--) {
87  mt[i] = (mt[i] ^ ((mt[i-1] ^ (mt[i-1] >> 30)) * 1664525UL))
88  + init_key[j] + j; /* non linear */
89  mt[i] &= 0xffffffffUL; /* for WORDSIZE > 32 machines */
90  i++; j++;
91  if (i>=N) { mt[0] = mt[N-1]; i=1; }
92  if (j>=key_length) j=0;
93  }
94  for (k=N-1; k; k--) {
95  mt[i] = (mt[i] ^ ((mt[i-1] ^ (mt[i-1] >> 30)) * 1566083941UL))
96  - i; /* non linear */
97  mt[i] &= 0xffffffffUL; /* for WORDSIZE > 32 machines */
98  i++;
99  if (i>=N) { mt[0] = mt[N-1]; i=1; }
100  }
101 
102  mt[0] = 0x80000000UL; /* MSB is 1; assuring non-zero initial array */
103 }

References init_genrand(), mt, and N.

Referenced by seedQuEST().

◆ init_genrand()

void init_genrand ( unsigned long  s)

Definition at line 61 of file mt19937ar.c.

62 {
63  mt[0]= s & 0xffffffffUL;
64  for (mti=1; mti<N; mti++) {
65  mt[mti] =
66  (1812433253UL * (mt[mti-1] ^ (mt[mti-1] >> 30)) + mti);
67  /* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */
68  /* In the previous versions, MSBs of the seed affect */
69  /* only MSBs of the array mt[]. */
70  /* 2002/01/09 modified by Makoto Matsumoto */
71  mt[mti] &= 0xffffffffUL;
72  /* for >32 bit machines */
73  }
74 }

References mt, mti, and N.

Referenced by genrand_int32(), and init_by_array().

unsigned long genrand_int32(void)
Definition: mt19937ar.c:106
void init_genrand(unsigned long s)
Definition: mt19937ar.c:61
static unsigned long mt[N]
Definition: mt19937ar.c:57
static int mti
Definition: mt19937ar.c:58
#define N
Definition: mt19937ar.c:47