Code organization
Back to Example. Forward to The seed. Up to Contents.

Random manipulates one data arrays, the seed and the state. These are manages by the following classes:

For most purposes, users should ignore the existence of RandomSeed, RandomGenerator/RandomEngine, and RandomCanonical and access all the capabilities of these classes via thru the class Random which inherits all the needed functionality of its bases classes. This documentation reflects this recommendation. (In restricted applications, a user might wish to interface to the library via the lower-level RandomGenerator class as a source of random words.)

Unfortunately the relation between this classes is sufficiently complicated to defeat doxygen's indexing capabilities; if you need to look up the definition of one of Random's member functions, you can refer to the brief index in Function index.

Finally, distributions such as the normal and exponential distribution are provided by the classes NormalDistribution and ExponentialDistribution. They access the random data by being passed a Random object as an argument to operator().

These routines have been developed and tested with g++ version 3.4.x and 4.x under Linux 2.6.x on 32-bit Intel and 64-bit AMD CPUs, MS Visual Studio 2005, under Windows 2000, and g++ 4.x under Darwin on a PowerPC. Earlier versions of this library were tested with g++ on 64-bit SPARC platforms. Porting to other platforms with a standard C++ compiler and template library should be straightforward provided that the radix for integer and real types is 2.

(g++ 3.3.x cannot handle the overloaded template definitions properly. Contact me for possible workarounds for this version of g++.)

A note about portability. For the most part, the code uses portable C++. System dependencies creep into the computation of SeedVector and SeedWord (e.g., to access the PID and the high-precision clock). In addition, it's assumed that unsigned integers can be cast into signed integers preserving the bit pattern (assuming a twos-complement convention for signed numbers).

Back to Example. Forward to The seed. Up to Contents.