This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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]

ERFC_SCALED compile-time simplification


Hi all,

This patch adds compile-time simplification for ERFC_SCALED (erfc_scaled(x) = erfc(x) * exp(x^2)). This is required by the standard because it is allowed in initialization expression, so we can do such wonderful things as:

      real, parameter :: r = 100*erfc_scaled(12.7)
      integer(kind=int(r)) :: i

Because there's no erfc_scaled in MPFR, we have to do the this the hard way. For values of the argument smaller than ARG_LIMIT, we calculate it from the formula (erfc(x) * exp(x^2)), with a very high precision for intermediate results. For arguments larger than ARG_LIMIT, we use an asymptotic expansion, using twice the final precision for intermediate results; to avoid doing useless iterations, we stop when the sum has reached the required precision.

The value of ARG_LIMIT (12), the maximum number of iterations (200, which is largely overestimated but we don't care, see above) and the chosen intermediate precisions were empirically determined.

Testcases cover the basics, plus compare the compile-time result to the results obtained using the runtime library. Bootstrapped and regtested on x86_64-linux.

OK to commit? If so, could someone please take care of it, as I don't have SVN write access set up anymore.

Regards,
FX


PS : please CC me on any negative fallout from this patch



Attachment: erfc_scaled.ChangeLog
Description: Binary data

Attachment: erfc_scaled.diff
Description: Binary data


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