mardi 29 mars 2016

boost::random::variate_generator - Change parameters after construction

Is it possible to change the parameters of the distribution after the variate generator has been constructed? Let's take for example this simple setup

typedef boost::mt19937 base_gen_type;
typedef boost::uniform_int<int> dist_type;
typedef boost::variate_generator<base_gen_type &, dist_type> var_gen_type;

unsigned seed = 1337;
int a = 0, b = 42;

base_gen_type base_gen(seed);
dist_type dist(a, b);
var_gen_type rng(base_gen, dist);

If I wanted to change a and b, would this need a new var_gen_type object? The state of the base_gen would of course be unaffected but I wonder if there is a less complicated way.

Using dist_type & as a template parameter did not work.




Aucun commentaire:

Enregistrer un commentaire