SourcePro® API Reference Guide

 
List of all members | Public Member Functions | Related Functions
RWRandGenMRG32K3A Class Reference

Generates random numbers uniformly distributed over the interval [0, 1]. More...

#include <rw/randmrg32k3a.h>

Public Member Functions

 RWRandGenMRG32K3A ()
 
 RWRandGenMRG32K3A (unsigned long seed)
 
 RWRandGenMRG32K3A (const RWRandGenMRG32K3A &u)
 
bool operator!= (const RWRandGenMRG32K3A &u) const
 
double operator() ()
 
RWRandGenMRG32K3Aoperator= (const RWRandGenMRG32K3A &u)
 
bool operator== (const RWRandGenMRG32K3A &u) const
 
void printOn (std::ostream &s) const
 
void restart ()
 
void restart (unsigned long seed)
 
void restoreFrom (RWFile &)
 
void restoreFrom (RWvistream &)
 
void saveOn (RWFile &) const
 
void saveOn (RWvostream &) const
 
void scanFrom (std::istream &s)
 
unsigned long seed () const
 

Related Functions

(Note that these are not member functions.)

std::ostream & operator<< (std::ostream &s, const RWRandGenMRG32K3A &gen)
 
std::istream & operator>> (std::istream &s, RWRandGenMRG32K3A &gen)
 

Detailed Description

Class RWRandGenMRG32K3A generates random numbers uniformly distributed over the interval [0, 1], and may be used instead of class RWRandGenerator as a template parameter to any of the distribution generators derived from abstract base class RWTRand. RWRandGenMRG32K3A is a combined multiple recursive generator with two components of order 3.

\[ \begin{align} x_{n} &= a_{11}x_{n-1} + a_{12}x_{n-2} + a_{13}x_{n-3}(\bmod m_{1})\\ y_{n} &= a_{21}y_{n-1} + a_{22}y_{n-2} + a_{23}y_{n-3}(\bmod m_{2})\\ z_{n} &= x_{n} - y_{n}(\bmod m_{1})\\ u_{n} &= z_{n}/m_{1}\\ a_{11} &= 0, a_{12} = 1403580, a_{13} = -810728, m_{1} = 2^{32}- 209 \end{align} \]

Unlike class RWRandGenerator, each instance of RWRandGenMRG32K3A contains and maintains its own, independent state. This can make it easier to use in some situations. The "internal state" of an instance of RWRandGenMRG32K3A consists of a seed and a series of six integers.

Synopsis
#include <rw/randmrg32k3a.h>

Constructor & Destructor Documentation

RWRandGenMRG32K3A::RWRandGenMRG32K3A ( )

Constructs a generator, arbitrarily seeded by a call to the time() function.

RWRandGenMRG32K3A::RWRandGenMRG32K3A ( unsigned long  seed)

Constructs a generator with a specified seed.

RWRandGenMRG32K3A::RWRandGenMRG32K3A ( const RWRandGenMRG32K3A u)

Constructs a copy of u. The copy's state will equal the state of u at the time the copy is created, but will not share the state of u.

Member Function Documentation

bool RWRandGenMRG32K3A::operator!= ( const RWRandGenMRG32K3A u) const

Returns true for two distinct instances of RWRandGenMRG32K3A if their internal states differ. "(x != x)" returns false.

double RWRandGenMRG32K3A::operator() ( )

Returns a random double in [0,1].

RWRandGenMRG32K3A& RWRandGenMRG32K3A::operator= ( const RWRandGenMRG32K3A u)

Sets an instance of RWRandGenMRG32K3A equal to the state of instance u.

bool RWRandGenMRG32K3A::operator== ( const RWRandGenMRG32K3A u) const

Returns true for two distinct instances of RWRandGenMRG32K3A if they will return identical sequences of values.

void RWRandGenMRG32K3A::printOn ( std::ostream &  s) const

Outputs a summary of self's internal state on ostream s.

void RWRandGenMRG32K3A::restart ( )

Restarts the generator, arbitrarily seeding it by a call to the time() function.

void RWRandGenMRG32K3A::restart ( unsigned long  seed)

Restarts the generator with specified seed.

void RWRandGenMRG32K3A::restoreFrom ( RWFile )

Restores internal state of self from an RWFile.

void RWRandGenMRG32K3A::restoreFrom ( RWvistream )

Restores internal state of self from a virtual stream.

void RWRandGenMRG32K3A::saveOn ( RWFile ) const

Stores internal state of self in a binary format to an RWFile.

void RWRandGenMRG32K3A::saveOn ( RWvostream ) const

Stores internal state of self to a virtual stream.

void RWRandGenMRG32K3A::scanFrom ( std::istream &  s)

Inputs an internal state from istream s to self.

unsigned long RWRandGenMRG32K3A::seed ( ) const

Returns the seed used to initialize the generator.

Friends And Related Function Documentation

std::ostream & operator<< ( std::ostream &  s,
const RWRandGenMRG32K3A gen 
)
related

Outputs a summary of gen's internal state on ostream s.

std::istream & operator>> ( std::istream &  s,
RWRandGenMRG32K3A gen 
)
related

Inputs an internal state from istream s to gen.

Copyright © 2022 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.