Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members

generators::LC_RNG Class Reference

A basic linear congruential RNG. More...

#include <LC_RNGs.h>

Inheritance diagram for generators::LC_RNG:

generators::RNG generators::QUICK generators::RANDU List of all members.

Public Member Functions

 LC_RNG ()
 Constructs a new default linear congruential RNG.
 LC_RNG (unsigned int a, unsigned int c, unsigned int m)
 Constructs a new linear congruential RNG.
virtual unsigned int getA ()
virtual unsigned int getC ()
virtual unsigned int getM ()
virtual unsigned int getMaximum ()

Protected Member Functions

virtual unsigned int nextInt ()
 Returns the next pseudo-random number from this RNG.
virtual unsigned int linear_congruential (unsigned int x)
 The linear congruential function for calculating '(ax+c) mod m'.

Protected Attributes

unsigned int _a
 Stores the values a, c and m as in (ax+c) mod m.
unsigned int _c
 Stores the values a, c and m as in (ax+c) mod m.
unsigned int _m
 Stores the values a, c and m as in (ax+c) mod m.

Detailed Description

A basic linear congruential RNG.

Linear congruential generators calculate the next pseudorandom number as:

next = (a*x+c) mod m


Constructor & Destructor Documentation

generators::LC_RNG::LC_RNG  ) 
 

Constructs a new default linear congruential RNG.

Use the three-argument constructor instead.

See also:
LC_RNG(unsigned int, unsigned int, unsigned int)

generators::LC_RNG::LC_RNG unsigned int  a,
unsigned int  c,
unsigned int  m
 

Constructs a new linear congruential RNG.

Parameters:
a The constant 'a' in '(ax+c) mod m' for this RNG.
c The constant 'c' in '(ax+c) mod m' for this RNG.
m The constant 'm' in '(ax+c) mod m' for this RNG.


Member Function Documentation

unsigned int generators::LC_RNG::getA  )  [inline, virtual]
 

Returns:
The constant 'a' in '(ax+c) mod m' for this RNG.

unsigned int generators::LC_RNG::getC  )  [inline, virtual]
 

Returns:
The constant 'c' in '(ax+c) mod m' for this RNG.

unsigned int generators::LC_RNG::getM  )  [inline, virtual]
 

Returns:
The constant 'm' in '(ax+c) mod m' for this RNG.

unsigned int generators::LC_RNG::getMaximum  )  [virtual]
 

Returns:
The maximal value that this RNG can ever produce.

Reimplemented from generators::RNG.

unsigned int generators::LC_RNG::linear_congruential unsigned int  x  )  [protected, virtual]
 

The linear congruential function for calculating '(ax+c) mod m'.

Parameters:
x The previous pseudo-random number.
Returns:
The next pseudo-random number.

unsigned int generators::LC_RNG::nextInt  )  [protected, virtual]
 

Returns the next pseudo-random number from this RNG.

Seed updating is done automatically. Uses the linear_congruential function to determine the next pseudo-random number.

Returns:
The next pseudo-random number.
See also:
linear_congruential(unsigned int)

Implements generators::RNG.


Member Data Documentation

unsigned int generators::LC_RNG::_a [protected]
 

Stores the values a, c and m as in (ax+c) mod m.

See also:
getA, getC, getM

unsigned int generators::LC_RNG::_c [protected]
 

Stores the values a, c and m as in (ax+c) mod m.

See also:
getA, getC, getM

unsigned int generators::LC_RNG::_m [protected]
 

Stores the values a, c and m as in (ax+c) mod m.

See also:
getA, getC, getM


The documentation for this class was generated from the following files:
Generated on Fri Sep 4 18:03:47 2009 for LabSci RNG/MC generators by  doxygen 1.3.9.1