prrng 1.12.1
|
Array of generators of which a chunk of random numbers is kept in memory. More...
#include <prrng.h>
Public Types | |
using | size_type = typename Data::size_type |
Size type of the data container. | |
Public Member Functions | |
pcg32_arrayBase_chunkBase (const pcg32_arrayBase_chunkBase &other) | |
Copy constructor. | |
void | operator= (const pcg32_arrayBase_chunkBase &other) |
Copy constructor. | |
template<class T > | |
pcg32_arrayBase_chunkBase & | operator+= (const T &values) |
Add values to each chunk. | |
template<class T > | |
pcg32_arrayBase_chunkBase & | operator-= (const T &values) |
Subtract values from each chunk. | |
bool | is_extendible () const |
true if the chunk is extendible. | |
size_type | chunk_size () const |
Size of the chunk per generator. | |
const Generator & | generators () const |
Reference to the underlying generators. | |
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. | |
const Index & | start () const |
Global index of the first element in the chunk. | |
void | set_start (const Index &index) |
Set global index of the first element in the chunk. | |
void | align_at (const Index &index) |
Get the index random number, which index specified per generator. | |
Index | index_at_align () const |
Global index of target (the last time prrng::pcg32_cumsum::align() was called). | |
const Index & | chunk_index_at_align () const |
Index of target relative to the beginning of the chunk (the last time prrng::pcg32_cumsum::align() was called). | |
template<class R > | |
void | left_of_align (R &ret) const |
Return the value of the cumsum left of the target (the last time prrng::pcg32_cumsum::align() was called). | |
template<class R > | |
void | right_of_align (R &ret) const |
Return the value of the cumsum right of the target (the last time prrng::pcg32_cumsum::align() was called). | |
template<class R > | |
R | left_of_align () const |
Return the value of the cumsum left of the target (the last time prrng::pcg32_cumsum::align() was called). | |
template<class R > | |
R | right_of_align () const |
Return the value of the cumsum right of the target (the last time prrng::pcg32_cumsum::align() was called). | |
template<class R , class T > | |
R | state_at (const T &index) |
The current "state" of the generator. | |
Protected Member Functions | |
template<class S , class T , class U > | |
void | init (const S &shape, const T &initstate, const U &initseq, enum distribution distribution, const std::vector< double > ¶meters, const alignment &align=alignment()) |
Constructor. | |
void | auto_functions () |
Set draw function. | |
void | copy_from (const pcg32_arrayBase_chunkBase &other) |
Copy constructor. | |
Protected Attributes | |
Generator | m_gen |
Array of generators. | |
Data | m_data |
Data container. | |
std::vector< std::function< xt::xtensor< double, 1 >(size_t)> > | m_draw |
Function to draw the next chunk of n random numbers starting from the curent state of the generator. | |
std::vector< std::function< double(size_t)> > | m_sum |
Function to get the cumsum of n random numbers starting from the curent state of the generator (used to skip allocating an list of size n ). | |
bool | m_extendible |
Signal if the drawing functions are specified, implying that the chunk can be changed. | |
alignment | m_align |
alignment settings, see prrng::alignment(). | |
distribution | m_distro |
Distribution name, see prrng::distribution(). | |
std::array< double, 3 > | m_param |
Distribution parameters. | |
Index | m_start |
Start index of the chunk. | |
Index | m_i |
Last known index of target in align. | |
size_t | m_n |
Size of the chunk. | |
Array of generators of which a chunk of random numbers is kept in memory.
Generator | Storage of the generator array, e.g. prrng::pcg32_tensor<N>. |
Data | Storage of the data, e.g. xt::xtensor<double, N + n>. |
Index | Storage of the index, e.g. xt::xtensor<ptrdiff_t, N>. |
using prrng::pcg32_arrayBase_chunkBase< Generator, Data, Index, is_cumsum >::size_type = typename Data::size_type |
|
inline |
|
inline |
Get the index
random number, which index
specified per generator.
alignment::min_margin
and alignment::strict
are not relevant: alignment is always exact.R | Return type. |
index | Index of the random number. |
|
inlineprotected |
|
inline |
Index of target
relative to the beginning of the chunk (the last time prrng::pcg32_cumsum::align() was called).
The currently held chunk of the cumsum of random numbers is is gen.data()
. As such,
gen.left_of_align() == gen.data()[gen.chunk_index_at_align()] <= target
.gen.right_of_align() == gen.data()[gen.chunk_index_at_align() + 1] > target
.
|
inline |
|
inlineprotected |
|
inline |
|
inline |
|
inline |
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()]
.
|
inlineprotected |
Constructor.
shape | Shape of the chunk to keep in memory per generator. |
initstate | State initiator for every item. |
initseq | Sequence initiator for every item. |
distribution | Distribution. |
parameters | Parameters for the distribution: appended by the following defaults if needed. |
align | Alignment parameters, see prrng::alignment(). |
|
inline |
|
inline |
Return the value of the cumsum left of the target
(the last time prrng::pcg32_cumsum::align() was called).
gen.left_of_align() == gen.data()[gen.chunk_index_at_align()] <= target
.
|
inline |
Return the value of the cumsum left of the target
(the last time prrng::pcg32_cumsum::align() was called).
ret | Array to store the result in. |
|
inline |
|
inline |
|
inline |
|
inline |
Return the value of the cumsum right of the target
(the last time prrng::pcg32_cumsum::align() was called).
gen.right_of_align() == gen.data()[gen.chunk_index_at_align() + 1] > target
.
|
inline |
Return the value of the cumsum right of the target
(the last time prrng::pcg32_cumsum::align() was called).
ret | Array to store the result in. |
|
inline |
Overwrite the current chunk of the cumsum of random numbers.
Please check if set_state() or set_start() should be called too.
data | The chunk. |
|
inline |
|
inline |
|
inline |
The current "state" of the generator.
If the same initseq() is used, this exact point in the sequence can be restored with restore().
R | use a different return-type. There are some internal checks if the type is able to store the internal state of type uint64_t . |
|
protected |
alignment settings, see prrng::alignment().
|
protected |
|
protected |
Distribution name, see prrng::distribution().
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |