LCG Class Reference

A linear conguential random number generator class. More...

#include <LCG.h>

Inheritance diagram for LCG::

RNG List of all members.

Public Methods

 LCG (unsigned short seed=0)
 Constructor. More...

void reseed (unsigned seed)
 Reseed the rng with a new seed value.

unsigned short getSeed ()
 Returns the seed used to initialize the rng.

virtual void reset ()
 Reset the number generator to prepare it for use.

virtual unsigned long asLong ()
 Return a long in 0 ... LONG_MAX.

virtual int write (std::ostream &output) const
 Write the rng state to an output stream.

virtual int read (std::istream &input)
 Read an rng state from an input stream.


Private Attributes

unsigned short State [3]
 The state for this rng.

unsigned short Seed
 Use to initialize the generator. More...


Detailed Description

A linear conguential random number generator class.

This is a simple wrapper for the Unix nrand48 routine, and thus it is somewhat portable.


Constructor & Destructor Documentation

LCG::LCG unsigned short    seed = 0
 

Constructor.

If no argument is provided, the seed is set to zero, so the rng is initialized with the current time information.


Member Data Documentation

unsigned short LCG::Seed [private]
 

Use to initialize the generator.

If zero, time is used to generate the random seed.


The documentation for this class was generated from the following file: