OpenMS
Loading...
Searching...
No Matches
RandomShuffler Class Reference

Portable random shuffle with a reproducible, platform-independent random sequence. More...

#include <OpenMS/MATH/MathFunctions.h>

Public Member Functions

 RandomShuffler ()=default
 Default constructor; the engine starts from its default seed.
 
 RandomShuffler (int seed)
 Constructor seeding the engine with seed.
 
template<class RandomAccessIterator >
void portable_random_shuffle (RandomAccessIterator first, RandomAccessIterator last)
 
void seed (uint64_t value)
 

Private Member Functions

std::ptrdiff_t randomIndex_ (std::ptrdiff_t upper)
 A uniform index in [0, upper], drawn so that every platform gets the same one.
 

Private Attributes

std::mt19937_64 rng_
 

Detailed Description

Portable random shuffle with a reproducible, platform-independent random sequence.

The engine is the standard MT19937-64; the index distribution that makes the sequence platform-independent is drawn in the implementation. A copy continues the sequence independently of its source.

Constructor & Destructor Documentation

◆ RandomShuffler() [1/2]

RandomShuffler ( )
default

Default constructor; the engine starts from its default seed.

◆ RandomShuffler() [2/2]

RandomShuffler ( int  seed)
inlineexplicit

Constructor seeding the engine with seed.

Member Function Documentation

◆ portable_random_shuffle()

template<class RandomAccessIterator >
void portable_random_shuffle ( RandomAccessIterator  first,
RandomAccessIterator  last 
)
inline

References first.

Referenced by RANSAC< TModelType >::ransac().

◆ randomIndex_()

std::ptrdiff_t randomIndex_ ( std::ptrdiff_t  upper)
private

A uniform index in [0, upper], drawn so that every platform gets the same one.

◆ seed()

void seed ( uint64_t  value)
inline

Member Data Documentation

◆ rng_

std::mt19937_64 rng_
private