diff options
author | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-10-01 23:10:02 +0000 |
---|---|---|
committer | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-10-01 23:10:02 +0000 |
commit | 485dedbc22da55e181409609709313cff688d4e4 (patch) | |
tree | a4c316e8f4ffabb8e3a5c7bb7536fb6b6d073aa7 /libstdc++-v3/include/ext | |
parent | 20bc37d32cc7456e747b4104eb5efa36f6127d3a (diff) | |
download | ppe42-gcc-485dedbc22da55e181409609709313cff688d4e4.tar.gz ppe42-gcc-485dedbc22da55e181409609709313cff688d4e4.zip |
2012-10-01 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/54757
* include/ext/random (rice_distribution<>::operator()): Use std::hypot
only if _GLIBCXX_USE_C99_MATH_TR1.
* include/ext/random.tcc (rice_distribution<>::__generate_impl):
Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@191944 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/include/ext')
-rw-r--r-- | libstdc++-v3/include/ext/random | 8 | ||||
-rw-r--r-- | libstdc++-v3/include/ext/random.tcc | 4 |
2 files changed, 12 insertions, 0 deletions
diff --git a/libstdc++-v3/include/ext/random b/libstdc++-v3/include/ext/random index 884e8a0ca91..8c40d6d420a 100644 --- a/libstdc++-v3/include/ext/random +++ b/libstdc++-v3/include/ext/random @@ -1042,7 +1042,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { result_type __x = this->_M_ndx(__urng); result_type __y = this->_M_ndy(__urng); +#if _GLIBCXX_USE_C99_MATH_TR1 return std::hypot(__x, __y); +#else + return std::sqrt(__x * __x + __y * __y); +#endif } template<typename _UniformRandomNumberGenerator> @@ -1054,7 +1058,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __px(__p.nu(), __p.sigma()), __py(result_type(0), __p.sigma()); result_type __x = this->_M_ndx(__px, __urng); result_type __y = this->_M_ndy(__py, __urng); +#if _GLIBCXX_USE_C99_MATH_TR1 return std::hypot(__x, __y); +#else + return std::sqrt(__x * __x + __y * __y); +#endif } template<typename _ForwardIterator, diff --git a/libstdc++-v3/include/ext/random.tcc b/libstdc++-v3/include/ext/random.tcc index 86bb67fedf9..4151daff83d 100644 --- a/libstdc++-v3/include/ext/random.tcc +++ b/libstdc++-v3/include/ext/random.tcc @@ -732,7 +732,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __px(__p.nu(), __p.sigma()), __py(result_type(0), __p.sigma()); result_type __x = this->_M_ndx(__px, __urng); result_type __y = this->_M_ndy(__py, __urng); +#if _GLIBCXX_USE_C99_MATH_TR1 *__f++ = std::hypot(__x, __y); +#else + *__f++ = std::sqrt(__x * __x + __y * __y); +#endif } } |