From: Paolo Carlini <paolo.carlini@oracle.com>
To: "Bin.Cheng" <amker.cheng@gmail.com>, Ulrich Drepper <drepper@gmail.com>
Cc: "libstdc++@gcc.gnu.org" <libstdc++@gcc.gnu.org>,
Jonathan Wakely <jwakely@redhat.com>,
GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] libstdc++: add uniform on sphere distribution
Date: Wed, 13 Aug 2014 11:25:00 -0000 [thread overview]
Message-ID: <53EB4B26.8070205@oracle.com> (raw)
In-Reply-To: <53EB24BB.7050906@oracle.com>
[-- Attachment #1: Type: text/plain, Size: 66 bytes --]
... fixed with the below.
Thanks,
Paolo.
//////////////////////
[-- Attachment #2: CL_62118 --]
[-- Type: text/plain, Size: 209 bytes --]
2014-08-13 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/62118
* include/ext/random.tcc (uniform_on_sphere_helper<2, _RealType>::
operator()): Use std::hypot only when _GLIBCXX_USE_C99_MATH_TR1.
[-- Attachment #3: patch_62118 --]
[-- Type: text/plain, Size: 1192 bytes --]
Index: include/ext/random.tcc
===================================================================
--- include/ext/random.tcc (revision 213898)
+++ include/ext/random.tcc (working copy)
@@ -1547,10 +1547,12 @@
template<std::size_t _Dimen, typename _RealType>
class uniform_on_sphere_helper
{
- typedef typename uniform_on_sphere_distribution<_Dimen, _RealType>::result_type result_type;
+ typedef typename uniform_on_sphere_distribution<_Dimen, _RealType>::
+ result_type result_type;
public:
- template<typename _NormalDistribution, typename _UniformRandomNumberGenerator>
+ template<typename _NormalDistribution,
+ typename _UniformRandomNumberGenerator>
result_type operator()(_NormalDistribution& __nd,
_UniformRandomNumberGenerator& __urng)
{
@@ -1604,9 +1606,13 @@
}
while (__sq == _RealType(0) || __sq > _RealType(1));
+#if _GLIBCXX_USE_C99_MATH_TR1
// Yes, we do not just use sqrt(__sq) because hypot() is more
// accurate.
auto __norm = std::hypot(__ret[0], __ret[1]);
+#else
+ auto __norm = std::sqrt(__ret[0] * __ret[0] + __ret[1] * __ret[1]);
+#endif
__ret[0] /= __norm;
__ret[1] /= __norm;
next prev parent reply other threads:[~2014-08-13 11:25 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-13 2:01 Ulrich Drepper
2014-07-13 2:06 ` Ulrich Drepper
2014-07-13 9:28 ` Paolo Carlini
2014-07-13 10:04 ` Ulrich Drepper
2014-07-13 10:40 ` Paolo Carlini
2014-07-23 10:05 ` Marc Glisse
2014-07-23 10:44 ` Jonathan Wakely
2014-07-24 22:14 ` Ulrich Drepper
2014-07-24 23:19 ` Jonathan Wakely
2014-08-08 23:24 ` Ulrich Drepper
2014-08-09 7:15 ` Marc Glisse
2014-08-09 11:55 ` Ulrich Drepper
2014-08-09 12:34 ` Marc Glisse
2014-08-09 15:24 ` Ulrich Drepper
2014-08-09 15:33 ` Marc Glisse
2014-08-09 16:55 ` Ed Smith-Rowland
2014-08-09 16:56 ` Ulrich Drepper
2014-08-09 17:40 ` Marc Glisse
2014-08-09 18:00 ` Ulrich Drepper
2014-08-13 7:36 ` Bin.Cheng
2014-08-13 7:43 ` Bin.Cheng
2014-08-13 8:41 ` Paolo Carlini
2014-08-13 11:25 ` Paolo Carlini [this message]
2014-08-13 11:32 ` Marc Glisse
2014-08-13 11:40 ` Paolo Carlini
2014-07-13 13:55 Ed Smith-Rowland
2014-07-13 14:12 ` Ulrich Drepper
2014-07-13 14:48 ` Ed Smith-Rowland
2014-07-13 15:47 ` Paolo Carlini
2014-07-13 16:04 ` Ulrich Drepper
2014-07-13 16:12 ` Paolo Carlini
2014-07-13 16:18 ` Ulrich Drepper
2014-07-13 16:29 ` Paolo Carlini
2014-07-13 16:45 ` Ulrich Drepper
2014-07-13 16:56 ` Paolo Carlini
2014-07-14 7:58 ` Andreas Schwab
2014-07-14 8:18 ` Paolo Carlini
2014-07-16 11:30 ` Ed Smith-Rowland
2014-07-16 15:03 ` Paolo Carlini
2014-07-16 17:38 ` Ulrich Drepper
2014-07-14 10:31 Dominique Dhumieres
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=53EB4B26.8070205@oracle.com \
--to=paolo.carlini@oracle.com \
--cc=amker.cheng@gmail.com \
--cc=drepper@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jwakely@redhat.com \
--cc=libstdc++@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).