SourcePro® API Reference Guide

 
Loading...
Searching...
No Matches
RWRandGenMCG59 Class Reference

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

#include <rw/randmcg59.h>

Inheritance diagram for RWRandGenMCG59:
RWRandGenBasicMLC

Public Member Functions

 RWRandGenMCG59 ()
 
 RWRandGenMCG59 (const RWRandGenMCG59 &u)
 
 RWRandGenMCG59 (unsigned long seed)
 
double operator() ()
 
RWRandGenMCG59operator= (const RWRandGenMCG59 &u)
 
- Public Member Functions inherited from RWRandGenBasicMLC
void printOn (std::ostream &s) const
 
void restoreFrom (RWFile &file)
 
void restoreFrom (RWvistream &s)
 
void saveOn (RWFile &file) const
 
void saveOn (RWvostream &s) const
 
void scanFrom (std::istream &s)
 

Additional Inherited Members

Detailed Description

Class RWRandGenMCG59 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. RWRandGenMCG59 is a 59-bit multiplicative congruential generator.

\[ \begin{align} x_{n} &= ax_{n-1}(\bmod m)\\ u_{n} &= x_{n}/m\\ a &= 13^{13}, m = 2^{59} \end{align} \]

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

Synopsis
#include <rw/randmcg59.h>
Generates random numbers uniformly distributed over the interval [0, 1].
Definition randmcg59.h:59

Constructor & Destructor Documentation

◆ RWRandGenMCG59() [1/3]

RWRandGenMCG59::RWRandGenMCG59 ( )
inline

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

◆ RWRandGenMCG59() [2/3]

RWRandGenMCG59::RWRandGenMCG59 ( unsigned long seed)
inline

Constructs a generator with a specified seed.

◆ RWRandGenMCG59() [3/3]

RWRandGenMCG59::RWRandGenMCG59 ( const RWRandGenMCG59 & u)
inline

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()()

double RWRandGenMCG59::operator() ( )
virtual

Returns a random double in [0,1].

Implements RWRandGenBasicMLC.

◆ operator=()

RWRandGenMCG59 & RWRandGenMCG59::operator= ( const RWRandGenMCG59 & u)
inline

Assigns a copy of u to self. 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.

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