diff mbox

[v3] libstdc++/54757

Message ID 506A2356.10203@oracle.com
State New
Headers show

Commit Message

Paolo Carlini Oct. 1, 2012, 11:12 p.m. UTC
Hi,

sanity checked x86_64-linux (both cases), committed to mainline.

Thanks,
Paolo.

/////////////////////////
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.
diff mbox

Patch

Index: include/ext/random
===================================================================
--- include/ext/random	(revision 191942)
+++ include/ext/random	(working copy)
@@ -1042,7 +1042,11 @@ 
 	{
 	  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 @@ 
 	    __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,
Index: include/ext/random.tcc
===================================================================
--- include/ext/random.tcc	(revision 191942)
+++ include/ext/random.tcc	(working copy)
@@ -732,7 +732,11 @@ 
 	      __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
 	  }
       }