This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[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 ----
        template<typename _Tp>
          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;
+ #else
+ 	  // High accuracy answer
            _Tp __res = abs(__z);
            return __res * __res;
+ #endif
          }
      };
    



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]