This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH] libstdc++: add uniform on sphere distribution
- From: Ulrich Drepper <drepper at gmail dot com>
- To: Paolo Carlini <paolo dot carlini at oracle dot com>
- Cc: Ed Smith-Rowland <3dw4rd at verizon dot net>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Sun, 13 Jul 2014 12:44:36 -0400
- Subject: Re: [PATCH] libstdc++: add uniform on sphere distribution
- Authentication-results: sourceware.org; auth=none
- References: <53C28FBB dot 9080708 at verizon dot net> <CAOPLpQcDX_mAdAxy2ZaqRE_UzYBOgQwcGkz66-RtfsEOhzkYmg at mail dot gmail dot com> <53C2A91D dot 1070808 at oracle dot com> <CAOPLpQc6OmUh=xStvxnUpEHdiP7vWf2-G31f4uCsJSp6iD75HQ at mail dot gmail dot com> <53C2AED6 dot 4040402 at oracle dot com> <CAOPLpQfWVJctTbSvmGBN6KKCgenbopjrr-+iHG4ti_jzgGebgg at mail dot gmail dot com> <53C2B301 dot 2030205 at oracle dot com>
On Sun, Jul 13, 2014 at 12:25 PM, Paolo Carlini
> I don't think so. It depends on the past of the two different
> uniform_on_sphere: each time each uniform_on_sphere calls _M_n(__urng) the
> state of *its own* _M_n changes, evolves from the initial state.
I indeed should use the normal_distribution operator<< and operator>>
but I think for a different reason than you think. The way the
normal_distribution is implemented produces two values at a time and
saves the second for a latter call. So, yes, that implicit state has
to be preserved and I should have followed what Ed said.
But your 4th and 7th call example by itself is not a reason. Again,
the input exclusively determined by the random numbers. Here, of
course, the 4th and 7th use will produce different results. But this
is not what the state of the distribution is supposed to capture. For
that you'll have to save the state of the RNG as well.
I've checked in a patch to save the _M_n state.