Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More C-Style Cast Removal #746

Merged
merged 1 commit into from
Jan 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ void barycentric_rational_imp<Real>::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<int64_t>(approximation_order), static_cast<int64_t>(0));
int64_t i_max = k;
if (k >= n - (std::ptrdiff_t)approximation_order)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void vector_barycentric_rational_imp<TimeContainer, SpaceContainer>::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<int64_t>(approximation_order), static_cast<int64_t>(0));
int64_t i_max = k;
if (k >= n - (std::ptrdiff_t)approximation_order)
{
Expand Down
2 changes: 1 addition & 1 deletion include/boost/math/quadrature/naive_monte_carlo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ class naive_monte_carlo
RandomNumberGenerator gen(seed);
Real inv_denom = 1/static_cast<Real>(((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<uint64_t>(1));
m_thread_calls.reset(new std::atomic<uint64_t>[threads]);
m_thread_Ss.reset(new std::atomic<Real>[threads]);
m_thread_averages.reset(new std::atomic<Real>[threads]);
Expand Down
8 changes: 4 additions & 4 deletions include/boost/math/special_functions/daubechies_scaling.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ std::vector<Real> daubechies_scaling_dyadic_grid(int64_t j_max)
std::vector<Real> v(2*p + (2*p-1)*((1<<j_max) -1), std::numeric_limits<Real>::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<int64_t>(phik.size()); ++i) {
v[i*(1uLL<<j_max)] = phik[i];
}

Expand All @@ -58,19 +58,19 @@ std::vector<Real> 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<int64_t>(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<int64_t>(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<int64_t>(v.size()))
{
term += c[l]*v[idx];
}
Expand Down
12 changes: 6 additions & 6 deletions include/boost/math/special_functions/detail/fp_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,11 +260,11 @@ template<> struct fp_traits_non_native<double, double_precision>
{
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<uint64_t>(0x80000000u) << 32;
static constexpr uint64_t exponent = static_cast<uint64_t>(0x7ff00000) << 32;
static constexpr uint64_t flag = 0;
static constexpr uint64_t significand
= (((uint64_t)0x000fffff) << 32) + ((uint64_t)0xffffffffu);
= (static_cast<uint64_t>(0x000fffff) << 32) + static_cast<uint64_t>(0xffffffffu);

typedef uint64_t bits;
static void get_bits(double x, uint64_t& a) { std::memcpy(&a, &x, 8); }
Expand Down Expand Up @@ -313,11 +313,11 @@ template<> struct fp_traits_non_native<long double, double_precision>
{
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<uint64_t>(0x80000000u) << 32;
static const uint64_t exponent = static_cast<uint64_t>(0x7ff00000) << 32;
static const uint64_t flag = 0;
static const uint64_t significand
= ((uint64_t)0x000fffff << 32) + (uint64_t)0xffffffffu;
= (static_cast<uint64_t>(0x000fffff) << 32) + static_cast<uint64_t>(0xffffffffu);

typedef uint64_t bits;
static void get_bits(long double x, uint64_t& a) { std::memcpy(&a, &x, 8); }
Expand Down
2 changes: 1 addition & 1 deletion reporting/performance/test_distributions_mode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int64_t> lefts) {
for (const long double &left: lefts) {
b->Args({(int64_t)left, (int64_t)(left/left_div_right)});
b->Args({static_cast<int64_t>(left), static_cast<int64_t>((left/left_div_right))});
}
}

Expand Down