diff --git a/include/boost/math/bindings/mpfr.hpp b/include/boost/math/bindings/mpfr.hpp index 9008beb778..ceb1f75790 100644 --- a/include/boost/math/bindings/mpfr.hpp +++ b/include/boost/math/bindings/mpfr.hpp @@ -537,7 +537,7 @@ mpfr_class digamma_imp(mpfr_class x, const std::integral_constant* , con // if(remainder == 0) { - return policies::raise_pole_error("boost::math::digamma<%1%>(%1%)", 0, (1-x), pol); + return policies::raise_pole_error("boost::math::digamma<%1%>(%1%)", nullptr, (1-x), pol); } result = constants::pi() / tan(constants::pi() * remainder); } diff --git a/include/boost/math/bindings/mpreal.hpp b/include/boost/math/bindings/mpreal.hpp index adceb8f12f..e8b6c4036a 100644 --- a/include/boost/math/bindings/mpreal.hpp +++ b/include/boost/math/bindings/mpreal.hpp @@ -487,7 +487,7 @@ mpfr::mpreal digamma_imp(mpfr::mpreal x, const std::integral_constant* , // if(remainder == 0) { - return policies::raise_pole_error("boost::math::digamma<%1%>(%1%)", 0, (1-x), pol); + return policies::raise_pole_error("boost::math::digamma<%1%>(%1%)", nullptr, (1-x), pol); } result = constants::pi() / tan(constants::pi() * remainder); } diff --git a/include/boost/math/bindings/rr.hpp b/include/boost/math/bindings/rr.hpp index 7c280e6169..6197560c0a 100644 --- a/include/boost/math/bindings/rr.hpp +++ b/include/boost/math/bindings/rr.hpp @@ -206,7 +206,7 @@ class RR int exp = 0; NTL::RR t; bool neg = a < V(0) ? true : false; - if(neg) + if(neg) a = -a; while(a) { @@ -467,7 +467,7 @@ struct ntl_lanczos return lanczos61UDT::lanczos_sum_near_2(z); } static ntl::RR g() - { + { unsigned long p = ntl::RR::precision(); if(p <= 72) return lanczos13UDT::g(); @@ -691,8 +691,8 @@ namespace ntl{ double r; conv(r, z.value()); return boost::math::tools::halley_iterate( - asin_root(z), - RR(std::asin(r)), + asin_root(z), + RR(std::asin(r)), RR(-boost::math::constants::pi()/2), RR(boost::math::constants::pi()/2), NTL::RR::precision()); @@ -719,8 +719,8 @@ namespace ntl{ double r; conv(r, z.value()); return boost::math::tools::halley_iterate( - acos_root(z), - RR(std::acos(r)), + acos_root(z), + RR(std::acos(r)), RR(-boost::math::constants::pi()/2), RR(boost::math::constants::pi()/2), NTL::RR::precision()); @@ -748,8 +748,8 @@ namespace ntl{ double r; conv(r, z.value()); return boost::math::tools::halley_iterate( - atan_root(z), - RR(std::atan(r)), + atan_root(z), + RR(std::atan(r)), -boost::math::constants::pi()/2, boost::math::constants::pi()/2, NTL::RR::precision()); @@ -858,7 +858,7 @@ ntl::RR digamma_imp(ntl::RR x, const std::integral_constant* , const Pol // if(remainder == 0) { - return policies::raise_pole_error("boost::math::digamma<%1%>(%1%)", 0, (1-x), pol); + return policies::raise_pole_error("boost::math::digamma<%1%>(%1%)", nullptr, (1-x), pol); } result = constants::pi() / tan(constants::pi() * remainder); } diff --git a/include/boost/math/concepts/distributions.hpp b/include/boost/math/concepts/distributions.hpp index 0ca351f98a..1c118fad7c 100644 --- a/include/boost/math/concepts/distributions.hpp +++ b/include/boost/math/concepts/distributions.hpp @@ -50,7 +50,7 @@ class distribution_archetype static distribution_archetype& get_object() { // will never get caled: - return *reinterpret_cast(0); + return *reinterpret_cast(nullptr); } }; // template class distribution_archetype diff --git a/include/boost/math/distributions/beta.hpp b/include/boost/math/distributions/beta.hpp index b313500bee..1de399ead2 100644 --- a/include/boost/math/distributions/beta.hpp +++ b/include/boost/math/distributions/beta.hpp @@ -498,7 +498,7 @@ namespace boost { return 1; } - return ibeta_inv(a, b, p, static_cast(0), Policy()); + return ibeta_inv(a, b, p, static_cast(nullptr), Policy()); } // quantile template @@ -535,7 +535,7 @@ namespace boost return 1; } - return ibetac_inv(a, b, q, static_cast(0), Policy()); + return ibetac_inv(a, b, q, static_cast(nullptr), Policy()); } // Quantile Complement } // namespace math diff --git a/include/boost/math/distributions/binomial.hpp b/include/boost/math/distributions/binomial.hpp index b54292aebd..02991e1b49 100644 --- a/include/boost/math/distributions/binomial.hpp +++ b/include/boost/math/distributions/binomial.hpp @@ -335,8 +335,8 @@ namespace boost // NOTE!!! The Clopper Pearson formula uses "successes" not // "successes+1" as usual to get the lower bound, // see http://www.itl.nist.gov/div898/handbook/prc/section2/prc241.htm - return (t == clopper_pearson_exact_interval) ? ibeta_inv(successes, trials - successes + 1, probability, static_cast(0), Policy()) - : ibeta_inv(successes + 0.5f, trials - successes + 0.5f, probability, static_cast(0), Policy()); + return (t == clopper_pearson_exact_interval) ? ibeta_inv(successes, trials - successes + 1, probability, static_cast(nullptr), Policy()) + : ibeta_inv(successes + 0.5f, trials - successes + 0.5f, probability, static_cast(nullptr), Policy()); } static RealType find_upper_bound_on_p( RealType trials, @@ -357,8 +357,8 @@ namespace boost if(trials == successes) return 1; - return (t == clopper_pearson_exact_interval) ? ibetac_inv(successes + 1, trials - successes, probability, static_cast(0), Policy()) - : ibetac_inv(successes + 0.5f, trials - successes + 0.5f, probability, static_cast(0), Policy()); + return (t == clopper_pearson_exact_interval) ? ibetac_inv(successes + 1, trials - successes, probability, static_cast(nullptr), Policy()) + : ibetac_inv(successes + 0.5f, trials - successes + 0.5f, probability, static_cast(nullptr), Policy()); } // Estimate number of trials parameter: // diff --git a/include/boost/math/distributions/detail/derived_accessors.hpp b/include/boost/math/distributions/detail/derived_accessors.hpp index e2eca511bf..d278e78776 100644 --- a/include/boost/math/distributions/detail/derived_accessors.hpp +++ b/include/boost/math/distributions/detail/derived_accessors.hpp @@ -65,7 +65,7 @@ inline typename Distribution::value_type hazard(const Distribution& dist, const value_type d = pdf(dist, x); if(d > p * tools::max_value()) return policies::raise_overflow_error( - "boost::math::hazard(const Distribution&, %1%)", 0, policy_type()); + "boost::math::hazard(const Distribution&, %1%)", nullptr, policy_type()); if(d == 0) { // This protects against 0/0, but is it the right thing to do? @@ -94,7 +94,7 @@ inline typename Distribution::value_type coefficient_of_variation(const Distribu value_type d = standard_deviation(dist); if((abs(m) < 1) && (d > abs(m) * tools::max_value())) { // Checks too that m is not zero, - return policies::raise_overflow_error("boost::math::coefficient_of_variation(const Distribution&, %1%)", 0, policy_type()); + return policies::raise_overflow_error("boost::math::coefficient_of_variation(const Distribution&, %1%)", nullptr, policy_type()); } return d / m; // so MSVC warning on zerodivide is spurious, and suppressed. } diff --git a/include/boost/math/distributions/detail/generic_quantile.hpp b/include/boost/math/distributions/detail/generic_quantile.hpp index f7852f8fc0..67d3f04f88 100644 --- a/include/boost/math/distributions/detail/generic_quantile.hpp +++ b/include/boost/math/distributions/detail/generic_quantile.hpp @@ -11,8 +11,8 @@ namespace boost{ namespace math{ namespace detail{ template struct generic_quantile_finder { - typedef typename Dist::value_type value_type; - typedef typename Dist::policy_type policy_type; + using value_type = typename Dist::value_type; + using policy_type = typename Dist::policy_type; generic_quantile_finder(const Dist& d, value_type t, bool c) : dist(d), target(t), comp(c) {} @@ -34,25 +34,31 @@ template inline T check_range_result(const T& x, const Policy& pol, const char* function) { if((x >= 0) && (x < tools::min_value())) - return policies::raise_underflow_error(function, 0, pol); + { + return policies::raise_underflow_error(function, nullptr, pol); + } if(x <= -tools::max_value()) - return -policies::raise_overflow_error(function, 0, pol); + { + return -policies::raise_overflow_error(function, nullptr, pol); + } if(x >= tools::max_value()) - return policies::raise_overflow_error(function, 0, pol); + { + return policies::raise_overflow_error(function, nullptr, pol); + } return x; } template typename Dist::value_type generic_quantile(const Dist& dist, const typename Dist::value_type& p, const typename Dist::value_type& guess, bool comp, const char* function) { - typedef typename Dist::value_type value_type; - typedef typename Dist::policy_type policy_type; - typedef typename policies::normalise< - policy_type, - policies::promote_float, - policies::promote_double, - policies::discrete_quantile<>, - policies::assert_undefined<> >::type forwarding_policy; + using value_type = typename Dist::value_type; + using policy_type = typename Dist::policy_type; + using forwarding_policy = typename policies::normalise< + policy_type, + policies::promote_float, + policies::promote_double, + policies::discrete_quantile<>, + policies::assert_undefined<> >::type; // // Special cases first: diff --git a/include/boost/math/distributions/empirical_cumulative_distribution_function.hpp b/include/boost/math/distributions/empirical_cumulative_distribution_function.hpp index d05dc46f18..ac1e4bee08 100644 --- a/include/boost/math/distributions/empirical_cumulative_distribution_function.hpp +++ b/include/boost/math/distributions/empirical_cumulative_distribution_function.hpp @@ -32,10 +32,10 @@ class empirical_cumulative_distribution_function { if constexpr (std::is_integral_v) { if (x < m_v[0]) { - return double(0); + return static_cast(0); } if (x >= m_v[m_v.size()-1]) { - return double(1); + return static_cast(1); } auto it = std::upper_bound(m_v.begin(), m_v.end(), x); return static_cast(std::distance(m_v.begin(), it))/static_cast(m_v.size()); diff --git a/include/boost/math/distributions/geometric.hpp b/include/boost/math/distributions/geometric.hpp index 9a9f0ea073..b091bf1c63 100644 --- a/include/boost/math/distributions/geometric.hpp +++ b/include/boost/math/distributions/geometric.hpp @@ -158,7 +158,7 @@ namespace boost // Discrete Distributions" Yong CAI and K. KRISHNAMOORTHY // http://www.ucs.louisiana.edu/~kxk4695/Discrete_new.pdf // - return ibeta_inv(successes, failures + 1, alpha, static_cast(0), Policy()); + return ibeta_inv(successes, failures + 1, alpha, static_cast(nullptr), Policy()); } // find_lower_bound_on_p static RealType find_upper_bound_on_p( @@ -187,7 +187,7 @@ namespace boost // Discrete Distributions" Yong CAI and K. Krishnamoorthy // http://www.ucs.louisiana.edu/~kxk4695/Discrete_new.pdf // - return ibetac_inv(successes, failures, alpha, static_cast(0), Policy()); + return ibetac_inv(successes, failures, alpha, static_cast(nullptr), Policy()); } // find_upper_bound_on_p // Estimate number of trials : @@ -222,7 +222,7 @@ namespace boost if(false == geometric_detail::check_dist_and_k( function, p, k, &result, Policy()) && detail::check_probability(function, alpha, &result, Policy())) - { + { return result; } result = ibetac_inva(k + 1, p, alpha, Policy()); // returns n - k @@ -270,7 +270,7 @@ namespace boost BOOST_MATH_STD_USING // ADL of std functions. return 0; } // mode - + template inline RealType variance(const geometric_distribution& dist) { // Variance of Binomial distribution = (1-p) / p^2. @@ -446,7 +446,7 @@ namespace boost { return 0; } - + // log(1-x) /log(1-success_fraction) -1; but use log1p in case success_fraction is small result = boost::math::log1p(-x, Policy()) / boost::math::log1p(-success_fraction, Policy()) - 1; // Subtract a few epsilons here too? diff --git a/include/boost/math/distributions/negative_binomial.hpp b/include/boost/math/distributions/negative_binomial.hpp index 34412bf4ba..18eec09939 100644 --- a/include/boost/math/distributions/negative_binomial.hpp +++ b/include/boost/math/distributions/negative_binomial.hpp @@ -176,7 +176,7 @@ namespace boost // Discrete Distributions" Yong CAI and K. KRISHNAMOORTHY // http://www.ucs.louisiana.edu/~kxk4695/Discrete_new.pdf // - return ibeta_inv(successes, failures + 1, alpha, static_cast(0), Policy()); + return ibeta_inv(successes, failures + 1, alpha, static_cast(nullptr), Policy()); } // find_lower_bound_on_p static RealType find_upper_bound_on_p( @@ -204,7 +204,7 @@ namespace boost // Discrete Distributions" Yong CAI and K. KRISHNAMOORTHY // http://www.ucs.louisiana.edu/~kxk4695/Discrete_new.pdf // - return ibetac_inv(successes, failures, alpha, static_cast(0), Policy()); + return ibetac_inv(successes, failures, alpha, static_cast(nullptr), Policy()); } // find_upper_bound_on_p // Estimate number of trials : diff --git a/include/boost/math/policies/error_handling.hpp b/include/boost/math/policies/error_handling.hpp index 3af1f976b5..c4120d4482 100644 --- a/include/boost/math/policies/error_handling.hpp +++ b/include/boost/math/policies/error_handling.hpp @@ -41,17 +41,17 @@ namespace boost{ namespace math{ #ifndef BOOST_NO_EXCEPTIONS - + class evaluation_error : public std::runtime_error { public: - evaluation_error(const std::string& s) : std::runtime_error(s){} + explicit evaluation_error(const std::string& s) : std::runtime_error(s){} }; class rounding_error : public std::runtime_error { public: - rounding_error(const std::string& s) : std::runtime_error(s){} + explicit rounding_error(const std::string& s) : std::runtime_error(s){} }; #endif @@ -132,10 +132,14 @@ inline const char* name_of() template void raise_error(const char* pfunction, const char* message) { - if(pfunction == 0) + if(pfunction == nullptr) + { pfunction = "Unknown function operating on type %1%"; - if(message == 0) + } + if(message == nullptr) + { message = "Cause unknown"; + } std::string function(pfunction); std::string msg("Error in function "); @@ -155,10 +159,14 @@ void raise_error(const char* pfunction, const char* message) template void raise_error(const char* pfunction, const char* pmessage, const T& val) { - if(pfunction == 0) + if(pfunction == nullptr) + { pfunction = "Unknown function operating on type %1%"; - if(pmessage == 0) + } + if(pmessage == nullptr) + { pmessage = "Cause unknown: error caused by bad argument with value %1%"; + } std::string function(pfunction); std::string message(pmessage); @@ -748,7 +756,7 @@ inline bool check_overflow(T val, R* result, const char* function, const Policy& BOOST_MATH_STD_USING if(fabs(val) > tools::max_value()) { - boost::math::policies::detail::raise_overflow_error(function, 0, pol); + boost::math::policies::detail::raise_overflow_error(function, nullptr, pol); *result = static_cast(val); return true; } @@ -769,7 +777,7 @@ inline bool check_underflow(T val, R* result, const char* function, const Policy { if((val != 0) && (static_cast(val) == 0)) { - *result = static_cast(boost::math::policies::detail::raise_underflow_error(function, 0, pol)); + *result = static_cast(boost::math::policies::detail::raise_underflow_error(function, nullptr, pol)); return true; } return false; @@ -808,22 +816,22 @@ inline bool check_denorm(std::complex val, R* result, const char* function, c // Default instantiations with ignore_error policy. template -inline constexpr bool check_overflow(T /* val */, R* /* result */, const char* /* function */, const overflow_error&) noexcept(BOOST_MATH_IS_FLOAT(R) && BOOST_MATH_IS_FLOAT(T)) +inline constexpr bool check_overflow(T /* val */, R* /* result */, const char* /* function */, const overflow_error&) noexcept(BOOST_MATH_IS_FLOAT(R) && BOOST_MATH_IS_FLOAT(T)) { return false; } template -inline constexpr bool check_overflow(std::complex /* val */, R* /* result */, const char* /* function */, const overflow_error&) noexcept(BOOST_MATH_IS_FLOAT(R) && BOOST_MATH_IS_FLOAT(T)) +inline constexpr bool check_overflow(std::complex /* val */, R* /* result */, const char* /* function */, const overflow_error&) noexcept(BOOST_MATH_IS_FLOAT(R) && BOOST_MATH_IS_FLOAT(T)) { return false; } template -inline constexpr bool check_underflow(T /* val */, R* /* result */, const char* /* function */, const underflow_error&) noexcept(BOOST_MATH_IS_FLOAT(R) && BOOST_MATH_IS_FLOAT(T)) +inline constexpr bool check_underflow(T /* val */, R* /* result */, const char* /* function */, const underflow_error&) noexcept(BOOST_MATH_IS_FLOAT(R) && BOOST_MATH_IS_FLOAT(T)) { return false; } template -inline constexpr bool check_underflow(std::complex /* val */, R* /* result */, const char* /* function */, const underflow_error&) noexcept(BOOST_MATH_IS_FLOAT(R) && BOOST_MATH_IS_FLOAT(T)) +inline constexpr bool check_underflow(std::complex /* val */, R* /* result */, const char* /* function */, const underflow_error&) noexcept(BOOST_MATH_IS_FLOAT(R) && BOOST_MATH_IS_FLOAT(T)) { return false; } template -inline constexpr bool check_denorm(T /* val */, R* /* result*/, const char* /* function */, const denorm_error&) noexcept(BOOST_MATH_IS_FLOAT(R) && BOOST_MATH_IS_FLOAT(T)) +inline constexpr bool check_denorm(T /* val */, R* /* result*/, const char* /* function */, const denorm_error&) noexcept(BOOST_MATH_IS_FLOAT(R) && BOOST_MATH_IS_FLOAT(T)) { return false; } template -inline constexpr bool check_denorm(std::complex /* val */, R* /* result*/, const char* /* function */, const denorm_error&) noexcept(BOOST_MATH_IS_FLOAT(R) && BOOST_MATH_IS_FLOAT(T)) +inline constexpr bool check_denorm(std::complex /* val */, R* /* result*/, const char* /* function */, const denorm_error&) noexcept(BOOST_MATH_IS_FLOAT(R) && BOOST_MATH_IS_FLOAT(T)) { return false; } } // namespace detail diff --git a/include/boost/math/policies/policy.hpp b/include/boost/math/policies/policy.hpp index ed4f58a7e4..9e12145a1f 100644 --- a/include/boost/math/policies/policy.hpp +++ b/include/boost/math/policies/policy.hpp @@ -15,7 +15,7 @@ #include #include -namespace boost{ namespace math{ +namespace boost{ namespace math{ namespace mp = tools::meta_programming; @@ -122,7 +122,7 @@ namespace policies{ static char test(const name* = nullptr); \ static double test(...); \ public: \ - static constexpr bool value = sizeof(test(static_cast(0))) == sizeof(char); \ + static constexpr bool value = sizeof(test(static_cast(nullptr))) == sizeof(char); \ }; \ } \ \ @@ -151,7 +151,7 @@ namespace policies{ static char test(const name* = nullptr); \ static double test(...); \ public: \ - static constexpr bool value = sizeof(test(static_cast(0))) == sizeof(char); \ + static constexpr bool value = sizeof(test(static_cast(nullptr))) == sizeof(char); \ }; \ } \ \ @@ -255,14 +255,14 @@ char test_is_valid_arg(const default_policy*); char test_is_default_arg(const default_policy*); template -class is_valid_policy_imp +class is_valid_policy_imp { public: - static constexpr bool value = sizeof(boost::math::policies::detail::test_is_valid_arg(static_cast(0))) == sizeof(char); + static constexpr bool value = sizeof(boost::math::policies::detail::test_is_valid_arg(static_cast(nullptr))) == sizeof(char); }; -template -class is_valid_policy +template +class is_valid_policy { public: static constexpr bool value = boost::math::policies::detail::is_valid_policy_imp::value; @@ -272,7 +272,7 @@ template class is_default_policy_imp { public: - static constexpr bool value = sizeof(boost::math::policies::detail::test_is_default_arg(static_cast(0))) == sizeof(char); + static constexpr bool value = sizeof(boost::math::policies::detail::test_is_default_arg(static_cast(nullptr))) == sizeof(char); }; template @@ -342,8 +342,8 @@ typedef default_args, evaluation_error<>>::type; using rounding_error_type = typename arg_type, rounding_error<>>::type; using indeterminate_result_error_type = typename arg_type, indeterminate_result_error<>>::type; - + // Precision: using precision_type = typename detail::precision::type; @@ -427,7 +427,7 @@ class policy // Discrete quantiles: using discrete_quantile_type = typename arg_type, discrete_quantile<>>::type; - + // Mathematically undefined properties: using assert_undefined_type = typename arg_type, assert_undefined<>>::type; @@ -491,9 +491,9 @@ struct policy; }; -template ; using reduced_list = mp::mp_remove_if_q; - + // Pad out the list with defaults: using result_type = typename detail::append_N::value)>::type; @@ -607,9 +607,9 @@ class normalise // Full specialisation to speed up compilation of the common case: template <> -struct normalise, - promote_float, - promote_double, +struct normalise, + promote_float, + promote_double, discrete_quantile<>, assert_undefined<>, default_policy, @@ -645,72 +645,72 @@ inline constexpr policy<> make_policy() noexcept template inline constexpr typename normalise, A1>::type make_policy(const A1&) noexcept -{ +{ typedef typename normalise, A1>::type result_type; - return result_type(); + return result_type(); } template inline constexpr typename normalise, A1, A2>::type make_policy(const A1&, const A2&) noexcept -{ +{ typedef typename normalise, A1, A2>::type result_type; - return result_type(); + return result_type(); } template inline constexpr typename normalise, A1, A2, A3>::type make_policy(const A1&, const A2&, const A3&) noexcept -{ +{ typedef typename normalise, A1, A2, A3>::type result_type; - return result_type(); + return result_type(); } template inline constexpr typename normalise, A1, A2, A3, A4>::type make_policy(const A1&, const A2&, const A3&, const A4&) noexcept -{ +{ typedef typename normalise, A1, A2, A3, A4>::type result_type; - return result_type(); + return result_type(); } template inline constexpr typename normalise, A1, A2, A3, A4, A5>::type make_policy(const A1&, const A2&, const A3&, const A4&, const A5&) noexcept -{ +{ typedef typename normalise, A1, A2, A3, A4, A5>::type result_type; - return result_type(); + return result_type(); } template inline constexpr typename normalise, A1, A2, A3, A4, A5, A6>::type make_policy(const A1&, const A2&, const A3&, const A4&, const A5&, const A6&) noexcept -{ +{ typedef typename normalise, A1, A2, A3, A4, A5, A6>::type result_type; - return result_type(); + return result_type(); } template inline constexpr typename normalise, A1, A2, A3, A4, A5, A6, A7>::type make_policy(const A1&, const A2&, const A3&, const A4&, const A5&, const A6&, const A7&) noexcept -{ +{ typedef typename normalise, A1, A2, A3, A4, A5, A6, A7>::type result_type; - return result_type(); + return result_type(); } template inline constexpr typename normalise, A1, A2, A3, A4, A5, A6, A7, A8>::type make_policy(const A1&, const A2&, const A3&, const A4&, const A5&, const A6&, const A7&, const A8&) noexcept -{ +{ typedef typename normalise, A1, A2, A3, A4, A5, A6, A7, A8>::type result_type; - return result_type(); + return result_type(); } template inline constexpr typename normalise, A1, A2, A3, A4, A5, A6, A7, A8, A9>::type make_policy(const A1&, const A2&, const A3&, const A4&, const A5&, const A6&, const A7&, const A8&, const A9&) noexcept -{ +{ typedef typename normalise, A1, A2, A3, A4, A5, A6, A7, A8, A9>::type result_type; - return result_type(); + return result_type(); } template inline constexpr typename normalise, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10>::type make_policy(const A1&, const A2&, const A3&, const A4&, const A5&, const A6&, const A7&, const A8&, const A9&, const A10&) noexcept -{ +{ typedef typename normalise, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10>::type result_type; - return result_type(); + return result_type(); } template @@ -753,7 +753,7 @@ struct precision // Possibly unknown precision: precision_type, typename std::conditional< - ((std::numeric_limits::digits <= precision_type::value) + ((std::numeric_limits::digits <= precision_type::value) || (Policy::precision_type::value <= 0)), // Default case, full precision for RealType: digits2< std::numeric_limits::digits>, @@ -899,8 +899,8 @@ inline constexpr T get_epsilon(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(T)) noexcept(st namespace detail{ -template class is_policy_imp { public: - static constexpr bool value = (sizeof(::boost::math::policies::detail::test_is_policy(static_cast(0))) == sizeof(char)); + static constexpr bool value = (sizeof(::boost::math::policies::detail::test_is_policy(static_cast(nullptr))) == sizeof(char)); }; } @@ -967,7 +967,7 @@ struct is_noexcept_error_policy typedef typename Policy::rounding_error_type t7; typedef typename Policy::indeterminate_result_error_type t8; - static constexpr bool value = + static constexpr bool value = ((t1::value != throw_on_error) && (t1::value != user_error) && (t2::value != throw_on_error) && (t2::value != user_error) && (t3::value != throw_on_error) && (t3::value != user_error) diff --git a/include/boost/math/special_functions/atanh.hpp b/include/boost/math/special_functions/atanh.hpp index 3bcf171d1c..6204dc434f 100644 --- a/include/boost/math/special_functions/atanh.hpp +++ b/include/boost/math/special_functions/atanh.hpp @@ -31,13 +31,13 @@ namespace boost namespace detail { // This is the main fare - + template inline T atanh_imp(const T x, const Policy& pol) { BOOST_MATH_STD_USING static const char* function = "boost::math::atanh<%1%>(%1%)"; - + if(x < -1) { return policies::raise_domain_error( @@ -59,12 +59,12 @@ namespace boost else if(x < -1 + tools::epsilon()) { // -Infinity: - return -policies::raise_overflow_error(function, 0, pol); + return -policies::raise_overflow_error(function, nullptr, pol); } else if(x > 1 - tools::epsilon()) { // Infinity: - return policies::raise_overflow_error(function, 0, pol); + return policies::raise_overflow_error(function, nullptr, pol); } else if(abs(x) >= tools::forth_root_epsilon()) { @@ -78,15 +78,15 @@ namespace boost // http://functions.wolfram.com/ElementaryFunctions/ArcTanh/06/01/03/01/ // approximation by taylor series in x at 0 up to order 2 T result = x; - + if (abs(x) >= tools::root_epsilon()) { T x3 = x*x*x; - + // approximation by taylor series in x at 0 up to order 4 result += x3/static_cast(3); } - + return(result); } } @@ -98,9 +98,9 @@ namespace boost typedef typename tools::promote_args::type result_type; typedef typename policies::evaluation::type value_type; typedef typename policies::normalise< - Policy, - policies::promote_float, - policies::promote_double, + Policy, + policies::promote_float, + policies::promote_double, policies::discrete_quantile<>, policies::assert_undefined<> >::type forwarding_policy; return policies::checked_narrowing_cast( diff --git a/include/boost/math/special_functions/bernoulli.hpp b/include/boost/math/special_functions/bernoulli.hpp index f22535286f..d77a52089e 100644 --- a/include/boost/math/special_functions/bernoulli.hpp +++ b/include/boost/math/special_functions/bernoulli.hpp @@ -31,7 +31,7 @@ OutputIterator bernoulli_number_imp(OutputIterator out, std::size_t start, std:: for(std::size_t i = (std::max)(static_cast(max_bernoulli_b2n::value + 1), start); i < start + n; ++i) { // We must overflow: - *out = (i & 1 ? 1 : -1) * policies::raise_overflow_error("boost::math::bernoulli_b2n<%1%>(n)", 0, T(i), pol); + *out = (i & 1 ? 1 : -1) * policies::raise_overflow_error("boost::math::bernoulli_b2n<%1%>(n)", nullptr, T(i), pol); ++out; } return out; diff --git a/include/boost/math/special_functions/bessel.hpp b/include/boost/math/special_functions/bessel.hpp index 8504cc12c9..837f39253a 100644 --- a/include/boost/math/special_functions/bessel.hpp +++ b/include/boost/math/special_functions/bessel.hpp @@ -106,7 +106,7 @@ T cyl_bessel_j_imp(T v, T x, const bessel_no_int_tag& t, const Policy& pol) function, "Got x = %1%, but we need x >= 0", x, pol); } - + T j, y; bessel_jy(v, x, &j, &y, need_j, pol); return j; @@ -160,7 +160,7 @@ inline T sph_bessel_j_imp(unsigned n, T x, const Policy& pol) // // Default case is just a naive evaluation of the definition: // - return sqrt(constants::pi() / (2 * x)) + return sqrt(constants::pi() / (2 * x)) * cyl_bessel_j_imp(T(T(n)+T(0.5f)), x, bessel_no_int_tag(), pol); } @@ -234,7 +234,7 @@ inline T cyl_bessel_k_imp(T v, T x, const bessel_no_int_tag& /* t */, const Poli } if(x == 0) { - return (v == 0) ? policies::raise_overflow_error(function, 0, pol) + return (v == 0) ? policies::raise_overflow_error(function, nullptr, pol) : policies::raise_domain_error( function, "Got x = %1%, but we need x > 0", x, pol); @@ -272,20 +272,20 @@ inline T cyl_neumann_imp(T v, T x, const bessel_no_int_tag&, const Policy& pol) if(x <= 0) { return (v == 0) && (x == 0) ? - policies::raise_overflow_error(function, 0, pol) + policies::raise_overflow_error(function, nullptr, pol) : policies::raise_domain_error( function, "Got x = %1%, but result is complex for x <= 0", x, pol); } T j, y; bessel_jy(v, x, &j, &y, need_y, pol); - // + // // Post evaluation check for internal overflow during evaluation, // can occur when x is small and v is large, in which case the result // is -INF: // if(!(boost::math::isfinite)(y)) - return -policies::raise_overflow_error(function, 0, pol); + return -policies::raise_overflow_error(function, nullptr, pol); return y; } @@ -329,13 +329,13 @@ inline T sph_neumann_imp(unsigned v, T x, const Policy& pol) "Got x = %1%, but function requires x > 0.", x, pol); if(x < 2 * tools::min_value()) - return -policies::raise_overflow_error(function, 0, pol); + return -policies::raise_overflow_error(function, nullptr, pol); T result = cyl_neumann_imp(T(T(v)+0.5f), x, bessel_no_int_tag(), pol); T tx = sqrt(constants::pi() / (2 * x)); if((tx > 1) && (tools::max_value() / tx < result)) - return -policies::raise_overflow_error(function, 0, pol); + return -policies::raise_overflow_error(function, nullptr, pol); return result * tx; } @@ -508,9 +508,9 @@ inline typename detail::bessel_traits::result_type cyl_bessel_j( typedef typename detail::bessel_traits::optimisation_tag tag_type; typedef typename policies::evaluation::type value_type; typedef typename policies::normalise< - Policy, - policies::promote_float, - policies::promote_double, + Policy, + policies::promote_float, + policies::promote_double, policies::discrete_quantile<>, policies::assert_undefined<> >::type forwarding_policy; return policies::checked_narrowing_cast(detail::cyl_bessel_j_imp(v, static_cast(x), tag_type(), forwarding_policy()), "boost::math::cyl_bessel_j<%1%>(%1%,%1%)"); @@ -529,9 +529,9 @@ inline typename detail::bessel_traits::result_type sph_bessel(unsi typedef typename detail::bessel_traits::result_type result_type; typedef typename policies::evaluation::type value_type; typedef typename policies::normalise< - Policy, - policies::promote_float, - policies::promote_double, + Policy, + policies::promote_float, + policies::promote_double, policies::discrete_quantile<>, policies::assert_undefined<> >::type forwarding_policy; return policies::checked_narrowing_cast(detail::sph_bessel_j_imp(v, static_cast(x), forwarding_policy()), "boost::math::sph_bessel<%1%>(%1%,%1%)"); @@ -550,9 +550,9 @@ inline typename detail::bessel_traits::result_type cyl_bessel_i( typedef typename detail::bessel_traits::result_type result_type; typedef typename policies::evaluation::type value_type; typedef typename policies::normalise< - Policy, - policies::promote_float, - policies::promote_double, + Policy, + policies::promote_float, + policies::promote_double, policies::discrete_quantile<>, policies::assert_undefined<> >::type forwarding_policy; return policies::checked_narrowing_cast(detail::cyl_bessel_i_imp(static_cast(v), static_cast(x), forwarding_policy()), "boost::math::cyl_bessel_i<%1%>(%1%,%1%)"); @@ -572,9 +572,9 @@ inline typename detail::bessel_traits::result_type cyl_bessel_k( typedef typename detail::bessel_traits::optimisation_tag128 tag_type; typedef typename policies::evaluation::type value_type; typedef typename policies::normalise< - Policy, - policies::promote_float, - policies::promote_double, + Policy, + policies::promote_float, + policies::promote_double, policies::discrete_quantile<>, policies::assert_undefined<> >::type forwarding_policy; return policies::checked_narrowing_cast(detail::cyl_bessel_k_imp(v, static_cast(x), tag_type(), forwarding_policy()), "boost::math::cyl_bessel_k<%1%>(%1%,%1%)"); @@ -594,9 +594,9 @@ inline typename detail::bessel_traits::result_type cyl_neumann(T typedef typename detail::bessel_traits::optimisation_tag tag_type; typedef typename policies::evaluation::type value_type; typedef typename policies::normalise< - Policy, - policies::promote_float, - policies::promote_double, + Policy, + policies::promote_float, + policies::promote_double, policies::discrete_quantile<>, policies::assert_undefined<> >::type forwarding_policy; return policies::checked_narrowing_cast(detail::cyl_neumann_imp(v, static_cast(x), tag_type(), forwarding_policy()), "boost::math::cyl_neumann<%1%>(%1%,%1%)"); @@ -615,9 +615,9 @@ inline typename detail::bessel_traits::result_type sph_neumann(uns typedef typename detail::bessel_traits::result_type result_type; typedef typename policies::evaluation::type value_type; typedef typename policies::normalise< - Policy, - policies::promote_float, - policies::promote_double, + Policy, + policies::promote_float, + policies::promote_double, policies::discrete_quantile<>, policies::assert_undefined<> >::type forwarding_policy; return policies::checked_narrowing_cast(detail::sph_neumann_imp(v, static_cast(x), forwarding_policy()), "boost::math::sph_neumann<%1%>(%1%,%1%)"); @@ -636,9 +636,9 @@ inline typename detail::bessel_traits::result_type cyl_bessel_j_ze typedef typename detail::bessel_traits::result_type result_type; typedef typename policies::evaluation::type value_type; typedef typename policies::normalise< - Policy, - policies::promote_float, - policies::promote_double, + Policy, + policies::promote_float, + policies::promote_double, policies::discrete_quantile<>, policies::assert_undefined<> >::type forwarding_policy; @@ -697,9 +697,9 @@ inline typename detail::bessel_traits::result_type cyl_neumann_zer typedef typename detail::bessel_traits::result_type result_type; typedef typename policies::evaluation::type value_type; typedef typename policies::normalise< - Policy, - policies::promote_float, - policies::promote_double, + Policy, + policies::promote_float, + policies::promote_double, policies::discrete_quantile<>, policies::assert_undefined<> >::type forwarding_policy; diff --git a/include/boost/math/special_functions/bessel_prime.hpp b/include/boost/math/special_functions/bessel_prime.hpp index 28c6cb963a..9615d40644 100644 --- a/include/boost/math/special_functions/bessel_prime.hpp +++ b/include/boost/math/special_functions/bessel_prime.hpp @@ -93,7 +93,7 @@ inline T sph_bessel_j_prime_imp(unsigned v, T x, const Policy& pol) // Special case for v == 0: // if (v == 0) - return (x == 0) ? boost::math::policies::raise_overflow_error(function, 0, pol) + return (x == 0) ? boost::math::policies::raise_overflow_error(function, nullptr, pol) : static_cast(-boost::math::detail::sph_bessel_j_imp(1, x, pol)); // // Special case for x == 0 and v > 0: diff --git a/include/boost/math/special_functions/beta.hpp b/include/boost/math/special_functions/beta.hpp index cebb834765..d1ce5a2467 100644 --- a/include/boost/math/special_functions/beta.hpp +++ b/include/boost/math/special_functions/beta.hpp @@ -328,7 +328,7 @@ T ibeta_power_terms(T a, { l += log(result); if(l >= tools::log_max_value()) - return policies::raise_overflow_error(function, 0, pol); + return policies::raise_overflow_error(function, nullptr, pol); result = exp(l); } else @@ -344,7 +344,7 @@ T ibeta_power_terms(T a, { l += log(result); if(l >= tools::log_max_value()) - return policies::raise_overflow_error(function, 0, pol); + return policies::raise_overflow_error(function, nullptr, pol); result = exp(l); } else @@ -383,7 +383,7 @@ T ibeta_power_terms(T a, { l2 += l1 + log(result); if(l2 >= tools::log_max_value()) - return policies::raise_overflow_error(function, 0, pol); + return policies::raise_overflow_error(function, nullptr, pol); result = exp(l2); } } @@ -400,7 +400,7 @@ T ibeta_power_terms(T a, { l2 += l1 + log(result); if(l2 >= tools::log_max_value()) - return policies::raise_overflow_error(function, 0, pol); + return policies::raise_overflow_error(function, nullptr, pol); result = exp(l2); } } @@ -1324,7 +1324,7 @@ T ibeta_imp(T a, T b, T x, const Policy& pol, bool inv, bool normalised, T* p_de { prefix = 1; } - fract = ibeta_a_step(bbar, a, y, x, n, pol, normalised, static_cast(0)); + fract = ibeta_a_step(bbar, a, y, x, n, pol, normalised, static_cast(nullptr)); fract = beta_small_b_large_a_series(a, bbar, x, y, fract, T(1), pol, normalised); fract /= prefix; BOOST_MATH_INSTRUMENT_VARIABLE(fract); @@ -1341,8 +1341,8 @@ T ibeta_imp(T a, T b, T x, const Policy& pol, bool inv, bool normalised, T* p_de --n; bbar += 1; } - fract = ibeta_a_step(bbar, a, y, x, n, pol, normalised, static_cast(0)); - fract += ibeta_a_step(a, bbar, x, y, 20, pol, normalised, static_cast(0)); + fract = ibeta_a_step(bbar, a, y, x, n, pol, normalised, static_cast(nullptr)); + fract += ibeta_a_step(a, bbar, x, y, 20, pol, normalised, static_cast(nullptr)); if(invert) fract -= 1; // Note this line would need changing if we ever enable this branch in non-normalized case fract = beta_small_b_large_a_series(T(a+20), bbar, x, y, fract, T(1), pol, normalised); @@ -1392,7 +1392,7 @@ T ibeta_imp(T a, T b, T x, const Policy& pol, bool inv, bool normalised, T* p_de template inline T ibeta_imp(T a, T b, T x, const Policy& pol, bool inv, bool normalised) { - return ibeta_imp(a, b, x, pol, inv, normalised, static_cast(0)); + return ibeta_imp(a, b, x, pol, inv, normalised, static_cast(nullptr)); } template @@ -1414,12 +1414,12 @@ T ibeta_derivative_imp(T a, T b, T x, const Policy& pol) if(x == 0) { return (a > 1) ? 0 : - (a == 1) ? 1 / boost::math::beta(a, b, pol) : policies::raise_overflow_error(function, 0, pol); + (a == 1) ? 1 / boost::math::beta(a, b, pol) : policies::raise_overflow_error(function, nullptr, pol); } else if(x == 1) { return (b > 1) ? 0 : - (b == 1) ? 1 / boost::math::beta(a, b, pol) : policies::raise_overflow_error(function, 0, pol); + (b == 1) ? 1 / boost::math::beta(a, b, pol) : policies::raise_overflow_error(function, nullptr, pol); } // // Now the regular cases: @@ -1467,7 +1467,7 @@ inline typename tools::promote_args::type beta(RT1 a, RT2 b, A arg) { typedef typename policies::is_policy::type tag; - return boost::math::detail::beta(a, b, arg, static_cast(0)); + return boost::math::detail::beta(a, b, arg, static_cast(nullptr)); } template diff --git a/include/boost/math/special_functions/binomial.hpp b/include/boost/math/special_functions/binomial.hpp index 3e55530bf6..f76b48cc13 100644 --- a/include/boost/math/special_functions/binomial.hpp +++ b/include/boost/math/special_functions/binomial.hpp @@ -26,7 +26,7 @@ T binomial_coefficient(unsigned n, unsigned k, const Policy& pol) static const char* function = "boost::math::binomial_coefficient<%1%>(unsigned, unsigned)"; if(k > n) return policies::raise_domain_error( - function, + function, "The binomial coefficient is undefined for k > n, but got k = %1%.", static_cast(k), pol); T result; @@ -50,7 +50,7 @@ T binomial_coefficient(unsigned n, unsigned k, const Policy& pol) else result = (n - k) * beta(static_cast(k+1), static_cast(n-k), pol); if(result == 0) - return policies::raise_overflow_error(function, 0, pol); + return policies::raise_overflow_error(function, nullptr, pol); result = 1 / result; } // convert to nearest integer: diff --git a/include/boost/math/special_functions/detail/bernoulli_details.hpp b/include/boost/math/special_functions/detail/bernoulli_details.hpp index 58015fec14..c1754db118 100644 --- a/include/boost/math/special_functions/detail/bernoulli_details.hpp +++ b/include/boost/math/special_functions/detail/bernoulli_details.hpp @@ -31,16 +31,16 @@ template T b2n_asymptotic(int n) { BOOST_MATH_STD_USING - const T nx = static_cast(n); + const auto nx = static_cast(n); const T nx2(nx * nx); - const T approximate_log_of_bernoulli_bn = + const T approximate_log_of_bernoulli_bn = ((boost::math::constants::half() + nx) * log(nx)) + ((boost::math::constants::half() - nx) * log(boost::math::constants::pi())) + (((T(3) / 2) - nx) * boost::math::constants::ln_two()) + ((nx * (T(2) - (nx2 * 7) * (1 + ((nx2 * 30) * ((nx2 * 12) - 1))))) / (((nx2 * nx2) * nx2) * 2520)); - return ((n / 2) & 1 ? 1 : -1) * (approximate_log_of_bernoulli_bn > tools::log_max_value() - ? policies::raise_overflow_error("boost::math::bernoulli_b2n<%1%>(std::size_t)", 0, nx, Policy()) + return ((n / 2) & 1 ? 1 : -1) * (approximate_log_of_bernoulli_bn > tools::log_max_value() + ? policies::raise_overflow_error("boost::math::bernoulli_b2n<%1%>(std::size_t)", nullptr, nx, Policy()) : static_cast(exp(approximate_log_of_bernoulli_bn))); } @@ -52,11 +52,15 @@ T t2n_asymptotic(int n) T t2n = fabs(b2n_asymptotic(2 * n)) / (2 * n); T p2 = ldexp(T(1), n); if(tools::max_value() / p2 < t2n) - return policies::raise_overflow_error("boost::math::tangent_t2n<%1%>(std::size_t)", 0, T(n), Policy()); + { + return policies::raise_overflow_error("boost::math::tangent_t2n<%1%>(std::size_t)", nullptr, T(n), Policy()); + } t2n *= p2; p2 -= 1; if(tools::max_value() / p2 < t2n) - return policies::raise_overflow_error("boost::math::tangent_t2n<%1%>(std::size_t)", 0, Policy()); + { + return policies::raise_overflow_error("boost::math::tangent_t2n<%1%>(std::size_t)", nullptr, Policy()); + } t2n *= p2; return t2n; } @@ -66,19 +70,19 @@ T t2n_asymptotic(int n) // us to elude a great deal of runtime checking for values below // n, and only perform the full overflow checks when we know that we're // getting close to the point where our calculations will overflow. -// We use Luschny's LogB3 formula (http://www.luschny.de/math/primes/bernincl.html) +// We use Luschny's LogB3 formula (http://www.luschny.de/math/primes/bernincl.html) // to find the limit, and since we're dealing with the log of the Bernoulli numbers // we need only perform the calculation at double precision and not with T // (which may be a multiprecision type). The limit returned is within 1 of the true // limit for all the types tested. Note that although the code below is basically -// the same as b2n_asymptotic above, it has been recast as a continuous real-valued +// the same as b2n_asymptotic above, it has been recast as a continuous real-valued // function as this makes the root finding go smoother/faster. It also omits the // sign of the Bernoulli number. // struct max_bernoulli_root_functor { - max_bernoulli_root_functor(unsigned long long t) : target(static_cast(t)) {} - double operator()(double n) + explicit max_bernoulli_root_functor(unsigned long long t) : target(static_cast(t)) {} + double operator()(double n) const { BOOST_MATH_STD_USING @@ -89,7 +93,7 @@ struct max_bernoulli_root_functor const double approximate_log_of_bernoulli_bn = ((boost::math::constants::half() + n) * log(n)) + ((boost::math::constants::half() - n) * log(boost::math::constants::pi())) - + (((double(3) / 2) - n) * boost::math::constants::ln_two()) + + (((static_cast(3) / 2) - n) * boost::math::constants::ln_two()) + ((n * (2 - (nx2 * 7) * (1 + ((nx2 * 30) * ((nx2 * 12) - 1))))) / (((nx2 * nx2) * nx2) * 2520)); return approximate_log_of_bernoulli_bn - target; @@ -102,16 +106,18 @@ template inline std::size_t find_bernoulli_overflow_limit(const std::false_type&) { // Set a limit on how large the result can ever be: - static const double max_result = static_cast((std::numeric_limits::max)() - 1000u); + static const auto max_result = static_cast((std::numeric_limits::max)() - 1000u); unsigned long long t = lltrunc(boost::math::tools::log_max_value()); max_bernoulli_root_functor fun(t); boost::math::tools::equal_floor tol; std::uintmax_t max_iter = boost::math::policies::get_max_root_iterations(); - double result = boost::math::tools::toms748_solve(fun, sqrt(double(t)), double(t), tol, max_iter).first / 2; + double result = boost::math::tools::toms748_solve(fun, sqrt(static_cast(t)), static_cast(t), tol, max_iter).first / 2; if (result > max_result) + { result = max_result; - + } + return static_cast(result); } @@ -126,7 +132,7 @@ std::size_t b2n_overflow_limit() { // This routine is called at program startup if it's called at all: // that guarantees safe initialization of the static variable. - typedef std::integral_constant::value >= 1) && (bernoulli_imp_variant::value <= 3)> tag_type; + using tag_type = std::integral_constant::value >= 1) && (bernoulli_imp_variant::value <= 3)>; static const std::size_t lim = find_bernoulli_overflow_limit(tag_type()); return lim; } @@ -162,22 +168,24 @@ inline T tangent_scale_factor() template struct fixed_vector : private std::allocator { - typedef unsigned size_type; - typedef T* iterator; - typedef const T* const_iterator; + using size_type = unsigned; + using iterator = T*; + using const_iterator = const T*; fixed_vector() : m_used(0) - { + { std::size_t overflow_limit = 5 + b2n_overflow_limit >(); m_capacity = static_cast((std::min)(overflow_limit, static_cast(100000u))); - m_data = this->allocate(m_capacity); + m_data = this->allocate(m_capacity); } ~fixed_vector() { - typedef std::allocator allocator_type; - typedef std::allocator_traits allocator_traits; - allocator_type& alloc = *this; + using allocator_type = std::allocator; + using allocator_traits = std::allocator_traits; + allocator_type& alloc = *this; for(unsigned i = 0; i < m_used; ++i) + { allocator_traits::destroy(alloc, &m_data[i]); + } allocator_traits::deallocate(alloc, m_data, m_capacity); } T& operator[](unsigned n) { BOOST_MATH_ASSERT(n < m_used); return m_data[n]; } @@ -208,7 +216,8 @@ struct fixed_vector : private std::allocator void clear() { m_used = 0; } private: T* m_data; - unsigned m_used, m_capacity; + unsigned m_used {}; + unsigned m_capacity; }; template @@ -220,7 +229,7 @@ class bernoulli_numbers_cache , m_current_precision(boost::math::tools::digits()) {} - typedef fixed_vector container_type; + using container_type = fixed_vector; bool tangent(std::size_t m) { @@ -343,7 +352,7 @@ class bernoulli_numbers_cache // There are basically 3 thread safety options: // // 1) There are no threads (BOOST_HAS_THREADS is not defined). - // 2) There are threads, but we do not have a true atomic integer type, + // 2) There are threads, but we do not have a true atomic integer type, // in this case we just use a mutex to guard against race conditions. // 3) There are threads, and we have an atomic integer: in this case we can // use the double-checked locking pattern to avoid thread synchronisation @@ -369,7 +378,7 @@ class bernoulli_numbers_cache } for(; n; ++start, --n) { - *out = policies::raise_overflow_error("boost::math::bernoulli_b2n<%1%>(std::size_t)", 0, T(start), pol); + *out = policies::raise_overflow_error("boost::math::bernoulli_b2n<%1%>(std::size_t)", nullptr, T(start), pol); ++out; } return out; @@ -400,7 +409,7 @@ class bernoulli_numbers_cache for(std::size_t i = (std::max)(std::size_t(max_bernoulli_b2n::value + 1), start); i < start + n; ++i) { - *out = (i >= m_overflow_limit) ? policies::raise_overflow_error("boost::math::bernoulli_b2n<%1%>(std::size_t)", 0, T(i), pol) : bn[i]; + *out = (i >= m_overflow_limit) ? policies::raise_overflow_error("boost::math::bernoulli_b2n<%1%>(std::size_t)", nullptr, T(i), pol) : bn[i]; ++out; } #else @@ -438,7 +447,7 @@ class bernoulli_numbers_cache for(std::size_t i = (std::max)(static_cast(max_bernoulli_b2n::value + 1), start); i < start + n; ++i) { - *out = (i >= m_overflow_limit) ? policies::raise_overflow_error("boost::math::bernoulli_b2n<%1%>(std::size_t)", 0, T(i), pol) : bn[static_cast(i)]; + *out = (i >= m_overflow_limit) ? policies::raise_overflow_error("boost::math::bernoulli_b2n<%1%>(std::size_t)", nullptr, T(i), pol) : bn[static_cast(i)]; ++out; } @@ -453,7 +462,7 @@ class bernoulli_numbers_cache // There are basically 3 thread safety options: // // 1) There are no threads (BOOST_HAS_THREADS is not defined). - // 2) There are threads, but we do not have a true atomic integer type, + // 2) There are threads, but we do not have a true atomic integer type, // in this case we just use a mutex to guard against race conditions. // 3) There are threads, and we have an atomic integer: in this case we can // use the double-checked locking pattern to avoid thread synchronisation @@ -507,11 +516,11 @@ class bernoulli_numbers_cache for(std::size_t i = start; i < start + n; ++i) { if(i >= m_overflow_limit) - *out = policies::raise_overflow_error("boost::math::bernoulli_b2n<%1%>(std::size_t)", 0, T(i), pol); + *out = policies::raise_overflow_error("boost::math::bernoulli_b2n<%1%>(std::size_t)", nullptr, T(i), pol); else { if(tools::max_value() * tangent_scale_factor() < tn[static_cast(i)]) - *out = policies::raise_overflow_error("boost::math::bernoulli_b2n<%1%>(std::size_t)", 0, T(i), pol); + *out = policies::raise_overflow_error("boost::math::bernoulli_b2n<%1%>(std::size_t)", nullptr, T(i), pol); else *out = tn[static_cast(i)] / tangent_scale_factor(); } @@ -555,11 +564,11 @@ class bernoulli_numbers_cache for(std::size_t i = start; i < start + n; ++i) { if(i >= m_overflow_limit) - *out = policies::raise_overflow_error("boost::math::bernoulli_b2n<%1%>(std::size_t)", 0, T(i), pol); + *out = policies::raise_overflow_error("boost::math::bernoulli_b2n<%1%>(std::size_t)", nullptr, T(i), pol); else { if(tools::max_value() * tangent_scale_factor() < tn[static_cast(i)]) - *out = policies::raise_overflow_error("boost::math::bernoulli_b2n<%1%>(std::size_t)", 0, T(i), pol); + *out = policies::raise_overflow_error("boost::math::bernoulli_b2n<%1%>(std::size_t)", nullptr, T(i), pol); else *out = tn[static_cast(i)] / tangent_scale_factor(); } @@ -598,7 +607,7 @@ inline typename std::enable_if<(std::numeric_limits::digits == 0) || (std::nu // or it's precision can vary at runtime. So make the cache thread_local so that each thread can // have it's own precision if required: // - static + static #ifndef BOOST_MATH_NO_THREAD_LOCAL_WITH_NON_TRIVIAL_TYPES BOOST_MATH_THREAD_LOCAL #endif diff --git a/include/boost/math/special_functions/detail/bessel_ik.hpp b/include/boost/math/special_functions/detail/bessel_ik.hpp index 612aea63b1..0d61835b27 100644 --- a/include/boost/math/special_functions/detail/bessel_ik.hpp +++ b/include/boost/math/special_functions/detail/bessel_ik.hpp @@ -30,7 +30,7 @@ struct cyl_bessel_i_small_z { typedef T result_type; - cyl_bessel_i_small_z(T v_, T z_) : k(0), v(v_), mult(z_*z_/4) + cyl_bessel_i_small_z(T v_, T z_) : k(0), v(v_), mult(z_*z_/4) { BOOST_MATH_STD_USING term = 1; @@ -70,7 +70,7 @@ inline T bessel_i_small_z_series(T v, T x, const Policy& pol) cyl_bessel_i_small_z s(v, x); std::uintmax_t max_iter = policies::get_max_series_iterations(); - + T result = boost::math::tools::sum_series(s, boost::math::policies::get_epsilon(), max_iter); policies::check_series_iterations("boost::math::bessel_j_small_z_series<%1%>(%1%,%1%)", max_iter, pol); @@ -141,9 +141,9 @@ int temme_ik(T v, T x, T* K, T* K1, const Policy& pol) coef *= x * x / (4 * k); sum += coef * f; sum1 += coef * h; - if (abs(coef * f) < abs(sum) * tolerance) - { - break; + if (abs(coef * f) < abs(sum) * tolerance) + { + break; } } policies::check_series_iterations("boost::math::bessel_ik<%1%>(%1%,%1%) in temme_ik", k, pol); @@ -187,9 +187,9 @@ int CF1_ik(T v, T x, T* fv, const Policy& pol) delta = C * D; f *= delta; BOOST_MATH_INSTRUMENT_VARIABLE(delta-1); - if (abs(delta - 1) <= tolerance) - { - break; + if (abs(delta - 1) <= tolerance) + { + break; } } BOOST_MATH_INSTRUMENT_VARIABLE(k); @@ -271,9 +271,9 @@ int CF2_ik(T v, T x, T* Kv, T* Kv1, const Policy& pol) BOOST_MATH_INSTRUMENT_VARIABLE(Q * delta); BOOST_MATH_INSTRUMENT_VARIABLE(abs(S) * tolerance); BOOST_MATH_INSTRUMENT_VARIABLE(S); - if (abs(Q * delta) < abs(S) * tolerance) - { - break; + if (abs(Q * delta) < abs(S) * tolerance) + { + break; } } policies::check_series_iterations("boost::math::bessel_ik<%1%>(%1%,%1%) in CF2_ik", k, pol); @@ -338,7 +338,7 @@ int bessel_ik(T v, T x, T* I, T* K, int kind, const Policy& pol) Iv = (v == 0) ? static_cast(1) : static_cast(0); if(kind & need_k) { - Kv = policies::raise_overflow_error(function, 0, pol); + Kv = policies::raise_overflow_error(function, nullptr, pol); } else { @@ -348,9 +348,9 @@ int bessel_ik(T v, T x, T* I, T* K, int kind, const Policy& pol) if(reflect && (kind & need_i)) { T z = (u + n % 2); - Iv = boost::math::sin_pi(z, pol) == 0 ? - Iv : - policies::raise_overflow_error(function, 0, pol); // reflection formula + Iv = boost::math::sin_pi(z, pol) == 0 ? + Iv : + policies::raise_overflow_error(function, nullptr, pol); // reflection formula } *I = Iv; @@ -403,7 +403,7 @@ int bessel_ik(T v, T x, T* I, T* K, int kind, const Policy& pol) // x is huge compared to v, CF1 may be very slow // to converge so use asymptotic expansion for large // x case instead. Note that the asymptotic expansion - // isn't very accurate - so it's deliberately very hard + // isn't very accurate - so it's deliberately very hard // to get here - probably we're going to overflow: Iv = asymptotic_bessel_i_large_x(v, x, pol); } @@ -427,7 +427,7 @@ int bessel_ik(T v, T x, T* I, T* K, int kind, const Policy& pol) if(fact == 0) *I = Iv; else if(tools::max_value() * scale < fact) - *I = (org_kind & need_i) ? T(sign(fact) * scale_sign * policies::raise_overflow_error(function, 0, pol)) : T(0); + *I = (org_kind & need_i) ? T(sign(fact) * scale_sign * policies::raise_overflow_error(function, nullptr, pol)) : T(0); else *I = Iv + fact / scale; // reflection formula } @@ -436,7 +436,7 @@ int bessel_ik(T v, T x, T* I, T* K, int kind, const Policy& pol) *I = Iv; } if(tools::max_value() * scale < Kv) - *K = (org_kind & need_k) ? T(sign(Kv) * scale_sign * policies::raise_overflow_error(function, 0, pol)) : T(0); + *K = (org_kind & need_k) ? T(sign(Kv) * scale_sign * policies::raise_overflow_error(function, nullptr, pol)) : T(0); else *K = Kv / scale; BOOST_MATH_INSTRUMENT_VARIABLE(*I); diff --git a/include/boost/math/special_functions/detail/bessel_jn.hpp b/include/boost/math/special_functions/detail/bessel_jn.hpp index c63e39bb03..3388e8df29 100644 --- a/include/boost/math/special_functions/detail/bessel_jn.hpp +++ b/include/boost/math/special_functions/detail/bessel_jn.hpp @@ -122,7 +122,7 @@ T bessel_jn(int n, T x, const Policy& pol) value *= factor; if(tools::max_value() * scale < fabs(value)) - return policies::raise_overflow_error("boost::math::bessel_jn<%1%>(%1%,%1%)", 0, pol); + return policies::raise_overflow_error("boost::math::bessel_jn<%1%>(%1%,%1%)", nullptr, pol); return value / scale; } diff --git a/include/boost/math/special_functions/detail/bessel_jy.hpp b/include/boost/math/special_functions/detail/bessel_jy.hpp index a319760b44..a43092603e 100644 --- a/include/boost/math/special_functions/detail/bessel_jy.hpp +++ b/include/boost/math/special_functions/detail/bessel_jy.hpp @@ -33,7 +33,7 @@ namespace boost { namespace math { // for use in A&S 9.2.5 and 9.2.6. // This series is quick to evaluate, but divergent unless // x is very large, in fact it's pretty hard to figure out - // with any degree of precision when this series actually + // with any degree of precision when this series actually // *will* converge!! Consequently, we may just have to // try it and see... // @@ -124,9 +124,9 @@ namespace boost { namespace math { coef *= coef_mult / k; sum += coef * g; sum1 += coef * h; - if (abs(coef * g) < abs(sum) * tolerance) - { - break; + if (abs(coef * g) < abs(sum) * tolerance) + { + break; } } policies::check_series_iterations("boost::math::bessel_jy<%1%>(%1%,%1%) in temme_jy", k, pol); @@ -168,7 +168,7 @@ namespace boost { namespace math { delta = C * D; f *= delta; if (D < 0) { s = -s; } - if (abs(delta - 1) < tolerance) + if (abs(delta - 1) < tolerance) { break; } } policies::check_series_iterations("boost::math::bessel_jy<%1%>(%1%,%1%) in CF1_jy", k / 100, pol); @@ -315,7 +315,7 @@ namespace boost { namespace math { if((kind & need_y) == 0) *Y = std::numeric_limits::quiet_NaN(); // any value will do, not using Y. else if(v == 0) - *Y = -policies::raise_overflow_error(function, 0, pol); + *Y = -policies::raise_overflow_error(function, nullptr, pol); else *Y = policies::raise_domain_error(function, "Value of Bessel Y_v(x) is complex-infinity at %1%", x, pol); // complex infinity return 1; @@ -344,7 +344,7 @@ namespace boost { namespace math { Jv = bessel_j_small_z_series(v, x, pol); else Jv = std::numeric_limits::quiet_NaN(); - if((org_kind&need_y && (!reflect || (cp != 0))) + if((org_kind&need_y && (!reflect || (cp != 0))) || (org_kind & need_j && (reflect && (sp != 0)))) { // Only calculate if we need it, and if the reflection formula will actually use it: @@ -361,7 +361,7 @@ namespace boost { namespace math { Jv = bessel_j_small_z_series(v, x, pol); else Jv = std::numeric_limits::quiet_NaN(); - if((org_kind&need_y && (!reflect || (cp != 0))) + if((org_kind&need_y && (!reflect || (cp != 0))) || (org_kind & need_j && (reflect && (sp != 0)))) { // Only calculate if we need it, and if the reflection formula will actually use it: @@ -388,7 +388,7 @@ namespace boost { namespace math { else if((x > 8) && hankel_PQ(v, x, &p, &q, pol)) { // - // Hankel approximation: note that this method works best when x + // Hankel approximation: note that this method works best when x // is large, but in that case we end up calculating sines and cosines // of large values, with horrendous resulting accuracy. It is fast though // when it works.... @@ -559,11 +559,11 @@ namespace boost { namespace math { if (reflect) { if((sp != 0) && (tools::max_value() * fabs(Yv_scale) < fabs(sp * Yv))) - *J = org_kind & need_j ? T(-sign(sp) * sign(Yv) * (Yv_scale != 0 ? sign(Yv_scale) : 1) * policies::raise_overflow_error(function, 0, pol)) : T(0); + *J = org_kind & need_j ? T(-sign(sp) * sign(Yv) * (Yv_scale != 0 ? sign(Yv_scale) : 1) * policies::raise_overflow_error(function, nullptr, pol)) : T(0); else *J = cp * Jv - (sp == 0 ? T(0) : T((sp * Yv) / Yv_scale)); // reflection formula if((cp != 0) && (tools::max_value() * fabs(Yv_scale) < fabs(cp * Yv))) - *Y = org_kind & need_y ? T(-sign(cp) * sign(Yv) * (Yv_scale != 0 ? sign(Yv_scale) : 1) * policies::raise_overflow_error(function, 0, pol)) : T(0); + *Y = org_kind & need_y ? T(-sign(cp) * sign(Yv) * (Yv_scale != 0 ? sign(Yv_scale) : 1) * policies::raise_overflow_error(function, nullptr, pol)) : T(0); else *Y = (sp != 0 ? sp * Jv : T(0)) + (cp == 0 ? T(0) : T((cp * Yv) / Yv_scale)); } @@ -571,7 +571,7 @@ namespace boost { namespace math { { *J = Jv; if(tools::max_value() * fabs(Yv_scale) < fabs(Yv)) - *Y = org_kind & need_y ? T(sign(Yv) * sign(Yv_scale) * policies::raise_overflow_error(function, 0, pol)) : T(0); + *Y = org_kind & need_y ? T(sign(Yv) * sign(Yv_scale) * policies::raise_overflow_error(function, nullptr, pol)) : T(0); else *Y = Yv / Yv_scale; } diff --git a/include/boost/math/special_functions/detail/bessel_jy_asym.hpp b/include/boost/math/special_functions/detail/bessel_jy_asym.hpp index 795ac66882..6f0eacaa87 100644 --- a/include/boost/math/special_functions/detail/bessel_jy_asym.hpp +++ b/include/boost/math/special_functions/detail/bessel_jy_asym.hpp @@ -125,11 +125,11 @@ inline bool asymptotic_bessel_large_x_limit(int v, const T& x) BOOST_MATH_STD_USING // // Determines if x is large enough compared to v to take the asymptotic - // forms above. From A&S 9.2.28 we require: + // forms above. From A&S 9.2.28 we require: // v < x * eps^1/8 // and from A&S 9.2.29 we require: // v^12/10 < 1.5 * x * eps^1/10 - // using the former seems to work OK in practice with broadly similar + // using the former seems to work OK in practice with broadly similar // error rates either side of the divide for v < 10000. // At double precision eps^1/8 ~= 0.01. // @@ -143,11 +143,11 @@ inline bool asymptotic_bessel_large_x_limit(const T& v, const T& x) BOOST_MATH_STD_USING // // Determines if x is large enough compared to v to take the asymptotic - // forms above. From A&S 9.2.28 we require: + // forms above. From A&S 9.2.28 we require: // v < x * eps^1/8 // and from A&S 9.2.29 we require: // v^12/10 < 1.5 * x * eps^1/10 - // using the former seems to work OK in practice with broadly similar + // using the former seems to work OK in practice with broadly similar // error rates either side of the divide for v < 10000. // At double precision eps^1/8 ~= 0.01. // @@ -213,8 +213,8 @@ T asymptotic_bessel_i_large_x(T v, T x, const Policy& pol) s = e * (e * s / sqrt(2 * x * constants::pi())); - return (boost::math::isfinite)(s) ? - s : policies::raise_overflow_error("boost::math::asymptotic_bessel_i_large_x<%1%>(%1%,%1%)", 0, pol); + return (boost::math::isfinite)(s) ? + s : policies::raise_overflow_error("boost::math::asymptotic_bessel_i_large_x<%1%>(%1%,%1%)", nullptr, pol); } }}} // namespaces diff --git a/include/boost/math/special_functions/detail/bessel_jy_derivatives_series.hpp b/include/boost/math/special_functions/detail/bessel_jy_derivatives_series.hpp index d78d0e46dd..d817ae8cf4 100644 --- a/include/boost/math/special_functions/detail/bessel_jy_derivatives_series.hpp +++ b/include/boost/math/special_functions/detail/bessel_jy_derivatives_series.hpp @@ -158,7 +158,7 @@ inline T bessel_y_derivative_small_z_series(T v, T x, const Policy& pol) if (boost::math::tools::max_value() * p < gam) { // This term will overflow to -INF, when combined with the series below it becomes +INF: - return boost::math::policies::raise_overflow_error(function, 0, pol); + return boost::math::policies::raise_overflow_error(function, nullptr, pol); } } prefix = -gam / (boost::math::constants::pi() * p); @@ -174,7 +174,7 @@ inline T bessel_y_derivative_small_z_series(T v, T x, const Policy& pol) scale /= (boost::math::tools::max_value() / 4); if (boost::math::tools::log_max_value() < prefix) { - return boost::math::policies::raise_overflow_error(function, 0, pol); + return boost::math::policies::raise_overflow_error(function, nullptr, pol); } } prefix = -exp(prefix); diff --git a/include/boost/math/special_functions/detail/bessel_jy_series.hpp b/include/boost/math/special_functions/detail/bessel_jy_series.hpp index 092ac3b3bf..35d3ae1030 100644 --- a/include/boost/math/special_functions/detail/bessel_jy_series.hpp +++ b/include/boost/math/special_functions/detail/bessel_jy_series.hpp @@ -127,7 +127,7 @@ struct bessel_y_small_z_series_term_b T term; }; // -// Series form for BesselY as z -> 0, +// Series form for BesselY as z -> 0, // see: http://functions.wolfram.com/Bessel-TypeFunctions/BesselY/06/01/04/01/01/0003/ // This series is only useful when the second term is small compared to the first // otherwise we get catastrophic cancellation errors. @@ -155,7 +155,7 @@ inline T bessel_y_small_z_series(T v, T x, T* pscale, const Policy& pol) gam = 1; if(tools::max_value() * p < gam) { - return -policies::raise_overflow_error(function, 0, pol); + return -policies::raise_overflow_error(function, nullptr, pol); } } prefix = -gam / (constants::pi() * p); @@ -171,7 +171,7 @@ inline T bessel_y_small_z_series(T v, T x, T* pscale, const Policy& pol) scale /= (tools::max_value() / 4); if(tools::log_max_value() < prefix) { - return -policies::raise_overflow_error(function, 0, pol); + return -policies::raise_overflow_error(function, nullptr, pol); } } prefix = -exp(prefix); @@ -222,14 +222,14 @@ T bessel_yn_small_z(int n, T z, T* scale, const Policy& pol) } else if(n == 1) { - return (z / constants::pi()) * log(z / 2) - - 2 / (constants::pi() * z) + return (z / constants::pi()) * log(z / 2) + - 2 / (constants::pi() * z) - (z / (2 * constants::pi())) * (1 - 2 * constants::euler()); } else if(n == 2) { - return (z * z) / (4 * constants::pi()) * log(z / 2) - - (4 / (constants::pi() * z * z)) + return (z * z) / (4 * constants::pi()) * log(z / 2) + - (4 / (constants::pi() * z * z)) - ((z * z) / (8 * constants::pi())) * (T(3)/2 - 2 * constants::euler()); } else @@ -243,7 +243,7 @@ T bessel_yn_small_z(int n, T z, T* scale, const Policy& pol) *scale /= div; if(p * tools::max_value() < result) { - return -policies::raise_overflow_error("bessel_yn_small_z<%1%>(%1%,%1%)", 0, pol); + return -policies::raise_overflow_error("bessel_yn_small_z<%1%>(%1%,%1%)", nullptr, pol); } } return result / p; diff --git a/include/boost/math/special_functions/detail/bessel_kn.hpp b/include/boost/math/special_functions/detail/bessel_kn.hpp index 486bcd138a..9463ce1615 100644 --- a/include/boost/math/special_functions/detail/bessel_kn.hpp +++ b/include/boost/math/special_functions/detail/bessel_kn.hpp @@ -36,7 +36,7 @@ T bessel_kn(int n, T x, const Policy& pol) } if (x == 0) { - return policies::raise_overflow_error(function, 0, pol); + return policies::raise_overflow_error(function, nullptr, pol); } if (n < 0) @@ -74,7 +74,7 @@ T bessel_kn(int n, T x, const Policy& pol) } while(k < n); if(tools::max_value() * scale < fabs(value)) - return sign(scale) * sign(value) * policies::raise_overflow_error(function, 0, pol); + return sign(scale) * sign(value) * policies::raise_overflow_error(function, nullptr, pol); value /= scale; } return value; diff --git a/include/boost/math/special_functions/detail/bessel_y0.hpp b/include/boost/math/special_functions/detail/bessel_y0.hpp index 2d27fbcd7a..1ea348b058 100644 --- a/include/boost/math/special_functions/detail/bessel_y0.hpp +++ b/include/boost/math/special_functions/detail/bessel_y0.hpp @@ -179,7 +179,7 @@ T bessel_y0(T x, const Policy& pol) } if (x == 0) { - return -policies::raise_overflow_error(function, 0, pol); + return -policies::raise_overflow_error(function, nullptr, pol); } if (x <= 3) // x in (0, 3] { diff --git a/include/boost/math/special_functions/detail/bessel_yn.hpp b/include/boost/math/special_functions/detail/bessel_yn.hpp index 7f746a8a21..939c04d0aa 100644 --- a/include/boost/math/special_functions/detail/bessel_yn.hpp +++ b/include/boost/math/special_functions/detail/bessel_yn.hpp @@ -32,7 +32,7 @@ T bessel_yn(int n, T x, const Policy& pol) if ((x == 0) && (n == 0)) { - return -policies::raise_overflow_error(function, 0, pol); + return -policies::raise_overflow_error(function, nullptr, pol); } if (x <= 0) { @@ -57,7 +57,7 @@ T bessel_yn(int n, T x, const Policy& pol) T scale = 1; value = bessel_yn_small_z(n, x, &scale, pol); if(tools::max_value() * fabs(scale) < fabs(value)) - return boost::math::sign(scale) * boost::math::sign(value) * policies::raise_overflow_error(function, 0, pol); + return boost::math::sign(scale) * boost::math::sign(value) * policies::raise_overflow_error(function, nullptr, pol); value /= scale; } else if(asymptotic_bessel_large_x_limit(n, x)) @@ -100,7 +100,7 @@ T bessel_yn(int n, T x, const Policy& pol) ++k; } if(fabs(tools::max_value() * factor) < fabs(value)) - return sign(value) * sign(factor) * policies::raise_overflow_error(function, 0, pol); + return sign(value) * sign(factor) * policies::raise_overflow_error(function, nullptr, pol); value /= factor; } return value; diff --git a/include/boost/math/special_functions/detail/erf_inv.hpp b/include/boost/math/special_functions/detail/erf_inv.hpp index f4a68cf12b..94e36e3852 100644 --- a/include/boost/math/special_functions/detail/erf_inv.hpp +++ b/include/boost/math/special_functions/detail/erf_inv.hpp @@ -15,7 +15,7 @@ #include -namespace boost{ namespace math{ +namespace boost{ namespace math{ namespace detail{ // @@ -28,7 +28,7 @@ T erf_inv_imp(const T& p, const T& q, const Policy&, const std::integral_constan BOOST_MATH_STD_USING // for ADL of std names. T result = 0; - + if(p <= 0.5) { // @@ -44,7 +44,7 @@ T erf_inv_imp(const T& p, const T& q, const Policy&, const std::integral_constan // Maximum Deviation Found (actual error term at infinite precision) 8.030e-21 // static const float Y = 0.0891314744949340820313f; - static const T P[] = { + static const T P[] = { BOOST_MATH_BIG_CONSTANT(T, 64, -0.000508781949658280665617), BOOST_MATH_BIG_CONSTANT(T, 64, -0.00836874819741736770379), BOOST_MATH_BIG_CONSTANT(T, 64, 0.0334806625409744615033), @@ -54,7 +54,7 @@ T erf_inv_imp(const T& p, const T& q, const Policy&, const std::integral_constan BOOST_MATH_BIG_CONSTANT(T, 64, 0.00822687874676915743155), BOOST_MATH_BIG_CONSTANT(T, 64, -0.00538772965071242932965) }; - static const T Q[] = { + static const T Q[] = { BOOST_MATH_BIG_CONSTANT(T, 64, 1.0), BOOST_MATH_BIG_CONSTANT(T, 64, -0.970005043303290640362), BOOST_MATH_BIG_CONSTANT(T, 64, -1.56574558234175846809), @@ -85,7 +85,7 @@ T erf_inv_imp(const T& p, const T& q, const Policy&, const std::integral_constan // Maximum Deviation Found (error term) 4.811e-20 // static const float Y = 2.249481201171875f; - static const T P[] = { + static const T P[] = { BOOST_MATH_BIG_CONSTANT(T, 64, -0.202433508355938759655), BOOST_MATH_BIG_CONSTANT(T, 64, 0.105264680699391713268), BOOST_MATH_BIG_CONSTANT(T, 64, 8.37050328343119927838), @@ -96,7 +96,7 @@ T erf_inv_imp(const T& p, const T& q, const Policy&, const std::integral_constan BOOST_MATH_BIG_CONSTANT(T, 64, 21.1294655448340526258), BOOST_MATH_BIG_CONSTANT(T, 64, -3.67192254707729348546) }; - static const T Q[] = { + static const T Q[] = { BOOST_MATH_BIG_CONSTANT(T, 64, 1.0), BOOST_MATH_BIG_CONSTANT(T, 64, 6.24264124854247537712), BOOST_MATH_BIG_CONSTANT(T, 64, 3.9713437953343869095), @@ -124,7 +124,7 @@ T erf_inv_imp(const T& p, const T& q, const Policy&, const std::integral_constan // // x(Y+R(x-B)) // - // where Y is a constant, B is the lowest value of x for which + // where Y is a constant, B is the lowest value of x for which // the approximation is valid, and R(x-B) is optimised for a low // absolute error compared to Y. // @@ -138,7 +138,7 @@ T erf_inv_imp(const T& p, const T& q, const Policy&, const std::integral_constan { // Max error found: 1.089051e-20 static const float Y = 0.807220458984375f; - static const T P[] = { + static const T P[] = { BOOST_MATH_BIG_CONSTANT(T, 64, -0.131102781679951906451), BOOST_MATH_BIG_CONSTANT(T, 64, -0.163794047193317060787), BOOST_MATH_BIG_CONSTANT(T, 64, 0.117030156341995252019), @@ -151,7 +151,7 @@ T erf_inv_imp(const T& p, const T& q, const Policy&, const std::integral_constan BOOST_MATH_BIG_CONSTANT(T, 64, 0.285225331782217055858e-7), BOOST_MATH_BIG_CONSTANT(T, 64, -0.681149956853776992068e-9) }; - static const T Q[] = { + static const T Q[] = { BOOST_MATH_BIG_CONSTANT(T, 64, 1.0), BOOST_MATH_BIG_CONSTANT(T, 64, 3.46625407242567245975), BOOST_MATH_BIG_CONSTANT(T, 64, 5.38168345707006855425), @@ -169,7 +169,7 @@ T erf_inv_imp(const T& p, const T& q, const Policy&, const std::integral_constan { // Max error found: 8.389174e-21 static const float Y = 0.93995571136474609375f; - static const T P[] = { + static const T P[] = { BOOST_MATH_BIG_CONSTANT(T, 64, -0.0350353787183177984712), BOOST_MATH_BIG_CONSTANT(T, 64, -0.00222426529213447927281), BOOST_MATH_BIG_CONSTANT(T, 64, 0.0185573306514231072324), @@ -180,7 +180,7 @@ T erf_inv_imp(const T& p, const T& q, const Policy&, const std::integral_constan BOOST_MATH_BIG_CONSTANT(T, 64, -0.230404776911882601748e-9), BOOST_MATH_BIG_CONSTANT(T, 64, 0.266339227425782031962e-11) }; - static const T Q[] = { + static const T Q[] = { BOOST_MATH_BIG_CONSTANT(T, 64, 1.0), BOOST_MATH_BIG_CONSTANT(T, 64, 1.3653349817554063097), BOOST_MATH_BIG_CONSTANT(T, 64, 0.762059164553623404043), @@ -197,7 +197,7 @@ T erf_inv_imp(const T& p, const T& q, const Policy&, const std::integral_constan { // Max error found: 1.481312e-19 static const float Y = 0.98362827301025390625f; - static const T P[] = { + static const T P[] = { BOOST_MATH_BIG_CONSTANT(T, 64, -0.0167431005076633737133), BOOST_MATH_BIG_CONSTANT(T, 64, -0.00112951438745580278863), BOOST_MATH_BIG_CONSTANT(T, 64, 0.00105628862152492910091), @@ -208,7 +208,7 @@ T erf_inv_imp(const T& p, const T& q, const Policy&, const std::integral_constan BOOST_MATH_BIG_CONSTANT(T, 64, -0.281128735628831791805e-13), BOOST_MATH_BIG_CONSTANT(T, 64, 0.99055709973310326855e-16) }; - static const T Q[] = { + static const T Q[] = { BOOST_MATH_BIG_CONSTANT(T, 64, 1.0), BOOST_MATH_BIG_CONSTANT(T, 64, 0.591429344886417493481), BOOST_MATH_BIG_CONSTANT(T, 64, 0.138151865749083321638), @@ -225,7 +225,7 @@ T erf_inv_imp(const T& p, const T& q, const Policy&, const std::integral_constan { // Max error found: 5.697761e-20 static const float Y = 0.99714565277099609375f; - static const T P[] = { + static const T P[] = { BOOST_MATH_BIG_CONSTANT(T, 64, -0.0024978212791898131227), BOOST_MATH_BIG_CONSTANT(T, 64, -0.779190719229053954292e-5), BOOST_MATH_BIG_CONSTANT(T, 64, 0.254723037413027451751e-4), @@ -235,7 +235,7 @@ T erf_inv_imp(const T& p, const T& q, const Policy&, const std::integral_constan BOOST_MATH_BIG_CONSTANT(T, 64, 0.145596286718675035587e-11), BOOST_MATH_BIG_CONSTANT(T, 64, -0.116765012397184275695e-17) }; - static const T Q[] = { + static const T Q[] = { BOOST_MATH_BIG_CONSTANT(T, 64, 1.0), BOOST_MATH_BIG_CONSTANT(T, 64, 0.207123112214422517181), BOOST_MATH_BIG_CONSTANT(T, 64, 0.0169410838120975906478), @@ -252,7 +252,7 @@ T erf_inv_imp(const T& p, const T& q, const Policy&, const std::integral_constan { // Max error found: 1.279746e-20 static const float Y = 0.99941349029541015625f; - static const T P[] = { + static const T P[] = { BOOST_MATH_BIG_CONSTANT(T, 64, -0.000539042911019078575891), BOOST_MATH_BIG_CONSTANT(T, 64, -0.28398759004727721098e-6), BOOST_MATH_BIG_CONSTANT(T, 64, 0.899465114892291446442e-6), @@ -262,7 +262,7 @@ T erf_inv_imp(const T& p, const T& q, const Policy&, const std::integral_constan BOOST_MATH_BIG_CONSTANT(T, 64, 0.135880130108924861008e-14), BOOST_MATH_BIG_CONSTANT(T, 64, -0.348890393399948882918e-21) }; - static const T Q[] = { + static const T Q[] = { BOOST_MATH_BIG_CONSTANT(T, 64, 1.0), BOOST_MATH_BIG_CONSTANT(T, 64, 0.0845746234001899436914), BOOST_MATH_BIG_CONSTANT(T, 64, 0.00282092984726264681981), @@ -301,7 +301,7 @@ T erf_inv_imp(const T& p, const T& q, const Policy& pol, const std::integral_con // // Generic version, get a guess that's accurate to 64-bits (10^-19) // - T guess = erf_inv_imp(p, q, pol, static_cast const*>(0)); + T guess = erf_inv_imp(p, q, pol, static_cast const*>(nullptr)); T result; // // If T has more bit's than 64 in it's mantissa then we need to iterate, @@ -406,9 +406,9 @@ typename tools::promote_args::type erfc_inv(T z, const Policy& pol) if((z < 0) || (z > 2)) return policies::raise_domain_error(function, "Argument outside range [0,2] in inverse erfc function (got p=%1%).", z, pol); if(z == 0) - return policies::raise_overflow_error(function, 0, pol); + return policies::raise_overflow_error(function, nullptr, pol); if(z == 2) - return -policies::raise_overflow_error(function, 0, pol); + return -policies::raise_overflow_error(function, nullptr, pol); // // Normalise the input, so it's in the range [0,1], we will // negate the result if z is outside that range. This is a simple @@ -442,9 +442,9 @@ typename tools::promote_args::type erfc_inv(T z, const Policy& pol) // typedef typename policies::evaluation::type eval_type; typedef typename policies::normalise< - Policy, - policies::promote_float, - policies::promote_double, + Policy, + policies::promote_float, + policies::promote_double, policies::discrete_quantile<>, policies::assert_undefined<> >::type forwarding_policy; @@ -454,7 +454,7 @@ typename tools::promote_args::type erfc_inv(T z, const Policy& pol) // And get the result, negating where required: // return s * policies::checked_narrowing_cast( - detail::erf_inv_imp(static_cast(p), static_cast(q), forwarding_policy(), static_cast(0)), function); + detail::erf_inv_imp(static_cast(p), static_cast(q), forwarding_policy(), static_cast(nullptr)), function); } template @@ -469,9 +469,9 @@ typename tools::promote_args::type erf_inv(T z, const Policy& pol) if((z < -1) || (z > 1)) return policies::raise_domain_error(function, "Argument outside range [-1, 1] in inverse erf function (got p=%1%).", z, pol); if(z == 1) - return policies::raise_overflow_error(function, 0, pol); + return policies::raise_overflow_error(function, nullptr, pol); if(z == -1) - return -policies::raise_overflow_error(function, 0, pol); + return -policies::raise_overflow_error(function, nullptr, pol); if(z == 0) return 0; // @@ -507,9 +507,9 @@ typename tools::promote_args::type erf_inv(T z, const Policy& pol) // typedef typename policies::evaluation::type eval_type; typedef typename policies::normalise< - Policy, - policies::promote_float, - policies::promote_double, + Policy, + policies::promote_float, + policies::promote_double, policies::discrete_quantile<>, policies::assert_undefined<> >::type forwarding_policy; // @@ -523,7 +523,7 @@ typename tools::promote_args::type erf_inv(T z, const Policy& pol) // And get the result, negating where required: // return s * policies::checked_narrowing_cast( - detail::erf_inv_imp(static_cast(p), static_cast(q), forwarding_policy(), static_cast(0)), function); + detail::erf_inv_imp(static_cast(p), static_cast(q), forwarding_policy(), static_cast(nullptr)), function); } template diff --git a/include/boost/math/special_functions/detail/gamma_inva.hpp b/include/boost/math/special_functions/detail/gamma_inva.hpp index 48b8f49382..75ac89e433 100644 --- a/include/boost/math/special_functions/detail/gamma_inva.hpp +++ b/include/boost/math/special_functions/detail/gamma_inva.hpp @@ -75,7 +75,7 @@ T gamma_inva_imp(const T& z, const T& p, const T& q, const Policy& pol) // if(p == 0) { - return policies::raise_overflow_error("boost::math::gamma_p_inva<%1%>(%1%, %1%)", 0, Policy()); + return policies::raise_overflow_error("boost::math::gamma_p_inva<%1%>(%1%, %1%)", nullptr, Policy()); } if(q == 0) { @@ -91,7 +91,7 @@ T gamma_inva_imp(const T& z, const T& p, const T& q, const Policy& pol) // tools::eps_tolerance tol(policies::digits()); // - // Now figure out a starting guess for what a may be, + // Now figure out a starting guess for what a may be, // we'll start out with a value that'll put p or q // right bang in the middle of their range, the functions // are quite sensitive so we should need too many steps @@ -102,7 +102,7 @@ T gamma_inva_imp(const T& z, const T& p, const T& q, const Policy& pol) if(z >= 1) { // - // We can use the relationship between the incomplete + // We can use the relationship between the incomplete // gamma function and the poisson distribution to // calculate an approximate inverse, for large z // this is actually pretty accurate, but it fails badly @@ -151,21 +151,21 @@ T gamma_inva_imp(const T& z, const T& p, const T& q, const Policy& pol) } // namespace detail template -inline typename tools::promote_args::type +inline typename tools::promote_args::type gamma_p_inva(T1 x, T2 p, const Policy& pol) { typedef typename tools::promote_args::type result_type; typedef typename policies::evaluation::type value_type; typedef typename policies::normalise< - Policy, - policies::promote_float, - policies::promote_double, + Policy, + policies::promote_float, + policies::promote_double, policies::discrete_quantile<>, policies::assert_undefined<> >::type forwarding_policy; if(p == 0) { - policies::raise_overflow_error("boost::math::gamma_p_inva<%1%>(%1%, %1%)", 0, Policy()); + policies::raise_overflow_error("boost::math::gamma_p_inva<%1%>(%1%, %1%)", nullptr, Policy()); } if(p == 1) { @@ -174,28 +174,28 @@ inline typename tools::promote_args::type return policies::checked_narrowing_cast( detail::gamma_inva_imp( - static_cast(x), - static_cast(p), - static_cast(1 - static_cast(p)), + static_cast(x), + static_cast(p), + static_cast(1 - static_cast(p)), pol), "boost::math::gamma_p_inva<%1%>(%1%, %1%)"); } template -inline typename tools::promote_args::type +inline typename tools::promote_args::type gamma_q_inva(T1 x, T2 q, const Policy& pol) { typedef typename tools::promote_args::type result_type; typedef typename policies::evaluation::type value_type; typedef typename policies::normalise< - Policy, - policies::promote_float, - policies::promote_double, + Policy, + policies::promote_float, + policies::promote_double, policies::discrete_quantile<>, policies::assert_undefined<> >::type forwarding_policy; if(q == 1) { - policies::raise_overflow_error("boost::math::gamma_q_inva<%1%>(%1%, %1%)", 0, Policy()); + policies::raise_overflow_error("boost::math::gamma_q_inva<%1%>(%1%, %1%)", nullptr, Policy()); } if(q == 0) { @@ -204,14 +204,14 @@ inline typename tools::promote_args::type return policies::checked_narrowing_cast( detail::gamma_inva_imp( - static_cast(x), - static_cast(1 - static_cast(q)), - static_cast(q), + static_cast(x), + static_cast(1 - static_cast(q)), + static_cast(q), pol), "boost::math::gamma_q_inva<%1%>(%1%, %1%)"); } template -inline typename tools::promote_args::type +inline typename tools::promote_args::type gamma_p_inva(T1 x, T2 p) { return boost::math::gamma_p_inva(x, p, policies::policy<>()); diff --git a/include/boost/math/special_functions/detail/hypergeometric_series.hpp b/include/boost/math/special_functions/detail/hypergeometric_series.hpp index 82a0a6fbee..e902498fa3 100644 --- a/include/boost/math/special_functions/detail/hypergeometric_series.hpp +++ b/include/boost/math/special_functions/detail/hypergeometric_series.hpp @@ -209,7 +209,7 @@ } template - inline T log_pochhammer(T z, unsigned n, const Policy pol, int* s = 0) + inline T log_pochhammer(T z, unsigned n, const Policy pol, int* s = nullptr) { BOOST_MATH_STD_USING #if 0 @@ -339,7 +339,7 @@ n = summit_location; term *= (b + (n - 1)) * n / ((a + (n - 1)) * z); --n; - + do { sum += term; diff --git a/include/boost/math/special_functions/detail/ibeta_inverse.hpp b/include/boost/math/special_functions/detail/ibeta_inverse.hpp index 195f6abe18..c08652740d 100644 --- a/include/boost/math/special_functions/detail/ibeta_inverse.hpp +++ b/include/boost/math/special_functions/detail/ibeta_inverse.hpp @@ -421,7 +421,7 @@ struct ibeta_roots BOOST_MATH_STD_USING // ADL of std names BOOST_FPU_EXCEPTION_GUARD - + T f1; T y = 1 - x; T f = ibeta_imp(a, b, x, Policy(), invert, true, &f1) - target; @@ -491,7 +491,7 @@ T ibeta_inv_imp(T a, T b, T p, T q, const Policy& pol, T* py) T x = 0; // Set to a safe zero to avoid a // MSVC 2005 warning C4701: potentially uninitialized local variable 'x' used // But code inspection appears to ensure that x IS assigned whatever the code path. - T y; + T y; // For some of the methods we can put tighter bounds // on the result than simply [0,1]: @@ -638,7 +638,7 @@ T ibeta_inv_imp(T a, T b, T p, T q, const Policy& pol, T* py) y = pow(b * q * bet, 1/b); x = 1 - y; } - else + else y = 1; if(y > 1e-5) { @@ -869,7 +869,7 @@ T ibeta_inv_imp(T a, T b, T p, T q, const Policy& pol, T* py) // thrash around and convergence may be slow in this case. // Try 3/4 of machine epsilon: // - digits *= 3; + digits *= 3; digits /= 2; } // @@ -899,7 +899,7 @@ T ibeta_inv_imp(T a, T b, T p, T q, const Policy& pol, T* py) } // namespace detail template -inline typename tools::promote_args::type +inline typename tools::promote_args::type ibeta_inv(T1 a, T2 b, T3 p, T4* py, const Policy& pol) { static const char* function = "boost::math::ibeta_inv<%1%>(%1%,%1%,%1%)"; @@ -907,9 +907,9 @@ inline typename tools::promote_args::type typedef typename tools::promote_args::type result_type; typedef typename policies::evaluation::type value_type; typedef typename policies::normalise< - Policy, - policies::promote_float, - policies::promote_double, + Policy, + policies::promote_float, + policies::promote_double, policies::discrete_quantile<>, policies::assert_undefined<> >::type forwarding_policy; @@ -934,30 +934,30 @@ inline typename tools::promote_args::type } template -inline typename tools::promote_args::type +inline typename tools::promote_args::type ibeta_inv(T1 a, T2 b, T3 p, T4* py) { return ibeta_inv(a, b, p, py, policies::policy<>()); } template -inline typename tools::promote_args::type +inline typename tools::promote_args::type ibeta_inv(T1 a, T2 b, T3 p) { typedef typename tools::promote_args::type result_type; - return ibeta_inv(a, b, p, static_cast(0), policies::policy<>()); + return ibeta_inv(a, b, p, static_cast(nullptr), policies::policy<>()); } template -inline typename tools::promote_args::type +inline typename tools::promote_args::type ibeta_inv(T1 a, T2 b, T3 p, const Policy& pol) { typedef typename tools::promote_args::type result_type; - return ibeta_inv(a, b, p, static_cast(0), pol); + return ibeta_inv(a, b, p, static_cast(nullptr), pol); } template -inline typename tools::promote_args::type +inline typename tools::promote_args::type ibetac_inv(T1 a, T2 b, T3 q, T4* py, const Policy& pol) { static const char* function = "boost::math::ibetac_inv<%1%>(%1%,%1%,%1%)"; @@ -965,9 +965,9 @@ inline typename tools::promote_args::type typedef typename tools::promote_args::type result_type; typedef typename policies::evaluation::type value_type; typedef typename policies::normalise< - Policy, - policies::promote_float, - policies::promote_double, + Policy, + policies::promote_float, + policies::promote_double, policies::discrete_quantile<>, policies::assert_undefined<> >::type forwarding_policy; @@ -992,18 +992,18 @@ inline typename tools::promote_args::type } template -inline typename tools::promote_args::type +inline typename tools::promote_args::type ibetac_inv(T1 a, T2 b, T3 q, T4* py) { return ibetac_inv(a, b, q, py, policies::policy<>()); } template -inline typename tools::promote_args::type +inline typename tools::promote_args::type ibetac_inv(RT1 a, RT2 b, RT3 q) { typedef typename tools::promote_args::type result_type; - return ibetac_inv(a, b, q, static_cast(0), policies::policy<>()); + return ibetac_inv(a, b, q, static_cast(nullptr), policies::policy<>()); } template @@ -1011,7 +1011,7 @@ inline typename tools::promote_args::type ibetac_inv(RT1 a, RT2 b, RT3 q, const Policy& pol) { typedef typename tools::promote_args::type result_type; - return ibetac_inv(a, b, q, static_cast(0), pol); + return ibetac_inv(a, b, q, static_cast(nullptr), pol); } } // namespace math diff --git a/include/boost/math/special_functions/detail/igamma_inverse.hpp b/include/boost/math/special_functions/detail/igamma_inverse.hpp index caea159c57..5d5ac2c7dd 100644 --- a/include/boost/math/special_functions/detail/igamma_inverse.hpp +++ b/include/boost/math/special_functions/detail/igamma_inverse.hpp @@ -122,7 +122,7 @@ T find_inverse_gamma(T a, T p, T q, const Policy& pol, bool* p_has_10_digits) BOOST_MATH_INSTRUMENT_VARIABLE(b); if((b > 0.6) || ((b >= 0.45) && (a >= 0.3))) { - // DiDonato & Morris Eq 21: + // DiDonato & Morris Eq 21: // // There is a slight variation from DiDonato and Morris here: // the first form given here is unstable when p is close to 1, @@ -343,9 +343,9 @@ struct gamma_p_inverse_func typedef typename policies::evaluation::type value_type; // typedef typename lanczos::lanczos::type evaluation_type; typedef typename policies::normalise< - Policy, - policies::promote_float, - policies::promote_double, + Policy, + policies::promote_float, + policies::promote_double, policies::discrete_quantile<>, policies::assert_undefined<> >::type forwarding_policy; @@ -354,8 +354,8 @@ struct gamma_p_inverse_func T f, f1; value_type ft; f = static_cast(boost::math::detail::gamma_incomplete_imp( - static_cast(a), - static_cast(x), + static_cast(a), + static_cast(x), true, invert, forwarding_policy(), &ft)); f1 = static_cast(ft); @@ -400,7 +400,7 @@ T gamma_p_inv_imp(T a, T p, const Policy& pol) if((p < 0) || (p > 1)) return policies::raise_domain_error(function, "Probability must be in the range [0,1] in the incomplete gamma function inverse (got p=%1%).", p, pol); if(p == 1) - return policies::raise_overflow_error(function, 0, Policy()); + return policies::raise_overflow_error(function, nullptr, Policy()); if(p == 0) return 0; bool has_10_digits; @@ -414,7 +414,7 @@ T gamma_p_inv_imp(T a, T p, const Policy& pol) // // Work out how many digits to converge to, normally this is // 2/3 of the digits in T, but if the first derivative is very - // large convergence is slow, so we'll bump it up to full + // large convergence is slow, so we'll bump it up to full // precision to prevent premature termination of the root-finding routine. // unsigned digits = policies::digits(); @@ -460,7 +460,7 @@ T gamma_q_inv_imp(T a, T q, const Policy& pol) if((q < 0) || (q > 1)) return policies::raise_domain_error(function, "Probability must be in the range [0,1] in the incomplete gamma function inverse (got q=%1%).", q, pol); if(q == 0) - return policies::raise_overflow_error(function, 0, Policy()); + return policies::raise_overflow_error(function, nullptr, Policy()); if(q == 1) return 0; bool has_10_digits; @@ -473,7 +473,7 @@ T gamma_q_inv_imp(T a, T q, const Policy& pol) // // Work out how many digits to converge to, normally this is // 2/3 of the digits in T, but if the first derivative is very - // large convergence is slow, so we'll bump it up to full + // large convergence is slow, so we'll bump it up to full // precision to prevent premature termination of the root-finding routine. // unsigned digits = policies::digits(); @@ -509,7 +509,7 @@ T gamma_q_inv_imp(T a, T q, const Policy& pol) } // namespace detail template -inline typename tools::promote_args::type +inline typename tools::promote_args::type gamma_p_inv(T1 a, T2 p, const Policy& pol) { typedef typename tools::promote_args::type result_type; @@ -519,7 +519,7 @@ inline typename tools::promote_args::type } template -inline typename tools::promote_args::type +inline typename tools::promote_args::type gamma_q_inv(T1 a, T2 p, const Policy& pol) { typedef typename tools::promote_args::type result_type; @@ -529,14 +529,14 @@ inline typename tools::promote_args::type } template -inline typename tools::promote_args::type +inline typename tools::promote_args::type gamma_p_inv(T1 a, T2 p) { return gamma_p_inv(a, p, policies::policy<>()); } template -inline typename tools::promote_args::type +inline typename tools::promote_args::type gamma_q_inv(T1 a, T2 p) { return gamma_q_inv(a, p, policies::policy<>()); diff --git a/include/boost/math/special_functions/detail/polygamma.hpp b/include/boost/math/special_functions/detail/polygamma.hpp index 4965c52fee..3a7c984edc 100644 --- a/include/boost/math/special_functions/detail/polygamma.hpp +++ b/include/boost/math/special_functions/detail/polygamma.hpp @@ -65,12 +65,12 @@ namespace boost { namespace math { namespace detail{ // (n-1)! / x^(n+1) // // which is common to both the first term of the series (with k = 1) - // and to the leading part. + // and to the leading part. // We can then get to the leading term by: // // part_term * (n + 2 * x) / 2 // - // and to the first term in the series + // and to the first term in the series // (excluding the Bernoulli number) by: // // part_term n * (n + 1) / (2x) @@ -79,7 +79,7 @@ namespace boost { namespace math { namespace detail{ // or the power term underflows, this just gets set to 0 and then we // know that we have to use logs for the initial terms: // - part_term = ((n > (int)boost::math::max_factorial::value) && (T(n) * n > tools::log_max_value())) + part_term = ((n > (int)boost::math::max_factorial::value) && (T(n) * n > tools::log_max_value())) ? T(0) : static_cast(boost::math::factorial(n - 1, pol) * pow(x, -n - 1)); if(part_term == 0) { @@ -126,7 +126,7 @@ namespace boost { namespace math { namespace detail{ return policies::raise_evaluation_error(function, "Series did not converge, closest value was %1%", sum, pol); } } - + if((n - 1) & 1) sum = -sum; @@ -200,22 +200,22 @@ namespace boost { namespace math { namespace detail{ T factorial_part = 1; // // "prefix" is what we'll be adding the accumulated sum to, it will - // be n! / z^(n+1), but since we're scaling by n! it's just + // be n! / z^(n+1), but since we're scaling by n! it's just // 1 / z^(n+1) for now: // T prefix = pow(x, n + 1); if(prefix == 0) - return boost::math::policies::raise_overflow_error(function, 0, pol); + return boost::math::policies::raise_overflow_error(function, nullptr, pol); prefix = 1 / prefix; // // First term in the series is necessarily < zeta(2) < 2, so // ignore the sum if it will have no effect on the result anyway: // if(prefix > 2 / policies::get_epsilon()) - return ((n & 1) ? 1 : -1) * - (tools::max_value() / prefix < scale ? policies::raise_overflow_error(function, 0, pol) : prefix * scale); + return ((n & 1) ? 1 : -1) * + (tools::max_value() / prefix < scale ? policies::raise_overflow_error(function, nullptr, pol) : prefix * scale); // - // As this is an alternating series we could accelerate it using + // As this is an alternating series we could accelerate it using // "Convergence Acceleration of Alternating Series", // Henri Cohen, Fernando Rodriguez Villegas, and Don Zagier, Experimental Mathematics, 1999. // In practice however, it appears not to make any difference to the number of terms @@ -245,7 +245,7 @@ namespace boost { namespace math { namespace detail{ // We need to multiply by the scale, at each stage checking for overflow: // if(boost::math::tools::max_value() / scale < sum) - return boost::math::policies::raise_overflow_error(function, 0, pol); + return boost::math::policies::raise_overflow_error(function, nullptr, pol); sum *= scale; return n & 1 ? sum : T(-sum); } @@ -398,7 +398,7 @@ namespace boost { namespace math { namespace detail{ } // - // We'll have to compute the coefficients up to n, + // We'll have to compute the coefficients up to n, // complexity is O(n^2) which we don't worry about for now // as the values are computed once and then cached. // However, if the final evaluation would have too many @@ -459,13 +459,13 @@ namespace boost { namespace math { namespace detail{ // T power_terms = n * log(boost::math::constants::pi()); if(s == 0) - return sum * boost::math::policies::raise_overflow_error(function, 0, pol); + return sum * boost::math::policies::raise_overflow_error(function, nullptr, pol); power_terms -= log(fabs(s)) * (n + 1); power_terms += boost::math::lgamma(T(n), pol); power_terms += log(fabs(sum)); if(power_terms > boost::math::tools::log_max_value()) - return sum * boost::math::policies::raise_overflow_error(function, 0, pol); + return sum * boost::math::policies::raise_overflow_error(function, nullptr, pol); return exp(power_terms) * ((s < 0) && ((n + 1) & 1) ? -1 : 1) * boost::math::sign(sum); } @@ -491,7 +491,7 @@ namespace boost { namespace math { namespace detail{ template const typename polygamma_initializer::init polygamma_initializer::initializer; - + template inline T polygamma_imp(const int n, T x, const Policy &pol) { @@ -508,7 +508,7 @@ namespace boost { namespace math { namespace detail{ // Result is infinity if x is odd, and a pole error if x is even. // if(lltrunc(x) & 1) - return policies::raise_overflow_error(function, 0, pol); + return policies::raise_overflow_error(function, nullptr, pol); else return policies::raise_pole_error(function, "Evaluation at negative integer %1%", x, pol); } @@ -540,7 +540,7 @@ namespace boost { namespace math { namespace detail{ { T result = (n & 1 ? 1 : -1) * boost::math::factorial(n, pol) * boost::math::zeta(T(n + 1), pol); if(fabs(result) >= ldexp(tools::max_value(), -n - 1)) - return boost::math::sign(result) * policies::raise_overflow_error(function, 0, pol); + return boost::math::sign(result) * policies::raise_overflow_error(function, nullptr, pol); result *= ldexp(T(1), n + 1) - 1; return result; } diff --git a/include/boost/math/special_functions/detail/t_distribution_inv.hpp b/include/boost/math/special_functions/detail/t_distribution_inv.hpp index 6ad7ed6d9b..bcbad38fca 100644 --- a/include/boost/math/special_functions/detail/t_distribution_inv.hpp +++ b/include/boost/math/special_functions/detail/t_distribution_inv.hpp @@ -146,37 +146,37 @@ T inverse_students_t_body_series(T df, T u, const Policy& pol) T in = 1 / df; c[2] = static_cast(0.16666666666666666667 + 0.16666666666666666667 * in); c[3] = static_cast((0.0083333333333333333333 * in - + 0.066666666666666666667) * in + + 0.066666666666666666667) * in + 0.058333333333333333333); c[4] = static_cast(((0.00019841269841269841270 * in - + 0.0017857142857142857143) * in - + 0.026785714285714285714) * in + + 0.0017857142857142857143) * in + + 0.026785714285714285714) * in + 0.025198412698412698413); c[5] = static_cast((((2.7557319223985890653e-6 * in - + 0.00037477954144620811287) * in - - 0.0011078042328042328042) * in - + 0.010559964726631393298) * in + + 0.00037477954144620811287) * in + - 0.0011078042328042328042) * in + + 0.010559964726631393298) * in + 0.012039792768959435626); c[6] = static_cast(((((2.5052108385441718775e-8 * in - - 0.000062705427288760622094) * in - + 0.00059458674042007375341) * in - - 0.0016095979637646304313) * in - + 0.0061039211560044893378) * in + - 0.000062705427288760622094) * in + + 0.00059458674042007375341) * in + - 0.0016095979637646304313) * in + + 0.0061039211560044893378) * in + 0.0038370059724226390893); c[7] = static_cast((((((1.6059043836821614599e-10 * in - + 0.000015401265401265401265) * in + + 0.000015401265401265401265) * in - 0.00016376804137220803887) * in - + 0.00069084207973096861986) * in - - 0.0012579159844784844785) * in - + 0.0010898206731540064873) * in + + 0.00069084207973096861986) * in + - 0.0012579159844784844785) * in + + 0.0010898206731540064873) * in + 0.0032177478835464946576); c[8] = static_cast(((((((7.6471637318198164759e-13 * in - 3.9851014346715404916e-6) * in + 0.000049255746366361445727) * in - - 0.00024947258047043099953) * in + - 0.00024947258047043099953) * in + 0.00064513046951456342991) * in - 0.00076245135440323932387) * in - + 0.000033530976880017885309) * in + + 0.000033530976880017885309) * in + 0.0017438262298340009980); c[9] = static_cast((((((((2.8114572543455207632e-15 * in + 1.0914179173496789432e-6) * in @@ -185,7 +185,7 @@ T inverse_students_t_body_series(T df, T u, const Policy& pol) - 0.00029133414466938067350) * in + 0.00051406605788341121363) * in - 0.00036307660358786885787) * in - - 0.00031101086326318780412) * in + - 0.00031101086326318780412) * in + 0.00096472747321388644237); c[10] = static_cast(((((((((8.2206352466243297170e-18 * in - 3.1239569599829868045e-7) * in @@ -438,7 +438,7 @@ inline T fast_students_t_quantile_imp(T df, T p, const Policy& pol, const std::f T t, x, y(0); x = ibeta_inv(df / 2, T(0.5), 2 * probability, &y, pol); if(df * y > tools::max_value() * x) - t = policies::raise_overflow_error("boost::math::students_t_quantile<%1%>(%1%,%1%)", 0, pol); + t = policies::raise_overflow_error("boost::math::students_t_quantile<%1%>(%1%,%1%)", nullptr, pol); else t = sqrt(df * y / x); // @@ -455,7 +455,7 @@ T fast_students_t_quantile_imp(T df, T p, const Policy& pol, const std::true_typ BOOST_MATH_STD_USING bool invert = false; if((df < 2) && (floor(df) != df)) - return boost::math::detail::fast_students_t_quantile_imp(df, p, pol, static_cast(0)); + return boost::math::detail::fast_students_t_quantile_imp(df, p, pol, static_cast(nullptr)); if(p > 0.5) { p = 1 - p; @@ -525,9 +525,9 @@ inline T fast_students_t_quantile(T df, T p, const Policy& pol) { typedef typename policies::evaluation::type value_type; typedef typename policies::normalise< - Policy, - policies::promote_float, - policies::promote_double, + Policy, + policies::promote_float, + policies::promote_double, policies::discrete_quantile<>, policies::assert_undefined<> >::type forwarding_policy; @@ -538,7 +538,7 @@ inline T fast_students_t_quantile(T df, T p, const Policy& pol) && (std::numeric_limits::radix == 2) > tag_type; - return policies::checked_narrowing_cast(fast_students_t_quantile_imp(static_cast(df), static_cast(p), pol, static_cast(0)), "boost::math::students_t_quantile<%1%>(%1%,%1%,%1%)"); + return policies::checked_narrowing_cast(fast_students_t_quantile_imp(static_cast(df), static_cast(p), pol, static_cast(nullptr)), "boost::math::students_t_quantile<%1%>(%1%,%1%,%1%)"); } }}} // namespaces diff --git a/include/boost/math/special_functions/digamma.hpp b/include/boost/math/special_functions/digamma.hpp index e0323f533c..92f916e113 100644 --- a/include/boost/math/special_functions/digamma.hpp +++ b/include/boost/math/special_functions/digamma.hpp @@ -216,7 +216,7 @@ T digamma_imp_1_2(T x, const std::integral_constant*) static const T root4 = (((T(503992070) / 1073741824uL) / 1073741824uL) / 1073741824uL) / 1073741824uL; static const T root5 = BOOST_MATH_BIG_CONSTANT(T, 113, 0.52112228569249997894452490385577338504019838794544e-36); - static const T P[] = { + static const T P[] = { BOOST_MATH_BIG_CONSTANT(T, 113, 0.25479851061131551526977464225335883769), BOOST_MATH_BIG_CONSTANT(T, 113, -0.18684290534374944114622235683619897417), BOOST_MATH_BIG_CONSTANT(T, 113, -0.80360876047931768958995775910991929922), @@ -228,7 +228,7 @@ T digamma_imp_1_2(T x, const std::integral_constant*) BOOST_MATH_BIG_CONSTANT(T, 113, -0.16454996865214115723416538844975174761e-4), BOOST_MATH_BIG_CONSTANT(T, 113, -0.20327832297631728077731148515093164955e-6) }; - static const T Q[] = { + static const T Q[] = { BOOST_MATH_BIG_CONSTANT(T, 113, 1.0), BOOST_MATH_BIG_CONSTANT(T, 113, 2.6210924610812025425088411043163287646), BOOST_MATH_BIG_CONSTANT(T, 113, 2.6850757078559596612621337395886392594), @@ -276,7 +276,7 @@ T digamma_imp_1_2(T x, const std::integral_constant*) static const T root2 = (T(381566830) / 1073741824uL) / 1073741824uL; static const T root3 = BOOST_MATH_BIG_CONSTANT(T, 64, 0.9016312093258695918615325266959189453125e-19); - static const T P[] = { + static const T P[] = { BOOST_MATH_BIG_CONSTANT(T, 64, 0.254798510611315515235), BOOST_MATH_BIG_CONSTANT(T, 64, -0.314628554532916496608), BOOST_MATH_BIG_CONSTANT(T, 64, -0.665836341559876230295), @@ -284,7 +284,7 @@ T digamma_imp_1_2(T x, const std::integral_constant*) BOOST_MATH_BIG_CONSTANT(T, 64, -0.0541156266153505273939), BOOST_MATH_BIG_CONSTANT(T, 64, -0.00289268368333918761452) }; - static const T Q[] = { + static const T Q[] = { BOOST_MATH_BIG_CONSTANT(T, 64, 1.0), BOOST_MATH_BIG_CONSTANT(T, 64, 2.1195759927055347547), BOOST_MATH_BIG_CONSTANT(T, 64, 1.54350554664961128724), @@ -326,7 +326,7 @@ T digamma_imp_1_2(T x, const std::integral_constant*) static const T root2 = (T(381566830) / 1073741824uL) / 1073741824uL; static const T root3 = BOOST_MATH_BIG_CONSTANT(T, 53, 0.9016312093258695918615325266959189453125e-19); - static const T P[] = { + static const T P[] = { BOOST_MATH_BIG_CONSTANT(T, 53, 0.25479851061131551), BOOST_MATH_BIG_CONSTANT(T, 53, -0.32555031186804491), BOOST_MATH_BIG_CONSTANT(T, 53, -0.65031853770896507), @@ -334,7 +334,7 @@ T digamma_imp_1_2(T x, const std::integral_constant*) BOOST_MATH_BIG_CONSTANT(T, 53, -0.045251321448739056), BOOST_MATH_BIG_CONSTANT(T, 53, -0.0020713321167745952) }; - static const T Q[] = { + static const T Q[] = { BOOST_MATH_BIG_CONSTANT(T, 53, 1.0), BOOST_MATH_BIG_CONSTANT(T, 53, 2.0767117023730469), BOOST_MATH_BIG_CONSTANT(T, 53, 1.4606242909763515), @@ -372,13 +372,13 @@ inline T digamma_imp_1_2(T x, const std::integral_constant*) static const float Y = 0.99558162689208984f; static const T root = 1532632.0f / 1048576; static const T root_minor = static_cast(0.3700660185912626595423257213284682051735604e-6L); - static const T P[] = { + static const T P[] = { 0.25479851023250261e0f, -0.44981331915268368e0f, -0.43916936919946835e0f, -0.61041765350579073e-1f }; - static const T Q[] = { + static const T Q[] = { 0.1e1, 0.15890202430554952e1f, 0.65341249856146947e0f, @@ -421,12 +421,12 @@ T digamma_imp(T x, const Tag* t, const Policy& pol) // if(remainder == 0) { - return policies::raise_pole_error("boost::math::digamma<%1%>(%1%)", 0, (1-x), pol); + return policies::raise_pole_error("boost::math::digamma<%1%>(%1%)", nullptr, (1-x), pol); } result = constants::pi() / tan(constants::pi() * remainder); } if(x == 0) - return policies::raise_pole_error("boost::math::digamma<%1%>(%1%)", 0, x, pol); + return policies::raise_pole_error("boost::math::digamma<%1%>(%1%)", nullptr, x, pol); // // If we're above the lower-limit for the // asymptotic expansion then use it: @@ -487,12 +487,12 @@ T digamma_imp(T x, const std::integral_constant* t, const Policy& pol) // if(remainder == 0) { - return policies::raise_pole_error("boost::math::digamma<%1%>(%1%)", 0, (1 - x), pol); + return policies::raise_pole_error("boost::math::digamma<%1%>(%1%)", nullptr, (1 - x), pol); } result = constants::pi() / tan(constants::pi() * remainder); } if(x == 0) - return policies::raise_pole_error("boost::math::digamma<%1%>(%1%)", 0, x, pol); + return policies::raise_pole_error("boost::math::digamma<%1%>(%1%)", nullptr, x, pol); // // If we're above the lower-limit for the // asymptotic expansion then use it, the @@ -584,7 +584,7 @@ const typename digamma_initializer::init digamma_initializer -inline typename tools::promote_args::type +inline typename tools::promote_args::type digamma(T x, const Policy&) { typedef typename tools::promote_args::type result_type; @@ -608,11 +608,11 @@ inline typename tools::promote_args::type return policies::checked_narrowing_cast(detail::digamma_imp( static_cast(x), - static_cast(0), forwarding_policy()), "boost::math::digamma<%1%>(%1%)"); + static_cast(nullptr), forwarding_policy()), "boost::math::digamma<%1%>(%1%)"); } template -inline typename tools::promote_args::type +inline typename tools::promote_args::type digamma(T x) { return digamma(x, policies::policy<>()); diff --git a/include/boost/math/special_functions/ellint_1.hpp b/include/boost/math/special_functions/ellint_1.hpp index f728d13235..cc634ad4ef 100644 --- a/include/boost/math/special_functions/ellint_1.hpp +++ b/include/boost/math/special_functions/ellint_1.hpp @@ -64,7 +64,7 @@ T ellint_f_imp(T phi, T k, const Policy& pol) if(phi >= tools::max_value()) { // Need to handle infinity as a special case: - result = policies::raise_overflow_error(function, 0, pol); + result = policies::raise_overflow_error(function, nullptr, pol); BOOST_MATH_INSTRUMENT_VARIABLE(result); } else if(phi > 1 / tools::epsilon()) @@ -145,7 +145,7 @@ T ellint_k_imp(T k, const Policy& pol) } if (abs(k) == 1) { - return policies::raise_overflow_error(function, 0, pol); + return policies::raise_overflow_error(function, nullptr, pol); } T x = 0; diff --git a/include/boost/math/special_functions/ellint_2.hpp b/include/boost/math/special_functions/ellint_2.hpp index cd4380941b..d5cd094d97 100644 --- a/include/boost/math/special_functions/ellint_2.hpp +++ b/include/boost/math/special_functions/ellint_2.hpp @@ -30,11 +30,11 @@ // Elliptic integrals (complete and incomplete) of the second kind // Carlson, Numerische Mathematik, vol 33, 1 (1979) -namespace boost { namespace math { - +namespace boost { namespace math { + template typename tools::promote_args::type ellint_2(T1 k, T2 phi, const Policy& pol); - + namespace detail{ template @@ -63,7 +63,7 @@ T ellint_e_imp(T phi, T k, const Policy& pol) if(phi >= tools::max_value()) { // Need to handle infinity as a special case: - result = policies::raise_overflow_error("boost::math::ellint_e<%1%>(%1%,%1%)", 0, pol); + result = policies::raise_overflow_error("boost::math::ellint_e<%1%>(%1%,%1%)", nullptr, pol); } else if(phi > 1 / tools::epsilon()) { diff --git a/include/boost/math/special_functions/ellint_d.hpp b/include/boost/math/special_functions/ellint_d.hpp index 8b6c242451..d50029f5f4 100644 --- a/include/boost/math/special_functions/ellint_d.hpp +++ b/include/boost/math/special_functions/ellint_d.hpp @@ -30,11 +30,11 @@ // Elliptic integrals (complete and incomplete) of the second kind // Carlson, Numerische Mathematik, vol 33, 1 (1979) -namespace boost { namespace math { - +namespace boost { namespace math { + template typename tools::promote_args::type ellint_d(T1 k, T2 phi, const Policy& pol); - + namespace detail{ template @@ -60,7 +60,7 @@ T ellint_d_imp(T phi, T k, const Policy& pol) if(phi >= tools::max_value()) { // Need to handle infinity as a special case: - result = policies::raise_overflow_error("boost::math::ellint_d<%1%>(%1%,%1%)", 0, pol); + result = policies::raise_overflow_error("boost::math::ellint_d<%1%>(%1%,%1%)", nullptr, pol); } else if(phi > 1 / tools::epsilon()) { diff --git a/include/boost/math/special_functions/expint.hpp b/include/boost/math/special_functions/expint.hpp index bad42f4883..a2aa83b1d1 100644 --- a/include/boost/math/special_functions/expint.hpp +++ b/include/boost/math/special_functions/expint.hpp @@ -37,7 +37,7 @@ namespace boost{ namespace math{ template inline typename tools::promote_args::type expint(unsigned n, T z, const Policy& /*pol*/); - + namespace detail{ template @@ -59,7 +59,7 @@ T expint_1_rational(const T& z, const std::integral_constant&) // Expected Error Term: 2.006e-18 // Max error found at double precision: 2.760e-17 static const T Y = 0.66373538970947265625F; - static const T P[6] = { + static const T P[6] = { BOOST_MATH_BIG_CONSTANT(T, 53, 0.0865197248079397976498), BOOST_MATH_BIG_CONSTANT(T, 53, 0.0320913665303559189999), BOOST_MATH_BIG_CONSTANT(T, 53, -0.245088216639761496153), @@ -67,7 +67,7 @@ T expint_1_rational(const T& z, const std::integral_constant&) BOOST_MATH_BIG_CONSTANT(T, 53, -0.00399167106081113256961), BOOST_MATH_BIG_CONSTANT(T, 53, -0.000111507792921197858394) }; - static const T Q[6] = { + static const T Q[6] = { BOOST_MATH_BIG_CONSTANT(T, 53, 1.0), BOOST_MATH_BIG_CONSTANT(T, 53, 0.37091387659397013215), BOOST_MATH_BIG_CONSTANT(T, 53, 0.056770677104207528384), @@ -75,7 +75,7 @@ T expint_1_rational(const T& z, const std::integral_constant&) BOOST_MATH_BIG_CONSTANT(T, 53, 0.000131049900798434683324), BOOST_MATH_BIG_CONSTANT(T, 53, -0.528611029520217142048e-6) }; - result = tools::evaluate_polynomial(P, z) + result = tools::evaluate_polynomial(P, z) / tools::evaluate_polynomial(Q, z); result += z - log(z) - Y; } @@ -83,7 +83,7 @@ T expint_1_rational(const T& z, const std::integral_constant&) { // Maximum Deviation Found (interpolated): 1.444e-17 // Max error found at double precision: 3.119e-17 - static const T P[11] = { + static const T P[11] = { BOOST_MATH_BIG_CONSTANT(T, 53, -0.121013190657725568138e-18), BOOST_MATH_BIG_CONSTANT(T, 53, -0.999999999999998811143), BOOST_MATH_BIG_CONSTANT(T, 53, -43.3058660811817946037), @@ -96,7 +96,7 @@ T expint_1_rational(const T& z, const std::integral_constant&) BOOST_MATH_BIG_CONSTANT(T, 53, -14751.4895786128450662), BOOST_MATH_BIG_CONSTANT(T, 53, -1185.45720315201027667) }; - static const T Q[12] = { + static const T Q[12] = { BOOST_MATH_BIG_CONSTANT(T, 53, 1.0), BOOST_MATH_BIG_CONSTANT(T, 53, 45.3058660811801465927), BOOST_MATH_BIG_CONSTANT(T, 53, 809.193214954550328455), @@ -134,7 +134,7 @@ T expint_1_rational(const T& z, const std::integral_constant&) // Max error found at long double precision: 6.249e-20 static const T Y = 0.66373538970947265625F; - static const T P[6] = { + static const T P[6] = { BOOST_MATH_BIG_CONSTANT(T, 64, 0.0865197248079397956816), BOOST_MATH_BIG_CONSTANT(T, 64, 0.0275114007037026844633), BOOST_MATH_BIG_CONSTANT(T, 64, -0.246594388074877139824), @@ -142,7 +142,7 @@ T expint_1_rational(const T& z, const std::integral_constant&) BOOST_MATH_BIG_CONSTANT(T, 64, -0.00259113319641673986276), BOOST_MATH_BIG_CONSTANT(T, 64, 0.30853660894346057053e-4) }; - static const T Q[7] = { + static const T Q[7] = { BOOST_MATH_BIG_CONSTANT(T, 64, 1.0), BOOST_MATH_BIG_CONSTANT(T, 64, 0.317978365797784100273), BOOST_MATH_BIG_CONSTANT(T, 64, 0.0393622602554758722511), @@ -151,7 +151,7 @@ T expint_1_rational(const T& z, const std::integral_constant&) BOOST_MATH_BIG_CONSTANT(T, 64, -0.202872781770207871975e-5), BOOST_MATH_BIG_CONSTANT(T, 64, 0.52779248094603709945e-7) }; - result = tools::evaluate_polynomial(P, z) + result = tools::evaluate_polynomial(P, z) / tools::evaluate_polynomial(Q, z); result += z - log(z) - Y; } @@ -159,7 +159,7 @@ T expint_1_rational(const T& z, const std::integral_constant&) { // Maximum Deviation Found (interpolated): 2.220e-20 // Max error found at long double precision: 1.346e-19 - static const T P[14] = { + static const T P[14] = { BOOST_MATH_BIG_CONSTANT(T, 64, -0.534401189080684443046e-23), BOOST_MATH_BIG_CONSTANT(T, 64, -0.999999999999999999905), BOOST_MATH_BIG_CONSTANT(T, 64, -62.1517806091379402505), @@ -175,7 +175,7 @@ T expint_1_rational(const T& z, const std::integral_constant&) BOOST_MATH_BIG_CONSTANT(T, 64, -65815.2605361889477244), BOOST_MATH_BIG_CONSTANT(T, 64, -2038.82870680427258038) }; - static const T Q[14] = { + static const T Q[14] = { BOOST_MATH_BIG_CONSTANT(T, 64, 1.0), BOOST_MATH_BIG_CONSTANT(T, 64, 64.1517806091379399478), BOOST_MATH_BIG_CONSTANT(T, 64, 1690.76044393722763785), @@ -215,7 +215,7 @@ T expint_1_rational(const T& z, const std::integral_constant&) // Max error found at long double precision: 6.810e-35 static const T Y = 0.66373538970947265625F; - static const T P[10] = { + static const T P[10] = { BOOST_MATH_BIG_CONSTANT(T, 113, 0.0865197248079397956434879099175975937), BOOST_MATH_BIG_CONSTANT(T, 113, 0.0369066175910795772830865304506087759), BOOST_MATH_BIG_CONSTANT(T, 113, -0.24272036838415474665971599314725545), @@ -227,7 +227,7 @@ T expint_1_rational(const T& z, const std::integral_constant&) BOOST_MATH_BIG_CONSTANT(T, 113, -0.346839106212658259681029388908658618e-7), BOOST_MATH_BIG_CONSTANT(T, 113, -0.340500302777838063940402160594523429e-9) }; - static const T Q[10] = { + static const T Q[10] = { BOOST_MATH_BIG_CONSTANT(T, 113, 1.0), BOOST_MATH_BIG_CONSTANT(T, 113, 0.426568827778942588160423015589537302), BOOST_MATH_BIG_CONSTANT(T, 113, 0.0841384046470893490592450881447510148), @@ -239,7 +239,7 @@ T expint_1_rational(const T& z, const std::integral_constant&) BOOST_MATH_BIG_CONSTANT(T, 113, 0.369373328141051577845488477377890236e-9), BOOST_MATH_BIG_CONSTANT(T, 113, -0.274149801370933606409282434677600112e-12) }; - result = tools::evaluate_polynomial(P, z) + result = tools::evaluate_polynomial(P, z) / tools::evaluate_polynomial(Q, z); result += z - log(z) - Y; } @@ -250,7 +250,7 @@ T expint_1_rational(const T& z, const std::integral_constant&) static const T Y = 0.70190334320068359375F; - static const T P[16] = { + static const T P[16] = { BOOST_MATH_BIG_CONSTANT(T, 113, 0.298096656795020369955077350585959794), BOOST_MATH_BIG_CONSTANT(T, 113, 12.9314045995266142913135497455971247), BOOST_MATH_BIG_CONSTANT(T, 113, 226.144334921582637462526628217345501), @@ -268,7 +268,7 @@ T expint_1_rational(const T& z, const std::integral_constant&) BOOST_MATH_BIG_CONSTANT(T, 113, -109.009437301400845902228611986479816), BOOST_MATH_BIG_CONSTANT(T, 113, -1.51492042209561411434644938098833499) }; - static const T Q[16] = { + static const T Q[16] = { BOOST_MATH_BIG_CONSTANT(T, 113, 1.0), BOOST_MATH_BIG_CONSTANT(T, 113, 46.734521442032505570517810766704587), BOOST_MATH_BIG_CONSTANT(T, 113, 908.694714348462269000247450058595655), @@ -296,7 +296,7 @@ T expint_1_rational(const T& z, const std::integral_constant&) // Max error in interpolated form: 4.413e-35 // Max error found at long double precision: 8.928e-35 - static const T P[19] = { + static const T P[19] = { BOOST_MATH_BIG_CONSTANT(T, 113, -0.559148411832951463689610809550083986e-40), BOOST_MATH_BIG_CONSTANT(T, 113, -0.999999999999999999999999999999999997), BOOST_MATH_BIG_CONSTANT(T, 113, -166.542326331163836642960118190147367), @@ -317,7 +317,7 @@ T expint_1_rational(const T& z, const std::integral_constant&) BOOST_MATH_BIG_CONSTANT(T, 113, -1077042281708.42654526404581272546244), BOOST_MATH_BIG_CONSTANT(T, 113, -68028222642.1941480871395695677675137) }; - static const T Q[20] = { + static const T Q[20] = { BOOST_MATH_BIG_CONSTANT(T, 113, 1.0), BOOST_MATH_BIG_CONSTANT(T, 113, 168.542326331163836642960118190147311), BOOST_MATH_BIG_CONSTANT(T, 113, 12535.7237814586576783518249115343619), @@ -377,7 +377,7 @@ inline T expint_as_fraction(unsigned n, T z, const Policy& pol) std::uintmax_t max_iter = policies::get_max_series_iterations(); expint_fraction f(n, z); T result = tools::continued_fraction_b( - f, + f, boost::math::policies::get_epsilon(), max_iter); policies::check_series_iterations("boost::math::expint_continued_fraction<%1%>(unsigned,%1%)", max_iter, pol); @@ -392,7 +392,7 @@ template struct expint_series { typedef T result_type; - expint_series(unsigned k_, T z_, T x_k_, T denom_, T fact_) + expint_series(unsigned k_, T z_, T x_k_, T denom_, T fact_) : k(k_), z(z_), x_k(x_k_), denom(denom_), fact(fact_){} T operator()() { @@ -430,7 +430,7 @@ inline T expint_as_series(unsigned n, T z, const Policy& pol) fact *= ++k; } BOOST_MATH_INSTRUMENT_VARIABLE(result) - result += pow(-z, static_cast(n - 1)) + result += pow(-z, static_cast(n - 1)) * (boost::math::digamma(static_cast(n), pol) - log(z)) / fact; BOOST_MATH_INSTRUMENT_VARIABLE(result) @@ -450,7 +450,7 @@ T expint_imp(unsigned n, T z, const Policy& pol, const Tag& tag) if(z < 0) return policies::raise_domain_error(function, "Function requires z >= 0 but got %1%.", z, pol); if(z == 0) - return n == 1 ? policies::raise_overflow_error(function, 0, pol) : T(1 / (static_cast(n - 1))); + return n == 1 ? policies::raise_overflow_error(function, nullptr, pol) : T(1 / (static_cast(n - 1))); T result; @@ -520,7 +520,7 @@ T expint_i_imp(T z, const Policy& pol, const Tag& tag) if(z < 0) return -expint_imp(1, T(-z), pol, tag); if(z == 0) - return -policies::raise_overflow_error(function, 0, pol); + return -policies::raise_overflow_error(function, nullptr, pol); return expint_i_as_series(z, pol); } @@ -532,7 +532,7 @@ T expint_i_imp(T z, const Policy& pol, const std::integral_constant& ta if(z < 0) return -expint_imp(1, T(-z), pol, tag); if(z == 0) - return -policies::raise_overflow_error(function, 0, pol); + return -policies::raise_overflow_error(function, nullptr, pol); T result; @@ -541,7 +541,7 @@ T expint_i_imp(T z, const Policy& pol, const std::integral_constant& ta // Maximum Deviation Found: 2.852e-18 // Expected Error Term: 2.852e-18 // Max Error found at double precision = Poly: 2.636335e-16 Cheb: 4.187027e-16 - static const T P[10] = { + static const T P[10] = { BOOST_MATH_BIG_CONSTANT(T, 53, 2.98677224343598593013), BOOST_MATH_BIG_CONSTANT(T, 53, 0.356343618769377415068), BOOST_MATH_BIG_CONSTANT(T, 53, 0.780836076283730801839), @@ -553,7 +553,7 @@ T expint_i_imp(T z, const Policy& pol, const std::integral_constant& ta BOOST_MATH_BIG_CONSTANT(T, 53, 0.798296365679269702435e-5), BOOST_MATH_BIG_CONSTANT(T, 53, 0.2777056254402008721e-6) }; - static const T Q[8] = { + static const T Q[8] = { BOOST_MATH_BIG_CONSTANT(T, 53, 1.0), BOOST_MATH_BIG_CONSTANT(T, 53, -1.17090412365413911947), BOOST_MATH_BIG_CONSTANT(T, 53, 0.62215109846016746276), @@ -570,7 +570,7 @@ T expint_i_imp(T z, const Policy& pol, const std::integral_constant& ta static const T r2 = BOOST_MATH_BIG_CONSTANT(T, 53, 0.131401834143860282009280387409357165515556574352422001206362e-16); static const T r = static_cast(BOOST_MATH_BIG_CONSTANT(T, 53, 0.372507410781366634461991866580119133535689497771654051555657435242200120636201854384926049951548942392)); T t = (z / 3) - 1; - result = tools::evaluate_polynomial(P, t) + result = tools::evaluate_polynomial(P, t) / tools::evaluate_polynomial(Q, t); t = (z - r1) - r2; result *= t; @@ -589,7 +589,7 @@ T expint_i_imp(T z, const Policy& pol, const std::integral_constant& ta // Expected Error Term: 6.546e-17 // Max Error found at double precision = Poly: 6.890169e-17 Cheb: 6.772128e-17 static const T Y = 1.158985137939453125F; - static const T P[8] = { + static const T P[8] = { BOOST_MATH_BIG_CONSTANT(T, 53, 0.00139324086199402804173), BOOST_MATH_BIG_CONSTANT(T, 53, -0.0349921221823888744966), BOOST_MATH_BIG_CONSTANT(T, 53, -0.0264095520754134848538), @@ -599,7 +599,7 @@ T expint_i_imp(T z, const Policy& pol, const std::integral_constant& ta BOOST_MATH_BIG_CONSTANT(T, 53, -0.554086272024881826253e-4), BOOST_MATH_BIG_CONSTANT(T, 53, -0.396487648924804510056e-5) }; - static const T Q[8] = { + static const T Q[8] = { BOOST_MATH_BIG_CONSTANT(T, 53, 1.0), BOOST_MATH_BIG_CONSTANT(T, 53, 0.744625566823272107711), BOOST_MATH_BIG_CONSTANT(T, 53, 0.329061095011767059236), @@ -622,7 +622,7 @@ T expint_i_imp(T z, const Policy& pol, const std::integral_constant& ta // Max Error found at double precision = Poly: 4.375868e-17 Cheb: 5.860967e-17 static const T Y = 1.0869731903076171875F; - static const T P[9] = { + static const T P[9] = { BOOST_MATH_BIG_CONSTANT(T, 53, -0.00893891094356945667451), BOOST_MATH_BIG_CONSTANT(T, 53, -0.0484607730127134045806), BOOST_MATH_BIG_CONSTANT(T, 53, -0.0652810444222236895772), @@ -633,7 +633,7 @@ T expint_i_imp(T z, const Policy& pol, const std::integral_constant& ta BOOST_MATH_BIG_CONSTANT(T, 53, -0.000209750022660200888349), BOOST_MATH_BIG_CONSTANT(T, 53, -0.138652200349182596186e-4) }; - static const T Q[9] = { + static const T Q[9] = { BOOST_MATH_BIG_CONSTANT(T, 53, 1.0), BOOST_MATH_BIG_CONSTANT(T, 53, 1.97017214039061194971), BOOST_MATH_BIG_CONSTANT(T, 53, 1.86232465043073157508), @@ -658,7 +658,7 @@ T expint_i_imp(T z, const Policy& pol, const std::integral_constant& ta static const T Y = 1.03937530517578125F; - static const T P[9] = { + static const T P[9] = { BOOST_MATH_BIG_CONSTANT(T, 53, -0.00356165148914447597995), BOOST_MATH_BIG_CONSTANT(T, 53, -0.0229930320357982333406), BOOST_MATH_BIG_CONSTANT(T, 53, -0.0449814350482277917716), @@ -669,7 +669,7 @@ T expint_i_imp(T z, const Policy& pol, const std::integral_constant& ta BOOST_MATH_BIG_CONSTANT(T, 53, -0.000192178045857733706044), BOOST_MATH_BIG_CONSTANT(T, 53, -0.113161784705911400295e-9) }; - static const T Q[9] = { + static const T Q[9] = { BOOST_MATH_BIG_CONSTANT(T, 53, 1.0), BOOST_MATH_BIG_CONSTANT(T, 53, 2.84354408840148561131), BOOST_MATH_BIG_CONSTANT(T, 53, 3.6599610090072393012), @@ -690,7 +690,7 @@ T expint_i_imp(T z, const Policy& pol, const std::integral_constant& ta // Max Error found at double precision = 3.381886e-17 static const T exp40 = static_cast(BOOST_MATH_BIG_CONSTANT(T, 53, 2.35385266837019985407899910749034804508871617254555467236651e17)); static const T Y= 1.013065338134765625F; - static const T P[6] = { + static const T P[6] = { BOOST_MATH_BIG_CONSTANT(T, 53, -0.0130653381347656243849), BOOST_MATH_BIG_CONSTANT(T, 53, 0.19029710559486576682), BOOST_MATH_BIG_CONSTANT(T, 53, 94.7365094537197236011), @@ -698,7 +698,7 @@ T expint_i_imp(T z, const Policy& pol, const std::integral_constant& ta BOOST_MATH_BIG_CONSTANT(T, 53, 18932.0850014925993025), BOOST_MATH_BIG_CONSTANT(T, 53, -38703.1431362056714134) }; - static const T Q[7] = { + static const T Q[7] = { BOOST_MATH_BIG_CONSTANT(T, 53, 1.0), BOOST_MATH_BIG_CONSTANT(T, 53, 61.9733592849439884145), BOOST_MATH_BIG_CONSTANT(T, 53, -2354.56211323420194283), @@ -718,14 +718,14 @@ T expint_i_imp(T z, const Policy& pol, const std::integral_constant& ta t = z - 40; if(t > tools::log_max_value()) { - result = policies::raise_overflow_error(function, 0, pol); + result = policies::raise_overflow_error(function, nullptr, pol); } else { result *= exp(z - 40) / z; if(result > tools::max_value() / exp40) { - result = policies::raise_overflow_error(function, 0, pol); + result = policies::raise_overflow_error(function, nullptr, pol); } else { @@ -746,7 +746,7 @@ T expint_i_imp(T z, const Policy& pol, const std::integral_constant& ta if(z < 0) return -expint_imp(1, T(-z), pol, tag); if(z == 0) - return -policies::raise_overflow_error(function, 0, pol); + return -policies::raise_overflow_error(function, nullptr, pol); T result; @@ -756,7 +756,7 @@ T expint_i_imp(T z, const Policy& pol, const std::integral_constant& ta // Expected Error Term: 3.883e-21 // Max Error found at long double precision = Poly: 3.344801e-19 Cheb: 4.989937e-19 - static const T P[11] = { + static const T P[11] = { BOOST_MATH_BIG_CONSTANT(T, 64, 2.98677224343598593764), BOOST_MATH_BIG_CONSTANT(T, 64, 0.25891613550886736592), BOOST_MATH_BIG_CONSTANT(T, 64, 0.789323584998672832285), @@ -769,7 +769,7 @@ T expint_i_imp(T z, const Policy& pol, const std::integral_constant& ta BOOST_MATH_BIG_CONSTANT(T, 64, 0.629499283139417444244e-6), BOOST_MATH_BIG_CONSTANT(T, 64, 0.177833045143692498221e-7) }; - static const T Q[9] = { + static const T Q[9] = { BOOST_MATH_BIG_CONSTANT(T, 64, 1.0), BOOST_MATH_BIG_CONSTANT(T, 64, -1.20352377969742325748), BOOST_MATH_BIG_CONSTANT(T, 64, 0.66707904942606479811), @@ -787,7 +787,7 @@ T expint_i_imp(T z, const Policy& pol, const std::integral_constant& ta static const T r2 = BOOST_MATH_BIG_CONSTANT(T, 64, 0.131401834143860282009280387409357165515556574352422001206362e-16); static const T r = static_cast(BOOST_MATH_BIG_CONSTANT(T, 64, 0.372507410781366634461991866580119133535689497771654051555657435242200120636201854384926049951548942392)); T t = (z / 3) - 1; - result = tools::evaluate_polynomial(P, t) + result = tools::evaluate_polynomial(P, t) / tools::evaluate_polynomial(Q, t); t = (z - r1) - r2; result *= t; @@ -807,7 +807,7 @@ T expint_i_imp(T z, const Policy& pol, const std::integral_constant& ta // Max Error found at long double precision = Poly: 1.208328e-20 Cheb: 1.073723e-20 static const T Y = 1.158985137939453125F; - static const T P[9] = { + static const T P[9] = { BOOST_MATH_BIG_CONSTANT(T, 64, 0.00139324086199409049399), BOOST_MATH_BIG_CONSTANT(T, 64, -0.0345238388952337563247), BOOST_MATH_BIG_CONSTANT(T, 64, -0.0382065278072592940767), @@ -818,7 +818,7 @@ T expint_i_imp(T z, const Policy& pol, const std::integral_constant& ta BOOST_MATH_BIG_CONSTANT(T, 64, -0.623067256376494930067e-5), BOOST_MATH_BIG_CONSTANT(T, 64, -0.377246883283337141444e-6) }; - static const T Q[10] = { + static const T Q[10] = { BOOST_MATH_BIG_CONSTANT(T, 64, 1.0), BOOST_MATH_BIG_CONSTANT(T, 64, 1.08073635708902053767), BOOST_MATH_BIG_CONSTANT(T, 64, 0.553681133533942532909), @@ -844,7 +844,7 @@ T expint_i_imp(T z, const Policy& pol, const std::integral_constant& ta static const T Y = 1.0869731903076171875F; - static const T P[10] = { + static const T P[10] = { BOOST_MATH_BIG_CONSTANT(T, 64, -0.00893891094356946995368), BOOST_MATH_BIG_CONSTANT(T, 64, -0.0487562980088748775943), BOOST_MATH_BIG_CONSTANT(T, 64, -0.0670568657950041926085), @@ -856,7 +856,7 @@ T expint_i_imp(T z, const Policy& pol, const std::integral_constant& ta BOOST_MATH_BIG_CONSTANT(T, 64, -0.44424044184395578775e-4), BOOST_MATH_BIG_CONSTANT(T, 64, -0.252788029251437017959e-5) }; - static const T Q[10] = { + static const T Q[10] = { BOOST_MATH_BIG_CONSTANT(T, 64, 1.0), BOOST_MATH_BIG_CONSTANT(T, 64, 2.00323265503572414261), BOOST_MATH_BIG_CONSTANT(T, 64, 1.94688958187256383178), @@ -881,7 +881,7 @@ T expint_i_imp(T z, const Policy& pol, const std::integral_constant& ta // Max Error found at long double precision = Poly: 3.419893e-19 Cheb: 3.359874e-19 static const T Y = 1.03937530517578125F; - static const T P[12] = { + static const T P[12] = { BOOST_MATH_BIG_CONSTANT(T, 64, -0.00356165148914447278177), BOOST_MATH_BIG_CONSTANT(T, 64, -0.0240235006148610849678), BOOST_MATH_BIG_CONSTANT(T, 64, -0.0516699967278057976119), @@ -895,7 +895,7 @@ T expint_i_imp(T z, const Policy& pol, const std::integral_constant& ta BOOST_MATH_BIG_CONSTANT(T, 64, 0.712662196671896837736e-10), BOOST_MATH_BIG_CONSTANT(T, 64, -0.533769629702262072175e-11) }; - static const T Q[9] = { + static const T Q[9] = { BOOST_MATH_BIG_CONSTANT(T, 64, 1.0), BOOST_MATH_BIG_CONSTANT(T, 64, 3.13286733695729715455), BOOST_MATH_BIG_CONSTANT(T, 64, 4.49281223045653491929), @@ -922,7 +922,7 @@ T expint_i_imp(T z, const Policy& pol, const std::integral_constant& ta static const T exp40 = static_cast(BOOST_MATH_BIG_CONSTANT(T, 64, 2.35385266837019985407899910749034804508871617254555467236651e17)); static const T Y= 1.013065338134765625F; - static const T P[9] = { + static const T P[9] = { BOOST_MATH_BIG_CONSTANT(T, 64, -0.0130653381347656250004), BOOST_MATH_BIG_CONSTANT(T, 64, 0.644487780349757303739), BOOST_MATH_BIG_CONSTANT(T, 64, 143.995670348227433964), @@ -933,7 +933,7 @@ T expint_i_imp(T z, const Policy& pol, const std::integral_constant& ta BOOST_MATH_BIG_CONSTANT(T, 64, -160695051.957997452509), BOOST_MATH_BIG_CONSTANT(T, 64, 137839271.592778020028) }; - static const T Q[9] = { + static const T Q[9] = { BOOST_MATH_BIG_CONSTANT(T, 64, 1.0), BOOST_MATH_BIG_CONSTANT(T, 64, 27.2103343964943718802), BOOST_MATH_BIG_CONSTANT(T, 64, -8785.48528692879413676), @@ -955,14 +955,14 @@ T expint_i_imp(T z, const Policy& pol, const std::integral_constant& ta t = z - 40; if(t > tools::log_max_value()) { - result = policies::raise_overflow_error(function, 0, pol); + result = policies::raise_overflow_error(function, nullptr, pol); } else { result *= exp(z - 40) / z; if(result > tools::max_value() / exp40) { - result = policies::raise_overflow_error(function, 0, pol); + result = policies::raise_overflow_error(function, nullptr, pol); } else { @@ -984,7 +984,7 @@ void expint_i_imp_113a(T& result, const T& z, const Policy& pol) // Max Error found at long double precision = Poly: 4.355299e-34 Cheb: 7.512581e-34 - static const T P[15] = { + static const T P[15] = { BOOST_MATH_BIG_CONSTANT(T, 113, 2.98677224343598593765287235997328555), BOOST_MATH_BIG_CONSTANT(T, 113, -0.333256034674702967028780537349334037), BOOST_MATH_BIG_CONSTANT(T, 113, 0.851831522798101228384971644036708463), @@ -1001,7 +1001,7 @@ void expint_i_imp_113a(T& result, const T& z, const Policy& pol) BOOST_MATH_BIG_CONSTANT(T, 113, 0.143971277122049197323415503594302307e-11), BOOST_MATH_BIG_CONSTANT(T, 113, 0.306243138978114692252817805327426657e-13) }; - static const T Q[15] = { + static const T Q[15] = { BOOST_MATH_BIG_CONSTANT(T, 113, 1.0), BOOST_MATH_BIG_CONSTANT(T, 113, -1.40178870313943798705491944989231793), BOOST_MATH_BIG_CONSTANT(T, 113, 0.943810968269701047641218856758605284), @@ -1029,7 +1029,7 @@ void expint_i_imp_113a(T& result, const T& z, const Policy& pol) static const T r3 = static_cast(BOOST_MATH_BIG_CONSTANT(T, 113, 0.283806480836357377069325311780969887585024578164571984232357e-31)); static const T r = static_cast(BOOST_MATH_BIG_CONSTANT(T, 113, 0.372507410781366634461991866580119133535689497771654051555657435242200120636201854384926049951548942392)); T t = (z / 3) - 1; - result = tools::evaluate_polynomial(P, t) + result = tools::evaluate_polynomial(P, t) / tools::evaluate_polynomial(Q, t); t = ((z - r1) - r2) - r3; result *= t; @@ -1052,7 +1052,7 @@ void expint_i_113b(T& result, const T& z) // Max Error found at long double precision = Poly: 2.576723e-35 Cheb: 1.236001e-34 static const T Y = 1.158985137939453125F; - static const T P[15] = { + static const T P[15] = { BOOST_MATH_BIG_CONSTANT(T, 113, 0.00139324086199409049282472239613554817), BOOST_MATH_BIG_CONSTANT(T, 113, -0.0338173111691991289178779840307998955), BOOST_MATH_BIG_CONSTANT(T, 113, -0.0555972290794371306259684845277620556), @@ -1069,7 +1069,7 @@ void expint_i_113b(T& result, const T& z) BOOST_MATH_BIG_CONSTANT(T, 113, -0.203015132965870311935118337194860863e-10), BOOST_MATH_BIG_CONSTANT(T, 113, -0.384276705503357655108096065452950822e-12) }; - static const T Q[15] = { + static const T Q[15] = { BOOST_MATH_BIG_CONSTANT(T, 113, 1.0), BOOST_MATH_BIG_CONSTANT(T, 113, 1.58784732785354597996617046880946257), BOOST_MATH_BIG_CONSTANT(T, 113, 1.18550755302279446339364262338114098), @@ -1103,7 +1103,7 @@ void expint_i_113c(T& result, const T& z) static const T Y = 1.091579437255859375F; - static const T P[17] = { + static const T P[17] = { BOOST_MATH_BIG_CONSTANT(T, 113, -0.00685089599550151282724924894258520532), BOOST_MATH_BIG_CONSTANT(T, 113, -0.0443313550253580053324487059748497467), BOOST_MATH_BIG_CONSTANT(T, 113, -0.071538561252424027443296958795814874), @@ -1122,7 +1122,7 @@ void expint_i_113c(T& result, const T& z) BOOST_MATH_BIG_CONSTANT(T, 113, -0.326283053716799774936661568391296584e-13), BOOST_MATH_BIG_CONSTANT(T, 113, 0.869226483473172853557775877908693647e-15) }; - static const T Q[15] = { + static const T Q[15] = { BOOST_MATH_BIG_CONSTANT(T, 113, 1.0), BOOST_MATH_BIG_CONSTANT(T, 113, 2.23227220874479061894038229141871087), BOOST_MATH_BIG_CONSTANT(T, 113, 2.40221000361027971895657505660959863), @@ -1155,7 +1155,7 @@ void expint_i_113d(T& result, const T& z) // Max Error found at long double precision = Poly: 4.158110e-35 Cheb: 5.385532e-35 static const T Y = 1.051731109619140625F; - static const T P[14] = { + static const T P[14] = { BOOST_MATH_BIG_CONSTANT(T, 113, -0.00144552494420652573815404828020593565), BOOST_MATH_BIG_CONSTANT(T, 113, -0.0126747451594545338365684731262912741), BOOST_MATH_BIG_CONSTANT(T, 113, -0.01757394877502366717526779263438073), @@ -1171,7 +1171,7 @@ void expint_i_113d(T& result, const T& z) BOOST_MATH_BIG_CONSTANT(T, 113, -0.595500337089495614285777067722823397e-9), BOOST_MATH_BIG_CONSTANT(T, 113, -0.133141358866324100955927979606981328e-10) }; - static const T Q[14] = { + static const T Q[14] = { BOOST_MATH_BIG_CONSTANT(T, 113, 1.0), BOOST_MATH_BIG_CONSTANT(T, 113, 1.72490783907582654629537013560044682), BOOST_MATH_BIG_CONSTANT(T, 113, 1.44524329516800613088375685659759765), @@ -1206,7 +1206,7 @@ void expint_i_113e(T& result, const T& z) // Max Error found at long double precision = Poly: 1.711721e-34 Cheb: 3.100018e-34 static const T Y = 1.032726287841796875F; - static const T P[15] = { + static const T P[15] = { BOOST_MATH_BIG_CONSTANT(T, 113, -0.00141056919297307534690895009969373233), BOOST_MATH_BIG_CONSTANT(T, 113, -0.0123384175302540291339020257071411437), BOOST_MATH_BIG_CONSTANT(T, 113, -0.0298127270706864057791526083667396115), @@ -1223,7 +1223,7 @@ void expint_i_113e(T& result, const T& z) BOOST_MATH_BIG_CONSTANT(T, 113, -0.350233957364028523971768887437839573e-7), BOOST_MATH_BIG_CONSTANT(T, 113, -0.105428907085424234504608142258423505e-8) }; - static const T Q[16] = { + static const T Q[16] = { BOOST_MATH_BIG_CONSTANT(T, 113, 1.0), BOOST_MATH_BIG_CONSTANT(T, 113, 3.17261315255467581204685605414005525), BOOST_MATH_BIG_CONSTANT(T, 113, 4.85267952971640525245338392887217426), @@ -1260,7 +1260,7 @@ void expint_i_113f(T& result, const T& z) // Max Error found at long double precision = Poly: 1.288958e-35 Cheb: 2.304586e-35 static const T Y = 1.0216197967529296875F; - static const T P[12] = { + static const T P[12] = { BOOST_MATH_BIG_CONSTANT(T, 113, -0.000322999116096627043476023926572650045), BOOST_MATH_BIG_CONSTANT(T, 113, -0.00385606067447365187909164609294113346), BOOST_MATH_BIG_CONSTANT(T, 113, -0.00686514524727568176735949971985244415), @@ -1274,7 +1274,7 @@ void expint_i_113f(T& result, const T& z) BOOST_MATH_BIG_CONSTANT(T, 113, -0.434084023639508143975983454830954835e-7), BOOST_MATH_BIG_CONSTANT(T, 113, -0.107839681938752337160494412638656696e-8) }; - static const T Q[12] = { + static const T Q[12] = { BOOST_MATH_BIG_CONSTANT(T, 113, 1.0), BOOST_MATH_BIG_CONSTANT(T, 113, 2.09913805456661084097134805151524958), BOOST_MATH_BIG_CONSTANT(T, 113, 2.07041755535439919593503171320431849), @@ -1307,7 +1307,7 @@ void expint_i_113g(T& result, const T& z) // Max Error found at long double precision = Poly: 9.976345e-35 Cheb: 8.358865e-35 static const T Y = 1.015148162841796875F; - static const T P[11] = { + static const T P[11] = { BOOST_MATH_BIG_CONSTANT(T, 113, -0.000435714784725086961464589957142615216), BOOST_MATH_BIG_CONSTANT(T, 113, -0.00432114324353830636009453048419094314), BOOST_MATH_BIG_CONSTANT(T, 113, -0.0100740363285526177522819204820582424), @@ -1320,7 +1320,7 @@ void expint_i_113g(T& result, const T& z) BOOST_MATH_BIG_CONSTANT(T, 113, -0.21972450610957417963227028788460299e-5), BOOST_MATH_BIG_CONSTANT(T, 113, -0.720558173805289167524715527536874694e-7) }; - static const T Q[11] = { + static const T Q[11] = { BOOST_MATH_BIG_CONSTANT(T, 113, 1.0), BOOST_MATH_BIG_CONSTANT(T, 113, 2.95918362458402597039366979529287095), BOOST_MATH_BIG_CONSTANT(T, 113, 3.96472247520659077944638411856748924), @@ -1352,7 +1352,7 @@ void expint_i_113h(T& result, const T& z) // Max Error found at long double precision = Poly: 2.058532e-35 Cheb: 2.165465e-27 static const T Y= 1.00849151611328125F; - static const T P[9] = { + static const T P[9] = { BOOST_MATH_BIG_CONSTANT(T, 113, -0.0084915161132812500000001440233607358), BOOST_MATH_BIG_CONSTANT(T, 113, 1.84479378737716028341394223076147872), BOOST_MATH_BIG_CONSTANT(T, 113, -130.431146923726715674081563022115568), @@ -1363,7 +1363,7 @@ void expint_i_113h(T& result, const T& z) BOOST_MATH_BIG_CONSTANT(T, 113, 8570600.041606912735872059184527855), BOOST_MATH_BIG_CONSTANT(T, 113, -6758379.93672362080947905580906028645) }; - static const T Q[10] = { + static const T Q[10] = { BOOST_MATH_BIG_CONSTANT(T, 113, 1.0), BOOST_MATH_BIG_CONSTANT(T, 113, -99.4868026047611434569541483506091713), BOOST_MATH_BIG_CONSTANT(T, 113, 3879.67753690517114249705089803055473), @@ -1390,7 +1390,7 @@ T expint_i_imp(T z, const Policy& pol, const std::integral_constant& t if(z < 0) return -expint_imp(1, T(-z), pol, tag); if(z == 0) - return -policies::raise_overflow_error(function, 0, pol); + return -policies::raise_overflow_error(function, nullptr, pol); T result; @@ -1434,7 +1434,7 @@ T expint_i_imp(T z, const Policy& pol, const std::integral_constant& t static const T exp40 = static_cast(BOOST_MATH_BIG_CONSTANT(T, 113, 2.35385266837019985407899910749034804508871617254555467236651e17)); static const T Y= 1.00252532958984375F; - static const T P[8] = { + static const T P[8] = { BOOST_MATH_BIG_CONSTANT(T, 113, -0.00252532958984375000000000000000000085), BOOST_MATH_BIG_CONSTANT(T, 113, 1.16591386866059087390621952073890359), BOOST_MATH_BIG_CONSTANT(T, 113, -67.8483431314018462417456828499277579), @@ -1444,7 +1444,7 @@ T expint_i_imp(T z, const Policy& pol, const std::integral_constant& t BOOST_MATH_BIG_CONSTANT(T, 113, -225025.189335919133214440347510936787), BOOST_MATH_BIG_CONSTANT(T, 113, 175864.614717440010942804684741336853) }; - static const T Q[9] = { + static const T Q[9] = { BOOST_MATH_BIG_CONSTANT(T, 113, 1.0), BOOST_MATH_BIG_CONSTANT(T, 113, -65.6998869881600212224652719706425129), BOOST_MATH_BIG_CONSTANT(T, 113, 1642.73850032324014781607859416890077), @@ -1466,14 +1466,14 @@ T expint_i_imp(T z, const Policy& pol, const std::integral_constant& t t = z - 40; if(t > tools::log_max_value()) { - result = policies::raise_overflow_error(function, 0, pol); + result = policies::raise_overflow_error(function, nullptr, pol); } else { result *= exp(z - 40) / z; if(result > tools::max_value() / exp40) { - result = policies::raise_overflow_error(function, 0, pol); + result = policies::raise_overflow_error(function, nullptr, pol); } else { @@ -1582,9 +1582,9 @@ inline typename tools::promote_args::type typedef typename policies::evaluation::type value_type; typedef typename policies::precision::type precision_type; typedef typename policies::normalise< - Policy, - policies::promote_float, - policies::promote_double, + Policy, + policies::promote_float, + policies::promote_double, policies::discrete_quantile<>, policies::assert_undefined<> >::type forwarding_policy; typedef std::integral_constant::type typedef typename policies::evaluation::type value_type; typedef typename policies::precision::type precision_type; typedef typename policies::normalise< - Policy, - policies::promote_float, - policies::promote_double, + Policy, + policies::promote_float, + policies::promote_double, policies::discrete_quantile<>, policies::assert_undefined<> >::type forwarding_policy; typedef std::integral_constant&, const Policy& pol) if(a >= tools::log_max_value()) { if(x > 0) - return policies::raise_overflow_error("boost::math::expm1<%1%>(%1%)", 0, pol); + return policies::raise_overflow_error("boost::math::expm1<%1%>(%1%)", nullptr, pol); return -1; } return exp(x) - T(1); @@ -147,7 +147,7 @@ T expm1_imp(T x, const std::integral_constant&, const P& pol) if(a >= tools::log_max_value()) { if(x > 0) - return policies::raise_overflow_error("boost::math::expm1<%1%>(%1%)", 0, pol); + return policies::raise_overflow_error("boost::math::expm1<%1%>(%1%)", nullptr, pol); return -1; } return exp(x) - T(1); @@ -174,7 +174,7 @@ T expm1_imp(T x, const std::integral_constant&, const P& pol) if(a >= tools::log_max_value()) { if(x > 0) - return policies::raise_overflow_error("boost::math::expm1<%1%>(%1%)", 0, pol); + return policies::raise_overflow_error("boost::math::expm1<%1%>(%1%)", nullptr, pol); return -1; } return exp(x) - T(1); @@ -183,16 +183,16 @@ T expm1_imp(T x, const std::integral_constant&, const P& pol) return x; static const float Y = 0.10281276702880859375e1f; - static const T n[] = { - BOOST_MATH_BIG_CONSTANT(T, 64, -0.281276702880859375e-1), - BOOST_MATH_BIG_CONSTANT(T, 64, 0.512980290285154286358e0), + static const T n[] = { + BOOST_MATH_BIG_CONSTANT(T, 64, -0.281276702880859375e-1), + BOOST_MATH_BIG_CONSTANT(T, 64, 0.512980290285154286358e0), BOOST_MATH_BIG_CONSTANT(T, 64, -0.667758794592881019644e-1), BOOST_MATH_BIG_CONSTANT(T, 64, 0.131432469658444745835e-1), BOOST_MATH_BIG_CONSTANT(T, 64, -0.72303795326880286965e-3), BOOST_MATH_BIG_CONSTANT(T, 64, 0.447441185192951335042e-4), BOOST_MATH_BIG_CONSTANT(T, 64, -0.714539134024984593011e-6) }; - static const T d[] = { + static const T d[] = { BOOST_MATH_BIG_CONSTANT(T, 64, 1.0), BOOST_MATH_BIG_CONSTANT(T, 64, -0.461477618025562520389e0), BOOST_MATH_BIG_CONSTANT(T, 64, 0.961237488025708540713e-1), @@ -217,7 +217,7 @@ T expm1_imp(T x, const std::integral_constant&, const P& pol) if(a >= tools::log_max_value()) { if(x > 0) - return policies::raise_overflow_error("boost::math::expm1<%1%>(%1%)", 0, pol); + return policies::raise_overflow_error("boost::math::expm1<%1%>(%1%)", nullptr, pol); return -1; } return exp(x) - T(1); @@ -226,7 +226,7 @@ T expm1_imp(T x, const std::integral_constant&, const P& pol) return x; static const float Y = 0.10281276702880859375e1f; - static const T n[] = { + static const T n[] = { BOOST_MATH_BIG_CONSTANT(T, 113, -0.28127670288085937499999999999999999854e-1), BOOST_MATH_BIG_CONSTANT(T, 113, 0.51278156911210477556524452177540792214e0), BOOST_MATH_BIG_CONSTANT(T, 113, -0.63263178520747096729500254678819588223e-1), @@ -238,7 +238,7 @@ T expm1_imp(T x, const std::integral_constant&, const P& pol) BOOST_MATH_BIG_CONSTANT(T, 113, -0.15995603306536496772374181066765665596e-8), BOOST_MATH_BIG_CONSTANT(T, 113, 0.45261820069007790520447958280473183582e-10) }; - static const T d[] = { + static const T d[] = { BOOST_MATH_BIG_CONSTANT(T, 113, 1.0), BOOST_MATH_BIG_CONSTANT(T, 113, -0.45441264709074310514348137469214538853e0), BOOST_MATH_BIG_CONSTANT(T, 113, 0.96827131936192217313133611655555298106e-1), @@ -265,9 +265,9 @@ inline typename tools::promote_args::type expm1(T x, const Policy& /* pol */) typedef typename policies::evaluation::type value_type; typedef typename policies::precision::type precision_type; typedef typename policies::normalise< - Policy, - policies::promote_float, - policies::promote_double, + Policy, + policies::promote_float, + policies::promote_double, policies::discrete_quantile<>, policies::assert_undefined<> >::type forwarding_policy; @@ -279,7 +279,7 @@ inline typename tools::promote_args::type expm1(T x, const Policy& /* pol */) > tag_type; detail::expm1_initializer::force_instantiate(); - + return policies::checked_narrowing_cast(detail::expm1_imp( static_cast(x), tag_type(), forwarding_policy()), "boost::math::expm1<%1%>(%1%)"); diff --git a/include/boost/math/special_functions/fpclassify.hpp b/include/boost/math/special_functions/fpclassify.hpp index 09fcf2924c..47d2a0e795 100644 --- a/include/boost/math/special_functions/fpclassify.hpp +++ b/include/boost/math/special_functions/fpclassify.hpp @@ -128,7 +128,7 @@ inline bool is_nan_helper(T, const std::false_type&) { return false; } -#if defined(BOOST_MATH_USE_FLOAT128) +#if defined(BOOST_MATH_USE_FLOAT128) #if defined(BOOST_MATH_HAS_QUADMATH_H) inline bool is_nan_helper(__float128 f, const std::true_type&) { return ::isnanq(f); } inline bool is_nan_helper(__float128 f, const std::false_type&) { return ::isnanq(f); } @@ -279,7 +279,7 @@ inline int fpclassify BOOST_NO_MACRO_EXPAND(T t) typedef typename traits::method method; typedef typename tools::promote_args_permissive::type value_type; #ifdef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS - if(std::numeric_limits::is_specialized && detail::is_generic_tag_false(static_cast(0))) + if(std::numeric_limits::is_specialized && detail::is_generic_tag_false(static_cast(nullptr))) return detail::fpclassify_imp(static_cast(t), detail::generic_tag()); return detail::fpclassify_imp(static_cast(t), method()); #else @@ -295,7 +295,7 @@ inline int fpclassify BOOST_NO_MACRO_EXPAND(long double t) typedef traits::method method; typedef long double value_type; #ifdef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS - if(std::numeric_limits::is_specialized && detail::is_generic_tag_false(static_cast(0))) + if(std::numeric_limits::is_specialized && detail::is_generic_tag_false(static_cast(nullptr))) return detail::fpclassify_imp(static_cast(t), detail::generic_tag()); return detail::fpclassify_imp(static_cast(t), method()); #else diff --git a/include/boost/math/special_functions/gamma.hpp b/include/boost/math/special_functions/gamma.hpp index 13cd25e087..4af5dfa314 100644 --- a/include/boost/math/special_functions/gamma.hpp +++ b/include/boost/math/special_functions/gamma.hpp @@ -158,7 +158,7 @@ T gamma_imp(T z, const Policy& pol, const Lanczos& l) else if (z < tools::root_epsilon()) { if (z < 1 / tools::max_value()) - result = policies::raise_overflow_error(function, 0, pol); + result = policies::raise_overflow_error(function, nullptr, pol); result *= 1 / z - constants::euler(); } else @@ -198,7 +198,7 @@ T gamma_imp(T z, const Policy& pol, const Lanczos& l) // lgamma(z) with Lanczos support: // template -T lgamma_imp(T z, const Policy& pol, const Lanczos& l, int* sign = 0) +T lgamma_imp(T z, const Policy& pol, const Lanczos& l, int* sign = nullptr) { #ifdef BOOST_MATH_INSTRUMENT static bool b = false; @@ -452,7 +452,7 @@ T scaled_tgamma_no_lanczos(const T& z, const Policy& pol, bool islog = false) // Forward declaration of the lgamma_imp template specialization. template -T lgamma_imp(T z, const Policy& pol, const lanczos::undefined_lanczos&, int* sign = 0); +T lgamma_imp(T z, const Policy& pol, const lanczos::undefined_lanczos&, int* sign = nullptr); template T gamma_imp(T z, const Policy& pol, const lanczos::undefined_lanczos&) @@ -512,16 +512,16 @@ T gamma_imp(T z, const Policy& pol, const lanczos::undefined_lanczos&) if (!n_recur) { if (zz > tools::log_max_value()) - return policies::raise_overflow_error(function, 0, pol); + return policies::raise_overflow_error(function, nullptr, pol); if (log(zz) * zz / 2 > tools::log_max_value()) - return policies::raise_overflow_error(function, 0, pol); + return policies::raise_overflow_error(function, nullptr, pol); } T gamma_value = scaled_tgamma_no_lanczos(zz, pol); T power_term = pow(zz, zz / 2); T exp_term = exp(-zz); gamma_value *= (power_term * exp_term); if(!n_recur && (tools::max_value() / power_term < gamma_value)) - return policies::raise_overflow_error(function, 0, pol); + return policies::raise_overflow_error(function, nullptr, pol); gamma_value *= power_term; // Rescale the result using downward recursion if necessary. @@ -619,7 +619,7 @@ T lgamma_imp(T z, const Policy& pol, const lanczos::undefined_lanczos&, int* sig if((boost::math::isnan)(z)) return policies::raise_domain_error(function, "Evaluation of lgamma at %1%.", z, pol); if((boost::math::isinf)(z)) - return policies::raise_overflow_error(function, 0, pol); + return policies::raise_overflow_error(function, nullptr, pol); const bool b_neg = (z < 0); @@ -665,7 +665,7 @@ T lgamma_imp(T z, const Policy& pol, const lanczos::undefined_lanczos&, int* sig } else { - // No issue with spurious overflow in reflection formula, + // No issue with spurious overflow in reflection formula, // just fall through to regular code: T g = gamma_imp(zz, pol, lanczos::undefined_lanczos()); if (sign) @@ -709,7 +709,7 @@ T lgamma_imp(T z, const Policy& pol, const lanczos::undefined_lanczos&, int* sig - log(t); } - if(sign != static_cast(0U)) { *sign = sign_of_result; } + if(sign != static_cast(nullptr)) { *sign = sign_of_result; } return log_gamma_value; } @@ -743,7 +743,7 @@ T tgammap1m1_imp(T dz, Policy const& pol, const Lanczos& l) else { // Use expm1 on lgamma: - result = boost::math::expm1(-boost::math::log1p(dz, pol) + result = boost::math::expm1(-boost::math::log1p(dz, pol) + lgamma_small_imp(dz+2, dz + 1, dz, tag_type(), pol, l), pol); BOOST_MATH_INSTRUMENT_CODE(result); } @@ -986,7 +986,7 @@ T regularised_gamma_prefix(T a, T z, const Policy& pol, const lanczos::undefined } else { - // + // // We failed, most probably we have z << 1, try again, this time // we calculate z^a e^-z / tgamma(a+shift), combining power terms // as we go. And again recurse down to the result. @@ -1139,7 +1139,7 @@ T incomplete_tgamma_large_x(const T& a, const T& x, const Policy& pol) // Main incomplete gamma entry point, handles all four incomplete gamma's: // template -T gamma_incomplete_imp(T a, T x, bool normalised, bool invert, +T gamma_incomplete_imp(T a, T x, bool normalised, bool invert, const Policy& pol, T* p_derivative) { static const char* function = "boost::math::gamma_p<%1%>(%1%, %1%)"; @@ -1214,11 +1214,11 @@ T gamma_incomplete_imp(T a, T x, bool normalised, bool invert, } } if(result > tools::log_max_value()) - return policies::raise_overflow_error(function, 0, pol); + return policies::raise_overflow_error(function, nullptr, pol); return exp(result); } - BOOST_MATH_ASSERT((p_derivative == 0) || normalised); + BOOST_MATH_ASSERT((p_derivative == nullptr) || normalised); bool is_int, is_half_int; bool is_small_a = (a < 30) && (a <= x + 1) && (x < tools::log_max_value()); @@ -1234,7 +1234,7 @@ T gamma_incomplete_imp(T a, T x, bool normalised, bool invert, } int eval_method; - + if(is_int && (x > 0.6)) { // calculate Q via finite sum: @@ -1311,7 +1311,7 @@ T gamma_incomplete_imp(T a, T x, bool normalised, bool invert, } else if(policies::digits() <= 64) { - // Note in this zone we can't use Temme's expansion for + // Note in this zone we can't use Temme's expansion for // types longer than an 80-bit real: // it would require too many terms in the polynomials. if(sigma < 0.4) @@ -1376,7 +1376,7 @@ T gamma_incomplete_imp(T a, T x, bool normalised, bool invert, // a few iterations if we set an initial value for the // series sum based on what we'll end up subtracting it from // at the end. - // Have to be careful though that this optimization doesn't + // Have to be careful though that this optimization doesn't // lead to spurious numeric overflow. Note that the // scary/expensive overflow checks below are more often // than not bypassed in practice for "sensible" input @@ -1450,7 +1450,7 @@ T gamma_incomplete_imp(T a, T x, bool normalised, bool invert, precision_type::value <= 113 ? 113 : 0 > tag_type; - result = igamma_temme_large(a, x, pol, static_cast(0)); + result = igamma_temme_large(a, x, pol, static_cast(nullptr)); if(x >= a) invert = !invert; if(p_derivative) @@ -1466,7 +1466,7 @@ T gamma_incomplete_imp(T a, T x, bool normalised, bool invert, else { #ifndef BOOST_NO_EXCEPTIONS - try + try { #endif result = pow(x, a) / boost::math::tgamma(a + 1, pol); @@ -1602,7 +1602,7 @@ T tgamma_delta_ratio_imp_lanczos(T z, T delta, const Policy& pol, const lanczos: long numerator_shift = 0; long denominator_shift = 0; const int min_z = minimum_argument_for_bernoulli_recursion(); - + if (min_z > z) numerator_shift = 1 + ltrunc(min_z - z); if (min_z > z + delta) @@ -1787,7 +1787,7 @@ T gamma_p_derivative_imp(T a, T x, const Policy& pol) if(x == 0) { return (a > 1) ? 0 : - (a == 1) ? 1 : policies::raise_overflow_error("boost::math::gamma_p_derivative<%1%>(%1%, %1%)", 0, pol); + (a == 1) ? 1 : policies::raise_overflow_error("boost::math::gamma_p_derivative<%1%>(%1%, %1%)", nullptr, pol); } // // Normal case: @@ -1797,7 +1797,7 @@ T gamma_p_derivative_imp(T a, T x, const Policy& pol) if((x < 1) && (tools::max_value() * x < f1)) { // overflow: - return policies::raise_overflow_error("boost::math::gamma_p_derivative<%1%>(%1%, %1%)", 0, pol); + return policies::raise_overflow_error("boost::math::gamma_p_derivative<%1%>(%1%, %1%)", nullptr, pol); } if(f1 == 0) { @@ -1812,7 +1812,7 @@ T gamma_p_derivative_imp(T a, T x, const Policy& pol) } template -inline typename tools::promote_args::type +inline typename tools::promote_args::type tgamma(T z, const Policy& /* pol */, const std::true_type) { BOOST_FPU_EXCEPTION_GUARD @@ -1820,9 +1820,9 @@ inline typename tools::promote_args::type typedef typename policies::evaluation::type value_type; typedef typename lanczos::lanczos::type evaluation_type; typedef typename policies::normalise< - Policy, - policies::promote_float, - policies::promote_double, + Policy, + policies::promote_float, + policies::promote_double, policies::discrete_quantile<>, policies::assert_undefined<> >::type forwarding_policy; return policies::checked_narrowing_cast(detail::gamma_imp(static_cast(z), forwarding_policy(), evaluation_type()), "boost::math::tgamma<%1%>(%1%)"); @@ -1924,9 +1924,9 @@ inline typename tools::promote_args::type typedef typename policies::evaluation::type value_type; // typedef typename lanczos::lanczos::type evaluation_type; typedef typename policies::normalise< - Policy, - policies::promote_float, - policies::promote_double, + Policy, + policies::promote_float, + policies::promote_double, policies::discrete_quantile<>, policies::assert_undefined<> >::type forwarding_policy; @@ -1935,7 +1935,7 @@ inline typename tools::promote_args::type return policies::checked_narrowing_cast( detail::gamma_incomplete_imp(static_cast(a), static_cast(z), false, true, - forwarding_policy(), static_cast(0)), "boost::math::tgamma<%1%>(%1%, %1%)"); + forwarding_policy(), static_cast(nullptr)), "boost::math::tgamma<%1%>(%1%, %1%)"); } template @@ -1949,14 +1949,14 @@ inline typename tools::promote_args::type } // namespace detail template -inline typename tools::promote_args::type +inline typename tools::promote_args::type tgamma(T z) { return tgamma(z, policies::policy<>()); } template -inline typename tools::promote_args::type +inline typename tools::promote_args::type lgamma(T z, int* sign, const Policy&) { BOOST_FPU_EXCEPTION_GUARD @@ -1964,9 +1964,9 @@ inline typename tools::promote_args::type typedef typename policies::evaluation::type value_type; typedef typename lanczos::lanczos::type evaluation_type; typedef typename policies::normalise< - Policy, - policies::promote_float, - policies::promote_double, + Policy, + policies::promote_float, + policies::promote_double, policies::discrete_quantile<>, policies::assert_undefined<> >::type forwarding_policy; @@ -1976,28 +1976,28 @@ inline typename tools::promote_args::type } template -inline typename tools::promote_args::type +inline typename tools::promote_args::type lgamma(T z, int* sign) { return lgamma(z, sign, policies::policy<>()); } template -inline typename tools::promote_args::type +inline typename tools::promote_args::type lgamma(T x, const Policy& pol) { - return ::boost::math::lgamma(x, 0, pol); + return ::boost::math::lgamma(x, nullptr, pol); } template -inline typename tools::promote_args::type +inline typename tools::promote_args::type lgamma(T x) { - return ::boost::math::lgamma(x, 0, policies::policy<>()); + return ::boost::math::lgamma(x, nullptr, policies::policy<>()); } template -inline typename tools::promote_args::type +inline typename tools::promote_args::type tgamma1pm1(T z, const Policy& /* pol */) { BOOST_FPU_EXCEPTION_GUARD @@ -2005,9 +2005,9 @@ inline typename tools::promote_args::type typedef typename policies::evaluation::type value_type; typedef typename lanczos::lanczos::type evaluation_type; typedef typename policies::normalise< - Policy, - policies::promote_float, - policies::promote_double, + Policy, + policies::promote_float, + policies::promote_double, policies::discrete_quantile<>, policies::assert_undefined<> >::type forwarding_policy; @@ -2015,7 +2015,7 @@ inline typename tools::promote_args::type } template -inline typename tools::promote_args::type +inline typename tools::promote_args::type tgamma1pm1(T z) { return tgamma1pm1(z, policies::policy<>()); @@ -2029,7 +2029,7 @@ inline typename tools::promote_args::type tgamma(T1 a, T2 z) { // - // Type T2 could be a policy object, or a value, select the + // Type T2 could be a policy object, or a value, select the // right overload based on T2: // typedef typename policies::is_policy::type maybe_policy; @@ -2053,9 +2053,9 @@ inline typename tools::promote_args::type typedef typename policies::evaluation::type value_type; // typedef typename lanczos::lanczos::type evaluation_type; typedef typename policies::normalise< - Policy, - policies::promote_float, - policies::promote_double, + Policy, + policies::promote_float, + policies::promote_double, policies::discrete_quantile<>, policies::assert_undefined<> >::type forwarding_policy; @@ -2064,7 +2064,7 @@ inline typename tools::promote_args::type return policies::checked_narrowing_cast( detail::gamma_incomplete_imp(static_cast(a), static_cast(z), false, false, - forwarding_policy(), static_cast(0)), "tgamma_lower<%1%>(%1%, %1%)"); + forwarding_policy(), static_cast(nullptr)), "tgamma_lower<%1%>(%1%, %1%)"); } template inline typename tools::promote_args::type @@ -2084,9 +2084,9 @@ inline typename tools::promote_args::type typedef typename policies::evaluation::type value_type; // typedef typename lanczos::lanczos::type evaluation_type; typedef typename policies::normalise< - Policy, - policies::promote_float, - policies::promote_double, + Policy, + policies::promote_float, + policies::promote_double, policies::discrete_quantile<>, policies::assert_undefined<> >::type forwarding_policy; @@ -2095,7 +2095,7 @@ inline typename tools::promote_args::type return policies::checked_narrowing_cast( detail::gamma_incomplete_imp(static_cast(a), static_cast(z), true, true, - forwarding_policy(), static_cast(0)), "gamma_q<%1%>(%1%, %1%)"); + forwarding_policy(), static_cast(nullptr)), "gamma_q<%1%>(%1%, %1%)"); } template inline typename tools::promote_args::type @@ -2115,9 +2115,9 @@ inline typename tools::promote_args::type typedef typename policies::evaluation::type value_type; // typedef typename lanczos::lanczos::type evaluation_type; typedef typename policies::normalise< - Policy, - policies::promote_float, - policies::promote_double, + Policy, + policies::promote_float, + policies::promote_double, policies::discrete_quantile<>, policies::assert_undefined<> >::type forwarding_policy; @@ -2126,7 +2126,7 @@ inline typename tools::promote_args::type return policies::checked_narrowing_cast( detail::gamma_incomplete_imp(static_cast(a), static_cast(z), true, false, - forwarding_policy(), static_cast(0)), "gamma_p<%1%>(%1%, %1%)"); + forwarding_policy(), static_cast(nullptr)), "gamma_p<%1%>(%1%, %1%)"); } template inline typename tools::promote_args::type @@ -2137,67 +2137,67 @@ inline typename tools::promote_args::type // ratios of gamma functions: template -inline typename tools::promote_args::type +inline typename tools::promote_args::type tgamma_delta_ratio(T1 z, T2 delta, const Policy& /* pol */) { BOOST_FPU_EXCEPTION_GUARD typedef typename tools::promote_args::type result_type; typedef typename policies::evaluation::type value_type; typedef typename policies::normalise< - Policy, - policies::promote_float, - policies::promote_double, + Policy, + policies::promote_float, + policies::promote_double, policies::discrete_quantile<>, policies::assert_undefined<> >::type forwarding_policy; return policies::checked_narrowing_cast(detail::tgamma_delta_ratio_imp(static_cast(z), static_cast(delta), forwarding_policy()), "boost::math::tgamma_delta_ratio<%1%>(%1%, %1%)"); } template -inline typename tools::promote_args::type +inline typename tools::promote_args::type tgamma_delta_ratio(T1 z, T2 delta) { return tgamma_delta_ratio(z, delta, policies::policy<>()); } template -inline typename tools::promote_args::type +inline typename tools::promote_args::type tgamma_ratio(T1 a, T2 b, const Policy&) { typedef typename tools::promote_args::type result_type; typedef typename policies::evaluation::type value_type; typedef typename policies::normalise< - Policy, - policies::promote_float, - policies::promote_double, + Policy, + policies::promote_float, + policies::promote_double, policies::discrete_quantile<>, policies::assert_undefined<> >::type forwarding_policy; return policies::checked_narrowing_cast(detail::tgamma_ratio_imp(static_cast(a), static_cast(b), forwarding_policy()), "boost::math::tgamma_delta_ratio<%1%>(%1%, %1%)"); } template -inline typename tools::promote_args::type +inline typename tools::promote_args::type tgamma_ratio(T1 a, T2 b) { return tgamma_ratio(a, b, policies::policy<>()); } template -inline typename tools::promote_args::type +inline typename tools::promote_args::type gamma_p_derivative(T1 a, T2 x, const Policy&) { BOOST_FPU_EXCEPTION_GUARD typedef typename tools::promote_args::type result_type; typedef typename policies::evaluation::type value_type; typedef typename policies::normalise< - Policy, - policies::promote_float, - policies::promote_double, + Policy, + policies::promote_float, + policies::promote_double, policies::discrete_quantile<>, policies::assert_undefined<> >::type forwarding_policy; return policies::checked_narrowing_cast(detail::gamma_p_derivative_imp(static_cast(a), static_cast(x), forwarding_policy()), "boost::math::gamma_p_derivative<%1%>(%1%, %1%)"); } template -inline typename tools::promote_args::type +inline typename tools::promote_args::type gamma_p_derivative(T1 a, T2 x) { return gamma_p_derivative(a, x, policies::policy<>()); diff --git a/include/boost/math/special_functions/hankel.hpp b/include/boost/math/special_functions/hankel.hpp index 4266ef808c..51b8390d99 100644 --- a/include/boost/math/special_functions/hankel.hpp +++ b/include/boost/math/special_functions/hankel.hpp @@ -51,12 +51,12 @@ std::complex hankel_imp(T v, T x, const bessel_no_int_tag&, const Policy& pol if(v == 0) { // J is 1, Y is -INF - return std::complex(1, sign * -policies::raise_overflow_error(function, 0, pol)); + return std::complex(1, sign * -policies::raise_overflow_error(function, nullptr, pol)); } else { // At least one of J and Y is complex infinity: - return std::complex(policies::raise_overflow_error(function, 0, pol), sign * policies::raise_overflow_error(function, 0, pol)); + return std::complex(policies::raise_overflow_error(function, nullptr, pol), sign * policies::raise_overflow_error(function, nullptr, pol)); } } @@ -137,9 +137,9 @@ inline std::complex::result_type> typedef typename detail::bessel_traits::result_type result_type; typedef typename policies::evaluation::type value_type; typedef typename policies::normalise< - Policy, - policies::promote_float, - policies::promote_double, + Policy, + policies::promote_float, + policies::promote_double, policies::discrete_quantile<>, policies::assert_undefined<> >::type forwarding_policy; @@ -159,9 +159,9 @@ inline std::complex::result_type> typedef typename detail::bessel_traits::result_type result_type; typedef typename policies::evaluation::type value_type; typedef typename policies::normalise< - Policy, - policies::promote_float, - policies::promote_double, + Policy, + policies::promote_float, + policies::promote_double, policies::discrete_quantile<>, policies::assert_undefined<> >::type forwarding_policy; diff --git a/include/boost/math/special_functions/hypergeometric_2F0.hpp b/include/boost/math/special_functions/hypergeometric_2F0.hpp index e42310330f..a8ebe2162e 100644 --- a/include/boost/math/special_functions/hypergeometric_2F0.hpp +++ b/include/boost/math/special_functions/hypergeometric_2F0.hpp @@ -73,7 +73,7 @@ namespace boost { namespace math { namespace detail { bool is_a2_integer = (a2 == floor(a2)); if (!asymptotic && !is_a1_integer && !is_a2_integer) - return boost::math::policies::raise_overflow_error(function, 0, pol); + return boost::math::policies::raise_overflow_error(function, nullptr, pol); if (!is_a1_integer || (a1 > 0)) { swap(a1, a2); @@ -83,7 +83,7 @@ namespace boost { namespace math { namespace detail { // At this point a1 must be a negative integer: // if(!asymptotic && (!is_a1_integer || (a1 > 0))) - return boost::math::policies::raise_overflow_error(function, 0, pol); + return boost::math::policies::raise_overflow_error(function, nullptr, pol); // // Special cases first: // diff --git a/include/boost/math/special_functions/hypot.hpp b/include/boost/math/special_functions/hypot.hpp index bfa797de80..c56c751102 100644 --- a/include/boost/math/special_functions/hypot.hpp +++ b/include/boost/math/special_functions/hypot.hpp @@ -31,14 +31,14 @@ T hypot_imp(T x, T y, const Policy& pol) y = fabs(y); #ifdef _MSC_VER -#pragma warning(push) +#pragma warning(push) #pragma warning(disable: 4127) #endif // special case, see C99 Annex F: if(std::numeric_limits::has_infinity && ((x == std::numeric_limits::infinity()) || (y == std::numeric_limits::infinity()))) - return policies::raise_overflow_error("boost::math::hypot<%1%>(%1%,%1%)", 0, pol); + return policies::raise_overflow_error("boost::math::hypot<%1%>(%1%,%1%)", nullptr, pol); #ifdef _MSC_VER #pragma warning(pop) #endif @@ -56,7 +56,7 @@ T hypot_imp(T x, T y, const Policy& pol) } template -inline typename tools::promote_args::type +inline typename tools::promote_args::type hypot(T1 x, T2 y) { typedef typename tools::promote_args::type result_type; @@ -65,7 +65,7 @@ inline typename tools::promote_args::type } template -inline typename tools::promote_args::type +inline typename tools::promote_args::type hypot(T1 x, T2 y, const Policy& pol) { typedef typename tools::promote_args::type result_type; diff --git a/include/boost/math/special_functions/jacobi_elliptic.hpp b/include/boost/math/special_functions/jacobi_elliptic.hpp index 156a66cd15..88d8b9dac2 100644 --- a/include/boost/math/special_functions/jacobi_elliptic.hpp +++ b/include/boost/math/special_functions/jacobi_elliptic.hpp @@ -123,9 +123,9 @@ inline typename tools::promote_args::type jacobi_elliptic(T k, U theta, typedef typename tools::promote_args::type result_type; typedef typename policies::evaluation::type value_type; typedef typename policies::normalise< - Policy, - policies::promote_float, - policies::promote_double, + Policy, + policies::promote_float, + policies::promote_double, policies::discrete_quantile<>, policies::assert_undefined<> >::type forwarding_policy; @@ -150,7 +150,7 @@ template inline typename tools::promote_args::type jacobi_sn(U k, T theta, const Policy& pol) { typedef typename tools::promote_args::type result_type; - return jacobi_elliptic(static_cast(k), static_cast(theta), static_cast(0), static_cast(0), pol); + return jacobi_elliptic(static_cast(k), static_cast(theta), static_cast(nullptr), static_cast(nullptr), pol); } template @@ -164,7 +164,7 @@ inline typename tools::promote_args::type jacobi_cn(T k, U theta, const Po { typedef typename tools::promote_args::type result_type; result_type cn; - jacobi_elliptic(static_cast(k), static_cast(theta), &cn, static_cast(0), pol); + jacobi_elliptic(static_cast(k), static_cast(theta), &cn, static_cast(nullptr), pol); return cn; } @@ -179,7 +179,7 @@ inline typename tools::promote_args::type jacobi_dn(T k, U theta, const Po { typedef typename tools::promote_args::type result_type; result_type dn; - jacobi_elliptic(static_cast(k), static_cast(theta), static_cast(0), &dn, pol); + jacobi_elliptic(static_cast(k), static_cast(theta), static_cast(nullptr), &dn, pol); return dn; } @@ -223,7 +223,7 @@ template inline typename tools::promote_args::type jacobi_ns(T k, U theta, const Policy& pol) { typedef typename tools::promote_args::type result_type; - return 1 / jacobi_elliptic(static_cast(k), static_cast(theta), static_cast(0), static_cast(0), pol); + return 1 / jacobi_elliptic(static_cast(k), static_cast(theta), static_cast(nullptr), static_cast(nullptr), pol); } template @@ -237,7 +237,7 @@ inline typename tools::promote_args::type jacobi_sd(T k, U theta, const Po { typedef typename tools::promote_args::type result_type; result_type sn, dn; - sn = jacobi_elliptic(static_cast(k), static_cast(theta), static_cast(0), &dn, pol); + sn = jacobi_elliptic(static_cast(k), static_cast(theta), static_cast(nullptr), &dn, pol); return sn / dn; } @@ -252,7 +252,7 @@ inline typename tools::promote_args::type jacobi_ds(T k, U theta, const Po { typedef typename tools::promote_args::type result_type; result_type sn, dn; - sn = jacobi_elliptic(static_cast(k), static_cast(theta), static_cast(0), &dn, pol); + sn = jacobi_elliptic(static_cast(k), static_cast(theta), static_cast(nullptr), &dn, pol); return dn / sn; } @@ -291,7 +291,7 @@ inline typename tools::promote_args::type jacobi_sc(T k, U theta, const Po { typedef typename tools::promote_args::type result_type; result_type sn, cn; - sn = jacobi_elliptic(static_cast(k), static_cast(theta), &cn, static_cast(0), pol); + sn = jacobi_elliptic(static_cast(k), static_cast(theta), &cn, static_cast(nullptr), pol); return sn / cn; } @@ -306,7 +306,7 @@ inline typename tools::promote_args::type jacobi_cs(T k, U theta, const Po { typedef typename tools::promote_args::type result_type; result_type sn, cn; - sn = jacobi_elliptic(static_cast(k), static_cast(theta), &cn, static_cast(0), pol); + sn = jacobi_elliptic(static_cast(k), static_cast(theta), &cn, static_cast(nullptr), pol); return cn / sn; } diff --git a/include/boost/math/special_functions/lambert_w.hpp b/include/boost/math/special_functions/lambert_w.hpp index 3537b70f9d..3ba49263dc 100644 --- a/include/boost/math/special_functions/lambert_w.hpp +++ b/include/boost/math/special_functions/lambert_w.hpp @@ -728,7 +728,7 @@ T lambert_w0_small_z(const T z, const Policy&, std::integral_constant co // This could be used for 128-bit quad (which requires a suffix Q for full precision). // But experiments with GCC 7.2.0 show that while this gives full 128-bit precision // when the -f-ext-numeric-literals option is in force and the libquadmath library available, -// over the range -0.049 to +0.049, +// over the range -0.049 to +0.049, // it is slightly slower than getting a double approximation followed by a single Halley step. #ifdef BOOST_HAS_FLOAT128 @@ -1685,7 +1685,7 @@ inline T lambert_w0_imp(T z, const Policy& pol, const std::integral_constant(function, 0, pol); + return policies::raise_overflow_error(function, nullptr, pol); // Or might return infinity if available else max_value, // but other Boost.Math special functions raise overflow. } @@ -1974,7 +1974,7 @@ T lambert_wm1_imp(const T z, const Policy& pol) } } bisect: - --n; + --n; // g[n] now holds lambert W of floor integer n and g[n+1] the ceil part; // these are used as initial values for bisection. #ifdef BOOST_MATH_INSTRUMENT_LAMBERT_WM1_LOOKUP @@ -2064,7 +2064,7 @@ T lambert_wm1_imp(const T z, const Policy& pol) : 2 // 64-bit (probably double) precision. >; - return lambert_w_detail::lambert_w0_imp(result_type(z), pol, tag_type()); // + return lambert_w_detail::lambert_w0_imp(result_type(z), pol, tag_type()); // } // lambert_w0(T z, const Policy& pol) //! Lambert W0 using default policy. @@ -2149,7 +2149,7 @@ T lambert_wm1_imp(const T z, const Policy& pol) { return lambert_w0_prime(z, policies::policy<>()); } - + template inline typename tools::promote_args::type lambert_wm1_prime(T z, const Policy& pol) diff --git a/include/boost/math/special_functions/log1p.hpp b/include/boost/math/special_functions/log1p.hpp index 2e7ed236cd..49588ddc50 100644 --- a/include/boost/math/special_functions/log1p.hpp +++ b/include/boost/math/special_functions/log1p.hpp @@ -72,10 +72,10 @@ namespace detail // Algorithm log1p is part of C99, but is not yet provided by many compilers. // // This version uses a Taylor series expansion for 0.5 > x > epsilon, which may -// require up to std::numeric_limits::digits+1 terms to be calculated. +// require up to std::numeric_limits::digits+1 terms to be calculated. // It would be much more efficient to use the equivalence: // log(1+x) == (log(1+x) * x) / ((1-x) - 1) -// Unfortunately many optimizing compilers make such a mess of this, that +// Unfortunately many optimizing compilers make such a mess of this, that // it performs no better than log(1+x): which is to say not very well at all. // template @@ -91,12 +91,12 @@ T log1p_imp(T const & x, const Policy& pol, const std::integral_constant function, "log1p(x) requires x > -1, but got x = %1%.", x, pol); if(x == -1) return -policies::raise_overflow_error( - function, 0, pol); + function, nullptr, pol); result_type a = abs(result_type(x)); if(a > result_type(0.5f)) return log(1 + result_type(x)); - // Note that without numeric_limits specialisation support, + // Note that without numeric_limits specialisation support, // epsilon just returns zero, and our "optimisation" will always fail: if(a < tools::epsilon()) return x; @@ -121,12 +121,12 @@ T log1p_imp(T const& x, const Policy& pol, const std::integral_constant function, "log1p(x) requires x > -1, but got x = %1%.", x, pol); if(x == -1) return -policies::raise_overflow_error( - function, 0, pol); + function, nullptr, pol); T a = fabs(x); if(a > 0.5f) return log(1 + x); - // Note that without numeric_limits specialisation support, + // Note that without numeric_limits specialisation support, // epsilon just returns zero, and our "optimisation" will always fail: if(a < tools::epsilon()) return x; @@ -135,7 +135,7 @@ T log1p_imp(T const& x, const Policy& pol, const std::integral_constant // Expected Error Term: 1.843e-017 // Maximum Relative Change in Control Points: 8.138e-004 // Max Error found at double precision = 3.250766e-016 - static const T P[] = { + static const T P[] = { 0.15141069795941984e-16L, 0.35495104378055055e-15L, 0.33333333333332835L, @@ -145,7 +145,7 @@ T log1p_imp(T const& x, const Policy& pol, const std::integral_constant 0.13703234928513215L, 0.011294864812099712L }; - static const T Q[] = { + static const T Q[] = { 1L, 3.7274719063011499L, 5.5387948649720334L, @@ -174,12 +174,12 @@ T log1p_imp(T const& x, const Policy& pol, const std::integral_constant function, "log1p(x) requires x > -1, but got x = %1%.", x, pol); if(x == -1) return -policies::raise_overflow_error( - function, 0, pol); + function, nullptr, pol); T a = fabs(x); if(a > 0.5f) return log(1 + x); - // Note that without numeric_limits specialisation support, + // Note that without numeric_limits specialisation support, // epsilon just returns zero, and our "optimisation" will always fail: if(a < tools::epsilon()) return x; @@ -188,7 +188,7 @@ T log1p_imp(T const& x, const Policy& pol, const std::integral_constant // Expected Error Term: 8.088e-20 // Maximum Relative Change in Control Points: 9.648e-05 // Max Error found at long double precision = 2.242324e-19 - static const T P[] = { + static const T P[] = { BOOST_MATH_BIG_CONSTANT(T, 64, -0.807533446680736736712e-19), BOOST_MATH_BIG_CONSTANT(T, 64, -0.490881544804798926426e-18), BOOST_MATH_BIG_CONSTANT(T, 64, 0.333333333333333373941), @@ -199,7 +199,7 @@ T log1p_imp(T const& x, const Policy& pol, const std::integral_constant BOOST_MATH_BIG_CONSTANT(T, 64, 0.0706537026422828914622), BOOST_MATH_BIG_CONSTANT(T, 64, 0.00441709903782239229447) }; - static const T Q[] = { + static const T Q[] = { BOOST_MATH_BIG_CONSTANT(T, 64, 1.0), BOOST_MATH_BIG_CONSTANT(T, 64, 4.26423872346263928361), BOOST_MATH_BIG_CONSTANT(T, 64, 7.48189472704477708962), @@ -229,12 +229,12 @@ T log1p_imp(T const& x, const Policy& pol, const std::integral_constant function, "log1p(x) requires x > -1, but got x = %1%.", x, pol); if(x == -1) return -policies::raise_overflow_error( - function, 0, pol); + function, nullptr, pol); T a = fabs(x); if(a > 0.5f) return log(1 + x); - // Note that without numeric_limits specialisation support, + // Note that without numeric_limits specialisation support, // epsilon just returns zero, and our "optimisation" will always fail: if(a < tools::epsilon()) return x; @@ -244,13 +244,13 @@ T log1p_imp(T const& x, const Policy& pol, const std::integral_constant // Maximum Relative Change in Control Points: 2.509e-04 // Max Error found at double precision = 6.910422e-08 // Max Error found at float precision = 8.357242e-08 - static const T P[] = { + static const T P[] = { -0.671192866803148236519e-7L, 0.119670999140731844725e-6L, 0.333339469182083148598L, 0.237827183019664122066L }; - static const T Q[] = { + static const T Q[] = { 1L, 1.46348272586988539733L, 0.497859871350117338894L, @@ -295,14 +295,14 @@ const typename log1p_initializer::init log1p_initializer inline typename tools::promote_args::type log1p(T x, const Policy&) -{ +{ typedef typename tools::promote_args::type result_type; typedef typename policies::evaluation::type value_type; typedef typename policies::precision::type precision_type; typedef typename policies::normalise< - Policy, - policies::promote_float, - policies::promote_double, + Policy, + policies::promote_float, + policies::promote_double, policies::discrete_quantile<>, policies::assert_undefined<> >::type forwarding_policy; @@ -329,51 +329,51 @@ inline typename tools::promote_args::type log1p(T x, const Policy&) # ifdef BOOST_MATH_USE_C99 template inline float log1p(float x, const Policy& pol) -{ +{ if(x < -1) return policies::raise_domain_error( "log1p<%1%>(%1%)", "log1p(x) requires x > -1, but got x = %1%.", x, pol); if(x == -1) return -policies::raise_overflow_error( - "log1p<%1%>(%1%)", 0, pol); - return ::log1pf(x); + "log1p<%1%>(%1%)", nullptr, pol); + return ::log1pf(x); } #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS template inline long double log1p(long double x, const Policy& pol) -{ +{ if(x < -1) return policies::raise_domain_error( "log1p<%1%>(%1%)", "log1p(x) requires x > -1, but got x = %1%.", x, pol); if(x == -1) return -policies::raise_overflow_error( - "log1p<%1%>(%1%)", 0, pol); - return ::log1pl(x); + "log1p<%1%>(%1%)", nullptr, pol); + return ::log1pl(x); } #endif #else template inline float log1p(float x, const Policy& pol) -{ +{ if(x < -1) return policies::raise_domain_error( "log1p<%1%>(%1%)", "log1p(x) requires x > -1, but got x = %1%.", x, pol); if(x == -1) return -policies::raise_overflow_error( - "log1p<%1%>(%1%)", 0, pol); - return ::log1p(x); + "log1p<%1%>(%1%)", nullptr, pol); + return ::log1p(x); } #endif template inline double log1p(double x, const Policy& pol) -{ +{ if(x < -1) return policies::raise_domain_error( "log1p<%1%>(%1%)", "log1p(x) requires x > -1, but got x = %1%.", x, pol); if(x == -1) return -policies::raise_overflow_error( - "log1p<%1%>(%1%)", 0, pol); - return ::log1p(x); + "log1p<%1%>(%1%)", nullptr, pol); + return ::log1p(x); } #elif defined(_MSC_VER) && (BOOST_MSVC >= 1400) // @@ -389,10 +389,10 @@ inline double log1p(double x, const Policy& pol) "log1p<%1%>(%1%)", "log1p(x) requires x > -1, but got x = %1%.", x, pol); if(x == -1) return -policies::raise_overflow_error( - "log1p<%1%>(%1%)", 0, pol); + "log1p<%1%>(%1%)", nullptr, pol); double u = 1+x; - if(u == 1.0) - return x; + if(u == 1.0) + return x; else return ::log(u)*(x/(u-1.0)); } @@ -414,10 +414,10 @@ inline long double log1p(long double x, const Policy& pol) "log1p<%1%>(%1%)", "log1p(x) requires x > -1, but got x = %1%.", x, pol); if(x == -1) return -policies::raise_overflow_error( - "log1p<%1%>(%1%)", 0, pol); + "log1p<%1%>(%1%)", nullptr, pol); long double u = 1+x; - if(u == 1.0) - return x; + if(u == 1.0) + return x; else return ::logl(u)*(x/(u-1.0)); } @@ -433,7 +433,7 @@ inline typename tools::promote_args::type log1p(T x) // Compute log(1+x)-x: // template -inline typename tools::promote_args::type +inline typename tools::promote_args::type log1pmx(T x, const Policy& pol) { typedef typename tools::promote_args::type result_type; @@ -445,12 +445,12 @@ inline typename tools::promote_args::type function, "log1pmx(x) requires x > -1, but got x = %1%.", x, pol); if(x == -1) return -policies::raise_overflow_error( - function, 0, pol); + function, nullptr, pol); result_type a = abs(result_type(x)); if(a > result_type(0.95f)) return log(1 + result_type(x)) - result_type(x); - // Note that without numeric_limits specialisation support, + // Note that without numeric_limits specialisation support, // epsilon just returns zero, and our "optimisation" will always fail: if(a < tools::epsilon()) return -x * x / 2; diff --git a/include/boost/math/special_functions/next.hpp b/include/boost/math/special_functions/next.hpp index 238766cfc9..07c55e8d4a 100644 --- a/include/boost/math/special_functions/next.hpp +++ b/include/boost/math/special_functions/next.hpp @@ -61,8 +61,8 @@ template struct has_hidden_guard_digits_10 : public std::integral_constant::digits10 != std::numeric_limits::max_digits10)> {}; template -struct has_hidden_guard_digits - : public has_hidden_guard_digits_10::is_specialized && (std::numeric_limits::radix == 10) > {}; @@ -70,7 +70,7 @@ struct has_hidden_guard_digits template inline const T& normalize_value(const T& val, const std::false_type&) { return val; } template -inline T normalize_value(const T& val, const std::true_type&) +inline T normalize_value(const T& val, const std::true_type&) { static_assert(std::numeric_limits::is_specialized, "Type T must be specialized."); static_assert(std::numeric_limits::radix != 2, "Type T must be specialized."); @@ -78,7 +78,7 @@ inline T normalize_value(const T& val, const std::true_type&) std::intmax_t shift = (std::intmax_t)std::numeric_limits::digits - (std::intmax_t)ilogb(val) - 1; T result = scalbn(val, shift); result = round(result); - return scalbn(result, -shift); + return scalbn(result, -shift); } template @@ -186,7 +186,7 @@ template T float_next_imp(const T& val, const std::true_type&, const Policy& pol) { typedef typename exponent_type::type exponent_type; - + BOOST_MATH_STD_USING exponent_type expon; static const char* function = "float_next<%1%>(%1%)"; @@ -203,7 +203,7 @@ T float_next_imp(const T& val, const std::true_type&, const Policy& pol) } if(val >= tools::max_value()) - return policies::raise_overflow_error(function, 0, pol); + return policies::raise_overflow_error(function, nullptr, pol); if(val == 0) return detail::get_smallest_value(); @@ -252,7 +252,7 @@ T float_next_imp(const T& val, const std::false_type&, const Policy& pol) } if(val >= tools::max_value()) - return policies::raise_overflow_error(function, 0, pol); + return policies::raise_overflow_error(function, nullptr, pol); if(val == 0) return detail::get_smallest_value(); @@ -302,7 +302,7 @@ inline double float_next(const double& val, const Policy& pol) "Argument must be finite, but got %1%", val, pol); if(val >= tools::max_value()) - return policies::raise_overflow_error(function, 0, pol); + return policies::raise_overflow_error(function, nullptr, pol); return ::_nextafter(val, tools::max_value()); } @@ -337,7 +337,7 @@ T float_prior_imp(const T& val, const std::true_type&, const Policy& pol) } if(val <= -tools::max_value()) - return -policies::raise_overflow_error(function, 0, pol); + return -policies::raise_overflow_error(function, nullptr, pol); if(val == 0) return -detail::get_smallest_value(); @@ -387,7 +387,7 @@ T float_prior_imp(const T& val, const std::false_type&, const Policy& pol) } if(val <= -tools::max_value()) - return -policies::raise_overflow_error(function, 0, pol); + return -policies::raise_overflow_error(function, nullptr, pol); if(val == 0) return -detail::get_smallest_value(); @@ -438,7 +438,7 @@ inline double float_prior(const double& val, const Policy& pol) "Argument must be finite, but got %1%", val, pol); if(val <= -tools::max_value()) - return -policies::raise_overflow_error(function, 0, pol); + return -policies::raise_overflow_error(function, nullptr, pol); return ::_nextafter(val, -tools::max_value()); } @@ -684,8 +684,8 @@ inline typename tools::promote_args::type float_distance(const T& a, const // We allow ONE of a and b to be an integer type, otherwise both must be the SAME type. // static_assert( - (std::is_same::value - || (std::is_integral::value && !std::is_integral::value) + (std::is_same::value + || (std::is_integral::value && !std::is_integral::value) || (!std::is_integral::value && std::is_integral::value) || (std::numeric_limits::is_specialized && std::numeric_limits::is_specialized && (std::numeric_limits::digits == std::numeric_limits::digits) diff --git a/include/boost/math/special_functions/powm1.hpp b/include/boost/math/special_functions/powm1.hpp index 79f7344f53..de23714370 100644 --- a/include/boost/math/special_functions/powm1.hpp +++ b/include/boost/math/special_functions/powm1.hpp @@ -36,7 +36,7 @@ inline T powm1_imp(const T x, const T y, const Policy& pol) if (l < 0.5) return boost::math::expm1(l, pol); if (l > boost::math::tools::log_max_value()) - return boost::math::policies::raise_overflow_error(function, 0, pol); + return boost::math::policies::raise_overflow_error(function, nullptr, pol); // fall through.... } } @@ -54,7 +54,7 @@ inline T powm1_imp(const T x, const T y, const Policy& pol) } // detail template -inline typename tools::promote_args::type +inline typename tools::promote_args::type powm1(const T1 a, const T2 z) { typedef typename tools::promote_args::type result_type; @@ -62,7 +62,7 @@ inline typename tools::promote_args::type } template -inline typename tools::promote_args::type +inline typename tools::promote_args::type powm1(const T1 a, const T2 z, const Policy& pol) { typedef typename tools::promote_args::type result_type; diff --git a/include/boost/math/special_functions/round.hpp b/include/boost/math/special_functions/round.hpp index 7e23e159f9..d46bd44809 100644 --- a/include/boost/math/special_functions/round.hpp +++ b/include/boost/math/special_functions/round.hpp @@ -20,12 +20,15 @@ namespace boost{ namespace math{ namespace detail{ template -inline typename tools::promote_args::type round(const T& v, const Policy& pol, const std::false_type&) +inline tools::promote_args_t round(const T& v, const Policy& pol, const std::false_type&) { BOOST_MATH_STD_USING - typedef typename tools::promote_args::type result_type; + using result_type = tools::promote_args_t; + if(!(boost::math::isfinite)(v)) - return policies::raise_rounding_error("boost::math::round<%1%>(%1%)", 0, static_cast(v), static_cast(v), pol); + { + return policies::raise_rounding_error("boost::math::round<%1%>(%1%)", nullptr, static_cast(v), static_cast(v), pol); + } // // The logic here is rather convoluted, but avoids a number of traps, // see discussion here https://github.com/boostorg/math/pull/8 @@ -52,7 +55,7 @@ inline typename tools::promote_args::type round(const T& v, const Policy& pol } } template -inline typename tools::promote_args::type round(const T& v, const Policy&, const std::true_type&) +inline tools::promote_args_t round(const T& v, const Policy&, const std::true_type&) { return v; } @@ -60,12 +63,12 @@ inline typename tools::promote_args::type round(const T& v, const Policy&, co } // namespace detail template -inline typename tools::promote_args::type round(const T& v, const Policy& pol) +inline tools::promote_args_t round(const T& v, const Policy& pol) { return detail::round(v, pol, std::integral_constant::value>()); } template -inline typename tools::promote_args::type round(const T& v) +inline tools::promote_args_t round(const T& v) { return round(v, policies::policy<>()); } @@ -74,11 +77,11 @@ inline typename tools::promote_args::type round(const T& v) // implicit conversion to the integer types. For user-defined // number types this will likely not be the case. In that case // these functions should either be specialized for the UDT in -// question, or else overloads should be placed in the same +// question, or else overloads should be placed in the same // namespace as the UDT: these will then be found via argument // dependent lookup. See our concept archetypes for examples. // -// Non-standard numeric limits syntax "(std::numeric_limits::max)()" +// Non-standard numeric limits syntax "(std::numeric_limits::max)()" // is to avoid macro substiution from MSVC // https://stackoverflow.com/questions/27442885/syntax-error-with-stdnumeric-limitsmax // @@ -86,10 +89,13 @@ template inline int iround(const T& v, const Policy& pol) { BOOST_MATH_STD_USING - typedef typename tools::promote_args::type result_type; + using result_type = tools::promote_args_t; + T r = boost::math::round(v, pol); if(r > static_cast((std::numeric_limits::max)()) || r < static_cast((std::numeric_limits::min)())) - return static_cast(policies::raise_rounding_error("boost::math::iround<%1%>(%1%)", 0, v, 0, pol)); + { + return static_cast(policies::raise_rounding_error("boost::math::iround<%1%>(%1%)", nullptr, v, 0, pol)); + } return static_cast(r); } template @@ -102,10 +108,12 @@ template inline long lround(const T& v, const Policy& pol) { BOOST_MATH_STD_USING - typedef typename tools::promote_args::type result_type; + using result_type = tools::promote_args_t; T r = boost::math::round(v, pol); if(r > static_cast((std::numeric_limits::max)()) || r < static_cast((std::numeric_limits::min)())) - return static_cast(policies::raise_rounding_error("boost::math::lround<%1%>(%1%)", 0, v, 0L, pol)); + { + return static_cast(policies::raise_rounding_error("boost::math::lround<%1%>(%1%)", nullptr, v, 0L, pol)); + } return static_cast(r); } template @@ -118,12 +126,13 @@ template inline long long llround(const T& v, const Policy& pol) { BOOST_MATH_STD_USING - typedef typename tools::promote_args::type result_type; + using result_type = tools::promote_args_t; + T r = boost::math::round(v, pol); - if(r > static_cast((std::numeric_limits::max)()) || + if(r > static_cast((std::numeric_limits::max)()) || r < static_cast((std::numeric_limits::min)())) { - return static_cast(policies::raise_rounding_error("boost::math::llround<%1%>(%1%)", 0, v, static_cast(0), pol)); + return static_cast(policies::raise_rounding_error("boost::math::llround<%1%>(%1%)", nullptr, v, static_cast(0), pol)); } return static_cast(r); } diff --git a/include/boost/math/special_functions/trigamma.hpp b/include/boost/math/special_functions/trigamma.hpp index 8db050bce0..f74b43db1f 100644 --- a/include/boost/math/special_functions/trigamma.hpp +++ b/include/boost/math/special_functions/trigamma.hpp @@ -108,7 +108,7 @@ T trigamma_prec(T x, const std::integral_constant*, const Policy&) T y = 1 / x; return (1 + tools::evaluate_polynomial(P_4_inf, y) / tools::evaluate_polynomial(Q_4_inf, y)) / x; } - + template T trigamma_prec(T x, const std::integral_constant*, const Policy&) { @@ -376,7 +376,7 @@ T trigamma_imp(T x, const Tag* t, const Policy& pol) // Argument reduction for tan: if(floor(x) == x) { - return policies::raise_pole_error("boost::math::trigamma<%1%>(%1%)", 0, (1-x), pol); + return policies::raise_pole_error("boost::math::trigamma<%1%>(%1%)", nullptr, (1-x), pol); } T s = fabs(x) < fabs(z) ? boost::math::sin_pi(x, pol) : boost::math::sin_pi(z, pol); return -trigamma_imp(z, t, pol) + boost::math::pow<2>(constants::pi()) / (s * s); @@ -427,7 +427,7 @@ const typename trigamma_initializer::init trigamma_initializer -inline typename tools::promote_args::type +inline typename tools::promote_args::type trigamma(T x, const Policy&) { typedef typename tools::promote_args::type result_type; @@ -451,11 +451,11 @@ inline typename tools::promote_args::type return policies::checked_narrowing_cast(detail::trigamma_imp( static_cast(x), - static_cast(0), forwarding_policy()), "boost::math::trigamma<%1%>(%1%)"); + static_cast(nullptr), forwarding_policy()), "boost::math::trigamma<%1%>(%1%)"); } template -inline typename tools::promote_args::type +inline typename tools::promote_args::type trigamma(T x) { return trigamma(x, policies::policy<>()); diff --git a/include/boost/math/special_functions/trunc.hpp b/include/boost/math/special_functions/trunc.hpp index 46a2a991f8..d128d2c485 100644 --- a/include/boost/math/special_functions/trunc.hpp +++ b/include/boost/math/special_functions/trunc.hpp @@ -19,17 +19,19 @@ namespace boost{ namespace math{ namespace detail{ template -inline typename tools::promote_args::type trunc(const T& v, const Policy& pol, const std::false_type&) +inline tools::promote_args_t trunc(const T& v, const Policy& pol, const std::false_type&) { BOOST_MATH_STD_USING - typedef typename tools::promote_args::type result_type; + using result_type = tools::promote_args_t; if(!(boost::math::isfinite)(v)) - return policies::raise_rounding_error("boost::math::trunc<%1%>(%1%)", 0, static_cast(v), static_cast(v), pol); + { + return policies::raise_rounding_error("boost::math::trunc<%1%>(%1%)", nullptr, static_cast(v), static_cast(v), pol); + } return (v >= 0) ? static_cast(floor(v)) : static_cast(ceil(v)); } template -inline typename tools::promote_args::type trunc(const T& v, const Policy&, const std::true_type&) +inline tools::promote_args_t trunc(const T& v, const Policy&, const std::true_type&) { return v; } @@ -37,12 +39,12 @@ inline typename tools::promote_args::type trunc(const T& v, const Policy&, co } template -inline typename tools::promote_args::type trunc(const T& v, const Policy& pol) +inline tools::promote_args_t trunc(const T& v, const Policy& pol) { return detail::trunc(v, pol, std::integral_constant::value>()); } template -inline typename tools::promote_args::type trunc(const T& v) +inline tools::promote_args_t trunc(const T& v) { return trunc(v, policies::policy<>()); } @@ -55,7 +57,7 @@ inline typename tools::promote_args::type trunc(const T& v) // namespace as the UDT: these will then be found via argument // dependent lookup. See our concept archetypes for examples. // -// Non-standard numeric limits syntax "(std::numeric_limits::max)()" +// Non-standard numeric limits syntax "(std::numeric_limits::max)()" // is to avoid macro substiution from MSVC // https://stackoverflow.com/questions/27442885/syntax-error-with-stdnumeric-limitsmax // @@ -63,10 +65,12 @@ template inline int itrunc(const T& v, const Policy& pol) { BOOST_MATH_STD_USING - typedef typename tools::promote_args::type result_type; + using result_type = tools::promote_args_t; result_type r = boost::math::trunc(v, pol); if(r > static_cast((std::numeric_limits::max)()) || r < static_cast((std::numeric_limits::min)())) - return static_cast(policies::raise_rounding_error("boost::math::itrunc<%1%>(%1%)", 0, static_cast(v), 0, pol)); + { + return static_cast(policies::raise_rounding_error("boost::math::itrunc<%1%>(%1%)", nullptr, static_cast(v), 0, pol)); + } return static_cast(r); } template @@ -79,10 +83,12 @@ template inline long ltrunc(const T& v, const Policy& pol) { BOOST_MATH_STD_USING - typedef typename tools::promote_args::type result_type; + using result_type = tools::promote_args_t; result_type r = boost::math::trunc(v, pol); if(r > static_cast((std::numeric_limits::max)()) || r < static_cast((std::numeric_limits::min)())) - return static_cast(policies::raise_rounding_error("boost::math::ltrunc<%1%>(%1%)", 0, static_cast(v), 0L, pol)); + { + return static_cast(policies::raise_rounding_error("boost::math::ltrunc<%1%>(%1%)", nullptr, static_cast(v), 0L, pol)); + } return static_cast(r); } template @@ -95,12 +101,12 @@ template inline long long lltrunc(const T& v, const Policy& pol) { BOOST_MATH_STD_USING - typedef typename tools::promote_args::type result_type; + using result_type = tools::promote_args_t; result_type r = boost::math::trunc(v, pol); - if(r > static_cast((std::numeric_limits::max)()) || + if(r > static_cast((std::numeric_limits::max)()) || r < static_cast((std::numeric_limits::min)())) { - return static_cast(policies::raise_rounding_error("boost::math::lltrunc<%1%>(%1%)", 0, v, static_cast(0), pol)); + return static_cast(policies::raise_rounding_error("boost::math::lltrunc<%1%>(%1%)", nullptr, v, static_cast(0), pol)); } return static_cast(r); } @@ -112,14 +118,14 @@ inline long long lltrunc(const T& v) template inline typename std::enable_if::value, int>::type - iconvert(const T& v, const Policy&) + iconvert(const T& v, const Policy&) { return static_cast(v); } template inline typename std::enable_if::value, int>::type - iconvert(const T& v, const Policy& pol) + iconvert(const T& v, const Policy& pol) { using boost::math::itrunc; return itrunc(v, pol); @@ -127,14 +133,14 @@ inline typename std::enable_if::value, int>::type template inline typename std::enable_if::value, long>::type - lconvert(const T& v, const Policy&) + lconvert(const T& v, const Policy&) { return static_cast(v); } template inline typename std::enable_if::value, long>::type - lconvert(const T& v, const Policy& pol) + lconvert(const T& v, const Policy& pol) { using boost::math::ltrunc; return ltrunc(v, pol); @@ -142,14 +148,14 @@ inline typename std::enable_if::value, long>::ty template inline typename std::enable_if::value, long long>::type - llconvertert(const T& v, const Policy&) + llconvertert(const T& v, const Policy&) { return static_cast(v); } template inline typename std::enable_if::value, long long>::type - llconvertert(const T& v, const Policy& pol) + llconvertert(const T& v, const Policy& pol) { using boost::math::lltrunc; return lltrunc(v, pol); diff --git a/include/boost/math/special_functions/ulp.hpp b/include/boost/math/special_functions/ulp.hpp index e78cd42e5a..532224e273 100644 --- a/include/boost/math/special_functions/ulp.hpp +++ b/include/boost/math/special_functions/ulp.hpp @@ -34,7 +34,7 @@ T ulp_imp(const T& val, const std::true_type&, const Policy& pol) } else if((fpclass == (int)FP_INFINITE) || (fabs(val) >= tools::max_value())) { - return (val < 0 ? -1 : 1) * policies::raise_overflow_error(function, 0, pol); + return (val < 0 ? -1 : 1) * policies::raise_overflow_error(function, nullptr, pol); } else if(fpclass == FP_ZERO) return detail::get_smallest_value(); @@ -68,7 +68,7 @@ T ulp_imp(const T& val, const std::false_type&, const Policy& pol) } else if((fpclass == (int)FP_INFINITE) || (fabs(val) >= tools::max_value())) { - return (val < 0 ? -1 : 1) * policies::raise_overflow_error(function, 0, pol); + return (val < 0 ? -1 : 1) * policies::raise_overflow_error(function, nullptr, pol); } else if(fpclass == FP_ZERO) return detail::get_smallest_value(); diff --git a/include/boost/math/special_functions/zeta.hpp b/include/boost/math/special_functions/zeta.hpp index 23aa9af856..0f3136d00f 100644 --- a/include/boost/math/special_functions/zeta.hpp +++ b/include/boost/math/special_functions/zeta.hpp @@ -41,10 +41,10 @@ template struct zeta_series_cache_size { // - // Work how large to make our cache size when evaluating the series + // Work how large to make our cache size when evaluating the series // evaluation: normally this is just large enough for the series - // to have converged, but for arbitrary precision types we need a - // really large cache to achieve reasonable precision in a reasonable + // to have converged, but for arbitrary precision types we need a + // really large cache to achieve reasonable precision in a reasonable // time. This is important when constructing rational approximations // to zeta for example. // @@ -69,7 +69,7 @@ T zeta_series_imp(T s, T sc, const Policy&) { // // Series evaluation from: - // Havil, J. Gamma: Exploring Euler's Constant. + // Havil, J. Gamma: Exploring Euler's Constant. // Princeton, NJ: Princeton University Press, 2003. // // See also http://mathworld.wolfram.com/RiemannZetaFunction.html @@ -132,7 +132,7 @@ inline T zeta_series2_imp(T s, const Policy& pol) std::uintmax_t max_iter = policies::get_max_series_iterations();; zeta_series2 f(s); T result = tools::sum_series( - f, + f, policies::get_epsilon(), max_iter); policies::check_series_iterations("boost::math::zeta_series2<%1%>(%1%)", max_iter, pol); @@ -145,8 +145,8 @@ T zeta_polynomial_series(T s, T sc, Policy const &) { // // This is algorithm 3 from: - // - // "An Efficient Algorithm for the Riemann Zeta Function", P. Borwein, + // + // "An Efficient Algorithm for the Riemann Zeta Function", P. Borwein, // Canadian Mathematical Society, Conference Proceedings. // See: http://www.cecm.sfu.ca/personal/pborwein/PAPERS/P155.pdf // @@ -158,7 +158,7 @@ T zeta_polynomial_series(T s, T sc, Policy const &) for(int j = 0; j < n; ++j) { sum += ej_sign * -two_n / pow(T(j + 1), s); - ej_sign = -ej_sign; + ej_sign = -ej_sign; } T ej_sum = 1; T ej_term = 1; @@ -180,14 +180,14 @@ T zeta_imp_prec(T s, T sc, const Policy& pol, const std::integral_constant= policies::digits()) return 1; - result = zeta_polynomial_series(s, sc, pol); + result = zeta_polynomial_series(s, sc, pol); #if 0 // Old code archived for future reference: // - // Only use power series if it will converge in 100 + // Only use power series if it will converge in 100 // iterations or less: the more iterations it consumes - // the slower convergence becomes so we have to be very + // the slower convergence becomes so we have to be very // careful in it's usage. // if (s > -log(tools::epsilon()) / 4.5) @@ -209,7 +209,7 @@ inline T zeta_imp_prec(T s, T sc, const Policy&, const std::integral_constant(0.24339294433593750202L), static_cast(-0.49092470516353571651L), static_cast(0.0557616214776046784287L), @@ -217,7 +217,7 @@ inline T zeta_imp_prec(T s, T sc, const Policy&, const std::integral_constant(0.000451534528645796438704L), static_cast(-0.933241270357061460782e-5L), }; - static const T Q[6] = { + static const T Q[6] = { static_cast(1L), static_cast(-0.279960334310344432495L), static_cast(0.0419676223309986037706L), @@ -234,7 +234,7 @@ inline T zeta_imp_prec(T s, T sc, const Policy&, const std::integral_constant(0.577215664901532860516L), static_cast(0.243210646940107164097L), static_cast(0.0417364673988216497593L), @@ -242,7 +242,7 @@ inline T zeta_imp_prec(T s, T sc, const Policy&, const std::integral_constant(0.000249606367151877175456L), static_cast(0.110108440976732897969e-4L), }; - static const T Q[6] = { + static const T Q[6] = { static_cast(1.0), static_cast(0.295201277126631761737L), static_cast(0.043460910607305495864L), @@ -258,7 +258,7 @@ inline T zeta_imp_prec(T s, T sc, const Policy&, const std::integral_constant(-0.0537258300023595030676L), static_cast(0.0445163473292365591906L), static_cast(0.0128677673534519952905L), @@ -266,7 +266,7 @@ inline T zeta_imp_prec(T s, T sc, const Policy&, const std::integral_constant(0.769875101573654070925e-4L), static_cast(0.328032510000383084155e-5L), }; - static const T Q[7] = { + static const T Q[7] = { 1.0f, static_cast(0.33383194553034051422L), static_cast(0.0487798431291407621462L), @@ -284,7 +284,7 @@ inline T zeta_imp_prec(T s, T sc, const Policy&, const std::integral_constant(-2.49710190602259410021L), static_cast(-2.60013301809475665334L), static_cast(-0.939260435377109939261L), @@ -292,7 +292,7 @@ inline T zeta_imp_prec(T s, T sc, const Policy&, const std::integral_constant(-0.00701721240549802377623L), static_cast(-0.229257310594893932383e-4L), }; - static const T Q[9] = { + static const T Q[9] = { 1.0f, static_cast(0.706039025937745133628L), static_cast(0.15739599649558626358L), @@ -311,7 +311,7 @@ inline T zeta_imp_prec(T s, T sc, const Policy&, const std::integral_constant(-4.78558028495135619286L), static_cast(-1.89197364881972536382L), static_cast(-0.211407134874412820099L), @@ -320,7 +320,7 @@ inline T zeta_imp_prec(T s, T sc, const Policy&, const std::integral_constant(0.639949204213164496988e-4L), static_cast(0.139348932445324888343e-5L), }; - static const T Q[9] = { + static const T Q[9] = { 1.0f, static_cast(0.244345337378188557777L), static_cast(0.00873370754492288653669L), @@ -338,7 +338,7 @@ inline T zeta_imp_prec(T s, T sc, const Policy&, const std::integral_constant(-10.3948950573308896825L), static_cast(-2.85827219671106697179L), static_cast(-0.347728266539245787271L), @@ -348,7 +348,7 @@ inline T zeta_imp_prec(T s, T sc, const Policy&, const std::integral_constant(-0.785523633796723466968e-6L), static_cast(-0.821465709095465524192e-8L), }; - static const T Q[10] = { + static const T Q[10] = { 1.0f, static_cast(0.208196333572671890965L), static_cast(0.0195687657317205033485L), @@ -383,7 +383,7 @@ T zeta_imp_prec(T s, T sc, const Policy&, const std::integral_constant& // Maximum Deviation Found: 3.099e-20 // Expected Error Term: 3.099e-20 // Max error found at long double precision: 5.890498e-20 - static const T P[6] = { + static const T P[6] = { BOOST_MATH_BIG_CONSTANT(T, 64, 0.243392944335937499969), BOOST_MATH_BIG_CONSTANT(T, 64, -0.496837806864865688082), BOOST_MATH_BIG_CONSTANT(T, 64, 0.0680008039723709987107), @@ -391,7 +391,7 @@ T zeta_imp_prec(T s, T sc, const Policy&, const std::integral_constant& BOOST_MATH_BIG_CONSTANT(T, 64, 0.000455369899250053003335), BOOST_MATH_BIG_CONSTANT(T, 64, -0.279496685273033761927e-4), }; - static const T Q[7] = { + static const T Q[7] = { BOOST_MATH_BIG_CONSTANT(T, 64, 1.0), BOOST_MATH_BIG_CONSTANT(T, 64, -0.30425480068225790522), BOOST_MATH_BIG_CONSTANT(T, 64, 0.050052748580371598736), @@ -411,7 +411,7 @@ T zeta_imp_prec(T s, T sc, const Policy&, const std::integral_constant& // Expected Error Term: 1.059e-21 // Max error found at long double precision: 1.626303e-19 - static const T P[6] = { + static const T P[6] = { BOOST_MATH_BIG_CONSTANT(T, 64, 0.577215664901532860605), BOOST_MATH_BIG_CONSTANT(T, 64, 0.222537368917162139445), BOOST_MATH_BIG_CONSTANT(T, 64, 0.0356286324033215682729), @@ -419,7 +419,7 @@ T zeta_imp_prec(T s, T sc, const Policy&, const std::integral_constant& BOOST_MATH_BIG_CONSTANT(T, 64, 0.000178102511649069421904), BOOST_MATH_BIG_CONSTANT(T, 64, 0.700867470265983665042e-5), }; - static const T Q[7] = { + static const T Q[7] = { BOOST_MATH_BIG_CONSTANT(T, 64, 1.0), BOOST_MATH_BIG_CONSTANT(T, 64, 0.259385759149531030085), BOOST_MATH_BIG_CONSTANT(T, 64, 0.0373974962106091316854), @@ -436,7 +436,7 @@ T zeta_imp_prec(T s, T sc, const Policy&, const std::integral_constant& // Maximum Deviation Found: 5.946e-22 // Expected Error Term: -5.946e-22 static const float Y = 0.6986598968505859375; - static const T P[7] = { + static const T P[7] = { BOOST_MATH_BIG_CONSTANT(T, 64, -0.053725830002359501027), BOOST_MATH_BIG_CONSTANT(T, 64, 0.0470551187571475844778), BOOST_MATH_BIG_CONSTANT(T, 64, 0.0101339410415759517471), @@ -445,7 +445,7 @@ T zeta_imp_prec(T s, T sc, const Policy&, const std::integral_constant& BOOST_MATH_BIG_CONSTANT(T, 64, 0.390972820219765942117e-5), BOOST_MATH_BIG_CONSTANT(T, 64, 0.540319769113543934483e-7), }; - static const T Q[8] = { + static const T Q[8] = { BOOST_MATH_BIG_CONSTANT(T, 64, 1.0), BOOST_MATH_BIG_CONSTANT(T, 64, 0.286577739726542730421), BOOST_MATH_BIG_CONSTANT(T, 64, 0.0447355811517733225843), @@ -461,7 +461,7 @@ T zeta_imp_prec(T s, T sc, const Policy&, const std::integral_constant& else if(s <= 7) { // Max error found at long double precision: 8.132216e-19 - static const T P[8] = { + static const T P[8] = { BOOST_MATH_BIG_CONSTANT(T, 64, -2.49710190602259407065), BOOST_MATH_BIG_CONSTANT(T, 64, -3.36664913245960625334), BOOST_MATH_BIG_CONSTANT(T, 64, -1.77180020623777595452), @@ -471,7 +471,7 @@ T zeta_imp_prec(T s, T sc, const Policy&, const std::integral_constant& BOOST_MATH_BIG_CONSTANT(T, 64, -0.000165556579779704340166), BOOST_MATH_BIG_CONSTANT(T, 64, -0.252884970740994069582e-5), }; - static const T Q[9] = { + static const T Q[9] = { BOOST_MATH_BIG_CONSTANT(T, 64, 1.0), BOOST_MATH_BIG_CONSTANT(T, 64, 1.01300131390690459085), BOOST_MATH_BIG_CONSTANT(T, 64, 0.387898115758643503827), @@ -489,7 +489,7 @@ T zeta_imp_prec(T s, T sc, const Policy&, const std::integral_constant& { // Max error in interpolated form: 1.133e-18 // Max error found at long double precision: 2.183198e-18 - static const T P[9] = { + static const T P[9] = { BOOST_MATH_BIG_CONSTANT(T, 64, -4.78558028495135548083), BOOST_MATH_BIG_CONSTANT(T, 64, -3.23873322238609358947), BOOST_MATH_BIG_CONSTANT(T, 64, -0.892338582881021799922), @@ -500,7 +500,7 @@ T zeta_imp_prec(T s, T sc, const Policy&, const std::integral_constant& BOOST_MATH_BIG_CONSTANT(T, 64, -0.626503445372641798925e-6), BOOST_MATH_BIG_CONSTANT(T, 64, -0.815696314790853893484e-8), }; - static const T Q[9] = { + static const T Q[9] = { BOOST_MATH_BIG_CONSTANT(T, 64, 1.0), BOOST_MATH_BIG_CONSTANT(T, 64, 0.525765665400123515036), BOOST_MATH_BIG_CONSTANT(T, 64, 0.10852641753657122787), @@ -518,7 +518,7 @@ T zeta_imp_prec(T s, T sc, const Policy&, const std::integral_constant& { // Max error in interpolated form: 1.668e-17 // Max error found at long double precision: 1.669714e-17 - static const T P[9] = { + static const T P[9] = { BOOST_MATH_BIG_CONSTANT(T, 64, -10.3948950573308861781), BOOST_MATH_BIG_CONSTANT(T, 64, -2.82646012777913950108), BOOST_MATH_BIG_CONSTANT(T, 64, -0.342144362739570333665), @@ -529,7 +529,7 @@ T zeta_imp_prec(T s, T sc, const Policy&, const std::integral_constant& BOOST_MATH_BIG_CONSTANT(T, 64, -0.165096762663509467061e-7), BOOST_MATH_BIG_CONSTANT(T, 64, -0.145392555873022044329e-9), }; - static const T Q[10] = { + static const T Q[10] = { BOOST_MATH_BIG_CONSTANT(T, 64, 1.0), BOOST_MATH_BIG_CONSTANT(T, 64, 0.205135978585281988052), BOOST_MATH_BIG_CONSTANT(T, 64, 0.0192359357875879453602), @@ -567,7 +567,7 @@ T zeta_imp_prec(T s, T sc, const Policy&, const std::integral_constant // Expected Error Term: 9.492e-37 // Max error found at long double precision: 7.281332e-31 - static const T P[10] = { + static const T P[10] = { BOOST_MATH_BIG_CONSTANT(T, 113, -1.0), BOOST_MATH_BIG_CONSTANT(T, 113, -0.0353008629988648122808504280990313668), BOOST_MATH_BIG_CONSTANT(T, 113, 0.0107795651204927743049369868548706909), @@ -579,7 +579,7 @@ T zeta_imp_prec(T s, T sc, const Policy&, const std::integral_constant BOOST_MATH_BIG_CONSTANT(T, 113, 0.660690993901506912123512551294239036e-9), BOOST_MATH_BIG_CONSTANT(T, 113, 0.113103113698388531428914333768142527e-10), }; - static const T Q[11] = { + static const T Q[11] = { BOOST_MATH_BIG_CONSTANT(T, 113, 1.0), BOOST_MATH_BIG_CONSTANT(T, 113, -0.387483472099602327112637481818565459), BOOST_MATH_BIG_CONSTANT(T, 113, 0.0802265315091063135271497708694776875), @@ -601,7 +601,7 @@ T zeta_imp_prec(T s, T sc, const Policy&, const std::integral_constant // Maximum Deviation Found: 1.616e-37 // Expected Error Term: -1.615e-37 - static const T P[10] = { + static const T P[10] = { BOOST_MATH_BIG_CONSTANT(T, 113, 0.577215664901532860606512090082402431), BOOST_MATH_BIG_CONSTANT(T, 113, 0.255597968739771510415479842335906308), BOOST_MATH_BIG_CONSTANT(T, 113, 0.0494056503552807274142218876983542205), @@ -613,7 +613,7 @@ T zeta_imp_prec(T s, T sc, const Policy&, const std::integral_constant BOOST_MATH_BIG_CONSTANT(T, 113, 0.583103205551702720149237384027795038e-9), BOOST_MATH_BIG_CONSTANT(T, 113, -0.835774625259919268768735944711219256e-11), }; - static const T Q[11] = { + static const T Q[11] = { BOOST_MATH_BIG_CONSTANT(T, 113, 1.0), BOOST_MATH_BIG_CONSTANT(T, 113, 0.316661751179735502065583176348292881), BOOST_MATH_BIG_CONSTANT(T, 113, 0.0540401806533507064453851182728635272), @@ -636,7 +636,7 @@ T zeta_imp_prec(T s, T sc, const Policy&, const std::integral_constant // Max error found: 2.171527e-35 static const float Y = 0.6986598968505859375; - static const T P[11] = { + static const T P[11] = { BOOST_MATH_BIG_CONSTANT(T, 113, -0.0537258300023595010275848333539748089), BOOST_MATH_BIG_CONSTANT(T, 113, 0.0429086930802630159457448174466342553), BOOST_MATH_BIG_CONSTANT(T, 113, 0.0136148228754303412510213395034056857), @@ -649,7 +649,7 @@ T zeta_imp_prec(T s, T sc, const Policy&, const std::integral_constant BOOST_MATH_BIG_CONSTANT(T, 113, 0.231904754577648077579913403645767214e-10), BOOST_MATH_BIG_CONSTANT(T, 113, 0.340169592866058506675897646629036044e-12), }; - static const T Q[12] = { + static const T Q[12] = { BOOST_MATH_BIG_CONSTANT(T, 113, 1.0), BOOST_MATH_BIG_CONSTANT(T, 113, 0.363755247765087100018556983050520554), BOOST_MATH_BIG_CONSTANT(T, 113, 0.0696581979014242539385695131258321598), @@ -673,7 +673,7 @@ T zeta_imp_prec(T s, T sc, const Policy&, const std::integral_constant static const T Y = 3.28348541259765625F; - static const T P[13] = { + static const T P[13] = { BOOST_MATH_BIG_CONSTANT(T, 113, 0.786383506575062179339611614117697622), BOOST_MATH_BIG_CONSTANT(T, 113, 0.495766593395271370974685959652073976), BOOST_MATH_BIG_CONSTANT(T, 113, -0.409116737851754766422360889037532228), @@ -688,7 +688,7 @@ T zeta_imp_prec(T s, T sc, const Policy&, const std::integral_constant BOOST_MATH_BIG_CONSTANT(T, 113, -0.214539416789686920918063075528797059e-8), BOOST_MATH_BIG_CONSTANT(T, 113, -0.15090220092460596872172844424267351e-10), }; - static const T Q[14] = { + static const T Q[14] = { BOOST_MATH_BIG_CONSTANT(T, 113, 1.0), BOOST_MATH_BIG_CONSTANT(T, 113, 1.69490865837142338462982225731926485), BOOST_MATH_BIG_CONSTANT(T, 113, 1.22697696630994080733321401255942464), @@ -713,7 +713,7 @@ T zeta_imp_prec(T s, T sc, const Policy&, const std::integral_constant // Max error in interpolated form: 1.999e-34 // Max error found at long double precision: 2.156186e-33 - static const T P[13] = { + static const T P[13] = { BOOST_MATH_BIG_CONSTANT(T, 113, -4.0545627381873738086704293881227365), BOOST_MATH_BIG_CONSTANT(T, 113, -4.70088348734699134347906176097717782), BOOST_MATH_BIG_CONSTANT(T, 113, -2.36921550900925512951976617607678789), @@ -728,7 +728,7 @@ T zeta_imp_prec(T s, T sc, const Policy&, const std::integral_constant BOOST_MATH_BIG_CONSTANT(T, 113, -0.500334720512030826996373077844707164e-10), BOOST_MATH_BIG_CONSTANT(T, 113, -0.420204769185233365849253969097184005e-12), }; - static const T Q[14] = { + static const T Q[14] = { BOOST_MATH_BIG_CONSTANT(T, 113, 1.0), BOOST_MATH_BIG_CONSTANT(T, 113, 0.97663511666410096104783358493318814), BOOST_MATH_BIG_CONSTANT(T, 113, 0.40878780231201806504987368939673249), @@ -751,7 +751,7 @@ T zeta_imp_prec(T s, T sc, const Policy&, const std::integral_constant { // Max error in interpolated form: 1.641e-32 // Max error found at long double precision: 1.696121e-32 - static const T P[13] = { + static const T P[13] = { BOOST_MATH_BIG_CONSTANT(T, 113, -6.91319491921722925920883787894829678), BOOST_MATH_BIG_CONSTANT(T, 113, -3.65491257639481960248690596951049048), BOOST_MATH_BIG_CONSTANT(T, 113, -0.813557553449954526442644544105257881), @@ -766,7 +766,7 @@ T zeta_imp_prec(T s, T sc, const Policy&, const std::integral_constant BOOST_MATH_BIG_CONSTANT(T, 113, 0.347873737198164757035457841688594788e-13), BOOST_MATH_BIG_CONSTANT(T, 113, -0.289187187441625868404494665572279364e-15), }; - static const T Q[14] = { + static const T Q[14] = { BOOST_MATH_BIG_CONSTANT(T, 113, 1.0), BOOST_MATH_BIG_CONSTANT(T, 113, 0.427310044448071818775721584949868806), BOOST_MATH_BIG_CONSTANT(T, 113, 0.074602514873055756201435421385243062), @@ -790,7 +790,7 @@ T zeta_imp_prec(T s, T sc, const Policy&, const std::integral_constant // Max error in interpolated form: 1.563e-31 // Max error found at long double precision: 1.562725e-31 - static const T P[13] = { + static const T P[13] = { BOOST_MATH_BIG_CONSTANT(T, 113, -11.7824798233959252791987402769438322), BOOST_MATH_BIG_CONSTANT(T, 113, -4.36131215284987731928174218354118102), BOOST_MATH_BIG_CONSTANT(T, 113, -0.732260980060982349410898496846972204), @@ -805,7 +805,7 @@ T zeta_imp_prec(T s, T sc, const Policy&, const std::integral_constant BOOST_MATH_BIG_CONSTANT(T, 113, -0.102397936697965977221267881716672084e-13), BOOST_MATH_BIG_CONSTANT(T, 113, -0.402663128248642002351627980255756363e-16), }; - static const T Q[14] = { + static const T Q[14] = { BOOST_MATH_BIG_CONSTANT(T, 113, 1.0), BOOST_MATH_BIG_CONSTANT(T, 113, 0.311288325355705609096155335186466508), BOOST_MATH_BIG_CONSTANT(T, 113, 0.0438318468940415543546769437752132748), @@ -828,7 +828,7 @@ T zeta_imp_prec(T s, T sc, const Policy&, const std::integral_constant { // Max error in interpolated form: 2.311e-27 // Max error found at long double precision: 2.297544e-27 - static const T P[14] = { + static const T P[14] = { BOOST_MATH_BIG_CONSTANT(T, 113, -20.7944102007844314586649688802236072), BOOST_MATH_BIG_CONSTANT(T, 113, -4.95759941987499442499908748130192187), BOOST_MATH_BIG_CONSTANT(T, 113, -0.563290752832461751889194629200298688), @@ -844,7 +844,7 @@ T zeta_imp_prec(T s, T sc, const Policy&, const std::integral_constant BOOST_MATH_BIG_CONSTANT(T, 113, -0.116313253429564048145641663778121898e-16), BOOST_MATH_BIG_CONSTANT(T, 113, -0.376708747782400769427057630528578187e-19), }; - static const T Q[16] = { + static const T Q[16] = { BOOST_MATH_BIG_CONSTANT(T, 113, 1.0), BOOST_MATH_BIG_CONSTANT(T, 113, 0.205076752981410805177554569784219717), BOOST_MATH_BIG_CONSTANT(T, 113, 0.0202526722696670378999575738524540269), @@ -922,8 +922,8 @@ T zeta_imp(T s, T sc, const Policy& pol, const Tag& tag) static const char* function = "boost::math::zeta<%1%>"; if(sc == 0) return policies::raise_pole_error( - function, - "Evaluation of zeta function at pole %1%", + function, + "Evaluation of zeta function at pole %1%", s, pol); T result; // @@ -988,17 +988,17 @@ T zeta_imp(T s, T sc, const Policy& pol, const Tag& tag) result = boost::math::lgamma(s, pol); result -= s * log(2 * constants::pi()); if(result > tools::log_max_value()) - return sign(mult) * policies::raise_overflow_error(function, 0, pol); + return sign(mult) * policies::raise_overflow_error(function, nullptr, pol); result = exp(result); if(tools::max_value() / fabs(mult) < result) - return boost::math::sign(mult) * policies::raise_overflow_error(function, 0, pol); + return boost::math::sign(mult) * policies::raise_overflow_error(function, nullptr, pol); result *= mult; } else { result = boost::math::sin_pi(0.5f * sc, pol) - * 2 * pow(2 * constants::pi(), -s) - * boost::math::tgamma(s, pol) + * 2 * pow(2 * constants::pi(), -s) + * boost::math::tgamma(s, pol) * zeta_imp(s, sc, pol, tag); } } @@ -1066,9 +1066,9 @@ inline typename tools::promote_args::type zeta(T s, const Policy&) typedef typename policies::evaluation::type value_type; typedef typename policies::precision::type precision_type; typedef typename policies::normalise< - Policy, - policies::promote_float, - policies::promote_double, + Policy, + policies::promote_float, + policies::promote_double, policies::discrete_quantile<>, policies::assert_undefined<> >::type forwarding_policy; typedef std::integral_constant::value_type; BOOST_MATH_ASSERT_MSG(first != last, "At least one sample is required to compute the mean."); - + if constexpr (std::is_integral_v) { if constexpr (std::is_same_v, decltype(std::execution::seq)>) @@ -77,7 +77,7 @@ template inline auto variance(ExecutionPolicy&& exec, ForwardIterator first, ForwardIterator last) { using Real = typename std::iterator_traits::value_type; - + if constexpr (std::is_integral_v) { if constexpr (std::is_same_v, decltype(std::execution::seq)>) @@ -208,14 +208,14 @@ inline auto first_four_moments(ExecutionPolicy&& exec, ForwardIterator first, Fo { if constexpr (std::is_same_v, decltype(std::execution::seq)>) { - const auto results = detail::first_four_moments_sequential_impl>(first, last); - return std::make_tuple(std::get<0>(results), std::get<1>(results) / std::get<4>(results), std::get<2>(results) / std::get<4>(results), + const auto results = detail::first_four_moments_sequential_impl>(first, last); + return std::make_tuple(std::get<0>(results), std::get<1>(results) / std::get<4>(results), std::get<2>(results) / std::get<4>(results), std::get<3>(results) / std::get<4>(results)); } else { const auto results = detail::first_four_moments_parallel_impl>(first, last); - return std::make_tuple(std::get<0>(results), std::get<1>(results) / std::get<4>(results), std::get<2>(results) / std::get<4>(results), + return std::make_tuple(std::get<0>(results), std::get<1>(results) / std::get<4>(results), std::get<2>(results) / std::get<4>(results), std::get<3>(results) / std::get<4>(results)); } } @@ -224,13 +224,13 @@ inline auto first_four_moments(ExecutionPolicy&& exec, ForwardIterator first, Fo if constexpr (std::is_same_v, decltype(std::execution::seq)>) { const auto results = detail::first_four_moments_sequential_impl>(first, last); - return std::make_tuple(std::get<0>(results), std::get<1>(results) / std::get<4>(results), std::get<2>(results) / std::get<4>(results), + return std::make_tuple(std::get<0>(results), std::get<1>(results) / std::get<4>(results), std::get<2>(results) / std::get<4>(results), std::get<3>(results) / std::get<4>(results)); } else { const auto results = detail::first_four_moments_parallel_impl>(first, last); - return std::make_tuple(std::get<0>(results), std::get<1>(results) / std::get<4>(results), std::get<2>(results) / std::get<4>(results), + return std::make_tuple(std::get<0>(results), std::get<1>(results) / std::get<4>(results), std::get<2>(results) / std::get<4>(results), std::get<3>(results) / std::get<4>(results)); } } @@ -272,7 +272,7 @@ inline auto skewness(ExecutionPolicy&& exec, ForwardIterator first, ForwardItera return detail::skewness_sequential_impl(first, last); } } - else + else { const auto [M1, M2, M3, M4] = first_four_moments(exec, first, last); const auto n = std::distance(first, last); @@ -284,7 +284,7 @@ inline auto skewness(ExecutionPolicy&& exec, ForwardIterator first, ForwardItera // A constant dataset has no skewness. if constexpr (std::is_integral_v) { - return double(0); + return static_cast(0); } else { @@ -430,9 +430,9 @@ inline auto gini_coefficient(ExecutionPolicy&& exec, RandomAccessIterator first, else { return detail::gini_coefficient_sequential_impl(first, last); - } + } } - + else if constexpr (std::is_integral_v) { return detail::gini_coefficient_parallel_impl(exec, first, last); @@ -488,7 +488,7 @@ inline auto sample_gini_coefficient(RandomAccessContainer & v) } template -auto median_absolute_deviation(ExecutionPolicy&& exec, RandomAccessIterator first, RandomAccessIterator last, +auto median_absolute_deviation(ExecutionPolicy&& exec, RandomAccessIterator first, RandomAccessIterator last, typename std::iterator_traits::value_type center=std::numeric_limits::value_type>::quiet_NaN()) { using std::abs; @@ -517,21 +517,21 @@ auto median_absolute_deviation(ExecutionPolicy&& exec, RandomAccessIterator firs } template -inline auto median_absolute_deviation(ExecutionPolicy&& exec, RandomAccessContainer & v, +inline auto median_absolute_deviation(ExecutionPolicy&& exec, RandomAccessContainer & v, typename RandomAccessContainer::value_type center=std::numeric_limits::quiet_NaN()) { return median_absolute_deviation(exec, std::begin(v), std::end(v), center); } template -inline auto median_absolute_deviation(RandomAccessIterator first, RandomAccessIterator last, +inline auto median_absolute_deviation(RandomAccessIterator first, RandomAccessIterator last, typename RandomAccessIterator::value_type center=std::numeric_limits::quiet_NaN()) { return median_absolute_deviation(std::execution::seq, first, last, center); } template -inline auto median_absolute_deviation(RandomAccessContainer & v, +inline auto median_absolute_deviation(RandomAccessContainer & v, typename RandomAccessContainer::value_type center=std::numeric_limits::quiet_NaN()) { return median_absolute_deviation(std::execution::seq, std::begin(v), std::end(v), center); @@ -598,7 +598,7 @@ inline auto interquartile_range(RandomAccessContainer & v) template inline OutputIterator mode(ExecutionPolicy&& exec, ForwardIterator first, ForwardIterator last, OutputIterator output) -{ +{ if(!std::is_sorted(exec, first, last)) { if constexpr (std::is_same_v::iterator_category(), std::random_access_iterator_tag>) @@ -677,7 +677,7 @@ namespace boost { namespace math { namespace statistics { template using enable_if_t = typename std::enable_if::type; -template::value_type, +template::value_type, enable_if_t::value, bool> = true> inline double mean(const ForwardIterator first, const ForwardIterator last) { @@ -685,14 +685,14 @@ inline double mean(const ForwardIterator first, const ForwardIterator last) return detail::mean_sequential_impl(first, last); } -template::value, bool> = true> inline double mean(const Container& c) { return mean(std::begin(c), std::end(c)); } -template::value_type, +template::value_type, enable_if_t::value, bool> = true> inline Real mean(const ForwardIterator first, const ForwardIterator last) { @@ -700,28 +700,28 @@ inline Real mean(const ForwardIterator first, const ForwardIterator last) return detail::mean_sequential_impl(first, last); } -template::value, bool> = true> inline Real mean(const Container& c) { return mean(std::begin(c), std::end(c)); } -template::value_type, +template::value_type, enable_if_t::value, bool> = true> inline double variance(const ForwardIterator first, const ForwardIterator last) { return std::get<2>(detail::variance_sequential_impl>(first, last)); } -template::value, bool> = true> inline double variance(const Container& c) { return variance(std::begin(c), std::end(c)); } -template::value_type, +template::value_type, enable_if_t::value, bool> = true> inline Real variance(const ForwardIterator first, const ForwardIterator last) { @@ -729,14 +729,14 @@ inline Real variance(const ForwardIterator first, const ForwardIterator last) } -template::value, bool> = true> inline Real variance(const Container& c) { return variance(std::begin(c), std::end(c)); } -template::value_type, +template::value_type, enable_if_t::value, bool> = true> inline double sample_variance(const ForwardIterator first, const ForwardIterator last) { @@ -745,14 +745,14 @@ inline double sample_variance(const ForwardIterator first, const ForwardIterator return n*variance(first, last)/(n-1); } -template::value, bool> = true> inline double sample_variance(const Container& c) { return sample_variance(std::begin(c), std::end(c)); } -template::value_type, +template::value_type, enable_if_t::value, bool> = true> inline Real sample_variance(const ForwardIterator first, const ForwardIterator last) { @@ -761,14 +761,14 @@ inline Real sample_variance(const ForwardIterator first, const ForwardIterator l return n*variance(first, last)/(n-1); } -template::value, bool> = true> inline Real sample_variance(const Container& c) { return sample_variance(std::begin(c), std::end(c)); } -template::value_type, +template::value_type, enable_if_t::value, bool> = true> inline std::pair mean_and_sample_variance(const ForwardIterator first, const ForwardIterator last) { @@ -776,14 +776,14 @@ inline std::pair mean_and_sample_variance(const ForwardIterator return std::make_pair(std::get<0>(results), std::get<3>(results)*std::get<2>(results)/(std::get<3>(results)-1.0)); } -template::value, bool> = true> inline std::pair mean_and_sample_variance(const Container& c) { return mean_and_sample_variance(std::begin(c), std::end(c)); } -template::value_type, +template::value_type, enable_if_t::value, bool> = true> inline std::pair mean_and_sample_variance(const ForwardIterator first, const ForwardIterator last) { @@ -791,74 +791,74 @@ inline std::pair mean_and_sample_variance(const ForwardIterator firs return std::make_pair(std::get<0>(results), std::get<3>(results)*std::get<2>(results)/(std::get<3>(results)-Real(1))); } -template::value, bool> = true> inline std::pair mean_and_sample_variance(const Container& c) { return mean_and_sample_variance(std::begin(c), std::end(c)); } -template::value_type, +template::value_type, enable_if_t::value, bool> = true> inline std::tuple first_four_moments(const ForwardIterator first, const ForwardIterator last) { - const auto results = detail::first_four_moments_sequential_impl>(first, last); - return std::make_tuple(std::get<0>(results), std::get<1>(results) / std::get<4>(results), std::get<2>(results) / std::get<4>(results), + const auto results = detail::first_four_moments_sequential_impl>(first, last); + return std::make_tuple(std::get<0>(results), std::get<1>(results) / std::get<4>(results), std::get<2>(results) / std::get<4>(results), std::get<3>(results) / std::get<4>(results)); } -template::value, bool> = true> inline std::tuple first_four_moments(const Container& c) { return first_four_moments(std::begin(c), std::end(c)); } -template::value_type, +template::value_type, enable_if_t::value, bool> = true> inline std::tuple first_four_moments(const ForwardIterator first, const ForwardIterator last) { const auto results = detail::first_four_moments_sequential_impl>(first, last); - return std::make_tuple(std::get<0>(results), std::get<1>(results) / std::get<4>(results), std::get<2>(results) / std::get<4>(results), + return std::make_tuple(std::get<0>(results), std::get<1>(results) / std::get<4>(results), std::get<2>(results) / std::get<4>(results), std::get<3>(results) / std::get<4>(results)); } -template::value, bool> = true> inline std::tuple first_four_moments(const Container& c) { return first_four_moments(std::begin(c), std::end(c)); } -template::value_type, +template::value_type, enable_if_t::value, bool> = true> inline double skewness(const ForwardIterator first, const ForwardIterator last) { return detail::skewness_sequential_impl(first, last); } -template::value, bool> = true> inline double skewness(const Container& c) { return skewness(std::begin(c), std::end(c)); } -template::value_type, +template::value_type, enable_if_t::value, bool> = true> inline Real skewness(const ForwardIterator first, const ForwardIterator last) { return detail::skewness_sequential_impl(first, last); } -template::value, bool> = true> inline Real skewness(const Container& c) { return skewness(std::begin(c), std::end(c)); } -template::value_type, +template::value_type, enable_if_t::value, bool> = true> inline double kurtosis(const ForwardIterator first, const ForwardIterator last) { @@ -874,19 +874,19 @@ inline double kurtosis(const ForwardIterator first, const ForwardIterator last) } } -template::value, bool> = true> inline double kurtosis(const Container& c) { return kurtosis(std::begin(c), std::end(c)); } -template::value_type, +template::value_type, enable_if_t::value, bool> = true> inline Real kurtosis(const ForwardIterator first, const ForwardIterator last) { std::tuple M = first_four_moments(first, last); - + if(std::get<1>(M) == 0) { return std::get<1>(M); @@ -897,35 +897,35 @@ inline Real kurtosis(const ForwardIterator first, const ForwardIterator last) } } -template::value, bool> = true> inline Real kurtosis(const Container& c) { return kurtosis(std::begin(c), std::end(c)); } -template::value_type, +template::value_type, enable_if_t::value, bool> = true> inline double excess_kurtosis(const ForwardIterator first, const ForwardIterator last) { return kurtosis(first, last) - 3; } -template::value, bool> = true> inline double excess_kurtosis(const Container& c) { return excess_kurtosis(std::begin(c), std::end(c)); } -template::value_type, +template::value_type, enable_if_t::value, bool> = true> inline Real excess_kurtosis(const ForwardIterator first, const ForwardIterator last) { return kurtosis(first, last) - 3; } -template::value, bool> = true> inline Real excess_kurtosis(const Container& c) { @@ -958,7 +958,7 @@ inline Real median(RandomAccessContainer& c) return median(std::begin(c), std::end(c)); } -template::value_type, +template::value_type, enable_if_t::value, bool> = true> inline double gini_coefficient(RandomAccessIterator first, RandomAccessIterator last) { @@ -970,14 +970,14 @@ inline double gini_coefficient(RandomAccessIterator first, RandomAccessIterator return detail::gini_coefficient_sequential_impl(first, last); } -template::value, bool> = true> inline double gini_coefficient(RandomAccessContainer& c) { return gini_coefficient(std::begin(c), std::end(c)); } -template::value_type, +template::value_type, enable_if_t::value, bool> = true> inline Real gini_coefficient(RandomAccessIterator first, RandomAccessIterator last) { @@ -989,14 +989,14 @@ inline Real gini_coefficient(RandomAccessIterator first, RandomAccessIterator la return detail::gini_coefficient_sequential_impl(first, last); } -template::value, bool> = true> inline Real gini_coefficient(RandomAccessContainer& c) { return gini_coefficient(std::begin(c), std::end(c)); } -template::value_type, +template::value_type, enable_if_t::value, bool> = true> inline double sample_gini_coefficient(RandomAccessIterator first, RandomAccessIterator last) { @@ -1004,14 +1004,14 @@ inline double sample_gini_coefficient(RandomAccessIterator first, RandomAccessIt return n*gini_coefficient(first, last)/(n-1); } -template::value, bool> = true> inline double sample_gini_coefficient(RandomAccessContainer& c) { return sample_gini_coefficient(std::begin(c), std::end(c)); } -template::value_type, +template::value_type, enable_if_t::value, bool> = true> inline Real sample_gini_coefficient(RandomAccessIterator first, RandomAccessIterator last) { @@ -1019,7 +1019,7 @@ inline Real sample_gini_coefficient(RandomAccessIterator first, RandomAccessIter return n*gini_coefficient(first, last)/(n-1); } -template::value, bool> = true> inline Real sample_gini_coefficient(RandomAccessContainer& c) { @@ -1083,8 +1083,8 @@ Real interquartile_range(ForwardIterator first, ForwardIterator last) std::nth_element(q1, q3, last); Real Q3 = *q3; return Q3 - Q1; - } - else + } + else { // j == 0 or j==1: auto q1 = first + k - 1; @@ -1109,10 +1109,10 @@ Real interquartile_range(Container& c) return interquartile_range(std::begin(c), std::end(c)); } -template::iterator_category(), std::random_access_iterator_tag>::value, bool> = true> inline OutputIterator mode(ForwardIterator first, ForwardIterator last, OutputIterator output) -{ +{ if(!std::is_sorted(first, last)) { std::sort(first, last); @@ -1121,10 +1121,10 @@ inline OutputIterator mode(ForwardIterator first, ForwardIterator last, OutputIt return detail::mode_impl(first, last, output); } -template::iterator_category(), std::random_access_iterator_tag>::value, bool> = true> inline OutputIterator mode(ForwardIterator first, ForwardIterator last, OutputIterator output) -{ +{ if(!std::is_sorted(first, last)) { BOOST_MATH_ASSERT("Data must be sorted for mode calculation"); diff --git a/include/boost/math/tools/norms.hpp b/include/boost/math/tools/norms.hpp index 7ed1598f95..073ad80cfa 100644 --- a/include/boost/math/tools/norms.hpp +++ b/include/boost/math/tools/norms.hpp @@ -332,7 +332,7 @@ auto lp_norm(ForwardIterator first, ForwardIterator last, unsigned p) double tmp = *it; lp += pow(abs(tmp), p); } - double result = pow(lp, 1.0/double(p)); + double result = pow(lp, 1.0/static_cast(p)); if (!isfinite(result)) { double a = boost::math::tools::sup_norm(first, last); @@ -342,7 +342,7 @@ auto lp_norm(ForwardIterator first, ForwardIterator last, unsigned p) double tmp = *it; lp += pow(abs(tmp)/a, p); } - result = a*pow(lp, double(1)/double(p)); + result = a*pow(lp, static_cast(1)/static_cast(p)); } return result; } @@ -400,7 +400,7 @@ auto lp_distance(ForwardIterator first1, ForwardIterator last1, ForwardIterator //double tmp = *it1++ - *it2++; dist += pow(abs(tmp1 - tmp2), p); } - return pow(dist, 1.0/double(p)); + return pow(dist, 1.0/static_cast(p)); } } diff --git a/include/boost/math/tools/precision.hpp b/include/boost/math/tools/precision.hpp index 5262185386..fb3049995c 100644 --- a/include/boost/math/tools/precision.hpp +++ b/include/boost/math/tools/precision.hpp @@ -41,7 +41,7 @@ inline constexpr int digits(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(T)) noexcept static_assert( ::std::numeric_limits::is_specialized, "Type T must be specialized"); static_assert( ::std::numeric_limits::radix == 2 || ::std::numeric_limits::radix == 10, "Type T must have a radix of 2 or 10"); - return std::numeric_limits::radix == 2 + return std::numeric_limits::radix == 2 ? std::numeric_limits::digits : ((std::numeric_limits::digits + 1) * 1000L) / 301L; } @@ -372,19 +372,19 @@ struct root_epsilon_traits template inline constexpr T root_epsilon() noexcept(std::is_floating_point::value && detail::root_epsilon_traits::has_noexcept) { - return detail::root_epsilon_imp(static_cast(0), typename detail::root_epsilon_traits::tag_type()); + return detail::root_epsilon_imp(static_cast(nullptr), typename detail::root_epsilon_traits::tag_type()); } template inline constexpr T cbrt_epsilon() noexcept(std::is_floating_point::value && detail::root_epsilon_traits::has_noexcept) { - return detail::cbrt_epsilon_imp(static_cast(0), typename detail::root_epsilon_traits::tag_type()); + return detail::cbrt_epsilon_imp(static_cast(nullptr), typename detail::root_epsilon_traits::tag_type()); } template inline constexpr T forth_root_epsilon() noexcept(std::is_floating_point::value && detail::root_epsilon_traits::has_noexcept) { - return detail::forth_root_epsilon_imp(static_cast(0), typename detail::root_epsilon_traits::tag_type()); + return detail::forth_root_epsilon_imp(static_cast(nullptr), typename detail::root_epsilon_traits::tag_type()); } } // namespace tools diff --git a/include/boost/math/tools/rational.hpp b/include/boost/math/tools/rational.hpp index d61ea8a76a..727720b2c0 100644 --- a/include/boost/math/tools/rational.hpp +++ b/include/boost/math/tools/rational.hpp @@ -205,14 +205,14 @@ template inline V evaluate_polynomial(const T(&a)[N], const V& val) BOOST_MATH_NOEXCEPT(V) { typedef std::integral_constant tag_type; - return detail::evaluate_polynomial_c_imp(static_cast(a), val, static_cast(0)); + return detail::evaluate_polynomial_c_imp(static_cast(a), val, static_cast(nullptr)); } template inline V evaluate_polynomial(const std::array& a, const V& val) BOOST_MATH_NOEXCEPT(V) { typedef std::integral_constant tag_type; - return detail::evaluate_polynomial_c_imp(static_cast(a.data()), val, static_cast(0)); + return detail::evaluate_polynomial_c_imp(static_cast(a.data()), val, static_cast(nullptr)); } // // Even polynomials are trivial: just square the argument! @@ -247,14 +247,14 @@ template inline V evaluate_odd_polynomial(const T(&a)[N], const V& z) BOOST_MATH_NOEXCEPT(V) { typedef std::integral_constant tag_type; - return a[0] + z * detail::evaluate_polynomial_c_imp(static_cast(a) + 1, V(z*z), static_cast(0)); + return a[0] + z * detail::evaluate_polynomial_c_imp(static_cast(a) + 1, V(z*z), static_cast(nullptr)); } template inline V evaluate_odd_polynomial(const std::array& a, const V& z) BOOST_MATH_NOEXCEPT(V) { typedef std::integral_constant tag_type; - return a[0] + z * detail::evaluate_polynomial_c_imp(static_cast(a.data()) + 1, V(z*z), static_cast(0)); + return a[0] + z * detail::evaluate_polynomial_c_imp(static_cast(a.data()) + 1, V(z*z), static_cast(nullptr)); } template @@ -313,13 +313,13 @@ V evaluate_rational(const T* num, const U* denom, const V& z_, std::size_t count template inline V evaluate_rational(const T(&a)[N], const U(&b)[N], const V& z) BOOST_MATH_NOEXCEPT(V) { - return detail::evaluate_rational_c_imp(a, b, z, static_cast*>(0)); + return detail::evaluate_rational_c_imp(a, b, z, static_cast*>(nullptr)); } template inline V evaluate_rational(const std::array& a, const std::array& b, const V& z) BOOST_MATH_NOEXCEPT(V) { - return detail::evaluate_rational_c_imp(a.data(), b.data(), z, static_cast*>(0)); + return detail::evaluate_rational_c_imp(a.data(), b.data(), z, static_cast*>(nullptr)); } } // namespace tools diff --git a/include/boost/math/tools/recurrence.hpp b/include/boost/math/tools/recurrence.hpp index 0f5fa04b78..519941be9f 100644 --- a/include/boost/math/tools/recurrence.hpp +++ b/include/boost/math/tools/recurrence.hpp @@ -139,7 +139,7 @@ namespace boost { // second: w(0); // template - inline T apply_recurrence_relation_forward(const NextCoefs& get_coefs, unsigned number_of_steps, T first, T second, long long* log_scaling = 0, T* previous = 0) + inline T apply_recurrence_relation_forward(const NextCoefs& get_coefs, unsigned number_of_steps, T first, T second, long long* log_scaling = nullptr, T* previous = nullptr) { BOOST_MATH_STD_USING using std::tuple; @@ -195,7 +195,7 @@ namespace boost { // second: w(0); // template - inline T apply_recurrence_relation_backward(const NextCoefs& get_coefs, unsigned number_of_steps, T first, T second, long long* log_scaling = 0, T* previous = 0) + inline T apply_recurrence_relation_backward(const NextCoefs& get_coefs, unsigned number_of_steps, T first, T second, long long* log_scaling = nullptr, T* previous = nullptr) { BOOST_MATH_STD_USING using std::tuple; @@ -209,7 +209,7 @@ namespace boost { { tie(a, b, c) = get_coefs(-static_cast(k)); - if ((log_scaling) && + if ((log_scaling) && ( (fabs(tools::max_value() * (a / b) / 2048) < fabs(second)) || (fabs(tools::max_value() * (a / c) / 2048) < fabs(first)) || (fabs(tools::min_value() * (a / b) * 2048) > fabs(second)) diff --git a/include/boost/math/tools/ulps_plot.hpp b/include/boost/math/tools/ulps_plot.hpp index 248828f2c0..0039a0d5a6 100644 --- a/include/boost/math/tools/ulps_plot.hpp +++ b/include/boost/math/tools/ulps_plot.hpp @@ -154,7 +154,7 @@ class ulps_plot { } } - int height = static_cast(floor(double(plot.width_)/1.61803)); + int height = static_cast(floor(static_cast(plot.width_)/1.61803)); int margin_top = 40; int margin_left = 25; if (plot.title_.size() == 0) @@ -509,7 +509,7 @@ ulps_plot::ulps_plot(F hi_acc_impl, CoarseReal a, Co static_assert(std::numeric_limits::digits10 <= std::numeric_limits::digits10, "Standalone mode does not support types with precision that exceeds long double"); std::uniform_real_distribution dis(static_cast(a), static_cast(b)); #endif - + precise_abscissas_.resize(samples); coarse_abscissas_.resize(samples); diff --git a/include/boost/math/tools/univariate_statistics.hpp b/include/boost/math/tools/univariate_statistics.hpp index 6f8fe882bc..36f9d44fcf 100644 --- a/include/boost/math/tools/univariate_statistics.hpp +++ b/include/boost/math/tools/univariate_statistics.hpp @@ -169,7 +169,7 @@ auto skewness(ForwardIterator first, ForwardIterator last) { // The limit is technically undefined, but the interpretation here is clear: // A constant dataset has no skewness. - return double(0); + return static_cast(0); } double skew = M3/(M2*sqrt(var)); return skew; @@ -345,7 +345,7 @@ auto gini_coefficient(RandomAccessIterator first, RandomAccessIterator last) // If the l1 norm is zero, all elements are zero, so every element is the same. if (denom == 0) { - return double(0); + return static_cast(0); } return ((2*num)/denom - i)/(i-1); diff --git a/include_private/boost/math/tools/test.hpp b/include_private/boost/math/tools/test.hpp index f71270a538..6330828091 100644 --- a/include_private/boost/math/tools/test.hpp +++ b/include_private/boost/math/tools/test.hpp @@ -304,7 +304,7 @@ void test_check_throw(Val v, boost::math::rounding_error const*) // but to keep things simple we really need it somewhere that's always included: // #ifdef BOOST_NO_EXCEPTIONS -# define BOOST_MATH_CHECK_THROW(x, ExceptionType) boost::math::tools::test_check_throw(x, static_cast(0)); +# define BOOST_MATH_CHECK_THROW(x, ExceptionType) boost::math::tools::test_check_throw(x, static_cast(nullptr)); #else # define BOOST_MATH_CHECK_THROW(x, y) BOOST_CHECK_THROW(x, y) #endif