surfrand: Random number generator based on SURF

Data Structures

struct  surfrand


void surfrand_init (struct surfrand *c, const uint32 *data, unsigned words)
uint32 surfrand_uint32 (struct surfrand *c)
double surfrand_double (struct surfrand *c)
void surfrand_fill (struct surfrand *c, unsigned char *buf, unsigned len)

Function Documentation

double surfrand_double ( struct surfrand c  ) 

Output a random double precision floating-point number in the range 0-1.

This routine uses two calls to surfrand_uint32 to fill all the precision of a double precision floating-point with randomness.

void surfrand_fill ( struct surfrand c,
unsigned char *  buf,
unsigned  len 

Fill the buffer with random data

void surfrand_init ( struct surfrand c,
const uint32 *  data,
unsigned  words 

Initialize the surfrand structure.

Initializes the seed in c from the input data, and sets the counter to zero. If more than SURF_SEED_U32 bytes of input data is given, the extra data is merged into the seed. If less, the given data is repeated until the seed is filled.

The counter is treated as a giant multi-word integer, and is incremented once each time data is generated. This makes the theoretical period of this generator 8*2^32^12 or >10^116.

uint32 surfrand_uint32 ( struct surfrand c  ) 

Output an random unsigned 32-bit integer.

All the bits in the output integer are equally random.

Generated on Thu Feb 19 11:11:50 2009 for bglibs by  doxygen 1.5.4