Boost logo

Boost-Commit :

From: john_at_[hidden]
Date: 2007-09-29 05:40:21


Author: johnmaddock
Date: 2007-09-29 05:40:16 EDT (Sat, 29 Sep 2007)
New Revision: 39593
URL: http://svn.boost.org/trac/boost/changeset/39593

Log:
Updated debug-tracing macros.
Fixed epsilon so it works on MacOS with a 106-bit long double now.
Text files modified:
   sandbox/math_toolkit/boost/math/special_functions/ellint_1.hpp | 18 ++++++++++--------
   sandbox/math_toolkit/boost/math/special_functions/ellint_rf.hpp | 8 ++++----
   sandbox/math_toolkit/boost/math/tools/config.hpp | 2 ++
   sandbox/math_toolkit/boost/math/tools/precision.hpp | 5 ++++-
   4 files changed, 20 insertions(+), 13 deletions(-)

Modified: sandbox/math_toolkit/boost/math/special_functions/ellint_1.hpp
==============================================================================
--- sandbox/math_toolkit/boost/math/special_functions/ellint_1.hpp (original)
+++ sandbox/math_toolkit/boost/math/special_functions/ellint_1.hpp 2007-09-29 05:40:16 EDT (Sat, 29 Sep 2007)
@@ -47,7 +47,7 @@
     bool invert = false;
     if(phi < 0)
     {
- BOOST_MATH_INSTRUMENT_CODE(phi);
+ BOOST_MATH_INSTRUMENT_VARIABLE(phi);
        phi = fabs(phi);
        invert = true;
     }
@@ -58,14 +58,14 @@
     {
        // Need to handle infinity as a special case:
        result = policies::raise_overflow_error<T>(function, 0, pol);
- BOOST_MATH_INSTRUMENT_CODE(result);
+ BOOST_MATH_INSTRUMENT_VARIABLE(result);
     }
     else if(phi > 1 / tools::epsilon<T>())
     {
        // Phi is so large that phi%pi is necessarily zero (or garbage),
        // just return the second part of the duplication formula:
        result = 2 * phi * ellint_k_imp(k, pol) / constants::pi<T>();
- BOOST_MATH_INSTRUMENT_CODE(result);
+ BOOST_MATH_INSTRUMENT_VARIABLE(result);
     }
     else
     {
@@ -77,25 +77,27 @@
        // so rewritten to use fmod instead:
        //
        T rphi = fmod(phi, constants::pi<T>() / 2);
- BOOST_MATH_INSTRUMENT_CODE(rphi);
+ BOOST_MATH_INSTRUMENT_VARIABLE(rphi);
        T m = 2 * (phi - rphi) / constants::pi<T>();
- BOOST_MATH_INSTRUMENT_CODE(m);
+ BOOST_MATH_INSTRUMENT_VARIABLE(m);
        int s = 1;
        if(fmod(m, T(2)) > 0.5)
        {
           m += 1;
           s = -1;
           rphi = constants::pi<T>() / 2 - rphi;
- BOOST_MATH_INSTRUMENT_CODE(rphi);
+ BOOST_MATH_INSTRUMENT_VARIABLE(rphi);
        }
        T sinp = sin(rphi);
        T cosp = cos(rphi);
+ BOOST_MATH_INSTRUMENT_VARIABLE(sinp);
+ BOOST_MATH_INSTRUMENT_VARIABLE(cosp);
        result = s * sinp * ellint_rf_imp(cosp * cosp, 1 - k * k * sinp * sinp, T(1), pol);
- BOOST_MATH_INSTRUMENT_CODE(result);
+ BOOST_MATH_INSTRUMENT_VARIABLE(result);
        if(m != 0)
        {
           result += m * ellint_k_imp(k, pol);
- BOOST_MATH_INSTRUMENT_CODE(result);
+ BOOST_MATH_INSTRUMENT_VARIABLE(result);
        }
     }
     return invert ? -result : result;

Modified: sandbox/math_toolkit/boost/math/special_functions/ellint_rf.hpp
==============================================================================
--- sandbox/math_toolkit/boost/math/special_functions/ellint_rf.hpp (original)
+++ sandbox/math_toolkit/boost/math/special_functions/ellint_rf.hpp 2007-09-29 05:40:16 EDT (Sat, 29 Sep 2007)
@@ -55,12 +55,12 @@
     if(policies::digits<T, Policy>() > 64)
     {
       tolerance = pow(tools::epsilon<T>(), T(1)/4.25f);
- BOOST_MATH_INSTRUMENT_CODE(tolerance);
+ BOOST_MATH_INSTRUMENT_VARIABLE(tolerance);
     }
     else
     {
       tolerance = pow(4*tools::epsilon<T>(), T(1)/6);
- BOOST_MATH_INSTRUMENT_CODE(tolerance);
+ BOOST_MATH_INSTRUMENT_VARIABLE(tolerance);
     }
 
     // duplication
@@ -89,13 +89,13 @@
 
     // Check to see if we gave up too soon:
     policies::check_series_iterations(function, k, pol);
- BOOST_MATH_INSTRUMENT_CODE(k);
+ BOOST_MATH_INSTRUMENT_VARIABLE(k);
 
     // Taylor series expansion to the 5th order
     E2 = X * Y - Z * Z;
     E3 = X * Y * Z;
     value = (1 + E2*(E2/24 - E3*T(3)/44 - T(0.1)) + E3/14) / sqrt(u);
- BOOST_MATH_INSTRUMENT_CODE(value);
+ BOOST_MATH_INSTRUMENT_VARIABLE(value);
 
     return value;
 }

Modified: sandbox/math_toolkit/boost/math/tools/config.hpp
==============================================================================
--- sandbox/math_toolkit/boost/math/tools/config.hpp (original)
+++ sandbox/math_toolkit/boost/math/tools/config.hpp 2007-09-29 05:40:16 EDT (Sat, 29 Sep 2007)
@@ -138,8 +138,10 @@
 #ifdef BOOST_MATH_INSTRUMENT
 #define BOOST_MATH_INSTRUMENT_CODE(x) \
    std::cout << std::setprecision(35) << __FILE__ << ":" << __LINE__ << " " << x << std::endl;
+#define BOOST_MATH_INSTRUMENT_VARIABLE(name) BOOST_MATH_INSTRUMENT_CODE(BOOST_STRINGIZE(name) << " = " << name)
 #else
 #define BOOST_MATH_INSTRUMENT_CODE(x)
+#define BOOST_MATH_INSTRUMENT_VARIABLE(name)
 #endif
 
 #endif // BOOST_MATH_TOOLS_CONFIG_HPP

Modified: sandbox/math_toolkit/boost/math/tools/precision.hpp
==============================================================================
--- sandbox/math_toolkit/boost/math/tools/precision.hpp (original)
+++ sandbox/math_toolkit/boost/math/tools/precision.hpp 2007-09-29 05:40:16 EDT (Sat, 29 Sep 2007)
@@ -16,6 +16,9 @@
 
 #include <iostream>
 #include <iomanip>
+// These two are for LDBL_MAN_DIG:
+#include <limits.h>
+#include <math.h>
 
 namespace boost{ namespace math
 {
@@ -148,7 +151,7 @@
    return std::numeric_limits<T>::epsilon();
 }
 
-#if (defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)) && (LDBL_MANT_DIG == 106)
+#if (defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)) && ((LDBL_MANT_DIG == 106) || (__LDBL_MANT_DIG__ == 106))
 template <>
 inline long double epsilon<long double>(const mpl::true_& BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(long double))
 {


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk