Boost logo

Boost Users :

Subject: [Boost-users] [random] number generator as static class member
From: Moritz Beber (moritz.beber_at_[hidden])
Date: 2010-02-13 20:32:29


Dear list users,
I have attached a reduced case of what I want to do. Basically, I
thought it would be a good idea to have one general number generator
that I attach to specific distributions in my member functions according
to my needs (uniform_01 in this example, but I also want to use others).
So for example I do the following in my real code, where 'rng' is my
static member object:

typedef boost::lagged_fibonacci607 rand_gen;

boost::bernoulli_distribution<double> b_dist(p);
boost::variate_generator<rand_gen&,
boost::bernoulli_distribution<double> > bool_gen(MyClass::rng, b_dist);

boost::uniform_smallint<short unsigned> in_dist(0, this->nodes_in - 1);
boost::variate_generator<rand_gen&, boost::uniform_smallint<short
unsigned> > in_gen(MyClass::rng, in_dist);

Unfortunately, as the code I attached demonstrates, every time I do that
the original state of the 'rng' seems to be used. Do you have
suggestions for fixing this?

Thank you in advance,

Moritz




Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net