SourcePro® 2022.1 |
SourcePro® API Reference Guide |
Generates random numbers uniformly distributed over the interval [0, 1]
.
More...
#include <rw/randgen.h>
Public Member Functions | |
RWRandGenerator () | |
RWRandGenerator (long seed) | |
RWRandGenerator (const RWRandGenerator &x) | |
void | deepenShallowCopy () |
double | operator() () |
RWRandGenerator & | operator= (const RWRandGenerator &x) |
void | printOn (std::ostream &s) const |
void | reference (const RWRandGenerator &x) |
void | restart () |
void | restart (long seed) |
void | restoreFrom (RWFile &) |
void | restoreFrom (RWvistream &) |
void | saveOn (RWFile &) const |
void | saveOn (RWvostream &) const |
void | scanFrom (std::istream &s) |
Related Functions | |
(Note that these are not member functions.) | |
std::ostream & | operator<< (std::ostream &s, const RWRandGenerator &rgen) |
std::istream & | operator>> (std::istream &s, RWRandGenerator &rgen) |
Class RWRandGenerator generates random numbers uniformly distributed over the interval [0, 1]
. RWRandGenerator objects can be independent or share state with each other. The Essential Math Module contains a global default state that is shared by all generators created with the default constructor. Using the default generator state does not guarantee repeatable sequences, even if you restart() it using a specific seed. This is because the global state may be shared among several applications in a multithreaded environment. There is no protection against multiple threads of control using the global default state at the same time. To achieve repeatable sequences, you must construct a generator with a specific seed value and use the generator for random number generation.
RWRandGenerator::RWRandGenerator | ( | ) |
Constructs a generator with the shared global default state.
RWRandGenerator::RWRandGenerator | ( | long | seed | ) |
Constructs a generator with specified initial seed. The generator has its own state.
RWRandGenerator::RWRandGenerator | ( | const RWRandGenerator & | x | ) |
Constructs a copy of x. The generators share state.
void RWRandGenerator::deepenShallowCopy | ( | ) |
Makes the state independent, but doesn't change it.
double RWRandGenerator::operator() | ( | ) |
Returns a random double in [0, 1]
.
RWRandGenerator& RWRandGenerator::operator= | ( | const RWRandGenerator & | x | ) |
Sets state to argument's state.
void RWRandGenerator::printOn | ( | std::ostream & | s | ) | const |
Outputs a summary of self's internal state on ostream s.
void RWRandGenerator::reference | ( | const RWRandGenerator & | x | ) |
Sets state to argument's state.
void RWRandGenerator::restart | ( | ) |
Restarts the generator with a random seed.
void RWRandGenerator::restart | ( | long | seed | ) |
Restarts the generator with the specified seed.
void RWRandGenerator::restoreFrom | ( | RWvistream & | ) |
Restores internal state of self from a virtual stream.
void RWRandGenerator::saveOn | ( | RWFile & | ) | const |
Stores internal state of self in a binary format to an RWFile.
void RWRandGenerator::saveOn | ( | RWvostream & | ) | const |
Stores internal state of self to a virtual stream.
void RWRandGenerator::scanFrom | ( | std::istream & | s | ) |
Inputs an internal state from istream s to self.
|
related |
Outputs a summary of the internal state of rgen on ostream s.
|
related |
Inputs an internal state from istream s to rgen.
Copyright © 2022 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved. |