lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] use boost::math:expm1() and log1p()


From: Václav Slavík
Subject: Re: [lmi] use boost::math:expm1() and log1p()
Date: Sun, 5 Apr 2009 21:20:02 +0200

Hi,

On Apr 4, 2009, at 20:26, Greg Chicares wrote:
Before we consider switching to a different boost version or using
boost's build system, let's measure the speed and accuracy of these
functions. Since you've already built this, could I ask you to run
the math_functors_test$(EXEEXT) unit test and post the results?

Before:

  Speed test: pow
    1.763e-06 s =       1763 ns, mean of 5672 iterations
  Speed test: expm1l
    1.587e-06 s =       1587 ns, mean of 6300 iterations

  -0.004 upper 365 by various methods
    long double precision, expm1l and log1pl
      -0.0039841072324612947578
    long double precision, pow
      -0.0039841072324612817473
    double precision, expm1l and log1pl
      -0.0039841072324612938904
    double precision, pow
      -0.0039841072324439119612

.... 26 tests succeeded
no errors detected

After:

  Speed test: pow
    1.289e-06 s =       1289 ns, mean of 7758 iterations
  Speed test: expm1
     1.553e-06 s =       1553 ns, mean of 6439 iterations

  -0.004 upper 365 by various methods
    long double precision, expm1 and log1p
      -0.0039841072324612947578
    long double precision, pow
      -0.0039841072324612817473
    double precision, expm1 and log1p
      -0.0039841072324612947578
    double precision, pow
      -0.0039841072324439119612

.... 26 tests succeeded
no errors detected

This is not surprising, because Boost uses system expm1l() if available (see also http://lists.nongnu.org/archive/html/lmi/2008-06/msg00053.html) .

It is slower after with the use of expm1l() disabled:

  Speed test: pow
    1.761e-06 s =       1761 ns, mean of 5679 iterations
  Speed test: expm1
     5.441e-06 s =       5441 ns, mean of 1838 iterations

  -0.004 upper 365 by various methods
    long double precision, expm1 and log1p
      -0.0039841072324612947578
    long double precision, pow
      -0.0039841072324612817473
    double precision, expm1 and log1p
      -0.0039841072324612947578
    double precision, pow
      -0.0039841072324439119612

.... 26 tests succeeded
no errors detected

In order to enable expm1l() on MinGW, you need Boost 1.38 and BOOST_MATH_USE_C99 must be defined. The config_ming323.hpp portion of my patch needs to be updated o define this macro too:

=== modified file 'config_ming323.hpp'
--- config_ming323.hpp  2008-12-27 02:57:00 +0000
+++ config_ming323.hpp  2009-04-05 19:15:32 +0000
@@ -43,18 +43,10 @@
 // Version numbers are in 'include/_mingw.h' here:
// http://cygwin.com/cgi-bin/cvsweb.cgi/src/winsup/mingw/? cvsroot=src

-#if 308 <= LMI_MINGW_VERSION
-#   define LMI_COMPILER_PROVIDES_EXPM1L
-#endif // 308 <= LMI_MINGW_VERSION
-
 #if 200 <= LMI_MINGW_VERSION
 #   define LMI_COMPILER_PROVIDES_ISNAN
 #endif // 200 <= LMI_MINGW_VERSION

-#if 202 <= LMI_MINGW_VERSION
-#   define LMI_COMPILER_PROVIDES_LOG1PL
-#endif // 202 <= LMI_MINGW_VERSION
-
 #if 200 <= LMI_MINGW_VERSION
 #   define LMI_COMPILER_PROVIDES_RINT
 #endif // 200 <= LMI_MINGW_VERSION
@@ -67,5 +59,24 @@
 #   define LMI_COMPILER_PROVIDES_STRTOLD
 #endif // 204 <= LMI_MINGW_VERSION

+// Configure Boost library for this compiler in cases where it lacks
+// features autodetection.
+
+#if defined BOOST_MATH_EXPM1_INCLUDED || defined BOOST_MATH_LOG1P_INCLUDED
+#   error config.hpp must be included before boost::math headers.
+#endif
+
+#if 308 <= LMI_MINGW_VERSION
+#   define BOOST_HAS_EXP1M
+#endif // 308 <= LMI_MINGW_VERSION
+
+#if 202 <= LMI_MINGW_VERSION
+#   define BOOST_HAS_LOG1P
+#endif // 202 <= LMI_MINGW_VERSION
+
+#ifndef BOOST_MATH_USE_C99
+#   define BOOST_MATH_USE_C99
+#endif
+
 #endif // config_ming323_hpp



Vaclav




reply via email to

[Prev in Thread] Current Thread [Next in Thread]