<tt>xoshiro
Loading...
Searching...
No Matches
xso::partition< RNG >

Partition a random number stream into a number of non-overlapping sub-streams. More...

#include <xoshiro.h>

Public Member Functions

 partition (const RNG &rng, std::size_t n_partitions)
 Constructs a partition for the passed parent random number generator rng.
RNG next ()
 Returns the next generator that is seeded at the start of the next sub-stream of the parent random number stream.

Detailed Description

template<typename RNG>
class xso::partition< RNG >

Partition a random number stream into a number of non-overlapping sub-streams.

The RNG template parameter should be a PRNG that defines an appropriate jump method.

Given a parent random number generator we can split its random number stream into a number of non-overlapping partitions. The substreams are just independent random number generators of the same type as the parent but seeded at the start of each partition. Each call to the partition's next() method returns the next such generator.

Constructor & Destructor Documentation

◆ partition()

template<typename RNG>
xso::partition< RNG >::partition ( const RNG & rng,
std::size_t n_partitions )
inline

Constructs a partition for the passed parent random number generator rng.

The stream from the parent rng is split into n_partitions non-overlapping sub-streams where each sub-stream is as large as possible. The substreams are actually independent random number generators of the same type as the paren but seeded at the start of each partition. Each call to the next() method returns the next such generator.

NOTE: The requested number of partitions is silently adjusted if it is zero.