Data Structures | |
struct | bn_unif |
struct | bn_gauss |
Files | |
file | msr.c |
Minimal Standard RANdom number generator. | |
Defines | |
#define | BN_CK_UNIF(_p) BU_CKMAG(_p, BN_UNIF_MAGIC, "bn_unif") |
#define | BN_CK_GAUSS(_p) BU_CKMAG(_p, BN_GAUSS_MAGIC, "bn_gauss") |
#define | BN_UNIF_LONG(_p) |
#define | BN_UNIF_DOUBLE(_p) |
#define | BN_UNIF_CIRCLE(_p, _x, _y, _r) |
#define | BN_UNIF_SPHERE(_p, _x, _y, _z, _r) |
#define | BN_GAUSS_DOUBLE(_p) |
#define | BN_MSR_MAXTBL 4096 |
#define | A 16807 |
#define | M 2147483647 |
#define | DM 2147483647.0 |
#define | Q 127773 |
#define | R 2836 |
Functions | |
struct bn_unif * | bn_unif_init (long setseed, int method) |
void | bn_unif_free (struct bn_unif *p) |
long | bn_unif_long_fill (struct bn_unif *p) |
double | bn_unif_double_fill (struct bn_unif *p) |
struct bn_gauss * | bn_gauss_init (long setseed, int method) |
void | bn_gauss_free (struct bn_gauss *p) |
double | bn_gauss_fill (struct bn_gauss *p) |
struct bn_unif * | bn_unif_init (long int setseed, int method) |
struct bn_gauss * | bn_gauss_init (long int setseed, int method) |
#define BN_CK_UNIF | ( | _p | ) | BU_CKMAG(_p, BN_UNIF_MAGIC, "bn_unif") |
Definition at line 706 of file bn.h.
Referenced by bn_unif_double_fill(), and bn_unif_long_fill().
#define BN_CK_GAUSS | ( | _p | ) | BU_CKMAG(_p, BN_GAUSS_MAGIC, "bn_gauss") |
Definition at line 707 of file bn.h.
Referenced by bn_gauss_fill().
#define BN_UNIF_LONG | ( | _p | ) |
(((_p)->msr_long_ptr) ? \ (_p)->msr_longs[--(_p)->msr_long_ptr] : \ bn_unif_long_fill(_p))
#define BN_UNIF_DOUBLE | ( | _p | ) |
(((_p)->msr_double_ptr) ? \ (_p)->msr_doubles[--(_p)->msr_double_ptr] : \ bn_unif_double_fill(_p))
#define BN_UNIF_CIRCLE | ( | _p, | |||
_x, | |||||
_y, | |||||
_r | ) |
{ \ do { \ (_x) = 2.0*BN_UNIF_DOUBLE((_p)); \ (_y) = 2.0*BN_UNIF_DOUBLE((_p)); \ (_r) = (_x)*(_x)+(_y)*(_y); \ } while ((_r) >= 1.0); }
Definition at line 743 of file bn.h.
Referenced by bn_gauss_fill().
#define BN_UNIF_SPHERE | ( | _p, | |||
_x, | |||||
_y, | |||||
_z, | |||||
_r | ) |
{ \ do { \ (_x) = 2.0*BN_UNIF_DOUBLE(_p); \ (_y) = 2.0*BN_UNIF_DOUBLE(_p); \ (_z) = 2.0*BN_UNIF_DOUBLE(_p); \ (_r) = (_x)*(_x)+(_y)*(_y)+(_z)*(_z);\ } while ((_r) >= 1.0) }
#define BN_GAUSS_DOUBLE | ( | _p | ) |
(((_p)->msr_gauss_ptr) ? \ (_p)->msr_gausses[--(_p)->msr_gauss_ptr] : \ bn_gauss_fill(_p))
#define BN_MSR_MAXTBL 4096 |
Note: BN_MSR_MAXTBL must be an even number, preferably a power of two. Size of random number tables.
Definition at line 45 of file msr.c.
Referenced by bn_gauss_fill(), bn_gauss_init(), bn_unif_double_fill(), bn_unif_init(), and bn_unif_long_fill().
#define A 16807 |
Definition at line 73 of file msr.c.
Referenced by bn_mat_ck(), bn_mat_fromto(), bn_poly_cubic_roots(), bn_unif_double_fill(), and bn_unif_long_fill().
#define M 2147483647 |
Definition at line 74 of file msr.c.
Referenced by bn_mat_fromto(), bn_randmt_state(), bn_unif_double_fill(), and bn_unif_long_fill().
#define DM 2147483647.0 |
Definition at line 75 of file msr.c.
Referenced by bn_unif_double_fill().
#define Q 127773 |
Q = M / A
Definition at line 76 of file msr.c.
Referenced by bn_mat_fromto(), bn_unif_double_fill(), and bn_unif_long_fill().
#define R 2836 |
R = M % A
Definition at line 77 of file msr.c.
Referenced by bn_mat_fromto(), bn_unif_double_fill(), and bn_unif_long_fill().
struct bn_unif* bn_unif_init | ( | long | setseed, | |
int | method | |||
) | [read] |
void bn_unif_free | ( | struct bn_unif * | p | ) |
Definition at line 226 of file msr.c.
References bn_unif::magic, bn_unif::msr_doubles, and bn_unif::msr_longs.
long bn_unif_long_fill | ( | struct bn_unif * | p | ) |
bn_unif_long_fill fill a random number table.
Use the msrad algorithm to fill a random number table with values from 1 to 2^31-1. These numbers can (and are) extracted from the random number table via high speed macros and bn_unif_long_fill called when the table is exauseted.
Definition at line 126 of file msr.c.
References A, BN_CK_UNIF, BN_MSR_MAXTBL, M, bn_unif::magic, bn_unif::msr_long_ptr, bn_unif::msr_longs, bn_unif::msr_seed, Q, and R.
double bn_unif_double_fill | ( | struct bn_unif * | p | ) |
bn_unif_double_fill fill a random number table.
Use the msrad algorithm to fill a random number table with values from -0.5 to 0.5. These numbers can (and are) extracted from the random number table via high speed macros and bn_unif_double_fill called when the table is exauseted.
Definition at line 188 of file msr.c.
References A, BN_CK_UNIF, BN_MSR_MAXTBL, DM, M, bn_unif::magic, bn_unif::msr_double_ptr, bn_unif::msr_doubles, bn_unif::msr_seed, Q, and R.
struct bn_gauss* bn_gauss_init | ( | long | setseed, | |
int | method | |||
) | [read] |
void bn_gauss_free | ( | struct bn_gauss * | p | ) |
Definition at line 339 of file msr.c.
References bn_gauss::msr_gauss_doubles, and bn_gauss::msr_gausses.
double bn_gauss_fill | ( | struct bn_gauss * | p | ) |
Definition at line 311 of file msr.c.
References BN_CK_GAUSS, BN_MSR_MAXTBL, BN_UNIF_CIRCLE, bn_gauss::msr_gauss_ptr, and bn_gauss::msr_gausses.
struct bn_unif* bn_unif_init | ( | long int | setseed, | |
int | method | |||
) | [read] |
Definition at line 79 of file msr.c.
References BN_MSR_MAXTBL, bn_unif::magic, bn_unif::msr_double_ptr, bn_unif::msr_doubles, bn_unif::msr_long_ptr, bn_unif::msr_longs, and bn_unif::msr_seed.
struct bn_gauss* bn_gauss_init | ( | long int | setseed, | |
int | method | |||
) | [read] |
Definition at line 260 of file msr.c.
References BN_MSR_MAXTBL, bn_gauss::magic, bn_gauss::msr_gauss_dbl_ptr, bn_gauss::msr_gauss_doubles, bn_gauss::msr_gauss_ptr, bn_gauss::msr_gauss_seed, and bn_gauss::msr_gausses.