This class encapsulates a useful, consistent, cross-platform random number generator with multiple utilities. More...
#include <MooseRandom.h>
Public Member Functions | |
| void | seed (std::size_t i, unsigned int seed) |
| The method seeds one of the independent random number generators. | |
| Real | rand (std::size_t i) |
| This method returns the next random number (Real format) from the specified generator. | |
| Real | randNormal (std::size_t i, Real mean, Real sigma) |
| This method returns the next random number (Real format) from the specified generator, drawn from a normal distribution centered around mean, with a width of sigma. | |
| Real | randNormal (std::size_t i) |
| Return next random number drawn from a standard distribution. | |
| uint32_t | randl (std::size_t i) |
| This method returns the next random number (long format) from the specified generator. | |
| uint32_t | randl (std::size_t i, uint32_t lower, uint32_t upper) |
| This method returns the next random number (long format) from the specified generator within the supplied range. | |
| void | saveState () |
| This method saves the current state of all generators which can be restored at a later time (i.e. | |
| void | restoreState () |
| This method restores the last saved generator state. | |
| std::size_t | size () |
| Return the number of states. | |
Static Public Member Functions | |
| static void | seed (unsigned int seed) |
| The method seeds the random number generator. | |
| static Real | rand () |
| This method returns the next random number (Real format) from the generator. | |
| static Real | randNormal (Real mean, Real sigma) |
| This method returns the next random number (Real format) from the generator, drawn from a normal distribution centered around mean, with a width of sigma. | |
| static Real | randNormal () |
| Return next random number drawn from a standard distribution. | |
| static uint32_t | randl () |
| This method returns the next random number (long format) from the generator. | |
Private Attributes | |
| std::unordered_map< std::size_t, std::pair< mt_state, mt_state > > | _states |
| We store a pair of states in this map. | |
| bool | _saved = false |
| Flag to make certain that saveState is called prior to restoreState. | |
Friends | |
| void | dataStore (std::ostream &stream, MooseRandom &v, void *context) |
| void | dataLoad (std::istream &stream, MooseRandom &v, void *context) |
This class encapsulates a useful, consistent, cross-platform random number generator with multiple utilities.
Definition at line 37 of file MooseRandom.h.
|
inlinestatic |
This method returns the next random number (Real format) from the generator.
Definition at line 50 of file MooseRandom.h.
Referenced by RandomPartitioner::_do_partition(), RandomICBase::generateRandom(), RankTwoTensorTempl< T >::genRandomSymmTensor(), SymmetricRankTwoTensorTempl< T >::genRandomSymmTensor(), RandomInterface::getRandomReal(), and PropertyReadFile::initVoronoiCenterPoints().
|
inline |
This method returns the next random number (Real format) from the specified generator.
| i | the index of the generator |
Definition at line 85 of file MooseRandom.h.
|
inlinestatic |
This method returns the next random number (long format) from the generator.
Definition at line 71 of file MooseRandom.h.
Referenced by RandomInterface::getRandomLong(), Sampler::init(), RandomICBase::RandomICBase(), MooseUtils::resample(), MooseUtils::resampleWithFunctor(), MooseUtils::shuffle(), and RandomData::updateGenerators().
|
inline |
This method returns the next random number (long format) from the specified generator.
| i | the index of the generator |
Definition at line 116 of file MooseRandom.h.
|
inline |
This method returns the next random number (long format) from the specified generator within the supplied range.
| lower | lower bounds of value |
| upper | upper bounds of value |
| i | the index of the generator |
Definition at line 131 of file MooseRandom.h.
|
inlinestatic |
Return next random number drawn from a standard distribution.
Definition at line 65 of file MooseRandom.h.
Referenced by randNormal().
|
inlinestatic |
This method returns the next random number (Real format) from the generator, drawn from a normal distribution centered around mean, with a width of sigma.
| mean | center of the random number distribution |
| sigma | width of the random number distribution |
Definition at line 60 of file MooseRandom.h.
|
inline |
Return next random number drawn from a standard distribution.
Definition at line 109 of file MooseRandom.h.
Referenced by randNormal().
|
inline |
This method returns the next random number (Real format) from the specified generator, drawn from a normal distribution centered around mean, with a width of sigma.
| i | the index of the generator |
| mean | center of the random number distribution |
| sigma | width of the random number distribution |
Definition at line 100 of file MooseRandom.h.
|
inline |
This method restores the last saved generator state.
Definition at line 153 of file MooseRandom.h.
Referenced by RandomData::updateSeeds().
|
inline |
This method saves the current state of all generators which can be restored at a later time (i.e.
re-generate the same sequence of random numbers of this generator
Definition at line 141 of file MooseRandom.h.
Referenced by RandomData::updateSeeds().
|
inline |
The method seeds one of the independent random number generators.
| i | the index of the generator |
| seed | the seed number |
Definition at line 78 of file MooseRandom.h.
|
inlinestatic |
The method seeds the random number generator.
| seed | the seed number |
Definition at line 44 of file MooseRandom.h.
Referenced by Sampler::init(), RankTwoTensorTempl< T >::initRandom(), SymmetricRankTwoTensorTempl< T >::initRandom(), PropertyReadFile::initVoronoiCenterPoints(), MooseInit::MooseInit(), RandomICBase::RandomICBase(), RandomPartitioner::RandomPartitioner(), seed(), seed(), and RandomData::updateGenerators().
|
inline |
|
friend |
Definition at line 191 of file MooseRandom.h.
|
friend |
Definition at line 185 of file MooseRandom.h.
|
private |
Flag to make certain that saveState is called prior to restoreState.
Definition at line 180 of file MooseRandom.h.
Referenced by restoreState(), and saveState().
|
private |
We store a pair of states in this map.
The first one is the active state, the second is the backup state. It is used to restore state at a later time to the active state.
Definition at line 173 of file MooseRandom.h.
Referenced by rand(), randl(), randl(), randNormal(), restoreState(), saveState(), seed(), and size().