BRL-CAD
randmt.c File Reference
#include "bu/log.h"
#include "bu/malloc.h"
#include "bn/randmt.h"
Include dependency graph for randmt.c:

Go to the source code of this file.

Data Structures

struct  _internal_state_s
 

Macros

#define N   624
 
#define M   397
 
#define MATRIX_A   0x9908b0df /* constant vector a */
 
#define UPPER_MASK   0x80000000 /* most significant w-r bits */
 
#define LOWER_MASK   0x7fffffff /* least significant r bits */
 
#define TEMPERING_MASK_B   0x9d2c5680
 
#define TEMPERING_MASK_C   0xefc60000
 
#define TEMPERING_SHIFT_U(y)   (y >> 11)
 
#define TEMPERING_SHIFT_S(y)   (y << 7)
 
#define TEMPERING_SHIFT_T(y)   (y << 15)
 
#define TEMPERING_SHIFT_L(y)   (y >> 18)
 
#define MERSENNE_MAGIC   0x4D54524E
 

Functions

void * bn_randmt_state_create (void)
 
void bn_randmt_state_seed (struct _internal_state_s *is, uint32_t seed)
 
double bn_randmt_state (struct _internal_state_s *is)
 
void bn_randmt_state_serialize (struct _internal_state_s *is, struct bu_vls *s)
 
void bn_randmt_state_deserialize (struct _internal_state_s *is, struct bu_vls *s)
 
void bn_randmt_seed (unsigned long seed)
 
double bn_randmt (void)
 Mersenne Twister random number generation as defined by MT19937. More...
 

Macro Definition Documentation

#define M   397

Definition at line 40 of file randmt.c.

Referenced by bn_randmt_state().

#define MATRIX_A   0x9908b0df /* constant vector a */

Definition at line 41 of file randmt.c.

Referenced by bn_randmt_state().

#define UPPER_MASK   0x80000000 /* most significant w-r bits */

Definition at line 42 of file randmt.c.

Referenced by bn_randmt_state().

#define LOWER_MASK   0x7fffffff /* least significant r bits */

Definition at line 43 of file randmt.c.

Referenced by bn_randmt_state().

#define TEMPERING_MASK_B   0x9d2c5680

Definition at line 47 of file randmt.c.

Referenced by bn_randmt_state().

#define TEMPERING_MASK_C   0xefc60000

Definition at line 48 of file randmt.c.

Referenced by bn_randmt_state().

#define TEMPERING_SHIFT_U (   y)    (y >> 11)

Definition at line 49 of file randmt.c.

Referenced by bn_randmt_state().

#define TEMPERING_SHIFT_S (   y)    (y << 7)

Definition at line 50 of file randmt.c.

Referenced by bn_randmt_state().

#define TEMPERING_SHIFT_T (   y)    (y << 15)

Definition at line 51 of file randmt.c.

Referenced by bn_randmt_state().

#define TEMPERING_SHIFT_L (   y)    (y >> 18)

Definition at line 52 of file randmt.c.

Referenced by bn_randmt_state().

#define MERSENNE_MAGIC   0x4D54524E

Definition at line 54 of file randmt.c.

Referenced by bn_randmt_state_create().

Function Documentation

void* bn_randmt_state_create ( void  )

Definition at line 65 of file randmt.c.

References BU_ALLOC, _internal_state_s::magic, MERSENNE_MAGIC, _internal_state_s::mti, and N.

void bn_randmt_state_seed ( struct _internal_state_s is,
uint32_t  seed 
)

Definition at line 77 of file randmt.c.

References _internal_state_s::mt, _internal_state_s::mti, and N.

Referenced by bn_randmt_seed().

double bn_randmt_state ( struct _internal_state_s is)

Definition at line 91 of file randmt.c.

References bn_randmt_seed(), LOWER_MASK, M, MATRIX_A, _internal_state_s::mt, _internal_state_s::mti, N, TEMPERING_MASK_B, TEMPERING_MASK_C, TEMPERING_SHIFT_L, TEMPERING_SHIFT_S, TEMPERING_SHIFT_T, TEMPERING_SHIFT_U, and UPPER_MASK.

Referenced by bn_randmt().

Here is the call graph for this function:

void bn_randmt_state_serialize ( struct _internal_state_s is,
struct bu_vls s 
)

Definition at line 132 of file randmt.c.

References bu_bomb().

Here is the call graph for this function:

void bn_randmt_state_deserialize ( struct _internal_state_s is,
struct bu_vls s 
)

Definition at line 138 of file randmt.c.

References bu_bomb().

Here is the call graph for this function: