This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] libstdc++: add uniform on sphere distribution
- From: Ulrich Drepper <drepper at gmail dot com>
- To: "libstdc++ at gcc dot gnu dot org" <libstdc++ at gcc dot gnu dot org>
- Cc: Jonathan Wakely <jwakely at redhat dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Sat, 9 Aug 2014 14:00:26 -0400
- Subject: Re: [PATCH] libstdc++: add uniform on sphere distribution
- Authentication-results: sourceware.org; auth=none
- References: <87a98eow4m dot fsf at x240 dot local dot i-did-not-set--mail-host-address--so-tickle-me> <alpine dot DEB dot 2 dot 11 dot 1407231149300 dot 1768 at laptop-mg dot saclay dot inria dot fr> <20140723102908 dot GM2361 at redhat dot com> <87d2catvi3 dot fsf at x240 dot local dot i-did-not-set--mail-host-address--so-tickle-me> <alpine dot DEB dot 2 dot 11 dot 1408090904200 dot 10998 at stedding dot saclay dot inria dot fr> <CAOPLpQePn5FO_5PsazROOi3PfmRXx6y7mwoYo5h2+h3TZnX-gQ at mail dot gmail dot com> <alpine dot DEB dot 2 dot 11 dot 1408091413520 dot 10998 at stedding dot saclay dot inria dot fr> <CAOPLpQc7EZ0JwsqOtu3==EOVskKchYswZx7iyhcMgER6oz_v3w at mail dot gmail dot com> <alpine dot DEB dot 2 dot 11 dot 1408091727040 dot 10998 at stedding dot saclay dot inria dot fr> <878umxtxei dot fsf at x240 dot local dot i-did-not-set--mail-host-address--so-tickle-me> <alpine dot DEB dot 2 dot 11 dot 1408091921450 dot 10998 at stedding dot saclay dot inria dot fr>
On Sat, Aug 9, 2014 at 1:40 PM, Marc Glisse <marc.glisse@inria.fr> wrote:
> __x = result_type(2.0) * __aurng() - 1.0;
You're right, we of course need the negatives as well.
> Assuming the 2 coordinates are obtained through a rescaling x->2*x-1, if
> __sq is not exactly 0, it must be between 2^-103 and 1 (for ieee
> double), so I am not sure hypot gains that much (at least in my mind
> hypot was mostly a gain close to 0 or infinity, but maybe it has more
> advantages). It can only hurt speed though, so not a big issue.
Depending on how similar in size the two values are, not using hypot()
can drop quite a few bits. Especially with the scaling through
division this error can be noticeable. Better be sure. Maybe at some
point I have time to investigate the worst case scenario for the
numbers in question but until this shows hypot isn't needed it's best
to leave it in.
I've committed the patch.