Loading...
Searching...
No Matches
casacore::MLCG Class Reference
casa package (libcasa_casa) » BasicMath_module

Multiplicative linear congruential generator. More...

`#include <Random.h>`

## Public Member Functions

| MLCG (Int seed1=0, Int seed2=1)
| The constructor allows you to specify seeds.
virtual | ~MLCG ()
| The destructor is trivial.
virtual uInt | asuInt ()
| Return the 32-random bits as an unsigned integer.
virtual void | reset ()
| Resets the random number generator.
Int | seed1 () const
| Functions that allow the user to retrieve or change the seed integers.
void | seed1 (Int s)
Int | seed2 () const
void | seed2 (Int s)
void | reseed (Int s1, Int s2)
Public Member Functions inherited from casacore::RNG
virtual | ~RNG ()
| A virtual destructor is needed to ensure that the destructor of derived classes gets used.
Float | asFloat ()
| Return random bits converted to either a Float or a Double.
Double | asDouble ()

## Private Attributes

Int | itsInitSeedOne
Int | itsInitSeedTwo
Int | itsSeedOne
Int | itsSeedTwo

## Detailed Description

Multiplicative linear congruential generator.

### Intended use:

Public interface

### Review Status

Reviewed By:
  UNKNOWN
Date Reviewed:
  before2004/08/25

### Prerequisite

- A knowledge of C++, in particular inheritance
- College level mathematics

### Etymology

MLCG stands for "Multiplicative Linear Congruential Generator"

### Synopsis

The MLCG class implements a Multiplicative Linear Congruential Generator. In particular, it is an implementation of the double MLCG described in Efficient and Portable Combined Random Number Generators by Pierre L'Ecuyer, appearing in Communications of the ACM, Vol. 31. No. 6. This generator has a fairly long period, and has been statistically analyzed to show that it gives good inter-sample independence.

The constructor has two parameters, both of which are seeds for the generator. As in the ACG generator, both seeds are modified to give a "better" distribution of seed digits. Thus, you can safely use values such as 0 or 1 for the seeds. The MLCG generator used much less state than the ACG generator; only two integers (8 bytes) are needed for each generator.

Warning: This class assumes that the integer and unsigned integer type is exactly 32 bits long;

### Example

### Thrown Exceptions

- AipsError: If a programming error or unexpected numeric size is detected. Should not occur in normal usage.

### To Do

- Nothing I hope!

Definition at line 304 of file Random.h.

## Constructor & Destructor Documentation

## MLCG()

casacore::MLCG::MLCG | ( | Int | seed1 = 0,
|  | Int | seed2 = 1 )

explicit

The constructor allows you to specify seeds.

References seed1(), and seed2().

## ~MLCG()

virtual casacore::MLCG::~MLCG | ( |  | ) |

virtual

The destructor is trivial.

## Member Function Documentation

## asuInt()

virtual uInt casacore::MLCG::asuInt | ( |  | ) |

virtual

Return the 32-random bits as an unsigned integer.

Implements casacore::RNG.

## reseed()

void casacore::MLCG::reseed | ( | Int | s1,
|  | Int | s2 )

inline

Definition at line 361 of file Random.h.

References itsInitSeedOne, itsInitSeedTwo, and reset().

## reset()

virtual void casacore::MLCG::reset | ( |  | ) |

virtual

Resets the random number generator.

After calling this function the random numbers generated will be the same as if the object had just been constructed.

Implements casacore::RNG.

Referenced by reseed(), seed1(), and seed2().

## seed1() [1/2]

Int casacore::MLCG::seed1 | ( |  | ) | const

inline

Functions that allow the user to retrieve or change the seed integers.

The seeds returned are not the user supplied values but the values obtained after some deterministic modification to produce a more uniform bit distribution.

Definition at line 339 of file Random.h.

References itsSeedOne.

Referenced by MLCG().

## seed1() [2/2]

void casacore::MLCG::seed1 | ( | Int | s | ) |

inline

Definition at line 344 of file Random.h.

References itsInitSeedOne, and reset().

## seed2() [1/2]

Int casacore::MLCG::seed2 | ( |  | ) | const

inline

Definition at line 350 of file Random.h.

References itsSeedTwo.

Referenced by MLCG().

## seed2() [2/2]

void casacore::MLCG::seed2 | ( | Int | s | ) |

inline

Definition at line 355 of file Random.h.

References itsInitSeedTwo, and reset().

## Member Data Documentation

## itsInitSeedOne

Int casacore::MLCG::itsInitSeedOne

private

Definition at line 333 of file Random.h.

Referenced by reseed(), and seed1().

## itsInitSeedTwo

Int casacore::MLCG::itsInitSeedTwo

private

Definition at line 334 of file Random.h.

Referenced by reseed(), and seed2().

## itsSeedOne

Int casacore::MLCG::itsSeedOne

private

Definition at line 335 of file Random.h.

Referenced by seed1().

## itsSeedTwo

Int casacore::MLCG::itsSeedTwo

private

Definition at line 336 of file Random.h.

Referenced by seed2().

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

- casa/BasicMath/Random.h