Skip to content
Open
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
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ target_link_libraries(boost_graph
Boost::integer
Boost::iterator
Boost::lexical_cast
Boost::math
Boost::mpl
Boost::multi_index
Boost::multiprecision
Expand Down
1 change: 0 additions & 1 deletion build.jam
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ constant boost_dependencies :
/boost/integer//boost_integer
/boost/iterator//boost_iterator
/boost/lexical_cast//boost_lexical_cast
/boost/math//boost_math_tr1
/boost/mpl//boost_mpl
/boost/multi_index//boost_multi_index
/boost/multiprecision//boost_multiprecision
Expand Down
3 changes: 1 addition & 2 deletions include/boost/graph/circle_layout.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#ifndef BOOST_GRAPH_CIRCLE_LAYOUT_HPP
#define BOOST_GRAPH_CIRCLE_LAYOUT_HPP
#include <boost/config/no_tr1/cmath.hpp>
#include <boost/math/constants/constants.hpp>
#include <boost/graph/graph_traits.hpp>
#include <boost/graph/iteration_macros.hpp>
#include <boost/graph/topology.hpp>
Expand All @@ -34,7 +33,7 @@ void circle_graph_layout(
{
BOOST_STATIC_ASSERT(
property_traits< PositionMap >::value_type::dimensions >= 2);
const double pi = boost::math::constants::pi< double >();
const double pi = 3.14159265358979323846;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

out of curiosity: any reason for not using https://en.cppreference.com/cpp/numeric/constants ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are C++20 😭😭😭
But yeah that was my hope too 😄 this std::numbers lib is dope ! Too bad it arrives so late !


#ifndef BOOST_NO_STDC_NAMESPACE
using std::cos;
Expand Down
37 changes: 19 additions & 18 deletions include/boost/graph/topology.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
#include <boost/algorithm/minmax.hpp>
#include <boost/config.hpp> // For BOOST_STATIC_CONSTANT
#include <boost/config/no_tr1/cmath.hpp>
#include <boost/math/constants/constants.hpp> // For root_two
#include <boost/math/special_functions/hypot.hpp>
#include <cmath>
#include <boost/random/uniform_01.hpp>
#include <boost/random/linear_congruential.hpp>
#include <boost/shared_ptr.hpp>
Expand Down Expand Up @@ -155,7 +154,7 @@ template < std::size_t Dims > class convex_topology
for (std::size_t i = 0; i < Dims; ++i)
{
double diff = b[i] - a[i];
dist = boost::math::hypot(dist, diff);
dist = std::hypot(dist, diff);
}
// Exact properties of the distance are not important, as long as
// < on what this returns matches real distances; l_2 is used because
Expand Down Expand Up @@ -209,7 +208,7 @@ template < std::size_t Dims > class convex_topology
{
double n = 0.;
for (std::size_t i = 0; i < Dims; ++i)
n = boost::math::hypot(n, delta[i]);
n = std::hypot(n, delta[i]);
return n;
}

Expand Down Expand Up @@ -476,7 +475,7 @@ class ball_topology : public convex_topology< Dims >
BOOST_USING_STD_MAX();
double r = 0.;
for (std::size_t i = 0; i < Dims; ++i)
r = boost::math::hypot(r, a[i]);
r = std::hypot(r, a[i]);
if (r <= radius)
return a;
double scaling_factor = radius / r;
Expand All @@ -490,7 +489,7 @@ class ball_topology : public convex_topology< Dims >
{
double r = 0.;
for (std::size_t i = 0; i < Dims; ++i)
r = boost::math::hypot(r, a[i]);
r = std::hypot(r, a[i]);
return radius - r;
}

Expand Down Expand Up @@ -560,6 +559,8 @@ template < typename RandomNumberGenerator = minstd_rand > class heart_topology
// Circle centered at (500, -500) radius 500*sqrt(2)
// Bounding box (-1000, -2000) - (1000, 500*(sqrt(2) - 1))

static constexpr double root_two = 1.41421356237309504880; // sqrt(2)

struct point
{
point()
Expand Down Expand Up @@ -590,11 +591,11 @@ template < typename RandomNumberGenerator = minstd_rand > class heart_topology
return false; // Bottom
if (p[1] <= -1000)
return true; // Diagonal of square
if (boost::math::hypot(p[0] - -500, p[1] - -500)
<= 500. * boost::math::constants::root_two< double >())
if (std::hypot(p[0] - -500, p[1] - -500)
<= 500. * root_two)
return true; // Left circle
if (boost::math::hypot(p[0] - 500, p[1] - -500)
<= 500. * boost::math::constants::root_two< double >())
if (std::hypot(p[0] - 500, p[1] - -500)
<= 500. * root_two)
return true; // Right circle
return false;
}
Expand Down Expand Up @@ -635,12 +636,12 @@ template < typename RandomNumberGenerator = minstd_rand > class heart_topology
{
result[0] = (*rand)()
* (1000
+ 1000 * boost::math::constants::root_two< double >())
- (500 + 500 * boost::math::constants::root_two< double >());
+ 1000 * root_two)
- (500 + 500 * root_two);
result[1] = (*rand)()
* (2000
+ 500
* (boost::math::constants::root_two< double >()
* (root_two
- 1))
- 2000;
} while (!in_heart(result));
Expand All @@ -655,13 +656,13 @@ template < typename RandomNumberGenerator = minstd_rand > class heart_topology
if (segment_within_heart(a, b))
{
// Straight line
return boost::math::hypot(b[0] - a[0], b[1] - a[1]);
return std::hypot(b[0] - a[0], b[1] - a[1]);
}
else
{
// Straight line bending around (0, 0)
return boost::math::hypot(a[0], a[1])
+ boost::math::hypot(b[0], b[1]);
return std::hypot(a[0], a[1])
+ std::hypot(b[0], b[1]);
}
}

Expand All @@ -675,8 +676,8 @@ template < typename RandomNumberGenerator = minstd_rand > class heart_topology
}
else
{
double distance_to_point_a = boost::math::hypot(a[0], a[1]);
double distance_to_point_b = boost::math::hypot(b[0], b[1]);
double distance_to_point_a = std::hypot(a[0], a[1]);
double distance_to_point_b = std::hypot(b[0], b[1]);
double location_of_point = distance_to_point_a
/ (distance_to_point_a + distance_to_point_b);
if (fraction < location_of_point)
Expand Down
Loading