Get rid of boost::math::constants::* and M_PI in favor of std::numbers (#6916)

This commit is contained in:
Siarhei Fedartsou
2024-05-30 19:40:56 +02:00
committed by GitHub
parent a9b1bd88d3
commit fb9d1cefcc
13 changed files with 35 additions and 48 deletions
@@ -6,7 +6,7 @@
#include <utility>
#include <vector>
#include <boost/math/constants/constants.hpp>
#include <numbers>
namespace osrm::engine::map_matching
{
@@ -21,10 +21,8 @@ struct NormalDistribution
// FIXME implement log-probability version since it's faster
double Density(const double val) const
{
using namespace boost::math::constants;
const double x = val - mean;
return 1.0 / (std::sqrt(two_pi<double>()) * standard_deviation) *
return 1.0 / (std::sqrt(2 * std::numbers::pi) * standard_deviation) *
std::exp(-x * x / (standard_deviation * standard_deviation));
}
@@ -4,7 +4,7 @@
#include "util/integer_range.hpp"
#include <boost/assert.hpp>
#include <boost/math/constants/constants.hpp>
#include <numbers>
#include <cmath>
@@ -14,7 +14,7 @@
namespace osrm::engine::map_matching
{
static const double log_2_pi = std::log(2. * boost::math::constants::pi<double>());
static const double log_2_pi = std::log(2. * std::numbers::pi);
static const double IMPOSSIBLE_LOG_PROB = -std::numeric_limits<double>::infinity();
static const double MINIMAL_LOG_PROB = std::numeric_limits<double>::lowest();
static const std::size_t INVALID_STATE = std::numeric_limits<std::size_t>::max();
@@ -2,7 +2,7 @@
#define ENGINE_MAP_MATCHING_CONFIDENCE_HPP
#include "engine/map_matching/bayes_classifier.hpp"
#include <boost/assert.hpp>
#include <cmath>
namespace osrm::engine::map_matching