|
template<class R , typename T = uint64_t, typename S = uint64_t> |
| pcg32_cumsum (const R &shape, T initstate=0x853c49e6748fea9bULL, S initseq=0xda3e39cb94b95bdbULL, enum distribution distribution=distribution::custom, const std::vector< double > ¶meters=std::vector< double >{}, const alignment &align=alignment()) |
|
void | set_functions (std::function< Data(size_t)> get_chunk, std::function< double(size_t)> get_cumsum, bool uses_generator=true) |
| Use external functions to draw the random numbers.
|
|
| pcg32_cumsum (const pcg32_cumsum &other) |
| Copy constructor.
|
|
void | operator= (const pcg32_cumsum &other) |
| Copy constructor.
|
|
bool | is_extendible () const |
| true if the chunk is extendible.
|
|
const pcg32_index & | generator () const |
| Pointer to the generator.
|
|
const auto & | shape () const |
| Shape of the chunk.
|
|
auto | size () const |
| Size of the chunk.
|
|
template<class T > |
pcg32_cumsum & | operator+= (const T &value) |
| Add value(s) to the chunk.
|
|
template<class T > |
pcg32_cumsum & | operator-= (const T &value) |
| Subtract value(s) from the chunk.
|
|
const Data & | data () const |
| The current chunk of the cumsum of random numbers.
|
|
void | set_data (const Data &data) |
| Overwrite the current chunk of the cumsum of random numbers.
|
|
ptrdiff_t | start () const |
| Global index of the first element in the chunk.
|
|
void | set_start (ptrdiff_t index) |
| Set global index of the first element in the chunk.
|
|
ptrdiff_t | index_at_align () const |
| Global index of target (the last time prrng::pcg32_cumsum::align() was called).
|
|
ptrdiff_t | chunk_index_at_align () const |
| Index of target relative to the beginning of the chunk (the last time prrng::pcg32_cumsum::align() was called).
|
|
double | left_of_align () const |
| Return the value of the cumsum left of the target (the last time prrng::pcg32_cumsum::align() was called).
|
|
double | right_of_align () const |
| Return the value of the cumsum right of the target (the last time prrng::pcg32_cumsum::align() was called).
|
|
uint64_t | state_at (ptrdiff_t index) |
| The current "state" of the generator.
|
|
void | restore (uint64_t state, double value, ptrdiff_t index) |
| Restore a specific state in the cumulative sum.
|
|
bool | contains (double target) const |
| Check if the chunk contains a target.
|
|
void | prev (size_t margin=0) |
| Shift chunk left.
|
|
void | next (size_t margin=0) |
| Shift chunk right.
|
|
void | align (double target) |
| Align the chunk to encompass a target value.
|
|
template<class Data>
class prrng::pcg32_cumsum< Data >
Generator of a random cumulative sum of which a chunk is kept in memory.
The random number generated by the pcg32 algorithm.
Suppose that cumsum
is the unlimited cumulative of random numbers starting from a seed, then a chunk gen.data() == cumsum[gen.start() : gen.start() + gen.size()]
is kept in memory by this class. The chunk that is kept in memory can be changed by calling:
Note that if the current chunk is far away from the seed a quick way to restore it without drawing all random numbers from the seed is to call prrng::pcg32_cumsum::restore(). Note that you need to know one value and its index.
- Template Parameters
-
Definition at line 3504 of file prrng.h.
Global index of target
(the last time prrng::pcg32_cumsum::align() was called).
Suppose that cumsum
is the unlimited cumsum of random numbers starting from a seed, then:
gen.left_of_align() == cumsum[gen.index_at_align()] <= target
.
gen.right_of_align() == cumsum[gen.index_at_align() + 1] > target
.
Note thought that cumsum
is not constructed by this class, that instead only holds a chunk gen.data() == cumsum[gen.start():gen.start() + gen.size()]
.
- Returns
- Global index.
Definition at line 3826 of file prrng.h.