Defines a multi-core random number generator and its operators.
More...
#include <rnd.h>
|
void | set_seed (int new_seed) |
|
int | get_seed () |
|
int | rnd_int (int lowerLimit, int upperLimit) |
|
float | rnd_flt (float min=0.0, float max=1.0) |
|
float | rnd_dbl (float min=0.0, float max=1.0) |
|
float | operator() (unsigned i) |
|
float | operator() () |
|
template<class RandomAccessIterator > |
void | shuffle (RandomAccessIterator first, RandomAccessIterator last) |
|
template<typename Iter > |
Iter | select_randomly (Iter start, Iter end) |
|
template<typename T > |
T | random_choice (const vector< T > &v) |
|
template<typename T , typename D > |
T | random_choice (const vector< T > &v, const vector< D > &w) |
|
float | gasdev () |
|
|
vector< std::mt19937 > | rg |
|
int | seed |
|
Defines a multi-core random number generator and its operators.
Definition at line 30 of file rnd.h.
◆ Rnd()
need a random generator for each core to do multiprocessing
Definition at line 14 of file rnd.cc.
◆ ~Rnd()
◆ destroy()
void FT::Util::Rnd::destroy |
( |
| ) |
|
|
static |
◆ gasdev()
float FT::Util::Rnd::gasdev |
( |
| ) |
|
◆ get_seed()
int FT::Util::Rnd::get_seed |
( |
| ) |
|
|
inline |
Definition at line 40 of file rnd.h.
◆ initRand()
Rnd * FT::Util::Rnd::initRand |
( |
| ) |
|
|
static |
◆ operator()() [1/2]
float FT::Util::Rnd::operator() |
( |
| ) |
|
◆ operator()() [2/2]
float FT::Util::Rnd::operator() |
( |
unsigned |
i | ) |
|
◆ random_choice() [1/2]
template<typename T >
T FT::Util::Rnd::random_choice |
( |
const vector< T > & |
v | ) |
|
|
inline |
return a random element of a vector.
Definition at line 73 of file rnd.h.
◆ random_choice() [2/2]
template<typename T , typename D >
T FT::Util::Rnd::random_choice |
( |
const vector< T > & |
v, |
|
|
const vector< D > & |
w |
|
) |
| |
|
inline |
return a weighted random element of a vector
Definition at line 85 of file rnd.h.
◆ rnd_dbl()
float FT::Util::Rnd::rnd_dbl |
( |
float |
min = 0.0 , |
|
|
float |
max = 1.0 |
|
) |
| |
◆ rnd_flt()
float FT::Util::Rnd::rnd_flt |
( |
float |
min = 0.0 , |
|
|
float |
max = 1.0 |
|
) |
| |
◆ rnd_int()
int FT::Util::Rnd::rnd_int |
( |
int |
lowerLimit, |
|
|
int |
upperLimit |
|
) |
| |
◆ select_randomly()
template<typename Iter >
Iter FT::Util::Rnd::select_randomly |
( |
Iter |
start, |
|
|
Iter |
end |
|
) |
| |
|
inline |
Definition at line 64 of file rnd.h.
◆ set_seed()
void FT::Util::Rnd::set_seed |
( |
int |
new_seed | ) |
|
set seeds for each core's random number generator
Definition at line 41 of file rnd.cc.
◆ shuffle()
template<class RandomAccessIterator >
void FT::Util::Rnd::shuffle |
( |
RandomAccessIterator |
first, |
|
|
RandomAccessIterator |
last |
|
) |
| |
|
inline |
Definition at line 53 of file rnd.h.
◆ instance
Rnd * FT::Util::Rnd::instance = NULL |
|
staticprivate |
◆ rg
vector<std::mt19937> FT::Util::Rnd::rg |
|
private |
◆ seed
The documentation for this class was generated from the following files: