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.
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 efficient bisection for 1D Newton root finder #1012
base: develop
Are you sure you want to change the base?
More efficient bisection for 1D Newton root finder #1012
Changes from 3 commits
6bd1d9c
eef5fe0
af08a6c
16b1033
c2d2b76
21dc82b
21d9374
2f60168
a803be2
7acf90c
0708745
19bbf76
752a1c5
777d64a
8c46b6d
f28048d
a14567f
0a64a5f
57c5512
3957093
6d27f3a
66a61a8
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should there be an assertion for long double as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added an explanation as to why
long double
does not use theMidpoint754
solver.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A guess there are a couple cases:
On some systems (e.g. Windows and MacOS)
long doubles
are just aliases todouble
. When long doubles are 64-bits we could just cast to double and useMidpoint754
to speed things up.On x86_64 linux systems you have the 80-bit
long double
. Normally you haveunsigned __int128
but you'd have to shift the bits around to cast it back properly. Likely not worth the magic required.On systems with IEEE 128-bit long doubles (e.g. ARM and S390x) you have access to
unsigned __int128
which should generally work. We have both of the aforementioned architectures running natively in the CI system.Here is where I have defined macros before for determining the size of long double.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These systems will use the specialization for
double
.I tried to make this work. Starting with
numeric_limits<long double>::max()
and adding 1 bit givesNaN
, notInf
as it does forfloat
,double
and__float128
. It's just not meant to be.I got this to work for both
_float128
andboost::multiprecision::float128
(wrapper for__float128
). The implementation does not requirelibquadmath
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may be able to get away without checking
has_denorm
because it was deprecated in C++23There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want to be able to bisect with denormals because the solution to the root finding problem could be a denormal number.
Reading the depreciation document, it seems like the depreciation of
has_denorm
has a lot to do with it being astatic constexpr
. This is problematic because the actual behavior can change at runtime with e.g.,_MM_SET_FLUSH_ZERO_MODE
.I think we can actually delete
std::numeric_limits::min()
becausedenorm_min
returnsnumeric_limits::min()
if denormals are off. Does that seen sensible?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so. Since you are already check for
is_specialized
you should avoid ever getting 0 instead of a finite minimum value.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
boostorg/multiprecision#562