Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r52335 - in trunk/boost/math: distributions/detail tools
From: john_at_[hidden]
Date: 2009-04-11 11:27:00


Author: johnmaddock
Date: 2009-04-11 11:26:59 EDT (Sat, 11 Apr 2009)
New Revision: 52335
URL: http://svn.boost.org/trac/boost/changeset/52335

Log:
Add more instrumentation code, along with some AMD64/Linux fixes.
Text files modified:
   trunk/boost/math/distributions/detail/hypergeometric_pdf.hpp | 31 +++++++++++++++++++++++++++++--
   trunk/boost/math/tools/config.hpp | 6 ++++--
   2 files changed, 33 insertions(+), 4 deletions(-)

Modified: trunk/boost/math/distributions/detail/hypergeometric_pdf.hpp
==============================================================================
--- trunk/boost/math/distributions/detail/hypergeometric_pdf.hpp (original)
+++ trunk/boost/math/distributions/detail/hypergeometric_pdf.hpp 2009-04-11 11:26:59 EDT (Sat, 11 Apr 2009)
@@ -82,6 +82,10 @@
    do{
       exponents[sorted_indexes[0]] -= exponents[sorted_indexes[1]];
       bases[sorted_indexes[1]] *= bases[sorted_indexes[0]];
+ if((bases[sorted_indexes[1]] < tools::min_value<T>()) && (exponents[sorted_indexes[1]] != 0))
+ {
+ return 0;
+ }
       base_e_factors[sorted_indexes[1]] += base_e_factors[sorted_indexes[0]];
       bubble_down_one(sorted_indexes, sorted_indexes + 9, sort_functor<T>(exponents));
    }while(exponents[sorted_indexes[1]] > 1);
@@ -104,10 +108,30 @@
       --j;
    }
 
- T result = pow(bases[sorted_indexes[0]] * exp(static_cast<T>(base_e_factors[sorted_indexes[0]])), exponents[sorted_indexes[0]]);
+#ifdef BOOST_MATH_INSTRUMENT
+ BOOST_MATH_INSTRUMENT_FPU
+ for(unsigned i = 0; i < 9; ++i)
+ {
+ BOOST_MATH_INSTRUMENT_VARIABLE(i);
+ BOOST_MATH_INSTRUMENT_VARIABLE(bases[i]);
+ BOOST_MATH_INSTRUMENT_VARIABLE(exponents[i]);
+ BOOST_MATH_INSTRUMENT_VARIABLE(base_e_factors[i]);
+ BOOST_MATH_INSTRUMENT_VARIABLE(sorted_indexes[i]);
+ }
+#endif
+
+ T result;
+ BOOST_MATH_INSTRUMENT_VARIABLE(bases[sorted_indexes[0]] * exp(static_cast<T>(base_e_factors[sorted_indexes[0]])));
+ BOOST_MATH_INSTRUMENT_VARIABLE(exponents[sorted_indexes[0]]);
+ {
+ BOOST_FPU_EXCEPTION_GUARD
+ result = pow(bases[sorted_indexes[0]] * exp(static_cast<T>(base_e_factors[sorted_indexes[0]])), exponents[sorted_indexes[0]]);
+ }
+ BOOST_MATH_INSTRUMENT_VARIABLE(result);
    for(unsigned i = 1; (i < 9) && (exponents[sorted_indexes[i]] > 0); ++i)
    {
- if(result == 0)
+ BOOST_FPU_EXCEPTION_GUARD
+ if(result < tools::min_value<T>())
          return 0; // short circuit further evaluation
       if(exponents[sorted_indexes[i]] == 1)
          result *= bases[sorted_indexes[i]] * exp(static_cast<T>(base_e_factors[sorted_indexes[i]]));
@@ -115,6 +139,8 @@
          result *= sqrt(bases[sorted_indexes[i]] * exp(static_cast<T>(base_e_factors[sorted_indexes[i]])));
       else
          result *= pow(bases[sorted_indexes[i]] * exp(static_cast<T>(base_e_factors[sorted_indexes[i]])), exponents[sorted_indexes[i]]);
+
+ BOOST_MATH_INSTRUMENT_VARIABLE(result);
    }
 
    result *= Lanczos::lanczos_sum_expG_scaled(static_cast<T>(n + 1))
@@ -128,6 +154,7 @@
          * Lanczos::lanczos_sum_expG_scaled(static_cast<T>(r - x + 1))
          * Lanczos::lanczos_sum_expG_scaled(static_cast<T>(N - n - r + x + 1)));
    
+ BOOST_MATH_INSTRUMENT_VARIABLE(result);
    return result;
 }
 

Modified: trunk/boost/math/tools/config.hpp
==============================================================================
--- trunk/boost/math/tools/config.hpp (original)
+++ trunk/boost/math/tools/config.hpp 2009-04-11 11:26:59 EDT (Sat, 11 Apr 2009)
@@ -280,9 +280,11 @@
    } // namespace detail
    }} // namespaces
 
- #define BOOST_FPU_EXCEPTION_GUARD boost::math::detail::fpu_guard local_guard_object;
+# define BOOST_FPU_EXCEPTION_GUARD boost::math::detail::fpu_guard local_guard_object;
+# define BOOST_MATH_INSTRUMENT_FPU do{ fexcept_t cpu_flags; fegetexceptflag(&cpu_flags, FE_ALL_EXCEPT); BOOST_MATH_INSTRUMENT_VARIABLE(cpu_flags); } while(0);
 #else // All other platforms.
- #define BOOST_FPU_EXCEPTION_GUARD
+# define BOOST_FPU_EXCEPTION_GUARD
+# define BOOST_MATH_INSTRUMENT_FPU
 #endif
 
 #ifdef BOOST_MATH_INSTRUMENT


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