Added the eoRandomReduce class - hence I also added the shuffle method
in eoPop (I had been postponing that for a long time!) which in turn required another class of random generator (whose operator() takes an unsigned as argument)
This commit is contained in:
parent
f988b42fed
commit
a8bf667774
1 changed files with 17 additions and 0 deletions
|
|
@ -112,6 +112,23 @@ bool random_generator<bool>::operator()(void)
|
|||
return random.flip(0.5);
|
||||
}
|
||||
|
||||
/**
|
||||
Another class random_generator that can be used in the STL random_shuffle
|
||||
function (see eoPop::shuffle): its operator() takes an unsigned argument m
|
||||
and must return an unsigned uniformly distributed in [0,m}
|
||||
*/
|
||||
template <class T = uint32> class UF_random_generator
|
||||
{
|
||||
public :
|
||||
UF_random_generator(eoRng& _rng = rng) :
|
||||
random(_rng) {}
|
||||
|
||||
T operator()(T _t) { return (T) (random.random(_t)); }
|
||||
|
||||
private :
|
||||
eoRng& random;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
The class normal_generator can be used in the STL generate function
|
||||
|
|
|
|||
Reference in a new issue