RNG Implementation module. More...
#include <ross.h>
Go to the source code of this file.
Macros | |
#define | H 32768 |
#define | S0_MAX 2147483646 |
#define | S1_MAX 2147483542 |
#define | S2_MAX 2147483422 |
#define | S3_MAX 2147483322 |
Functions | |
long long | FindB (long long a, long long k, long long m) |
Find B to run CLCG4 backwards. More... | |
int32_t | MultModM (int32_t s, int32_t t, int32_t M) |
Returns(s*t) MOD M. More... | |
void | clamp_seed (uint32_t s[4]) |
void | rng_set_seed (tw_rng_stream *g, uint32_t s[4]) |
void | rng_write_state (tw_rng_stream *g, FILE *f) |
void | rng_get_state (tw_rng_stream *g, uint32_t s[4]) |
void | rng_put_state (tw_rng_stream *g, uint32_t s[4]) |
void | rng_init_generator (tw_rng_stream *g, SeedType Where) |
void | tw_rand_initial_seed (tw_rng_stream *g, tw_lpid id) |
void | tw_rand_init_streams (tw_lp *lp, unsigned int nstreams) |
tw_rng * | rng_init (int v, int w) |
double | rng_gen_val (tw_rng_stream *g) |
double | rng_gen_reverse_val (tw_rng_stream *g) |
Variables | |
static tw_rng * | rng = NULL |
int32_t | seed [4] = { 11111111, 22222222, 33333333, 44444444 } |
Random number generator, provides all of the features GTW requires by default. Chris hacked this pretty well, he would know the features better.
Definition in file rand-clcg4.c.
#define H 32768 |
Definition at line 20 of file rand-clcg4.c.
Referenced by MultModM().
#define S0_MAX 2147483646 |
Definition at line 144 of file rand-clcg4.c.
Referenced by clamp_seed().
#define S1_MAX 2147483542 |
Definition at line 145 of file rand-clcg4.c.
Referenced by clamp_seed().
#define S2_MAX 2147483422 |
Definition at line 146 of file rand-clcg4.c.
Referenced by clamp_seed().
#define S3_MAX 2147483322 |
Definition at line 147 of file rand-clcg4.c.
Referenced by clamp_seed().
void clamp_seed | ( | uint32_t | s[4] | ) |
These seeds MUST adhere to these requirements. This is explicitly stated in L'Ecuyer and Andres (1997)
Definition at line 153 of file rand-clcg4.c.
References S0_MAX, S1_MAX, S2_MAX, and S3_MAX.
Referenced by rng_init(), and rng_set_seed().
long long FindB | ( | long long | a, |
long long | k, | ||
long long | m | ||
) |
FindB B is which is used in running the CLCG4 backwards Added by Chris Carothers, 5/15/98
Definition at line 37 of file rand-clcg4.c.
Referenced by rng_init().
int32_t MultModM | ( | int32_t | s, |
int32_t | t, | ||
int32_t | M | ||
) |
MultiModM See L'Ecuyer and Cote(1991).
Returns(s*t) MOD M. Assumes that -M < s < M and -M < t < M.
Definition at line 77 of file rand-clcg4.c.
References H.
Referenced by rng_init(), rng_init_generator(), and tw_rand_initial_seed().
double rng_gen_reverse_val | ( | tw_rng_stream * | g | ) |
Definition at line 451 of file rand-clcg4.c.
References tw_rng::b, tw_rng_stream::Cg, tw_rng_stream::count, tw_rng::m, tw_error(), and TW_LOC.
double rng_gen_val | ( | tw_rng_stream * | g | ) |
Definition at line 392 of file rand-clcg4.c.
References tw_rng_stream::Cg, and tw_rng_stream::count.
void rng_get_state | ( | tw_rng_stream * | g, |
uint32_t | s[4] | ||
) |
Definition at line 212 of file rand-clcg4.c.
References tw_rng_stream::Cg.
tw_rng* rng_init | ( | int | v, |
int | w | ||
) |
Definition at line 338 of file rand-clcg4.c.
References tw_rng::a, tw_rng::avw, tw_rng::aw, tw_rng::b, clamp_seed(), FindB(), g_tw_rng_seed, tw_rng::m, MultModM(), rng, tw_rng::seed, tw_calloc(), and TW_LOC.
Referenced by tw_rand_init().
void rng_init_generator | ( | tw_rng_stream * | g, |
SeedType | Where | ||
) |
Definition at line 239 of file rand-clcg4.c.
References tw_rng::aw, tw_rng_stream::Cg, tw_rng_stream::Ig, InitialSeed, LastSeed, tw_rng_stream::Lg, tw_rng::m, MultModM(), and NewSeed.
Referenced by rng_set_seed().
void rng_put_state | ( | tw_rng_stream * | g, |
uint32_t | s[4] | ||
) |
Definition at line 226 of file rand-clcg4.c.
References tw_rng_stream::Cg.
void rng_set_seed | ( | tw_rng_stream * | g, |
uint32_t | s[4] | ||
) |
Definition at line 181 of file rand-clcg4.c.
References clamp_seed(), tw_rng_stream::Ig, InitialSeed, and rng_init_generator().
void rng_write_state | ( | tw_rng_stream * | g, |
FILE * | f | ||
) |
Definition at line 198 of file rand-clcg4.c.
References tw_rng_stream::Cg.
void tw_rand_init_streams | ( | tw_lp * | lp, |
unsigned int | nstreams | ||
) |
Definition at line 320 of file rand-clcg4.c.
References g_tw_nRNG_per_lp, tw_lp::gid, tw_lp::rng, tw_calloc(), tw_error(), TW_LOC, and tw_rand_initial_seed().
Referenced by tw_define_lps().
void tw_rand_initial_seed | ( | tw_rng_stream * | g, |
tw_lpid | id | ||
) |
Definition at line 265 of file rand-clcg4.c.
References tw_rng::avw, tw_rng_stream::count, tw_rng::m, MultModM(), and tw_rng::seed.
Referenced by tw_rand_init_streams().
|
static |
Definition at line 23 of file rand-clcg4.c.
Referenced by rng_init().
int32_t seed[4] = { 11111111, 22222222, 33333333, 44444444 } |
Definition at line 26 of file rand-clcg4.c.