Matrix Elements VB-800 Instrukcja Użytkownika Strona 167

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 172
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 166
Appendix A8 Random Number Generators 159
static unsigned int s_uiSeed2GM = GM_INIT_2;
#define GM_MUL1 36969
#define GM_MUL2 18000
double DRanGM(void)
{ /* 1/2^32=2.3283064370808e-010 */
static double dMinv = 2.32830643708e-010;
s_uiSeed1GM = GM_MUL1 * (s_uiSeed1GM & 0xFFFF) + (s_uiSeed1GM >> 16);
s_uiSeed2GM = GM_MUL2 * (s_uiSeed2GM & 0xFFFF) + (s_uiSeed2GM >> 16);
return ((s_uiSeed1GM << 16) + (s_uiSeed2GM & 0xFFFF)) * dMinv;
}
A8.3 L’Ecuyer’s generator
Code for this random number generator is published in figure 1 of L’Ecuyer (1999). It
is a linear shift register (or Tausworthe) generator with period of 2
113
. The C code
used in Ox is slightly rewritten from the original as:
#define LFSR_B(s, a1, a2) (((s << a1) ^ s) >> a2)
#define LFSR_S(s, a1, a2, b) (((s & a1) << a2) ^ b)
#define LELFSR_INIT1 ( 1+ 111)
#define LELFSR_INIT2 ( 7+ 1111)
#define LELFSR_INIT3 ( 15+ 11111)
#define LELFSR_INIT4 (127+111111)
static unsigned int s_uiSeed1LE = LELFSR_INIT1;
static unsigned int s_uiSeed2LE = LELFSR_INIT2;
static unsigned int s_uiSeed3LE = LELFSR_INIT3;
static unsigned int s_uiSeed4LE = LELFSR_INIT4;
static double JDCALL DRanLE_lfsr(void)
{ /* 1.0 / 4294967296 */
static double factor = 2.3283064365387e-010;
unsigned int b;
b = LFSR_B(s_uiSeed1LE, 6,13);
s_uiSeed1LE = LFSR_S(s_uiSeed1LE,4294967294,18,b);
b = LFSR_B(s_uiSeed2LE, 2,27);
s_uiSeed2LE = LFSR_S(s_uiSeed2LE,4294967288, 2,b);
b = LFSR_B(s_uiSeed3LE,13,21);
s_uiSeed3LE = LFSR_S(s_uiSeed3LE,4294967280, 7,b);
b = LFSR_B(s_uiSeed4LE, 3,12);
s_uiSeed4LE = LFSR_S(s_uiSeed4LE,4294967168,13,b);
return (s_uiSeed1LE ^ s_uiSeed2LE ^ s_uiSeed3LE ^ s_uiSeed4LE) * factor;
}
The four seeds need to satisfy (> 1,> 7,> 15,> 127) respectively. The actual
seeds choosen here satisfy this restrictions. New seeds will only be excepted when they
satisfy this restriction.
Przeglądanie stron 166

Komentarze do niniejszej Instrukcji

Brak uwag