SourcePro® API Reference Guide

 
Loading...
Searching...
No Matches
RWRandGenMRG32K3A Class Reference

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

#include <rw/randmrg32k3a.h>

Public Member Functions

 RWRandGenMRG32K3A ()
 
 RWRandGenMRG32K3A (const RWRandGenMRG32K3A &u)
 
 RWRandGenMRG32K3A (unsigned long seed)
 
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 Symbols

(Note that these are not member symbols.)

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>
Generates random numbers uniformly distributed over the interval [0, 1].
Definition randmrg32k3a.h:64

Constructor & Destructor Documentation

◆ RWRandGenMRG32K3A() [1/3]

RWRandGenMRG32K3A::RWRandGenMRG32K3A ( )

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

◆ RWRandGenMRG32K3A() [2/3]

RWRandGenMRG32K3A::RWRandGenMRG32K3A ( unsigned long seed)

Constructs a generator with a specified seed.

◆ RWRandGenMRG32K3A() [3/3]

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

◆ operator!=()

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

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

◆ operator()()

double RWRandGenMRG32K3A::operator() ( )

Returns a random double in [0,1].

◆ operator=()

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

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

◆ operator==()

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

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

◆ printOn()

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

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

◆ restart() [1/2]

void RWRandGenMRG32K3A::restart ( )

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

◆ restart() [2/2]

void RWRandGenMRG32K3A::restart ( unsigned long seed)

Restarts the generator with specified seed.

◆ restoreFrom() [1/2]

void RWRandGenMRG32K3A::restoreFrom ( RWFile & )

Restores internal state of self from an RWFile.

◆ restoreFrom() [2/2]

void RWRandGenMRG32K3A::restoreFrom ( RWvistream & )

Restores internal state of self from a virtual stream.

◆ saveOn() [1/2]

void RWRandGenMRG32K3A::saveOn ( RWFile & ) const

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

◆ saveOn() [2/2]

void RWRandGenMRG32K3A::saveOn ( RWvostream & ) const

Stores internal state of self to a virtual stream.

◆ scanFrom()

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

Inputs an internal state from istream s to self.

◆ seed()

unsigned long RWRandGenMRG32K3A::seed ( ) const

Returns the seed used to initialize the generator.

Friends And Related Symbol Documentation

◆ operator<<()

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

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

◆ operator>>()

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

Inputs an internal state from istream s to gen.

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