From e4151666280c0c80ec6a4bc84798d24179696bcf Mon Sep 17 00:00:00 2001 From: Felix von Drigalski Date: Wed, 10 Mar 2021 22:15:35 +0900 Subject: [PATCH 1/5] Update constants.hpp --- include/boost/math/constants/constants.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/include/boost/math/constants/constants.hpp b/include/boost/math/constants/constants.hpp index 9d2c9e503..665a976f6 100644 --- a/include/boost/math/constants/constants.hpp +++ b/include/boost/math/constants/constants.hpp @@ -261,6 +261,7 @@ namespace boost{ namespace math BOOST_DEFINE_MATH_CONSTANT(third_pi, 1.047197551196597746154214461093167628e+00, "1.04719755119659774615421446109316762806572313312503527365831486410260546876206966620934494178070568932738269550e+00") BOOST_DEFINE_MATH_CONSTANT(sixth_pi, 5.235987755982988730771072305465838140e-01, "5.23598775598298873077107230546583814032861566562517636829157432051302734381034833104672470890352844663691347752e-01") BOOST_DEFINE_MATH_CONSTANT(two_pi, 6.283185307179586476925286766559005768e+00, "6.28318530717958647692528676655900576839433879875021164194988918461563281257241799725606965068423413596429617303e+00") + BOOST_DEFINE_MATH_CONSTANT(tau, 6.283185307179586476925286766559005768e+00, "6.28318530717958647692528676655900576839433879875021164194988918461563281257241799725606965068423413596429617303e+00") BOOST_DEFINE_MATH_CONSTANT(two_thirds_pi, 2.094395102393195492308428922186335256e+00, "2.09439510239319549230842892218633525613144626625007054731662972820521093752413933241868988356141137865476539101e+00") BOOST_DEFINE_MATH_CONSTANT(three_quarters_pi, 2.356194490192344928846982537459627163e+00, "2.35619449019234492884698253745962716314787704953132936573120844423086230471465674897102611900658780098661106488e+00") BOOST_DEFINE_MATH_CONSTANT(four_thirds_pi, 4.188790204786390984616857844372670512e+00, "4.18879020478639098461685784437267051226289253250014109463325945641042187504827866483737976712282275730953078202e+00") From 982ad5c1337df658d8e030f41a871ac17207552d Mon Sep 17 00:00:00 2001 From: Felix von Drigalski Date: Sat, 13 Mar 2021 23:55:26 +0900 Subject: [PATCH 2/5] Add tau alias --- include/boost/math/constants/constants.hpp | 12 ++++++++++++ test/test_constants.cpp | 1 + 2 files changed, 13 insertions(+) diff --git a/include/boost/math/constants/constants.hpp b/include/boost/math/constants/constants.hpp index 665a976f6..32d591f53 100644 --- a/include/boost/math/constants/constants.hpp +++ b/include/boost/math/constants/constants.hpp @@ -328,6 +328,18 @@ namespace boost{ namespace math BOOST_DEFINE_MATH_CONSTANT(laplace_limit, 0.662743419349181580974742097109252907056233549115022417, "0.66274341934918158097474209710925290705623354911502241752039253499097185308651127724965480259895818168") #endif +template::value, bool>::type = true> +constexpr T tau() +{ + return two_pi(); +} + +template::value, bool>::type = true> +const T tau() +{ + return two_pi(); +} + } // namespace constants } // namespace math } // namespace boost diff --git a/test/test_constants.cpp b/test/test_constants.cpp index 72ab2e19b..a107980f7 100644 --- a/test/test_constants.cpp +++ b/test/test_constants.cpp @@ -150,6 +150,7 @@ void test_spots(RealType) CHECK_ULP_CLOSE(3.14159265358979323846264338327950288419716939937510L/4, quarter_pi(), 2); CHECK_ULP_CLOSE(3.14159265358979323846264338327950288419716939937510L/6, sixth_pi(), 2); CHECK_ULP_CLOSE(2 * 3.14159265358979323846264338327950288419716939937510L, two_pi(), 2); + CHECK_ULP_CLOSE(2 * 3.14159265358979323846264338327950288419716939937510L, tau(), 2); CHECK_ULP_CLOSE(3 * 3.14159265358979323846264338327950288419716939937510L / 4, three_quarters_pi(), 2); CHECK_ULP_CLOSE(4 * 3.14159265358979323846264338327950288419716939937510L / 3, four_thirds_pi(), 2); CHECK_ULP_CLOSE(1 / (3.14159265358979323846264338327950288419716939937510L), one_div_pi(), 2); From 8bca7172fb034073d4d360f065a1ed3f91f820b5 Mon Sep 17 00:00:00 2001 From: Felix von Drigalski Date: Sat, 13 Mar 2021 23:58:47 +0900 Subject: [PATCH 3/5] Remove explicit tau definition --- include/boost/math/constants/constants.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/include/boost/math/constants/constants.hpp b/include/boost/math/constants/constants.hpp index 32d591f53..02e113c99 100644 --- a/include/boost/math/constants/constants.hpp +++ b/include/boost/math/constants/constants.hpp @@ -261,7 +261,6 @@ namespace boost{ namespace math BOOST_DEFINE_MATH_CONSTANT(third_pi, 1.047197551196597746154214461093167628e+00, "1.04719755119659774615421446109316762806572313312503527365831486410260546876206966620934494178070568932738269550e+00") BOOST_DEFINE_MATH_CONSTANT(sixth_pi, 5.235987755982988730771072305465838140e-01, "5.23598775598298873077107230546583814032861566562517636829157432051302734381034833104672470890352844663691347752e-01") BOOST_DEFINE_MATH_CONSTANT(two_pi, 6.283185307179586476925286766559005768e+00, "6.28318530717958647692528676655900576839433879875021164194988918461563281257241799725606965068423413596429617303e+00") - BOOST_DEFINE_MATH_CONSTANT(tau, 6.283185307179586476925286766559005768e+00, "6.28318530717958647692528676655900576839433879875021164194988918461563281257241799725606965068423413596429617303e+00") BOOST_DEFINE_MATH_CONSTANT(two_thirds_pi, 2.094395102393195492308428922186335256e+00, "2.09439510239319549230842892218633525613144626625007054731662972820521093752413933241868988356141137865476539101e+00") BOOST_DEFINE_MATH_CONSTANT(three_quarters_pi, 2.356194490192344928846982537459627163e+00, "2.35619449019234492884698253745962716314787704953132936573120844423086230471465674897102611900658780098661106488e+00") BOOST_DEFINE_MATH_CONSTANT(four_thirds_pi, 4.188790204786390984616857844372670512e+00, "4.18879020478639098461685784437267051226289253250014109463325945641042187504827866483737976712282275730953078202e+00") From 1f6a72d4b2726ccf20e1a73135250f4876d77eb1 Mon Sep 17 00:00:00 2001 From: Felix von Drigalski Date: Sun, 14 Mar 2021 13:04:18 +0900 Subject: [PATCH 4/5] Add doc entry --- doc/constants/constants.qbk | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/constants/constants.qbk b/doc/constants/constants.qbk index 3569bf36e..5ca17cb7b 100644 --- a/doc/constants/constants.qbk +++ b/doc/constants/constants.qbk @@ -318,6 +318,7 @@ This section lists the mathematical constants, their use(s) (and sometimes ratio [[quarter_pi] [[pi]/4] [0.78539816] [Equivalent to POSIX constant M_PI_4] ] [[sixth_pi] [[pi]/6] [0.523598] [] ] [[two_pi] [2[pi]] [6.28318] [Many uses, most simply, circumference of a circle]] +[[tau] [[tau]] [6.28318] [@https://en.wikipedia.org/wiki/Turn_(angle)#Tau_proposals Many uses, most simply, circumference of a circle. Equal to two_pi.]] [[two_thirds_pi] [2/3 [pi]] [2.09439] [[@http://en.wikipedia.org/wiki/Sphere#Volume_of_a_sphere volume of a hemi-sphere] = 4/3 [pi] r[cubed]]] [[three_quarters_pi] [3/4 [pi]] [2.35619] [ = 3/4 [pi] ]] [[four_thirds_pi] [4/3 [pi]] [4.18879] [[@http://en.wikipedia.org/wiki/Sphere#Volume_of_a_sphere volume of a sphere] = 4/3 [pi] r[cubed]]] From 57e55868562b24c8e34be82e77b4d0908d456d0c Mon Sep 17 00:00:00 2001 From: Felix von Drigalski Date: Mon, 15 Mar 2021 17:42:08 +0900 Subject: [PATCH 5/5] Simplify overload --- include/boost/math/constants/constants.hpp | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/include/boost/math/constants/constants.hpp b/include/boost/math/constants/constants.hpp index 02e113c99..4ed08fb49 100644 --- a/include/boost/math/constants/constants.hpp +++ b/include/boost/math/constants/constants.hpp @@ -327,17 +327,8 @@ namespace boost{ namespace math BOOST_DEFINE_MATH_CONSTANT(laplace_limit, 0.662743419349181580974742097109252907056233549115022417, "0.66274341934918158097474209710925290705623354911502241752039253499097185308651127724965480259895818168") #endif -template::value, bool>::type = true> -constexpr T tau() -{ - return two_pi(); -} - -template::value, bool>::type = true> -const T tau() -{ - return two_pi(); -} +template +inline constexpr T tau() { return two_pi(); } } // namespace constants } // namespace math