diff options
Diffstat (limited to 'libstdc++-v3/include/std/std_complex.h')
-rw-r--r-- | libstdc++-v3/include/std/std_complex.h | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/libstdc++-v3/include/std/std_complex.h b/libstdc++-v3/include/std/std_complex.h index f297296386b..252070b1389 100644 --- a/libstdc++-v3/include/std/std_complex.h +++ b/libstdc++-v3/include/std/std_complex.h @@ -456,7 +456,7 @@ namespace std inline _Tp norm(const complex<_Tp>& __z) { - return _Norm_helper<__is_floating<_Tp>::_M_type>::_S_do_it(__z); + return _Norm_helper<__is_floating<_Tp>::_M_type && !_GLIBCPP_FAST_MATH>::_S_do_it(__z); } template<typename _Tp> @@ -565,24 +565,30 @@ namespace std } template<typename _Tp> - inline complex<_Tp> + complex<_Tp> pow(const complex<_Tp>& __x, const _Tp& __y) { - return exp(__y * log(__x)); + if (__x.imag() == _Tp()) + return pow(__x.real(), __y); + + complex<_Tp> __t = log(__x); + return polar(exp(__y * __t.real()), __y * __t.imag()); } template<typename _Tp> inline complex<_Tp> pow(const complex<_Tp>& __x, const complex<_Tp>& __y) { - return exp(__y * log(__x)); + return __x == _Tp() ? _Tp() : exp(__y * log(__x)); } template<typename _Tp> inline complex<_Tp> pow(const _Tp& __x, const complex<_Tp>& __y) { - return exp(__y * log(__x)); + return __x == _Tp() + ? _Tp() + : polar(pow(__x, __y.real()), __y.imag() * log(__x)); } // 26.2.3 complex specializations |