re PR libstdc++/50880 (__complex_acosh() picks wrong complex branch)

2011-11-02  Richard B. Kreckel  <kreckel@ginac.de>
	    Paolo Carlini  <paolo.carlini@oracle.com>

	PR libstdc++/50880
	* include/std/complex (__complex_acosh): Fix in a better way,
	use Kahan's formula.
	* include/tr1/complex (__complex_acosh): Likewise.

From-SVN: r180787
This commit is contained in:
Richard B. Kreckel 2011-11-02 18:43:26 +00:00 committed by Paolo Carlini
parent 2d4e2a688e
commit af7c185869
2 changed files with 6 additions and 16 deletions

View File

@ -1686,14 +1686,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
std::complex<_Tp>
__complex_acosh(const std::complex<_Tp>& __z)
{
std::complex<_Tp> __t((__z.real() - __z.imag())
* (__z.real() + __z.imag()) - _Tp(1.0),
_Tp(2.0) * __z.real() * __z.imag());
__t = std::sqrt(__t);
if (__z.real() < _Tp())
__t = -__t;
return std::log(__t + __z);
// Kahan's formula.
return _Tp(2.0) * std::log(std::sqrt(_Tp(0.5) * (__z + _Tp(1.0)))
+ std::sqrt(_Tp(0.5) * (__z - _Tp(1.0))));
}
#if _GLIBCXX_USE_C99_COMPLEX_TR1

View File

@ -185,14 +185,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
std::complex<_Tp>
__complex_acosh(const std::complex<_Tp>& __z)
{
std::complex<_Tp> __t((__z.real() - __z.imag())
* (__z.real() + __z.imag()) - _Tp(1.0),
_Tp(2.0) * __z.real() * __z.imag());
__t = std::sqrt(__t);
if (__z.real() < _Tp())
__t = -__t;
return std::log(__t + __z);
// Kahan's formula.
return _Tp(2.0) * std::log(std::sqrt(_Tp(0.5) * (__z + _Tp(1.0)))
+ std::sqrt(_Tp(0.5) * (__z - _Tp(1.0))));
}
#if _GLIBCXX_USE_C99_COMPLEX_TR1