Boost logo

Boost Users :

Subject: Re: [Boost-users] [random] streamable state of normal_distribution to ostream not accurate
From: Oei, YC (oei.yungchin_at_[hidden])
Date: 2008-11-06 20:20:07


On Fri, Nov 7, 2008 at 12:44 AM, Dave Steenburgh
<dave.steenburgh_at_[hidden]> wrote:
>> mt19937 rng;
>> normal_distribution<> gauss;
>> variate_generator<mt19937&, normal_distribution<> > var(rng, gauss);
>
> gauss is passed by value, and so var has a copy of it. This means that when
> you generate values with var, the state of gauss does not change.

Wow, thanks for helping me out there so fast. I completely missed
this, and was especially confused because storing rng did work -
which, I only now realise, is because that is passed by reference
(something I did to share the generator among several
variate_generators I suppose).

Thanks. I'll sleep more sound now :)


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