Go to the previous, next section.

CNLCG -- Linear Congruence RNG

SYNOPSIS

#include <CNCL/LCG.h>

TYPE

CN_LCG

BASE CLASSES

CNRNG

DERIVED CLASSES

None

RELATED CLASSES

CNRandom

DESCRIPTION

CNLCG is a linear congruence random number generator class.

This class is using the easiest method for pseudo random number generator. It is the fastest one, but its short-comings should not be neglected. The period is very short, usually not sufficient for any serious simulation. Depending on the chosen seed value only even or odd numbers are drawn. Any period of drawn numbers are highly correlated. Thus this class should not be used at any important simulation.

Constructors:

CNLCG(unsigned long seed = 929);
CNLCG(CNParam *param);
Initializes CNLCG with initial seed.

In addition to the member functions required by CNCL, CNLCG 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 LCG produces only 31bit integer values.

virtual void reset();
Resets the CNLCG to its initial state.

void seed(unsigned long);
Sets the CNLCG seed value.

Go to the previous, next section.