Dear List,
I am using the following (typical) code to use boost::random
---------------------------------------------
typedef boost::mt19937 generator_type;
typedef boost::variate_generator rand01Generator;
generator_type random_gen;
boost::uniform_real<double> distrib(0.0, 1.0);
rand01Generator rand01(random_gen, distrib);
----------------------------------------------
I would like to give users the ability to choose random number generators
through something like:
// global generator that is being used everywhere
generator global_generator;
void setGenerator(string type)
{
if(type == "mt19937")
global_generator = ...
...
}
However, the generators are templates so the type of global generator
can not be specified. Is there any workaround? It seems that a wrapper
class with instances of all available generators and some if-else
code can do this but there should be better ideas.
Many thanks in advance.
Bo