From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32034 invoked by alias); 25 Jan 2013 12:23:27 -0000 Received: (qmail 31961 invoked by uid 48); 25 Jan 2013 12:23:06 -0000 From: "glisse at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/56106] New: complex pow improvements Date: Fri, 25 Jan 2013 12:23:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: glisse at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2013-01/txt/msg02360.txt.bz2 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: unassigned@gcc.gnu.org ReportedBy: glisse@gcc.gnu.org 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.