Brahe - a heterogenous collection of mathematical tools

Main Index
Home Page

Created by Scott Robert Ladd


Data Structures | Enumerations | Functions | Variables
prng.h File Reference
#include "mathtools.h"

Go to the source code of this file.

Data Structures

struct  brahe_prng_state_t
 Contains state variables for a PRNG. More...
 

Enumerations

Functions

bool brahe_prng_init (brahe_prng_state_t *prng_state, const brahe_prng_type_t type, const uint32_t seed)
 Initialize a psuedo-random number generator (PRNG) More...
 
void brahe_prng_free (brahe_prng_state_t *prng_state)
 Free resources used by PRNG. More...
 
uint32_t brahe_prng_next (brahe_prng_state_t *prng_state)
 Get the next integer. More...
 
uint32_t brahe_prng_range (brahe_prng_state_t *prng_state, const uint32_t lo, const uint32_t hi)
 Get the next integer in the range [lo,hi]. More...
 
size_t brahe_prng_index (brahe_prng_state_t *prng_state, const size_t length)
 Get the next random value as a size_t index. More...
 
double brahe_prng_real1 (brahe_prng_state_t *prng_state)
 Get the next number in the range [0,1]. More...
 
double brahe_prng_real2 (brahe_prng_state_t *prng_state)
 Get the next number in the range [0,1) More...
 
double brahe_prng_real3 (brahe_prng_state_t *prng_state)
 Get the next number in the range (0,1) More...
 
double brahe_prng_real53 (brahe_prng_state_t *prng_state)
 Get the next number in the range [0,1) More...
 

Variables

static uint32_t BRAHE_UNKNOWN_SEED = 0
 

Enumeration Type Documentation

Enumerator
BRAHE_PRNG_MARSENNE_TWISTER 

Marsenne Twister (Matsumoto & Nishimura)

BRAHE_PRNG_KISS 

Keep is Simple, Stupid (Marsaglia)

BRAHE_PRNG_CMWC4096 

CMWC4096 (Marsaglia)

BRAHE_PRNG_MWC1038 

MWC1038 (Marsaglia)

BRAHE_PRNG_ISAAC 

Indirect, Shift, Accumulate, Add, and Count (Jenkins)

Function Documentation

void brahe_prng_free ( brahe_prng_state_t prng_state)

Frees the resources used by a PRNG

Parameters
prng_stateObject containing the state of a PRNG
Returns
true if successful, false if failed
size_t brahe_prng_index ( brahe_prng_state_t prng_state,
const size_t  length 
)

Returns the next value as a size_t "index" in the range [0,length).

Parameters
prng_stateObject containing the state of a PRNG
length- Maximum value of result
Returns
A pseudorandom size_t value
bool brahe_prng_init ( brahe_prng_state_t prng_state,
const brahe_prng_type_t  type,
const uint32_t  seed 
)

Initializes a psuedo-random number generator using a specified algorithm.

Parameters
prng_stateObject to be initialized for a specific algorithm
typeAlgorithm to be used for this PRNG
seedInitialization seed
Returns
true if successful, false if failed
uint32_t brahe_prng_next ( brahe_prng_state_t prng_state)

Returns the next uint32_t in sequence.

Parameters
prng_stateObject containing the state of a PRNG
Returns
A pseudorandom uint32_t value
uint32_t brahe_prng_range ( brahe_prng_state_t prng_state,
const uint32_t  lo,
const uint32_t  hi 
)

Returns the next int_value between lo and hi, inclusive.

Parameters
prng_stateObject containing the state of a PRNG
lo- Minimum value of result
hi- Maximum value of result
Returns
A pseudorandom uint32_t value
double brahe_prng_real1 ( brahe_prng_state_t prng_state)

Returns the next real number in the range [0,1], i.e., a number greater than or equal to 0 and less than or equal to 1. Provides 32-bit precision.

Parameters
prng_stateObject containing the state of a PRNG
Returns
A pseudorandom double value
double brahe_prng_real2 ( brahe_prng_state_t prng_state)

Returns the next real number in the range [0,1), i.e., a number greater than or equal to 0 and less than 1. Provides 32-bit precision.

Parameters
prng_stateObject containing the state of a PRNG
Returns
A pseudorandom double value
double brahe_prng_real3 ( brahe_prng_state_t prng_state)

Returns the next real number in the range (0,1), i.e., a number greater than 0 and less than 1. Provides 32-bit precision.

Parameters
prng_stateObject containing the state of a PRNG
Returns
A pseudorandom double value
double brahe_prng_real53 ( brahe_prng_state_t prng_state)

Returns the next real number in the range [0,1), i.e., a number greater than or equal to 0 and less than 1. Provides 53-bit precision.

Parameters
prng_stateObject containing the state of a PRNG
Returns
A pseudorandom double value

Variable Documentation

uint32_t BRAHE_UNKNOWN_SEED = 0
static

© 2011 Scott Robert Ladd. All rights reserved.
HTML documentation generated by Dimitri van Heesch's excellent Doxygen tool.