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

Ulrich Drepper drepper@gmail.com
Sat Aug 9 11:55:00 GMT 2014

On Sat, Aug 9, 2014 at 3:15 AM, Marc Glisse <marc.glisse@inria.fr> wrote:
> While there, do we want to also reject infinite norms?
> I would have done: while (__sum < small || __sum > large)
> but testing exactly for 0 and infinity seems good enough.

I guess the squaring can theoretically overflow and produce infinity.
It will never happen with the way we generate normally distributed
numbers, though.  These values are always so unlikely that it is OK
that the algorithms cannot return them.  If you insist I'll add a test
for infinity.

The other change (which would eliminate the necessity for this test in
a special case) is to use hypot for _Dimen==2.  This might be a case
common enough to warrant that little bit of extra text.  I'll prepare
a patch.

More information about the Libstdc++ mailing list