diff options
| author | gdr <gdr@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-05-20 06:52:11 +0000 |
|---|---|---|
| committer | gdr <gdr@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-05-20 06:52:11 +0000 |
| commit | ab6501eff3b9e1638296bfae030377b9f358b077 (patch) | |
| tree | ea744e6750ac1694c4136ebf05f2ad62dad71e22 /libstdc++-v3/include/std/std_complex.h | |
| parent | f11036bc2635bd7d9f71def03e83b4927b3f9cba (diff) | |
| download | ppe42-gcc-ab6501eff3b9e1638296bfae030377b9f358b077.tar.gz ppe42-gcc-ab6501eff3b9e1638296bfae030377b9f358b077.zip | |
PR libstdc++/10689
* include/std/std_complex.h (pow): Tidy
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@66989 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/include/std/std_complex.h')
| -rw-r--r-- | libstdc++-v3/include/std/std_complex.h | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/libstdc++-v3/include/std/std_complex.h b/libstdc++-v3/include/std/std_complex.h index 87e4bcb4d26..e943f5edcee 100644 --- a/libstdc++-v3/include/std/std_complex.h +++ b/libstdc++-v3/include/std/std_complex.h @@ -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 |

