summaryrefslogtreecommitdiff
path: root/libstdc++-v3/include/tr1
diff options
context:
space:
mode:
authorRichard B. Kreckel <kreckel@ginac.de>2011-11-02 18:43:26 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2011-11-02 18:43:26 +0000
commitaf7c185869e5c5f1535127dd138db51eb5c3b932 (patch)
treed7679da43ffa3636ae8f3dcfa7dc84d9a971e9f2 /libstdc++-v3/include/tr1
parent2d4e2a688ea50fdde672bf7502c202c049924039 (diff)
downloadgcc-af7c185869e5c5f1535127dd138db51eb5c3b932.tar.gz
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
Diffstat (limited to 'libstdc++-v3/include/tr1')
-rw-r--r--libstdc++-v3/include/tr1/complex11
1 files changed, 3 insertions, 8 deletions
diff --git a/libstdc++-v3/include/tr1/complex b/libstdc++-v3/include/tr1/complex
index d831eeb0146..689ea167ba2 100644
--- a/libstdc++-v3/include/tr1/complex
+++ b/libstdc++-v3/include/tr1/complex
@@ -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