Hello all,
A question regarding Boost's random number generators.
Here's a simple example use-case:
/////////////////////////////////////////////////////////
#include <iostream>
#include <vector>
#include
#include
using namespace std;
using namespace boost;
void generate_random_numbers(vector<double> &x,
mt19937 &rng)
{
BOOST_FOREACH(double &z, x)
z = uniform_real<double> (0.0, 5.0) (rng);
}
int main()
{
mt19937 rng;
vector<double> x;
x.resize(1000);
generate_random_numbers(x,rng);
for(size_t i=0;i!=10;++i)
cout << x.at(i) << endl;
// and now do something fun with x ... :-)
return 0;
}
/////////////////////////////////////////////////////////
The question is, how do I go about getting generate_random_numbers() to
use an _arbitrary_ random number generator instead of having to be
mt19937? In particular, is there a way to do this without needing to
have a template function?
Thanks & best wishes,
-- Joe