diff options
author | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-11-02 18:43:26 +0000 |
---|---|---|
committer | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-11-02 18:43:26 +0000 |
commit | c1aeb0ddd9dafdaba9a74ada8358eff863b1dfce (patch) | |
tree | d7679da43ffa3636ae8f3dcfa7dc84d9a971e9f2 /libstdc++-v3/include/tr1 | |
parent | 609cab98a1445d1297053e842d0799dbe02e532c (diff) | |
download | gcc-c1aeb0ddd9dafdaba9a74ada8358eff863b1dfce.tar.gz |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@180787 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/include/tr1')
-rw-r--r-- | libstdc++-v3/include/tr1/complex | 11 |
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 |