BRL-CAD
Minimal Standard Random Numbers
Collaboration diagram for Minimal Standard Random Numbers:

Files

file  msr.c
 Minimal Standard RANdom number generator.
 

Data Structures

struct  bn_unif
 Minimal Standard RANdom number generator. More...
 
struct  bn_gauss
 

Macros

#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 /* Size of random number tables. */
 
#define A   16807
 
#define M   2147483647
 
#define DM   2147483647.0
 
#define Q   127773 /* Q = M / A */
 
#define R   2836 /* R = M % A */
 

Functions

struct bn_unifbn_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_gaussbn_gauss_init (long setseed, int method)
 
void bn_gauss_free (struct bn_gauss *p)
 
double bn_gauss_fill (struct bn_gauss *p)
 
struct bn_unifbn_unif_init (long int setseed, int method)
 
struct bn_gaussbn_gauss_init (long int setseed, int method)
 

Detailed Description

Macro Definition Documentation

#define BN_CK_UNIF (   _p)    BU_CKMAG(_p, BN_UNIF_MAGIC, "bn_unif")

Definition at line 62 of file msr.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 63 of file msr.h.

Referenced by bn_gauss_fill().

#define BN_UNIF_LONG (   _p)
Value:
(((_p)->msr_long_ptr) ? \
(_p)->msr_longs[--(_p)->msr_long_ptr] : \
long bn_unif_long_fill(struct bn_unif *p)
Definition: msr.c:78

Definition at line 241 of file msr.h.

#define BN_UNIF_DOUBLE (   _p)
Value:
(((_p)->msr_double_ptr) ? \
(_p)->msr_doubles[--(_p)->msr_double_ptr] : \
double bn_unif_double_fill(struct bn_unif *p)
Definition: msr.c:115

Definition at line 245 of file msr.h.

#define BN_UNIF_CIRCLE (   _p,
  _x,
  _y,
  _r 
)
Value:
{ \
do { \
(_x) = 2.0*BN_UNIF_DOUBLE((_p)); \
(_y) = 2.0*BN_UNIF_DOUBLE((_p)); \
(_r) = (_x)*(_x)+(_y)*(_y); \
} while ((_r) >= 1.0); }
#define BN_UNIF_DOUBLE(_p)
Definition: msr.h:245

Definition at line 250 of file msr.h.

Referenced by bn_gauss_fill().

#define BN_UNIF_SPHERE (   _p,
  _x,
  _y,
  _z,
  _r 
)
Value:
{ \
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_UNIF_DOUBLE(_p)
Definition: msr.h:245

Definition at line 257 of file msr.h.

#define BN_GAUSS_DOUBLE (   _p)
Value:
(((_p)->msr_gauss_ptr) ? \
(_p)->msr_gausses[--(_p)->msr_gauss_ptr] : \
double bn_gauss_fill(struct bn_gauss *p)
Definition: msr.c:190

Definition at line 265 of file msr.h.

#define BN_MSR_MAXTBL   4096 /* Size of random number tables. */

Note: BN_MSR_MAXTBL must be an even number, preferably a power of two.

Definition at line 48 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 DM   2147483647.0

Definition at line 53 of file msr.c.

Referenced by bn_unif_double_fill().

#define Q   127773 /* Q = M / A */

Function Documentation

struct bn_unif* bn_unif_init ( long  setseed,
int  method 
)
void bn_unif_free ( struct bn_unif p)

Definition at line 155 of file msr.c.

References bu_free(), bn_unif::magic, bn_unif::msr_doubles, and bn_unif::msr_longs.

Here is the call graph for this function:

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)

Definition at line 220 of file msr.c.

References bu_free(), bn_gauss::msr_gauss_doubles, and bn_gauss::msr_gausses.

Here is the call graph for this function:

double bn_gauss_fill ( struct bn_gauss p)
struct bn_unif* bn_unif_init ( long int  setseed,
int  method 
)

Definition at line 58 of file msr.c.

References BN_MSR_MAXTBL, BN_UNIF_MAGIC, BU_ALLOC, bu_bomb(), bu_malloc(), 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.

Here is the call graph for this function:

struct bn_gauss* bn_gauss_init ( long int  setseed,
int  method 
)

Definition at line 169 of file msr.c.

References BN_GAUSS_MAGIC, BN_MSR_MAXTBL, BU_ALLOC, bu_bomb(), bu_malloc(), 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.

Here is the call graph for this function: