SourcePro C++ 12.0 |
SourcePro® C++ API Reference Guide |
SourcePro C++ Documentation Home |
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) | |
double | operator() () |
void | restart () |
void | restart (long seed) |
void | reference (const RWRandGenerator &x) |
void | deepenShallowCopy () |
void | operator= (const RWRandGenerator &x) |
void | printOn (std::ostream &s) const |
void | scanFrom (std::istream &s) |
void | restoreFrom (RWFile &) |
void | restoreFrom (RWvistream &) |
void | saveOn (RWFile &) const |
void | saveOn (RWvostream &) const |
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.
#include <rw/randgen.h> RWRandGenerator gen;
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]
.
void 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 | ( | long | seed | ) |
Restarts the generator with the specified seed.
void RWRandGenerator::restart | ( | ) |
Restarts the generator with a random seed.
void RWRandGenerator::restoreFrom | ( | RWvistream & | ) |
Restores internal state of self from a virtual stream.
void RWRandGenerator::saveOn | ( | RWvostream & | ) | const |
Stores internal state of self to a virtual stream.
void RWRandGenerator::saveOn | ( | RWFile & | ) | const |
Stores internal state of self in a binary format to an RWFile.
void RWRandGenerator::scanFrom | ( | std::istream & | s | ) |
Inputs an internal state from istream s to self.
std::ostream & operator<< | ( | std::ostream & | s, | |
const RWRandGenerator & | rgen | |||
) | [related] |
Outputs a summary of the internal state of rgen on ostream s.
std::istream & operator>> | ( | std::istream & | s, | |
RWRandGenerator & | rgen | |||
) | [related] |
Inputs an internal state from istream s to rgen.
© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.