-
Notifications
You must be signed in to change notification settings - Fork 80
Rationalize the handling of Boost multiprecision types #4272
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
Closed
Closed
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
c4563be
A test with multiprecision.
pleroy 16c0e98
Clean up FMA.
pleroy 7dccab3
Move concepts to quantities.
pleroy 9a20b0c
Concepts for generators.
pleroy f1c157f
Better concepts, maybe.
pleroy 5ebfcd0
Merge branch 'MoveConcepts' into Dimensionless
pleroy 25dc0ab
Cantorian concepts.
pleroy 5ac72c7
Cantor and dimension concepts.
pleroy b74a29a
Cantor test.
pleroy eb67b5a
Cantor improvements and FMA.
pleroy e38e98b
Add concepts for Boost multiprecision and simplify the places that ne…
pleroy e88ba86
More FMA fixes.
pleroy cd71e77
Readying.
pleroy 72967ed
Merge branch 'master' into Dimensionless
pleroy 8e41f40
Cleanups.
pleroy bb64033
Fix a NaN test.
pleroy 4aa7965
After egg's review.
pleroy db40dcb
Lint.
pleroy dbf8525
Renamings I missed.
pleroy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| #pragma once | ||
|
|
||
| #include <concepts> | ||
|
|
||
| #include "base/traits.hpp" | ||
| #include "boost/multiprecision/number.hpp" | ||
|
|
||
| namespace principia { | ||
| namespace quantities { | ||
| namespace _cantor { | ||
| namespace internal { | ||
|
|
||
| using namespace boost::multiprecision; | ||
| using namespace principia::base::_traits; | ||
|
|
||
| // The `boost_cpp_` concepts should be used sparingly, and only in places where | ||
| // the Boost multiprecision API differs from ours or from the standard C++ API. | ||
| // At any rate, the multiprecision traits should never be used directly. | ||
|
|
||
| template<typename T> | ||
| concept boost_cpp_number = | ||
| (is_number<T>::value || is_number_expression<T>::value) && | ||
| number_category<T>::value != number_kind_unknown; | ||
|
|
||
| template<typename T> | ||
| concept boost_cpp_bin_float = | ||
| boost_cpp_number<T> && | ||
| number_category<T>::value == number_kind_floating_point; | ||
|
|
||
| template<typename T> | ||
| concept boost_cpp_int = | ||
| boost_cpp_number<T> && number_category<T>::value == number_kind_integer; | ||
|
|
||
| template<typename T> | ||
| concept boost_cpp_rational = | ||
| boost_cpp_number<T> && number_category<T>::value == number_kind_rational; | ||
|
|
||
| template<typename T> | ||
| concept discrete = std::integral<T> || boost_cpp_int<T>; | ||
|
|
||
| template<typename T> | ||
| concept countable = discrete<T> || boost_cpp_rational<T>; | ||
|
|
||
| template<typename T> | ||
| concept continuum = std::floating_point<T> || boost_cpp_bin_float<T>; | ||
|
|
||
| } // namespace internal | ||
|
|
||
| using internal::boost_cpp_bin_float; | ||
| using internal::boost_cpp_int; | ||
| using internal::boost_cpp_number; | ||
| using internal::boost_cpp_rational; | ||
| using internal::continuum; | ||
| using internal::countable; | ||
| using internal::discrete; | ||
|
|
||
| } // namespace _cantor | ||
| } // namespace quantities | ||
| } // namespace principia |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| #include "quantities/cantor.hpp" | ||
|
|
||
| #include "boost/multiprecision/cpp_bin_float.hpp" | ||
| #include "boost/multiprecision/cpp_int.hpp" | ||
| #include "gtest/gtest.h" | ||
|
|
||
| namespace principia { | ||
| namespace quantities { | ||
|
|
||
| using namespace boost::multiprecision; | ||
| using namespace principia::quantities::_cantor; | ||
|
|
||
| TEST(Cantor, CppBinFloat) { | ||
| static_assert(boost_cpp_bin_float<cpp_bin_float_50>); | ||
| static_assert(boost_cpp_bin_float<cpp_bin_float_100>); | ||
| static_assert(!boost_cpp_bin_float<cpp_int>); | ||
| static_assert(!boost_cpp_bin_float<cpp_rational>); | ||
| static_assert(!boost_cpp_bin_float<double>); | ||
| static_assert(!boost_cpp_bin_float<int>); | ||
| } | ||
|
|
||
| TEST(Cantor, Discrete) { | ||
| static_assert(discrete<int>); | ||
| static_assert(discrete<cpp_int>); | ||
| static_assert(!discrete<cpp_rational>); | ||
| static_assert(!discrete<double>); | ||
| static_assert(!discrete<cpp_bin_float_50>); | ||
| } | ||
|
|
||
| TEST(Cantor, Countable) { | ||
| static_assert(countable<int>); | ||
| static_assert(countable<cpp_int>); | ||
| static_assert(countable<cpp_rational>); | ||
| static_assert(!countable<double>); | ||
| static_assert(!countable<cpp_bin_float_50>); | ||
| } | ||
|
|
||
| TEST(Cantor, Continuum) { | ||
| static_assert(continuum<double>); | ||
| static_assert(continuum<cpp_bin_float_50>); | ||
| static_assert(!continuum<int>); | ||
| static_assert(!continuum<cpp_int>); | ||
| static_assert(!continuum<cpp_rational>); | ||
| } | ||
|
|
||
| } // namespace quantities | ||
| } // namespace principia |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.