From c8c1feb5c57989335b2bce291e1dec6c9317a1a0 Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Fri, 21 Jan 2022 22:24:54 +0200 Subject: [PATCH] More C-Style Cast Removal --- .../detail/barycentric_rational_detail.hpp | 2 +- .../detail/vector_barycentric_rational_detail.hpp | 2 +- include/boost/math/quadrature/naive_monte_carlo.hpp | 2 +- .../math/special_functions/daubechies_scaling.hpp | 8 ++++---- .../math/special_functions/detail/fp_traits.hpp | 12 ++++++------ reporting/performance/test_distributions_mode.cpp | 2 +- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/include/boost/math/interpolators/detail/barycentric_rational_detail.hpp b/include/boost/math/interpolators/detail/barycentric_rational_detail.hpp index 4da19d3b58..a363e1861b 100644 --- a/include/boost/math/interpolators/detail/barycentric_rational_detail.hpp +++ b/include/boost/math/interpolators/detail/barycentric_rational_detail.hpp @@ -104,7 +104,7 @@ void barycentric_rational_imp::calculate_weights(size_t approximation_orde m_w.resize(n, 0); for(int64_t k = 0; k < n; ++k) { - int64_t i_min = (std::max)(k - (int64_t) approximation_order, (int64_t) 0); + int64_t i_min = (std::max)(k - static_cast(approximation_order), static_cast(0)); int64_t i_max = k; if (k >= n - (std::ptrdiff_t)approximation_order) { diff --git a/include/boost/math/interpolators/detail/vector_barycentric_rational_detail.hpp b/include/boost/math/interpolators/detail/vector_barycentric_rational_detail.hpp index 81fd2bde31..f4650784bf 100644 --- a/include/boost/math/interpolators/detail/vector_barycentric_rational_detail.hpp +++ b/include/boost/math/interpolators/detail/vector_barycentric_rational_detail.hpp @@ -68,7 +68,7 @@ void vector_barycentric_rational_imp::calculate_w w_.resize(n, Real(0)); for(int64_t k = 0; k < n; ++k) { - int64_t i_min = (std::max)(k - (int64_t) approximation_order, (int64_t) 0); + int64_t i_min = (std::max)(k - static_cast(approximation_order), static_cast(0)); int64_t i_max = k; if (k >= n - (std::ptrdiff_t)approximation_order) { diff --git a/include/boost/math/quadrature/naive_monte_carlo.hpp b/include/boost/math/quadrature/naive_monte_carlo.hpp index 807a01e1d7..a1fcfb3d28 100644 --- a/include/boost/math/quadrature/naive_monte_carlo.hpp +++ b/include/boost/math/quadrature/naive_monte_carlo.hpp @@ -163,7 +163,7 @@ class naive_monte_carlo RandomNumberGenerator gen(seed); Real inv_denom = 1/static_cast(((gen.max)()-(gen.min)())); - m_num_threads = (std::max)(m_num_threads, (uint64_t) 1); + m_num_threads = (std::max)(m_num_threads, static_cast(1)); m_thread_calls.reset(new std::atomic[threads]); m_thread_Ss.reset(new std::atomic[threads]); m_thread_averages.reset(new std::atomic[threads]); diff --git a/include/boost/math/special_functions/daubechies_scaling.hpp b/include/boost/math/special_functions/daubechies_scaling.hpp index 6493060ba6..9c10bc72cb 100644 --- a/include/boost/math/special_functions/daubechies_scaling.hpp +++ b/include/boost/math/special_functions/daubechies_scaling.hpp @@ -46,7 +46,7 @@ std::vector daubechies_scaling_dyadic_grid(int64_t j_max) std::vector v(2*p + (2*p-1)*((1<::quiet_NaN()); v[0] = 0; v[v.size()-1] = 0; - for (int64_t i = 0; i < (int64_t) phik.size(); ++i) { + for (int64_t i = 0; i < static_cast(phik.size()); ++i) { v[i*(1uLL< daubechies_scaling_dyadic_grid(int64_t j_max) // Where this value will go: int64_t delivery_idx = k*(1uLL << (j_max-j)); // This is a nice check, but we've tested this exhaustively, and it's an expensive check: - //if (delivery_idx >= (int64_t) v.size()) { + //if (delivery_idx >= static_cast(v.size())) { // std::cerr << "Delivery index out of range!\n"; // continue; //} Real term = 0; - for (int64_t l = 0; l < (int64_t) c.size(); ++l) + for (int64_t l = 0; l < static_cast(c.size()); ++l) { int64_t idx = k*(int64_t(1) << (j_max - j + 1)) - l*(int64_t(1) << j_max); if (idx < 0) { break; } - if (idx < (int64_t) v.size()) + if (idx < static_cast(v.size())) { term += c[l]*v[idx]; } diff --git a/include/boost/math/special_functions/detail/fp_traits.hpp b/include/boost/math/special_functions/detail/fp_traits.hpp index fcc3aab893..ee98bc51fc 100644 --- a/include/boost/math/special_functions/detail/fp_traits.hpp +++ b/include/boost/math/special_functions/detail/fp_traits.hpp @@ -260,11 +260,11 @@ template<> struct fp_traits_non_native { typedef ieee_copy_all_bits_tag method; - static constexpr uint64_t sign = ((uint64_t)0x80000000u) << 32; - static constexpr uint64_t exponent = ((uint64_t)0x7ff00000) << 32; + static constexpr uint64_t sign = static_cast(0x80000000u) << 32; + static constexpr uint64_t exponent = static_cast(0x7ff00000) << 32; static constexpr uint64_t flag = 0; static constexpr uint64_t significand - = (((uint64_t)0x000fffff) << 32) + ((uint64_t)0xffffffffu); + = (static_cast(0x000fffff) << 32) + static_cast(0xffffffffu); typedef uint64_t bits; static void get_bits(double x, uint64_t& a) { std::memcpy(&a, &x, 8); } @@ -313,11 +313,11 @@ template<> struct fp_traits_non_native { typedef ieee_copy_all_bits_tag method; - static const uint64_t sign = (uint64_t)0x80000000u << 32; - static const uint64_t exponent = (uint64_t)0x7ff00000 << 32; + static const uint64_t sign = static_cast(0x80000000u) << 32; + static const uint64_t exponent = static_cast(0x7ff00000) << 32; static const uint64_t flag = 0; static const uint64_t significand - = ((uint64_t)0x000fffff << 32) + (uint64_t)0xffffffffu; + = (static_cast(0x000fffff) << 32) + static_cast(0xffffffffu); typedef uint64_t bits; static void get_bits(long double x, uint64_t& a) { std::memcpy(&a, &x, 8); } diff --git a/reporting/performance/test_distributions_mode.cpp b/reporting/performance/test_distributions_mode.cpp index 5df744ffe7..0ae42f322b 100644 --- a/reporting/performance/test_distributions_mode.cpp +++ b/reporting/performance/test_distributions_mode.cpp @@ -38,7 +38,7 @@ void test_mode_2param(benchmark::State& state) static void fixed_ratio_2args(benchmark::internal::Benchmark* b, long double left_div_right, std::vector lefts) { for (const long double &left: lefts) { - b->Args({(int64_t)left, (int64_t)(left/left_div_right)}); + b->Args({static_cast(left), static_cast((left/left_div_right))}); } }