BRL-CAD
Minimal Standard Random Numbers

Minimal Standard RANdom number generator. More...

Collaboration diagram for Minimal Standard Random Numbers:

Files

file  msr.h
 

Data Structures

struct  bn_unif
 
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)
 

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)
 

Detailed Description

Minimal Standard RANdom number generator.

From:
Stephen K. Park and Keith W. Miller
"Random number generators: good ones are hard to find"
CACM vol 31 no 10, Oct 88

Macro Definition Documentation

◆ BN_CK_UNIF

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

Definition at line 62 of file msr.h.

◆ BN_CK_GAUSS

#define BN_CK_GAUSS (   _p)    BU_CKMAG(_p, BN_GAUSS_MAGIC, "bn_gauss")

Definition at line 63 of file msr.h.

◆ BN_UNIF_LONG

#define BN_UNIF_LONG (   _p)
Value:
(((_p)->msr_long_ptr) ? \
(_p)->msr_longs[--(_p)->msr_long_ptr] : \
bn_unif_long_fill(_p))

Definition at line 241 of file msr.h.

◆ BN_UNIF_DOUBLE

#define BN_UNIF_DOUBLE (   _p)
Value:
(((_p)->msr_double_ptr) ? \
(_p)->msr_doubles[--(_p)->msr_double_ptr] : \
bn_unif_double_fill(_p))

Definition at line 245 of file msr.h.

◆ BN_UNIF_CIRCLE

#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.

◆ BN_UNIF_SPHERE

#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) }

Definition at line 257 of file msr.h.

◆ BN_GAUSS_DOUBLE

#define BN_GAUSS_DOUBLE (   _p)
Value:
(((_p)->msr_gauss_ptr) ? \
(_p)->msr_gausses[--(_p)->msr_gauss_ptr] : \
bn_gauss_fill(_p))

Definition at line 265 of file msr.h.

Function Documentation

◆ bn_unif_init()

struct bn_unif * bn_unif_init ( long  setseed,
int  method 
)

◆ bn_unif_free()

void bn_unif_free ( struct bn_unif p)

◆ bn_unif_long_fill()

long bn_unif_long_fill ( struct bn_unif p)

◆ bn_unif_double_fill()

double bn_unif_double_fill ( struct bn_unif p)

◆ bn_gauss_init()

struct bn_gauss * bn_gauss_init ( long  setseed,
int  method 
)

◆ bn_gauss_free()

void bn_gauss_free ( struct bn_gauss p)

◆ bn_gauss_fill()

double bn_gauss_fill ( struct bn_gauss p)