mirror of
https://github.com/boostorg/math.git
synced 2026-01-19 04:22:09 +00:00
Minor fixes for gcc in poisson.hpp
Tidied up fraction.hpp. Updated linux acceptable error rates. [SVN r3346]
This commit is contained in:
@@ -149,28 +149,6 @@ namespace boost
|
||||
return true;
|
||||
} // bool check_dist_and_prob
|
||||
|
||||
// Constrain probability not used as no indications so far
|
||||
// that computed values ever stray outside the range 0 to 1.
|
||||
//template <class RealType>
|
||||
//RealType constrain_probability(const RealType& p)
|
||||
//{ // Constrain 0 <= probability <= 1.
|
||||
// // Numerical errors might cause probability to be slightly outside the range < 0 or > 1.
|
||||
// // This might cause trouble downstream, so warn, & possibly throw exception,
|
||||
// // but constrain to the 0 to 1 limits.
|
||||
// if (probability < static_cast<RealType>(0.))
|
||||
// {
|
||||
// tools::logic_error<RealType>(BOOST_CURRENT_FUNCTION,
|
||||
// "probability %1% is < 0, so has been constrained to zero !", probability);
|
||||
// return static_cast<RealType>(0.); // Constrain to zero if logic_error does not throw.
|
||||
// }
|
||||
// if(probability > static_cast<RealType>(1.))
|
||||
// {
|
||||
// tools::logic_error<RealType>(BOOST_CURRENT_FUNCTION,
|
||||
// "probability %1% is > 1, so has been constrained to unity!", probability);
|
||||
// return static_cast<RealType>(1.); // Constrain to unity if logic_error does not throw.
|
||||
// }
|
||||
//} // RealType constrained_probability
|
||||
|
||||
} // namespace poisson_detail
|
||||
|
||||
template <class RealType = double>
|
||||
@@ -295,7 +273,7 @@ namespace boost
|
||||
// (e ^ -mean * mean ^ k) / k!
|
||||
// == exp(log(e ^ -mean) + log (mean ^ k) - lgamma(k+1))
|
||||
// exp( -mean + log(mean) * k - lgamma(k+1))
|
||||
return exp(-mean + log(mean) * k - lgamma(k+1));
|
||||
return exp(-mean + log(mean) * k - boost::math::lgamma(k+1));
|
||||
// return gamma_P_derivative(k+1, mean); // equivalent & also passes tests.
|
||||
}
|
||||
} // pdf
|
||||
@@ -475,3 +453,5 @@ namespace boost
|
||||
#include <boost/math/distributions/detail/derived_accessors.hpp>
|
||||
|
||||
#endif // BOOST_MATH_SPECIAL_POISSON_HPP
|
||||
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ typename detail::fraction_traits<Gen>::result_type continued_fraction_b(Gen& g,
|
||||
typedef typename traits::result_type result_type;
|
||||
typedef typename traits::value_type value_type;
|
||||
|
||||
result_type factor = 1 / pow(result_type(2), bits);
|
||||
result_type factor = ldexp(1.0f, 1 - bits); // 1 / pow(result_type(2), bits);
|
||||
result_type tiny = tools::min_value<result_type>();
|
||||
|
||||
value_type v = g();
|
||||
@@ -126,7 +126,7 @@ typename detail::fraction_traits<Gen>::result_type continued_fraction_b(Gen& g,
|
||||
typedef typename traits::result_type result_type;
|
||||
typedef typename traits::value_type value_type;
|
||||
|
||||
result_type factor = 1 / pow(result_type(2), bits);
|
||||
result_type factor = ldexp(1.0f, 1 - bits); // 1 / pow(result_type(2), bits);
|
||||
result_type tiny = tools::min_value<result_type>();
|
||||
|
||||
value_type v = g();
|
||||
@@ -181,7 +181,7 @@ typename detail::fraction_traits<Gen>::result_type continued_fraction_a(Gen& g,
|
||||
typedef typename traits::result_type result_type;
|
||||
typedef typename traits::value_type value_type;
|
||||
|
||||
result_type factor = 1 / pow(result_type(2), bits);
|
||||
result_type factor = ldexp(1.0f, 1-bits); // 1 / pow(result_type(2), bits);
|
||||
result_type tiny = tools::min_value<result_type>();
|
||||
|
||||
value_type v = g();
|
||||
@@ -219,7 +219,7 @@ typename detail::fraction_traits<Gen>::result_type continued_fraction_a(Gen& g,
|
||||
typedef typename traits::result_type result_type;
|
||||
typedef typename traits::value_type value_type;
|
||||
|
||||
result_type factor = 1 / pow(result_type(2), bits);
|
||||
result_type factor = ldexp(1.0f, 1-bits); // 1 / pow(result_type(2), bits);
|
||||
result_type tiny = tools::min_value<result_type>();
|
||||
|
||||
value_type v = g();
|
||||
|
||||
@@ -204,7 +204,7 @@ void test_spots(T)
|
||||
BOOST_CHECK_CLOSE(
|
||||
::boost::math::falling_factorial(static_cast<T>(30.75), 30),
|
||||
static_cast<T>(naive_falling_factorial(30.75L, 30)),
|
||||
tolerance);
|
||||
tolerance * 3);
|
||||
if(boost::math::tools::digits<T>() > 50)
|
||||
{
|
||||
BOOST_CHECK_CLOSE(
|
||||
|
||||
@@ -64,6 +64,12 @@ void expected_results()
|
||||
//
|
||||
// Linux:
|
||||
//
|
||||
// These should not really be needed, but on *some* Linux
|
||||
// versions these error rates are quite large and appear to
|
||||
// be related to the accuracy of powl and expl. On Itanium
|
||||
// or Xeon machines the error rates are much lower than this.
|
||||
// Worst cases appear to be AMD64 machines.
|
||||
//
|
||||
add_expected_result(
|
||||
"[^|]*", // compiler
|
||||
"[^|]*", // stdlib
|
||||
@@ -71,6 +77,13 @@ void expected_results()
|
||||
largest_type, // test type(s)
|
||||
"[^|]*medium[^|]*", // test data group
|
||||
"[^|]*", 1000, 200); // test function
|
||||
add_expected_result(
|
||||
"[^|]*", // compiler
|
||||
"[^|]*", // stdlib
|
||||
"linux", // platform
|
||||
largest_type, // test type(s)
|
||||
"[^|]*integer[^|]*", // test data group
|
||||
"[^|]*", 1000, 200); // test function
|
||||
add_expected_result(
|
||||
"[^|]*", // compiler
|
||||
"[^|]*", // stdlib
|
||||
@@ -78,6 +91,13 @@ void expected_results()
|
||||
"real_concept", // test type(s)
|
||||
"[^|]*medium[^|]*", // test data group
|
||||
"[^|]*", 600, 200); // test function
|
||||
add_expected_result(
|
||||
"[^|]*", // compiler
|
||||
"[^|]*", // stdlib
|
||||
"linux", // platform
|
||||
"real_concept", // test type(s)
|
||||
"[^|]*integer[^|]*", // test data group
|
||||
"[^|]*", 600, 200); // test function
|
||||
|
||||
//
|
||||
// HP-UX:
|
||||
|
||||
@@ -84,6 +84,24 @@ void expected_results()
|
||||
"[^|]*small[^|]*", // test data group
|
||||
"[^|]*", 70000, 8000); // test function
|
||||
}
|
||||
//
|
||||
// These high error rates are seen on on some Linux
|
||||
// architectures:
|
||||
//
|
||||
add_expected_result(
|
||||
"[^|]*", // compiler
|
||||
"[^|]*", // stdlib
|
||||
"linux.*", // platform
|
||||
largest_type, // test type(s)
|
||||
"[^|]*medium[^|]*", // test data group
|
||||
"[^|]*", 350, 5); // test function
|
||||
add_expected_result(
|
||||
"[^|]*", // compiler
|
||||
"[^|]*", // stdlib
|
||||
"linux.*", // platform
|
||||
largest_type, // test type(s)
|
||||
"[^|]*large[^|]*", // test data group
|
||||
"[^|]*", 150, 5); // test function
|
||||
|
||||
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user