This is the mail archive of the
mailing list for the libstdc++ project.
[v3] Possible fix for PR 5730
- From: Jerry Quinn <jlquinn at optonline dot net>
- To: libstdc++ at gcc dot gnu dot org
- Date: Wed, 19 Mar 2003 09:09:15 -0500
- Subject: [v3] Possible fix for PR 5730
I just tried the test case comparing gcc 2.95 and 3.3 branch. The gap is now
smaller than the reporter saw, but it is there:
gcc 2.95 1.2s
gcc 3.3 1.6s
Can someone that actually understands floating point explain the accuracy
improvement with the current implementation? Mathematically (ignoring fp
limitations), they are equivalent. So how does the distinction show up with
actual fp math?
Anyway, I thought that if the more accurate answer is required, the faster
solution could still be used under --fast-math. Opinions?
2003-03-19 Jerry Quinn <jlquinn at optonline dot net>
* include/std/std_complex.h (_Norm_helper<true>): Use faster,
less accurate computation for builtin float types under --fast-math.
*** std_complex.h.~1.3.~ Thu Feb 27 01:48:45 2003
--- std_complex.h Wed Mar 19 08:55:00 2003
*** 447,454 ****
--- 447,462 ----
static inline _Tp _S_do_it(const complex<_Tp>& __z)
+ #ifdef __FAST_MATH__
+ // Quicker answer
+ const _Tp __x = __z.real();
+ const _Tp __y = __z.imag();
+ return __x * __x + __y * __y;
+ // High accuracy answer
_Tp __res = abs(__z);
return __res * __res;