LibRan
0.1
Pseudo-random number distribution generator
|
Specialized sequential congruential uniform pseudo-random number generator. More...
Go to the source code of this file.
Macros | |
#define | SQRT3 1.7320508075688772935 |
#define | PI 3.141592653589793238462643 |
Functions | |
void | _set_rand (void) |
int | LR_irand (LR_obj *o) |
LR_irand(LR_obj *) - returns int in range [0,LR_IRAND_IMAX]. More... | |
float | LR_frand (LR_obj *o) |
LR_frand(LR_obj *) - returns float in range [0.0,1.0) More... | |
void | LR_isetseed (LR_obj *o, int X) |
LR_isetseed(LR_obj *, int X) - set the seed to X. More... | |
int | LR_igetseed (LR_obj *o) |
LR_igetseed(LR_obj *) - get the current seed. More... | |
int | LR_igetrand (LR_obj *o) |
LR_igetrand(LR_obj *) - get the current pseudo-random number. More... | |
float | LR_fgetrand (LR_obj *o) |
LR_fgetrand(LR_obj *) - get the current pseudo-random number. More... | |
long | LR_lrand (LR_obj *o) |
LR_lrand(LR_obj *) - returns long in range [0,LR_IRAND_LMAX]. More... | |
double | LR_drand (LR_obj *o) |
LR_drand(LR_obj *) - returns double in range [0.0,1.0) More... | |
void | LR_lsetseed (LR_obj *o, long X) |
LR_lsetseed(LR_obj *, long X) - set the seed to X. More... | |
long | LR_lgetseed (LR_obj *o) |
LR_lgetseed(LR_obj *) - get the current seed. More... | |
long | LR_lgetrand (LR_obj *o) |
LR_lgetrand(LR_obj *) - get the current pseudo-random number. More... | |
double | LR_dgetrand (LR_obj *o) |
LR_dgetrand(LR_obj *) - get the current pseudo-random number. More... | |
int | LR_igetval (char *val) |
LR_igetval(char *val) - return the configure value. More... | |
long | LR_lgetval (char *val) |
LR_lgetval(char *val) - return the configure value. More... | |
float | LR_fgetval (char *val) |
LR_fgetval(char *val) - return the configure value. More... | |
double | LR_dgetval (char *val) |
LR_dgetval(char *val) - return the configure value. More... | |
Variables | |
float | lr_fscale |
float | lr_fhalfm |
double | lr_dscale |
double | lr_dhalfm |
int | lr_ia = 0 |
int | lr_ic = 0 |
int | lr_imc = 0 |
long | lr_la = 0 |
long | lr_lc = 0 |
long | lr_lmc = 0 |
Specialized sequential congruential uniform pseudo-random number generator.
Urand is a specialized sequential congruential uniform pseudo-random number generator based on theory and suggestions given in D.E. Knuth (1969), vol 2. and then republished by G.E. Forsysth, M.A. Malcolm, and C.B. Moler (1977); and converted from Fortran 77 to C with f2c.
Modified to fit into the LibRan package, and to isolate each pseudo-random sequence to each LibRan object.
This routine is highly optimized by the configuration step to provide the fastest set of operations for computing the next value in the sequence. However, this does not lend itself to cross compiling, since the configuration step requires testing on the actual intended hardware and environment.
The LR_*rand
routine should generally not be called directly ... call the LR_obj
object with the unif distribution instead as follows.
These routines are specific to this internal LibRan sequential congruential uniform pseudo-random generator. If a different pseudo-random generator is used then these are probably no longer effective.
Definition in file urand.c.
double LR_dgetrand | ( | LR_obj * | o | ) |
LR_dgetrand(LR_obj *) - get the current pseudo-random number.
Get the current pseudo-random number from this LR_obj
.
o | LR_obj object |
double LR_dgetval | ( | char * | val | ) |
LR_dgetval(char *val) - return the configure value.
Return the value computed from the library configuration step, such as LR_DEPS
, and LR_DSQEPS
.
val | configuration parameter |
double LR_drand | ( | LR_obj * | o | ) |
LR_drand(LR_obj *) - returns double in range [0.0,1.0)
Returns a pseudo-random double in the range [0.0, 1.0)
o | LR_obj object |
float LR_fgetrand | ( | LR_obj * | o | ) |
LR_fgetrand(LR_obj *) - get the current pseudo-random number.
Get the current pseudo-random number from this LR_obj
.
o | LR_obj object |
float LR_fgetval | ( | char * | val | ) |
LR_fgetval(char *val) - return the configure value.
Return the value computed from the library configuration step, such as LR_FEPS
, and LR_FSQEPS
.
val | configuration parameter |
float LR_frand | ( | LR_obj * | o | ) |
LR_frand(LR_obj *) - returns float in range [0.0,1.0)
Returns a pseudo-random float in the range [0.0, 1.0)
o | LR_obj object |
int LR_igetrand | ( | LR_obj * | o | ) |
LR_igetrand(LR_obj *) - get the current pseudo-random number.
Get the current pseudo-random number from this LR_obj
.
o | LR_obj object |
int LR_igetseed | ( | LR_obj * | o | ) |
LR_igetseed(LR_obj *) - get the current seed.
Get the seed from this LR_obj
.
o | LR_obj object |
int LR_igetval | ( | char * | val | ) |
LR_igetval(char *val) - return the configure value.
Return the value computed from the library configuration step, such as LR_IRAND_IMAX2
, LR_IRAND_IMAX
, and LR_IRAND_INOT
.
val | configuration parameter |
int LR_irand | ( | LR_obj * | o | ) |
LR_irand(LR_obj *) - returns int in range [0,LR_IRAND_IMAX].
Returns a pseudo-random int in the range [0,LR_IRAND_MAX]
o | LR_obj object |
void LR_isetseed | ( | LR_obj * | o, |
int | X | ||
) |
LR_isetseed(LR_obj *, int X) - set the seed to X.
Set the seed for this LR_obj
.
o | LR_obj object |
X | int with new seed |
long LR_lgetrand | ( | LR_obj * | o | ) |
LR_lgetrand(LR_obj *) - get the current pseudo-random number.
Get the current pseudo-random number from this LR_obj
.
o | LR_obj object |
long LR_lgetseed | ( | LR_obj * | o | ) |
LR_lgetseed(LR_obj *) - get the current seed.
Get the seed from this LR_obj
.
o | LR_obj object |
long LR_lgetval | ( | char * | val | ) |
LR_lgetval(char *val) - return the configure value.
Return the value computed from the library configuration step, such as LR_IRAND_LMAX2
, LR_IRAND_LMAX
, and LR_IRAND_LNOT
.
val | configuration parameter |
long LR_lrand | ( | LR_obj * | o | ) |
LR_lrand(LR_obj *) - returns long in range [0,LR_IRAND_LMAX].
Returns a pseudo-random int in the range [0,LR_IRAND_LMAX]
o | LR_obj object |