Celeritas
0.5.0-56+6b053cd
|
"Random" number generator that returns a sequence of values. More...
#include <SequenceEngine.hh>
Public Types | |
Type aliases | |
using | result_type = std::uint32_t |
using | VecResult = std::vector< result_type > |
using | LimitsT = std::numeric_limits< result_type > |
using | size_type = VecResult::size_type |
Public Member Functions | |
SequenceEngine (VecResult values) | |
Construct from a sequence of integers (the sequence to reproduce). | |
result_type | operator() () |
Get the next random value in the sequence. More... | |
size_type | count () const |
size_type | max_count () const |
Static Public Member Functions | |
static SequenceEngine | from_reals (Span< double const > values) |
Construct a sequence to nearly reproduce the given stream of reals. More... | |
static SequenceEngine | from_reals (std::initializer_list< double > values) |
Construct a sequence to nearly reproduce the given stream of reals. | |
Engine limits | |
static constexpr result_type | min () |
static constexpr result_type | max () |
"Random" number generator that returns a sequence of values.
This is useful for testing algorithms that expect a random stream on the host: you can specify the sequence of values to return. When the sequence is used up, the next operator call will raise an exception.
The factory function SequenceEngine::from_reals will create an integer sequence that exactly reproduces the given real numbers (which must be in the half-open interval \( [0, 1) \)) using the generate_canonical
function.
|
inlinestatic |
Construct a sequence to nearly reproduce the given stream of reals.
Values below 1e-64 will not be represented. Furthermore, some other values (see the RngEngine unit test) will not be exactly reproduced. All input values must be bounded in \( [0, 1) \) .
|
inline |
Get the next random value in the sequence.
This is designed to throw an error rather than dereference an off-the-end iterator even when debugging is disabled, since this class is only used inside of tests.