update boost on linux

This commit is contained in:
Bassem Girgis
2019-08-10 16:06:25 -05:00
parent 76ad52be58
commit 861b918727
5363 changed files with 483306 additions and 116507 deletions

View File

@@ -14,6 +14,11 @@
// using boost::math::isfinite;
// using boost::math::isnan;
#ifdef BOOST_MSVC
# pragma warning(push)
# pragma warning(disable: 4702) // unreachable code (return after domain_error throw).
#endif
namespace boost{ namespace math{ namespace detail
{
@@ -112,6 +117,26 @@ inline bool check_x(
return true;
} // bool check_x
template <class RealType, class Policy>
inline bool check_x_not_NaN(
const char* function,
RealType x,
RealType* result,
const Policy& pol)
{
// Note that this test catches only NaN.
// Some distributions permit x to be infinite, leaving this test to catch any NaNs.
// See Normal, Logistic, Laplace and Cauchy for example.
if ((boost::math::isnan)(x))
{
*result = policies::raise_domain_error<RealType>(
function,
"Random variate x is %1%, but must be finite or + or - infinity!", x, pol);
return false;
}
return true;
} // bool check_x_not_NaN
template <class RealType, class Policy>
inline bool check_x_gt0(
const char* function,
@@ -191,4 +216,8 @@ inline bool check_finite(
} // namespace math
} // namespace boost
#ifdef BOOST_MSVC
# pragma warning(pop)
#endif
#endif // BOOST_MATH_DISTRIBUTIONS_COMMON_ERROR_HANDLING_HPP

View File

@@ -228,7 +228,7 @@ inline RealType mean(const extreme_value_distribution<RealType, Policy>& dist)
RealType result = 0;
if(0 == detail::verify_scale_b("boost::math::mean(const extreme_value_distribution<%1%>&)", b, &result, Policy()))
return result;
if(0 == detail::check_scale("boost::math::mean(const extreme_value_distribution<%1%>&)", a, &result, Policy()))
if (0 == detail::check_finite("boost::math::mean(const extreme_value_distribution<%1%>&)", a, &result, Policy()))
return result;
return a + constants::euler<RealType>() * b;
}
@@ -242,7 +242,7 @@ inline RealType standard_deviation(const extreme_value_distribution<RealType, Po
RealType result = 0;
if(0 == detail::verify_scale_b("boost::math::standard_deviation(const extreme_value_distribution<%1%>&)", b, &result, Policy()))
return result;
if(0 == detail::check_scale("boost::math::standard_deviation(const extreme_value_distribution<%1%>&)", dist.location(), &result, Policy()))
if(0 == detail::check_finite("boost::math::standard_deviation(const extreme_value_distribution<%1%>&)", dist.location(), &result, Policy()))
return result;
return constants::pi<RealType>() * b / sqrt(static_cast<RealType>(6));
}

View File

@@ -1,5 +1,5 @@
// Copyright John Maddock 2006.
// Copyright Paul A. Bristow 2006, 2012.
// Copyright Paul A. Bristow 2006, 2012, 2017.
// Copyright Thomas Mang 2012.
// Use, modification and distribution are subject to the
@@ -25,7 +25,7 @@
# pragma warning(disable: 4702) // unreachable code (return after domain_error throw).
#endif
namespace boost{ namespace math{
namespace boost { namespace math {
template <class RealType = double, class Policy = policies::policy<> >
class students_t_distribution
@@ -56,7 +56,7 @@ public:
private:
// Data member:
RealType df_; // degrees of freedom is a real number or +infinity.
RealType df_; // degrees of freedom is a real number > 0 or +infinity.
};
typedef students_t_distribution<double> students_t; // Convenience typedef for double version.
@@ -64,17 +64,20 @@ typedef students_t_distribution<double> students_t; // Convenience typedef for d
template <class RealType, class Policy>
inline const std::pair<RealType, RealType> range(const students_t_distribution<RealType, Policy>& /*dist*/)
{ // Range of permissible values for random variable x.
// NOT including infinity.
// Now including infinity.
using boost::math::tools::max_value;
return std::pair<RealType, RealType>(-max_value<RealType>(), max_value<RealType>());
//return std::pair<RealType, RealType>(-max_value<RealType>(), max_value<RealType>());
return std::pair<RealType, RealType>(((::std::numeric_limits<RealType>::is_specialized & ::std::numeric_limits<RealType>::has_infinity) ? -std::numeric_limits<RealType>::infinity() : -max_value<RealType>()), ((::std::numeric_limits<RealType>::is_specialized & ::std::numeric_limits<RealType>::has_infinity) ? +std::numeric_limits<RealType>::infinity() : +max_value<RealType>()));
}
template <class RealType, class Policy>
inline const std::pair<RealType, RealType> support(const students_t_distribution<RealType, Policy>& /*dist*/)
{ // Range of supported values for random variable x.
// Now including infinity.
// This is range where cdf rises from 0 to 1, and outside it, the pdf is zero.
using boost::math::tools::max_value;
return std::pair<RealType, RealType>(-max_value<RealType>(), max_value<RealType>());
//return std::pair<RealType, RealType>(-max_value<RealType>(), max_value<RealType>());
return std::pair<RealType, RealType>(((::std::numeric_limits<RealType>::is_specialized & ::std::numeric_limits<RealType>::has_infinity) ? -std::numeric_limits<RealType>::infinity() : -max_value<RealType>()), ((::std::numeric_limits<RealType>::is_specialized & ::std::numeric_limits<RealType>::has_infinity) ? +std::numeric_limits<RealType>::infinity() : +max_value<RealType>()));
}
template <class RealType, class Policy>
@@ -84,7 +87,7 @@ inline RealType pdf(const students_t_distribution<RealType, Policy>& dist, const
BOOST_MATH_STD_USING // for ADL of std functions.
RealType error_result;
if(false == detail::check_x(
if(false == detail::check_x_not_NaN(
"boost::math::pdf(const students_t_distribution<%1%>&, %1%)", x, &error_result, Policy()))
return error_result;
RealType df = dist.degrees_of_freedom();
@@ -94,9 +97,8 @@ inline RealType pdf(const students_t_distribution<RealType, Policy>& dist, const
RealType result;
if ((boost::math::isinf)(x))
{ // +infinity.
normal_distribution<RealType, Policy> n(0, 1);
result = pdf(n, x);
{ // - or +infinity.
result = static_cast<RealType>(0);
return result;
}
RealType limit = policies::get_epsilon<RealType, Policy>();
@@ -130,26 +132,28 @@ template <class RealType, class Policy>
inline RealType cdf(const students_t_distribution<RealType, Policy>& dist, const RealType& x)
{
RealType error_result;
if(false == detail::check_x(
"boost::math::pdf(const students_t_distribution<%1%>&, %1%)", x, &error_result, Policy()))
return error_result;
// degrees_of_freedom > 0 or infinity check:
RealType df = dist.degrees_of_freedom();
// Error check:
if(false == detail::check_df_gt0_to_inf( // Check that df > 0 or == +infinity.
"boost::math::cdf(const students_t_distribution<%1%>&, %1%)", df, &error_result, Policy()))
if (false == detail::check_df_gt0_to_inf( // Check that df > 0 or == +infinity.
"boost::math::cdf(const students_t_distribution<%1%>&, %1%)", df, &error_result, Policy()))
{
return error_result;
}
// Check for bad x first.
if(false == detail::check_x_not_NaN(
"boost::math::cdf(const students_t_distribution<%1%>&, %1%)", x, &error_result, Policy()))
{
return error_result;
}
if (x == 0)
{ // Special case with exact result.
return static_cast<RealType>(0.5);
}
if ((boost::math::isinf)(x))
{ // +infinity.
normal_distribution<RealType, Policy> n(0, 1);
RealType result = cdf(n, x);
return result;
{ // x == - or + infinity, regardless of df.
return ((x < 0) ? static_cast<RealType>(0) : static_cast<RealType>(1));
}
RealType limit = policies::get_epsilon<RealType, Policy>();
// Use policies so that if policy requests lower precision,
// then get the normal distribution approximation earlier.
@@ -227,7 +231,6 @@ inline RealType quantile(const students_t_distribution<RealType, Policy>& dist,
// incomplete beta inverse, but code retained for future reference:
//
// Calculate quantile of Student's t using the incomplete beta function inverse:
//
probability = (probability > 0.5) ? 1 - probability : probability;
RealType t, x, y;
x = ibeta_inv(degrees_of_freedom / 2, RealType(0.5), 2 * probability, &y);