Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

mlib::RandomGen Class Reference
[MLIB]

Random number generator class.

Private to objects (a la meshes) who need their own source of random variables. More...

#include <random.H>

List of all members.

Public Member Functions

Constructors
 RandomGen ()
 Default constructor. Creates a random number generator with a default seed (1).
 RandomGen (long i)
 Constructor that creates a random number generator with the seed given in the argument.
Seed Accessor Functions
void srand (long i=1)
 Seeds the random number generator with the seed i.
long get_seed ()
 Gets the current seed value.
Random Number Generation Functions
long lrand ()
 Generate a random long integer.
double drand ()
 Generate a random double precision floating point value in the range [0.0, 1.0].

Static Public Attributes

static long R_MAX = RAND_MAX
 The maximum integer value that can be produced by this random number generator.

Private Member Functions

void update ()
 Generate the next seed (i.e. the next random value).

Private Attributes

long _seed
 The current seed value.


Detailed Description

Random number generator class.

Private to objects (a la meshes) who need their own source of random variables.

Definition at line 21 of file random.H.


Constructor & Destructor Documentation

mlib::RandomGen::RandomGen  )  [inline]
 

Default constructor. Creates a random number generator with a default seed (1).

Definition at line 31 of file random.H.

References srand().

mlib::RandomGen::RandomGen long  i  )  [inline]
 

Constructor that creates a random number generator with the seed given in the argument.

Definition at line 35 of file random.H.

References srand().


Member Function Documentation

double mlib::RandomGen::drand  )  [inline]
 

Generate a random double precision floating point value in the range [0.0, 1.0].

Definition at line 64 of file random.H.

References lrand(), and R_MAX.

long mlib::RandomGen::get_seed  )  [inline]
 

Gets the current seed value.

Note:
This changes each time a new number is generated.

Definition at line 52 of file random.H.

References _seed.

long mlib::RandomGen::lrand  )  [inline]
 

Generate a random long integer.

Definition at line 60 of file random.H.

References _seed, and update().

Referenced by drand().

void mlib::RandomGen::srand long  i = 1  )  [inline]
 

Seeds the random number generator with the seed i.

Definition at line 47 of file random.H.

References _seed.

Referenced by RandomGen().

void mlib::RandomGen::update  )  [private]
 

Generate the next seed (i.e. the next random value).

Definition at line 15 of file random.C.

References _seed.

Referenced by lrand().


Member Data Documentation

long mlib::RandomGen::_seed [private]
 

The current seed value.

Definition at line 70 of file random.H.

Referenced by get_seed(), lrand(), srand(), and update().

long mlib::RandomGen::R_MAX = RAND_MAX [static]
 

The maximum integer value that can be produced by this random number generator.

Definition at line 41 of file random.H.

Referenced by drand().


The documentation for this class was generated from the following files:
Generated on Mon Sep 18 11:48:25 2006 for jot by  doxygen 1.4.4