From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22677 invoked by alias); 16 Jul 2014 15:02:01 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 22663 invoked by uid 89); 16 Jul 2014 15:02:00 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 X-HELO: aserp1040.oracle.com Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Wed, 16 Jul 2014 15:01:57 +0000 Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id s6GF1r5L022750 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 16 Jul 2014 15:01:54 GMT Received: from aserz7021.oracle.com (aserz7021.oracle.com [141.146.126.230]) by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s6GF1qPx024576 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 16 Jul 2014 15:01:53 GMT Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s6GF1qpl026383; Wed, 16 Jul 2014 15:01:52 GMT Received: from [192.168.1.4] (/79.27.214.118) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 16 Jul 2014 08:01:52 -0700 Message-ID: <53C693DC.70600@oracle.com> Date: Wed, 16 Jul 2014 15:03:00 -0000 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: Ed Smith-Rowland <3dw4rd@verizon.net>, Andreas Schwab , Ulrich Drepper CC: gcc-patches Subject: Re: [PATCH] libstdc++: add uniform on sphere distribution References: <53C28FBB.9080708@verizon.net> <53C2A91D.1070808@oracle.com> <53C2AED6.4040402@oracle.com> <53C2B301.2030205@oracle.com> <53C39149.8000001@oracle.com> <53C65C72.2010400@verizon.net> In-Reply-To: <53C65C72.2010400@verizon.net> Content-Type: multipart/mixed; boundary="------------010809050008040506050405" X-IsSubscribed: yes X-SW-Source: 2014-07/txt/msg01154.txt.bz2 This is a multi-part message in MIME format. --------------010809050008040506050405 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 254 Hi, On 07/16/2014 01:05 PM, Ed Smith-Rowland wrote: > One thing we all forgot: the operator== is also non-trivial because it > needs to compare _M_n. Right. And reset too. I'm going to test and apply the below. Thanks, Paolo. /////////////////////// --------------010809050008040506050405 Content-Type: text/plain; charset=UTF-8; name="CL" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="CL" Content-length: 474 2014-07-16 Paolo Carlini * include/ext/random: Minor formatting and cosmetic tweaks. (uniform_on_sphere_distribution<>::operator== (const uniform_on_sphere_distribution&, const uniform_on_sphere_distribution&)): Compare the _M_nds. (uniform_on_sphere_distribution<>::reset): Reset _M_nd. (operator!=(const uniform_on_sphere_distribution&, const uniform_on_sphere_distribution&)): Adjust. * include/ext/random.tcc: Minor cosmetc tweaks. --------------010809050008040506050405 Content-Type: text/plain; charset=UTF-8; name="patchlet" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="patchlet" Content-length: 4548 Index: include/ext/random =================================================================== --- include/ext/random (revision 212581) +++ include/ext/random (working copy) @@ -598,7 +598,7 @@ inline bool operator!=(const __gnu_cxx::beta_distribution<_RealType>& __d1, const __gnu_cxx::beta_distribution<_RealType>& __d2) - { return !(__d1 == __d2); } + { return !(__d1 == __d2); } /** @@ -2575,7 +2575,7 @@ inline bool operator!=(const __gnu_cxx::triangular_distribution<_RealType>& __d1, const __gnu_cxx::triangular_distribution<_RealType>& __d2) - { return !(__d1 == __d2); } + { return !(__d1 == __d2); } /** @@ -2810,7 +2810,7 @@ inline bool operator!=(const __gnu_cxx::von_mises_distribution<_RealType>& __d1, const __gnu_cxx::von_mises_distribution<_RealType>& __d2) - { return !(__d1 == __d2); } + { return !(__d1 == __d2); } /** @@ -3328,12 +3328,12 @@ */ explicit uniform_on_sphere_distribution() - : _M_param(), _M_n(_RealType(0), _RealType(1)) + : _M_param(), _M_nd() { } explicit uniform_on_sphere_distribution(const param_type& __p) - : _M_param(__p), _M_n(_RealType(0), _RealType(1)) + : _M_param(__p), _M_nd() { } /** @@ -3341,7 +3341,7 @@ */ void reset() - { } + { _M_nd.reset(); } /** * @brief Returns the parameter set of the distribution. @@ -3425,14 +3425,15 @@ friend bool operator==(const uniform_on_sphere_distribution& __d1, const uniform_on_sphere_distribution& __d2) - { return true; } + { return __d1._M_nd == __d2._M_nd; } /** - * @brief Inserts a %uniform_on_sphere_distribution random number distribution - * @p __x into the output stream @p __os. + * @brief Inserts a %uniform_on_sphere_distribution random number + * distribution @p __x into the output stream @p __os. * * @param __os An output stream. - * @param __x A %uniform_on_sphere_distribution random number distribution. + * @param __x A %uniform_on_sphere_distribution random number + * distribution. * * @returns The output stream with the state of @p __x inserted or in * an error state. @@ -3446,11 +3447,13 @@ __x); /** - * @brief Extracts a %uniform_on_sphere_distribution random number distribution + * @brief Extracts a %uniform_on_sphere_distribution random number + * distribution * @p __x from the input stream @p __is. * * @param __is An input stream. - * @param __x A %uniform_on_sphere_distribution random number generator engine. + * @param __x A %uniform_on_sphere_distribution random number + * generator engine. * * @returns The input stream with @p __x extracted or in an error state. */ @@ -3470,7 +3473,7 @@ const param_type& __p); param_type _M_param; - std::normal_distribution<_RealType> _M_n; + std::normal_distribution<_RealType> _M_nd; }; /** @@ -3482,7 +3485,7 @@ _RealType>& __d1, const __gnu_cxx::uniform_on_sphere_distribution<_Dimen, _RealType>& __d2) - { return false; } + { return !(__d1 == __d2); } _GLIBCXX_END_NAMESPACE_VERSION } // namespace __gnu_cxx Index: include/ext/random.tcc =================================================================== --- include/ext/random.tcc (revision 212581) +++ include/ext/random.tcc (working copy) @@ -1551,7 +1551,7 @@ _RealType __sum = _RealType(0); std::generate(__ret.begin(), __ret.end(), - [&__urng, &__sum, this](){ _RealType __t = _M_n(__urng); + [&__urng, &__sum, this](){ _RealType __t = _M_nd(__urng); __sum += __t * __t; return __t; }); auto __norm = std::sqrt(__sum); @@ -1583,8 +1583,7 @@ const __gnu_cxx::uniform_on_sphere_distribution<_Dimen, _RealType>& __x) { - // The distribution has no state, nothing to save. - return __os << __x._M_n; + return __os << __x._M_nd; } template& __x) { - // The distribution has no state, nothing to restore. - return __is >> __x._M_n; + return __is >> __x._M_nd; } _GLIBCXX_END_NAMESPACE_VERSION --------------010809050008040506050405--