This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] libstdc++: add uniform on sphere distribution


Hi,

On 07/13/2014 06:18 PM, Ulrich Drepper wrote:
On Sun, Jul 13, 2014 at 12:07 PM, Paolo Carlini
<paolo.carlini@oracle.com> wrote:
Sorry, I still don't get it. When operator() of x and y, two
uniform_on_sphere_distribution, call _M_n(__urng) and those _M_n have a
different state, the numbers produced are in general different.
Correct.  But in the case of this distribution once you have the
random numbers the remainder of the work is done by a fixed formula:

    v = (N(0,1), ..., N(0,1))

    result = v / ||v||_2

That's it, nothing else to be done.

If you have two calls of operator() of two different uniform_on_sphere
objects and you pass to each an RNG object in exactly the same state
you will get the same result.
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. For instance, you call it 4 times on one and 7 times on another. The states of the two _M_n are different, and from that point the next numbers will be different. This is exactly what happens when you call os << x and is >> y, no object is destroyed, no object is constructed, and x has called _M_n(__urng) 4 times, and y has called it 7 times. Your inserters and extractors are trivial. The next numbers will be different. Note that, if I understand the standard correctly, we are comparing the numbers *from that point on*, not the whole story, whatever that may mean. In other terms, I'm saying the sequence of numbers produced after the 4th number isn't in general the same sequence of numbers produced after the 7th number.

Paolo.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]