|
Boost Users : |
From: Graham Reitz (graham.cpp_at_[hidden])
Date: 2007-10-23 17:51:40
Ok I got it. Yikes, talk about type safety. It really, really,
wanted a boost::uint32_t for the seed parameter.
I passed it a double to see what kind of warning I would receive,
hoping it would tell me what the parent time is:
warning: passing `double' for converting 1 of `void
boost::random::mersenne_twister<UIntType, w, n, m, r, a, u, s, b, t
, c, l, val>::seed(UIntType) [with UIntType = boost::uint32_t, int w =
32, int n = 624, int m = 397, int r = 31, UIntType a = -1727483681u,
int u = 11, int s = 7, UIntType b = -1658038656u, int t = 15
, UIntType c = -272236544u, int l = 18, UIntType val = -948541730u]'
Thanks again,
Graham
On 10/23/07, Graham Reitz <graham.cpp_at_[hidden]> wrote:
> Thanks for the reply Mike. I am still stumped. Any ideas on how I
> can tell what type the "DataType" is?
>
> Graham
>
> On 10/23/07, Michael Linck <mgl_at_[hidden]> wrote:
> > Looks like you seed it by converting your time stamp to whatever
> > "DataType" you're trying to get back and using it as an arg to seed:
> > "
> > lass random::mersenne_twister
> > {
> > public:
> > typedef DataType result_type;
> > .
> > .
> > .
> > void seed();
> > void seed(DataType value);
> > " -- http://www.boost.org/libs/random/random-generators.html#mersenne_twister
> >
> > Or you can take the - possibly more complicated - route of trying to figure out how to use the Generator template.
> >
> > Hope that helps,
> >
> > mike
> >
> > On Tue, 2007-10-23 at 12:00 -0500, Graham Reitz wrote:
> > > I am little confused on how to see a random generator.
> > >
> > > What am I missing?
> > >
> > > // Grab the seed
> > > HighResTimer::Time time_secs = high_res_timer.getTime();
> > >
> > > // Go ahead and truncate, it's just a seed
> > > boost::int32_t time = static_cast<boost::int32_t>(time_secs * 100000);
> > >
> > > // produces randomness out of thin air
> > > // see pseudo-random number generators
> > > boost::mt19937 rng;
> > > rng.seed(); // How do you seed this with the time?
> > >
> > > // distribution that maps to 0..1
> > > // see random number distributions
> > > boost::uniform_real<> zero_to_one(0,1);
> > >
> > > // glues randomness with mapping
> > > boost::variate_generator<boost::mt19937&, boost::uniform_real<> >
> > > be_random zero_to_one);
> > > _______________________________________________
> > > Boost-users mailing list
> > > Boost-users_at_[hidden]
> > > http://lists.boost.org/mailman/listinfo.cgi/boost-users
> >
> > _______________________________________________
> > Boost-users mailing list
> > Boost-users_at_[hidden]
> > http://lists.boost.org/mailman/listinfo.cgi/boost-users
> >
>
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