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


CNRndInt -- Random Integers

SYNOPSIS

#include <CNCL/RndInt.h>

TYPE

CN_RNDINT

BASE CLASSES

CNObject

DERIVED CLASSES

None

RELATED CLASSES

CNRNG

DESCRIPTION

CNRndInt generates uniform distributed random integers in a given interval. The result is the same as provided by the CNDiscUniform distribution, but CNRndInt is more efficient.

BEWARE: do NOT use the CNLCG RNG as a base generator for CNRndInt.

Constructors:

CNRndInt();
CNRndInt(CNParam *param);
CNRndInt(long low, long high, CNRNG *gen);
CNRndInt(long high, CNRNG *gen);
CNRndInt(CNRNG *gen);
Initializes a CNRndInt with base RNG gen and upper/lower interval limits low/high.

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

CNRNG *generator() const;
CNRNG *generator(CNRNG *gen);
Gets/sets the base CNRNG used by CNRndInt.
long low() const;
long high() const;
long low(long x);
long high(long x);
Gets/sets the upper/lower interval limits.
long operator()();
long operator()(long high);
long operator()(long low, long high);
long as_long();
long as_long(long high);
long as_long(long low, long high);
Draws a long random integer. Interval limits may be passed as optional parameters.
int as_int();
int as_int(long high);
int as_int(long low, long high);
Draws a int random integer. Interval limits may be passed as optional parameters.


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