xso::generator
— Read Access to the State
We have methods that provide read-only access to the state:
1constexpr word_type operator[](std::size_t i) const;
template<typename Iter>
2constexpr void get_state(Iter dst) const;
- 1
-
Read-only access to the word
i
of state. - 2
-
Copies the whole state into the destination
dst
.
The index i should be less than word_count() . Calls with larger values of i will result in undefined behaviour.
|
Example:
#include <xoshiro.h>
int main()
{
1::rng g0(1);
xso::rng g1(2);
xso
for(std::size_t i = 0; i < xso::rng::word_count(); ++i) {
2std::cout << "g0[" << i << "] = " << g0[i] << '\t';
std::cout << "g1[" << i << "] = " << g1[i] << '\n';
}
}
- 1
- Create a pair of generators that are seeded from neighbouring integers.
- 2
- Print each word of state for the two generators.
Output: Varies from run to run
1g0[0] = 2973750756608955175 g1[0] = 17576013672004619970
g0[1] = 11413743089567126834 g1[1] = 16442790642303457438
g0[2] = 4383533935485149688 g1[2] = 3610580237369810524
g0[3] = 3535799440905119283 g1[3] = 11046704898693758421
- 1
-
Seeded
g0
andg1
with neighbouring values.
SplitMix64
was used to mix those seeds up and get them to very different underlying state arrays.