summaryrefslogtreecommitdiffstats
path: root/libstdc++-v3/include/std/std_complex.h
diff options
context:
space:
mode:
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2004-03-10 09:16:12 +0000
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2004-03-10 09:16:12 +0000
commitd892842736e25525d6013da2f0377f9b6a08ac8d (patch)
tree4b71efb5adf002e92b61121c55148848d34fdc3f /libstdc++-v3/include/std/std_complex.h
parenta9ca39a06a57ccb6ba278bb32578401a64e75aa2 (diff)
downloadppe42-gcc-d892842736e25525d6013da2f0377f9b6a08ac8d.tar.gz
ppe42-gcc-d892842736e25525d6013da2f0377f9b6a08ac8d.zip
2004-03-10 Paul Kienzle <pkienzle@nist.gov>
Paolo Carlini <pcarlini@suse.de> PR libstdc++/13450 * include/std/std_complex.h (pow(const complex&, const _Tp&), pow(const _Tp&, const complex&)): Use cmath pow only when safe. * testsuite/26_numerics/complex/13450.cc: New. * testsuite/26_numerics/cmath/overloads.C: Rename to overloads.cc. * testsuite/26_numerics/complex/pow.C: Rename to pow.cc and fix. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@79227 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/include/std/std_complex.h')
-rw-r--r--libstdc++-v3/include/std/std_complex.h7
1 files changed, 3 insertions, 4 deletions
diff --git a/libstdc++-v3/include/std/std_complex.h b/libstdc++-v3/include/std/std_complex.h
index 25c657f2701..d997867c588 100644
--- a/libstdc++-v3/include/std/std_complex.h
+++ b/libstdc++-v3/include/std/std_complex.h
@@ -705,7 +705,7 @@ namespace std
complex<_Tp>
pow(const complex<_Tp>& __x, const _Tp& __y)
{
- if (__x.imag() == _Tp())
+ if (__x.imag() == _Tp() && __x.real() > _Tp())
return pow(__x.real(), __y);
complex<_Tp> __t = log(__x);
@@ -723,9 +723,8 @@ namespace std
inline complex<_Tp>
pow(const _Tp& __x, const complex<_Tp>& __y)
{
- return __x == _Tp()
- ? _Tp()
- : std::polar(pow(__x, __y.real()), __y.imag() * log(__x));
+ return __x > _Tp() ? polar(pow(__x, __y.real()), __y.imag() * log(__x))
+ : pow(complex<_Tp>(__x, _Tp()), __y);
}
// 26.2.3 complex specializations
OpenPOWER on IntegriCloud