http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56106
Bug #: 56106
Summary: complex pow improvements
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
AssignedTo: [email protected]
ReportedBy: [email protected]
See this discussion for more details:
http://gcc.gnu.org/ml/libstdc++/2013-01/msg00058.html
Several improvements seem possible.
1) in pow(const complex<_Tp>& __x, const _Tp& __y), if _GLIBCXX_USE_C99_COMPLEX
&& !_GLIBCXX_FAST_MATH, we could convert y to a complex and call the libc
version, more accurate than chaining several calls. (I mention
_GLIBCXX_FAST_MATH assuming that the version with polar, exp and log is faster
than the general libc version, I don't know if that is really the case)
2) among the pow(complex,scalar) overloads, those for which scalar is an
integer could be split out and implemented with recursive squaring (as
currently done in C++03 mode for int only). Note that when the exponent is not
-1, 0, 1 or 2, this might also require _GLIBCXX_FAST_MATH ||
!_GLIBCXX_USE_C99_COMPLEX as it may not give anymore the correctly rounded
result.
Note that the libc version may already test for real or small integer
arguments, so we can't expect a huge performance benefit from not calling it in
these cases.