|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r51755 - trunk/boost/math/distributions/detail
From: john_at_[hidden]
Date: 2009-03-13 13:56:29
Author: johnmaddock
Date: 2009-03-13 13:56:28 EDT (Fri, 13 Mar 2009)
New Revision: 51755
URL: http://svn.boost.org/trac/boost/changeset/51755
Log:
Add instrumentation code and some FPU control options.
Text files modified:
trunk/boost/math/distributions/detail/hypergeometric_cdf.hpp | 4 ++--
trunk/boost/math/distributions/detail/hypergeometric_quantile.hpp | 38 ++++++++++++++++++++++++++++++++++++++
2 files changed, 40 insertions(+), 2 deletions(-)
Modified: trunk/boost/math/distributions/detail/hypergeometric_cdf.hpp
==============================================================================
--- trunk/boost/math/distributions/detail/hypergeometric_cdf.hpp (original)
+++ trunk/boost/math/distributions/detail/hypergeometric_cdf.hpp 2009-03-13 13:56:28 EDT (Fri, 13 Mar 2009)
@@ -21,7 +21,7 @@
# pragma warning(disable:4267)
#endif
BOOST_MATH_STD_USING
- T result = 0;
+ T result = 0;
T mode = floor(T(r + 1) * T(n + 1) / (N + 2));
if(x < mode)
{
@@ -72,7 +72,7 @@
inline T hypergeometric_cdf(unsigned x, unsigned r, unsigned n, unsigned N, bool invert, const Policy&)
{
BOOST_FPU_EXCEPTION_GUARD
- typedef typename tools::promote_args<T>::type result_type;
+ typedef typename tools::promote_args<T>::type result_type;
typedef typename policies::evaluation<result_type, Policy>::type value_type;
typedef typename policies::normalise<
Policy,
Modified: trunk/boost/math/distributions/detail/hypergeometric_quantile.hpp
==============================================================================
--- trunk/boost/math/distributions/detail/hypergeometric_quantile.hpp (original)
+++ trunk/boost/math/distributions/detail/hypergeometric_quantile.hpp 2009-03-13 13:56:28 EDT (Fri, 13 Mar 2009)
@@ -17,7 +17,10 @@
inline unsigned round_x_from_p(unsigned x, T p, T cum, T fudge_factor, unsigned lbound, unsigned /*ubound*/, const policies::discrete_quantile<policies::integer_round_down>&)
{
if((p < cum * fudge_factor) && (x != lbound))
+ {
+ BOOST_MATH_INSTRUMENT_VARIABLE(x-1);
return --x;
+ }
return x;
}
@@ -25,7 +28,10 @@
inline unsigned round_x_from_p(unsigned x, T p, T cum, T fudge_factor, unsigned /*lbound*/, unsigned ubound, const policies::discrete_quantile<policies::integer_round_up>&)
{
if((cum < p * fudge_factor) && (x != ubound))
+ {
+ BOOST_MATH_INSTRUMENT_VARIABLE(x+1);
return ++x;
+ }
return x;
}
@@ -55,7 +61,10 @@
inline unsigned round_x_from_q(unsigned x, T q, T cum, T fudge_factor, unsigned lbound, unsigned /*ubound*/, const policies::discrete_quantile<policies::integer_round_down>&)
{
if((q * fudge_factor > cum) && (x != lbound))
+ {
+ BOOST_MATH_INSTRUMENT_VARIABLE(x-1);
return --x;
+ }
return x;
}
@@ -63,7 +72,10 @@
inline unsigned round_x_from_q(unsigned x, T q, T cum, T fudge_factor, unsigned /*lbound*/, unsigned ubound, const policies::discrete_quantile<policies::integer_round_up>&)
{
if((q < cum * fudge_factor) && (x != ubound))
+ {
+ BOOST_MATH_INSTRUMENT_VARIABLE(x+1);
return ++x;
+ }
return x;
}
@@ -98,11 +110,21 @@
#endif
typedef typename Policy::discrete_quantile_type discrete_quantile_type;
BOOST_MATH_STD_USING
+ BOOST_FPU_EXCEPTION_GUARD
T result;
T fudge_factor = 1 + tools::epsilon<T>() * ((N <= boost::math::prime(boost::math::max_prime - 1)) ? 50 : 2 * N);
unsigned base = static_cast<unsigned>((std::max)(0, (int)(n + r) - (int)(N)));
unsigned lim = (std::min)(r, n);
+ BOOST_MATH_INSTRUMENT_VARIABLE(p);
+ BOOST_MATH_INSTRUMENT_VARIABLE(q);
+ BOOST_MATH_INSTRUMENT_VARIABLE(r);
+ BOOST_MATH_INSTRUMENT_VARIABLE(n);
+ BOOST_MATH_INSTRUMENT_VARIABLE(N);
+ BOOST_MATH_INSTRUMENT_VARIABLE(fudge_factor);
+ BOOST_MATH_INSTRUMENT_VARIABLE(base);
+ BOOST_MATH_INSTRUMENT_VARIABLE(lim);
+
if(p <= 0.5)
{
unsigned x = base;
@@ -117,6 +139,14 @@
break;
++x;
result += diff;
+#ifdef BOOST_MATH_INSTRUMENT
+ if(diff != 0)
+ {
+ BOOST_MATH_INSTRUMENT_VARIABLE(x);
+ BOOST_MATH_INSTRUMENT_VARIABLE(diff);
+ BOOST_MATH_INSTRUMENT_VARIABLE(result);
+ }
+#endif
}
return round_x_from_p(x, p, result, fudge_factor, base, lim, discrete_quantile_type());
}
@@ -132,6 +162,14 @@
? x * T(N + x - n - r) * diff / (T(1 + n - x) * T(1 + r - x))
: hypergeometric_pdf<T>(x - 1, r, n, N, pol);
--x;
+#ifdef BOOST_MATH_INSTRUMENT
+ if(diff != 0)
+ {
+ BOOST_MATH_INSTRUMENT_VARIABLE(x);
+ BOOST_MATH_INSTRUMENT_VARIABLE(diff);
+ BOOST_MATH_INSTRUMENT_VARIABLE(result);
+ }
+#endif
}
return round_x_from_q(x, q, result, fudge_factor, base, lim, discrete_quantile_type());
}
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