diff options
author | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-09-27 09:27:05 +0000 |
---|---|---|
committer | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-09-27 09:27:05 +0000 |
commit | 86e067d23c26d4648ad1ed517e5823ea6a4b9bfd (patch) | |
tree | e91a88e04ef45c0add337e06a9114ba5e687d471 /libstdc++-v3/include/std | |
parent | 27f9384b06cee518556f982e305b268178116530 (diff) | |
download | gcc-86e067d23c26d4648ad1ed517e5823ea6a4b9bfd.tar.gz |
2010-09-27 Paolo Carlini <paolo.carlini@oracle.com>
* include/c_std/cmath (__pow_helper): Remove.
(__cmath_power): Remove declaration.
* include/c_global/cmath: Likewise.
* include/std/complex (__complex_pow_unsigned): Add.
(pow(const complex<_Tp>&, int)): Use the latter.
* include/c_std/cmath.tcc: Remove file.
* include/c_global/cmath.tcc: Likewise.
* acinclude.m4: Adjust.
* include/Makefile.am: Likewise.
* configure: Regenerate.
* include/Makefile.in: Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@164645 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/include/std')
-rw-r--r-- | libstdc++-v3/include/std/complex | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/libstdc++-v3/include/std/complex b/libstdc++-v3/include/std/complex index 31c44363137..93056510e08 100644 --- a/libstdc++-v3/include/std/complex +++ b/libstdc++-v3/include/std/complex @@ -951,12 +951,32 @@ _GLIBCXX_BEGIN_NAMESPACE(std) // raised to the __y-th power. The branch // cut is on the negative axis. #ifndef __GXX_EXPERIMENTAL_CXX0X__ + template<typename _Tp> + complex<_Tp> + __complex_pow_unsigned(complex<_Tp> __x, unsigned __n) + { + complex<_Tp> __y = __n % 2 ? __x : complex<_Tp>(1); + + while (__n >>= 1) + { + __x *= __x; + if (__n % 2) + __y *= __x; + } + + return __y; + } + // _GLIBCXX_RESOLVE_LIB_DEFECTS // DR 844. complex pow return type is ambiguous. template<typename _Tp> inline complex<_Tp> pow(const complex<_Tp>& __z, int __n) - { return std::__pow_helper(__z, __n); } + { + return __n < 0 + ? complex<_Tp>(1) / std::__complex_pow_unsigned(__z, -__n) + : std::__complex_pow_unsigned(__z, __n); + } #endif template<typename _Tp> |