|
TRIQS/TRIQS 4.0.0
Researching Interacting Quantum Systems
|
#include <triqs/mc_tools/random_generator.hpp>
Random number generator with a selectable underlying engine.
The following engine names are currently accepted by the constructor:
For non-empty names, the underlying engine is provided by boost.random.
For performance reasons, we use a buffer for the generated random numbers to avoid some of the costs of repeated function calls to the RNG.
Definition at line 71 of file random_generator.hpp.
Public Member Functions | |
| random_generator () | |
| Default constructor uses the mt19937 engine with the default seed. | |
| random_generator (random_generator &&)=default | |
| Default move constructor. | |
| random_generator (random_generator const &)=delete | |
| Deleted copy constructor. | |
| random_generator (std::string name, std::uint32_t seed, std::size_t buffer_size=1000) | |
| Construct a random generator by wrapping the specified RNG and seeding it with the given seed. | |
| std::string | name () const |
| Get the name of the underlying RNG. | |
| double | operator() () |
| Generate a random sample from the uniform distribution defined on the interval \( [0, 1) \). | |
| double | operator() (double a, double b) |
| Generate a random sample from the uniform distribution defined on the interval \( [a, b) \). | |
| double | operator() (double b) |
| Generate a random sample from the uniform distribution defined on the interval \( [0, b) \). | |
| template<typename T> requires (std::integral<T>) | |
| T | operator() (T i) |
| Generate a random sample from the uniform integer distribution defined on \( \{0, ..., i-1 \}\). | |
| random_generator & | operator= (random_generator &&)=default |
| Default move assignment operator. | |
| double | preview () |
| Look ahead at the next value that will be generated when the generator is called. | |
Static Public Member Functions | |
| static std::string | hdf5_format () |
| Get the HDF5 format tag. | |
Static Public Attributes | |
| static constexpr std::uint32_t | default_seed = 198 |
| Default seed for the underlying RNG. | |
Friends | |
| void | h5_read (h5::group g, std::string const &name, random_generator &rng) |
| Read the RNG object from HDF5. | |
| void | h5_write (h5::group g, std::string const &name, random_generator const &rng) |
| Write the RNG object to HDF5. | |
| triqs::mc_tools::random_generator::random_generator | ( | std::string | name, |
| std::uint32_t | seed, | ||
| std::size_t | buffer_size = 1000 ) |
Construct a random generator by wrapping the specified RNG and seeding it with the given seed.
The given name has to correspond to one of the supported engines. If the name does not match any of the supported engines, a runtime error is raised.
An empty name selects the built-in custom Mersenne Twister RNG.
| name | Name of the RNG to be used. |
| seed | Seed for the RNG. |
| buffer_size | Size of the buffer used to store random numbers. |
Definition at line 51 of file random_generator.cpp.
|
inline |
Generate a random sample from the uniform distribution defined on the interval \( [0, 1) \).
Definition at line 159 of file random_generator.hpp.
|
inline |
Generate a random sample from the uniform distribution defined on the interval \( [a, b) \).
| a | Lower bound of the interval. |
| b | Upper bound of the interval. |
Definition at line 178 of file random_generator.hpp.
|
inline |
Generate a random sample from the uniform distribution defined on the interval \( [0, b) \).
| b | Upper bound of the interval. |
Definition at line 169 of file random_generator.hpp.
|
inline |
Generate a random sample from the uniform integer distribution defined on \( \{0, ..., i-1 \}\).
| T | Integral type. |
| i | Upper bound (excluded). |
Definition at line 142 of file random_generator.hpp.
|
inlinenodiscard |
Look ahead at the next value that will be generated when the generator is called.
Definition at line 150 of file random_generator.hpp.
|
friend |
Read the RNG object from HDF5.
| g | h5::group to be read from. |
| name | Name of the dataset/subgroup. |
| rng | RNG object to be read into. |
Definition at line 211 of file random_generator.hpp.
|
friend |
Write the RNG object to HDF5.
| g | h5::group to be written to. |
| name | Name of the dataset/subgroup. |
| rng | RNG object to be written. |
Definition at line 193 of file random_generator.hpp.