Go to the first, previous, next, last section, table of contents.


CNMLCG -- Multiple Linear Congruence RNG

SYNOPSIS

#include <CNCL/MLCG.h>

TYPE

CN_CNMLCG

BASE CLASSES

CNRNG

DERIVED CLASSES

None

RELATED CLASSES

CNRandom

DESCRIPTION

CNMLCG is a multiple linear congruence random number generator class combining the results of two different CNLCGs. It is the double MLCG described by L'Ecuyer [6]. The implementation was taken from the GNU-library libg++. This generator has a fairly long period, and has been statistically analyzed to show that it gives good intersample-independence. The 'CNMLCG::CNMLCG' constructor has two parameters, both of which are seeds for the generator. Both seeds are modified to give a "better" distribution of seed digits. Thus, you can safely use values such as '0' and '1' for the seeds. Such values are mapped to values with a sufficient number and distribution of bits. Hence the constructor contains a table with 32 tested seed values.

Constructors:

CNMLCG();
CNMLCG(long seed1, long seed2);
CNMLCG(CNParam *param);
Initializes CNMLCG with two seeds, seed1 and seed2. The default constructor sets both seeds to 0.

In addition to the member functions required by CNCL, CNMLCG provides:

virtual unsigned long as_long32();
Draws a random number. The result is an unsigned integer in the range 0 ... 2^31-1.
virtual bool has_long32();
Returns FALSE because CNMLCG produces only 31bit intger values.
virtual void reset();
Resets the CNMLCG to its initial state.
void seed(unsigned long s);
Sets the two seed values, the first one to s and the second one to s + 2147483561.
void seed_internal(unsigned long, unsigned long);
Sets both seed values.


Go to the first, previous, next, last section, table of contents.