SourcePro® 2024.1 |
SourcePro® API Reference Guide |
Generates random numbers uniformly distributed over the interval [0, 1]
.
More...
#include <rw/randmcg31m1.h>
Public Member Functions | |
RWRandGenMCG31M1 () | |
RWRandGenMCG31M1 (const RWRandGenMCG31M1 &u) | |
RWRandGenMCG31M1 (unsigned long seed) | |
double | operator() () |
RWRandGenMCG31M1 & | operator= (const RWRandGenMCG31M1 &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 | |
Related Symbols inherited from RWRandGenBasicMLC | |
std::ostream & | operator<< (std::ostream &s, const RWRandGenBasicMLC &gen) |
std::istream & | operator>> (std::istream &s, RWRandGenBasicMLC &gen) |
Class RWRandGenMCG31M1 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.
RWRandGenMCG31M1 is a 31-bit multiplicative congruential generator.
\[ \begin{align} x_n &= ax_{n-1}(\bmod m)\\ u_n &= x_{n}/m\\ a &= 1132489760, m = 2^{31 - 1} \end{align} \]
Unlike RWRandGenerator, each instance of RWRandGenMCG31M1 contains and maintains its own, independent state. This can make it easier to use in some situations. The "internal state" of an instance of RWRandGenMCG31M1 consists of only a seed.
RWRandGenMCG31M1::RWRandGenMCG31M1 | ( | ) |
Constructs a generator, arbitrarily seeded by a call to the time() function.
RWRandGenMCG31M1::RWRandGenMCG31M1 | ( | unsigned long | seed | ) |
Constructs a generator with a specified seed.
|
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.
|
virtual |
Returns a random double in [0,1]
.
Implements RWRandGenBasicMLC.
|
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. |