Template class wrapping a single random number generator function. More...
#include <MooseRandomStateless.h>
Public Member Functions | |
| Generator (std::function< T(mt_state *)> rng_func, unsigned int seed) | |
| Construct a new Generator with a function and seed. More... | |
| T | evaluate (std::size_t n) const |
| Evaluate the n-th random number in the sequence. More... | |
| void | advance (std::size_t count) |
| Advance the internal RNG state by a fixed count. More... | |
Private Member Functions | |
| void | advance (mt_state &state, std::size_t count) |
Advance a given RNG state count times. More... | |
Private Attributes | |
| const std::function< T(mt_state *)> | _rng_func |
| RNG function pointer. More... | |
| mt_state | _initial_state |
| Base RNG state (seeded) More... | |
| mt_state | _current_state |
| Cached working RNG state. More... | |
| std::size_t | _current_index |
| Index of next number to be generated. More... | |
Template class wrapping a single random number generator function.
| T | Output type of the RNG (e.g., Real or unsigned int) |
Each Generator stores:
Definition at line 182 of file MooseRandomStateless.h.
|
inline |
Construct a new Generator with a function and seed.
| rng_func | RNG function to apply to mt_state (e.g., mts_ldrand) |
| seed | Seed used to initialize the base state |
Definition at line 191 of file MooseRandomStateless.h.
|
inline |
Advance the internal RNG state by a fixed count.
This resets _current_state to _initial_state after advancing.
| count | Number of RNG calls to skip |
Definition at line 231 of file MooseRandomStateless.h.
Referenced by MooseRandomStateless::advance(), and MooseRandomStateless::Generator< Real >::advance().
|
inlineprivate |
Advance a given RNG state count times.
Definition at line 240 of file MooseRandomStateless.h.
|
inline |
Evaluate the n-th random number in the sequence.
Uses cached state when n >= _current_index for sequential access. If n < _current_index, it resets to the initial seed and recomputes.
| n | 0-based index in the random sequence |
Definition at line 209 of file MooseRandomStateless.h.
Referenced by MooseRandomStateless::rand(), and MooseRandomStateless::randl().
|
mutableprivate |
Index of next number to be generated.
Definition at line 253 of file MooseRandomStateless.h.
Referenced by MooseRandomStateless::Generator< Real >::advance(), MooseRandomStateless::Generator< Real >::evaluate(), and MooseRandomStateless::Generator< Real >::Generator().
|
mutableprivate |
Cached working RNG state.
Definition at line 251 of file MooseRandomStateless.h.
Referenced by MooseRandomStateless::Generator< Real >::advance(), MooseRandomStateless::Generator< Real >::evaluate(), and MooseRandomStateless::Generator< Real >::Generator().
|
private |
Base RNG state (seeded)
Definition at line 249 of file MooseRandomStateless.h.
Referenced by MooseRandomStateless::Generator< Real >::advance(), MooseRandomStateless::Generator< Real >::evaluate(), and MooseRandomStateless::Generator< Real >::Generator().
|
private |
RNG function pointer.
Definition at line 247 of file MooseRandomStateless.h.
Referenced by MooseRandomStateless::Generator< Real >::advance(), and MooseRandomStateless::Generator< Real >::evaluate().
1.8.14