From d2a42e9501c73099f2261fc90574a42a08d3c909 Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Sun, 3 Jul 2022 17:36:23 -0700 Subject: [PATCH] Change implicit type conversion to explicit --- .../boost/math/distributions/skew_normal.hpp | 58 +++++++++---------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/include/boost/math/distributions/skew_normal.hpp b/include/boost/math/distributions/skew_normal.hpp index 8da751b0b..646965995 100644 --- a/include/boost/math/distributions/skew_normal.hpp +++ b/include/boost/math/distributions/skew_normal.hpp @@ -70,17 +70,17 @@ namespace boost{ namespace math{ } RealType location()const - { + { return location_; } RealType scale()const - { + { return scale_; } RealType shape()const - { + { return shape_; } @@ -110,7 +110,7 @@ namespace boost{ namespace math{ { // Range of permissible values for random variable x. using boost::math::tools::max_value; return std::pair( - std::numeric_limits::has_infinity ? -std::numeric_limits::infinity() : -max_value(), + std::numeric_limits::has_infinity ? -std::numeric_limits::infinity() : -max_value(), std::numeric_limits::has_infinity ? std::numeric_limits::infinity() : max_value()); // - to + max value. } @@ -310,7 +310,7 @@ namespace boost{ namespace math{ /* TODO No closed expression for mode, so use max of pdf. */ - + template inline RealType mode_fallback(const skew_normal_distribution& dist) { // mode. @@ -318,7 +318,7 @@ namespace boost{ namespace math{ const RealType scale = dist.scale(); const RealType location = dist.location(); const RealType shape = dist.shape(); - + RealType result; if(!detail::check_scale( function, @@ -343,7 +343,7 @@ namespace boost{ namespace math{ result = location-scale*result; return result; } - + BOOST_MATH_STD_USING // 21 elements @@ -398,9 +398,9 @@ namespace boost{ namespace math{ const RealType* result_ptr = std::lower_bound(shapes, shapes+21, shape); typedef typename std::iterator_traits::difference_type diff_type; - + const diff_type d = std::distance(shapes, result_ptr); - + BOOST_MATH_ASSERT(d > static_cast(0)); // refine @@ -416,21 +416,21 @@ namespace boost{ namespace math{ } skew_normal_distribution helper(0, 1, shape); - + result = detail::generic_find_mode_01(helper, result, function); - + result = result*scale + location; - + return result; } // mode_fallback - - + + /* * TODO No closed expression for mode, so use f'(x) = 0 */ template struct skew_normal_mode_functor - { + { skew_normal_mode_functor(const boost::math::skew_normal_distribution dist) : distribution(dist) { @@ -451,9 +451,9 @@ namespace boost{ namespace math{ private: const boost::math::skew_normal_distribution distribution; }; - + } // namespace detail - + template inline RealType mode(const skew_normal_distribution& dist) { @@ -537,9 +537,9 @@ namespace boost{ namespace math{ const RealType* result_ptr = std::lower_bound(shapes, shapes+21, shape); typedef typename std::iterator_traits::difference_type diff_type; - + const diff_type d = std::distance(shapes, result_ptr); - + BOOST_MATH_ASSERT(d > static_cast(0)); // TODO: make the search bounds smarter, depending on the shape parameter @@ -559,22 +559,22 @@ namespace boost{ namespace math{ result = 1e-4f; search_max = guess[19]; // set 19 instead of 20 to have a safety margin because the table may not be exact @ shape=100 } - - const int get_digits = policies::digits();// get digits from policy, + + const int get_digits = policies::digits();// get digits from policy, std::uintmax_t m = policies::get_max_root_iterations(); // and max iterations. skew_normal_distribution helper(0, 1, shape); result = tools::newton_raphson_iterate(detail::skew_normal_mode_functor(helper), result, search_min, search_max, get_digits, m); - + result = result*scale + location; return result; } - - + + template inline RealType skewness(const skew_normal_distribution& dist) { @@ -584,8 +584,8 @@ namespace boost{ namespace math{ static const RealType factor = four_minus_pi()/static_cast(2); const RealType delta = dist.shape() / sqrt(static_cast(1)+dist.shape()*dist.shape()); - return factor * pow(root_two_div_pi() * delta, 3) / - pow(static_cast(1)-two_div_pi()*delta*delta, static_cast(1.5)); + return static_cast(factor * pow(root_two_div_pi() * delta, 3) / + pow(static_cast(1)-two_div_pi()*delta*delta, static_cast(1.5))); } template @@ -614,7 +614,7 @@ namespace boost{ namespace math{ template struct skew_normal_quantile_functor - { + { skew_normal_quantile_functor(const boost::math::skew_normal_distribution dist, RealType const& p) : distribution(dist), prob(p) { @@ -630,7 +630,7 @@ namespace boost{ namespace math{ } private: const boost::math::skew_normal_distribution distribution; - RealType prob; + RealType prob; }; } // namespace detail @@ -679,7 +679,7 @@ namespace boost{ namespace math{ const RealType search_min = range(dist).first; const RealType search_max = range(dist).second; - const int get_digits = policies::digits();// get digits from policy, + const int get_digits = policies::digits();// get digits from policy, std::uintmax_t m = policies::get_max_root_iterations(); // and max iterations. result = tools::newton_raphson_iterate(detail::skew_normal_quantile_functor(dist, p), result,