-
Notifications
You must be signed in to change notification settings - Fork 226
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
Improve ulps plot: #417
Improve ulps plot: #417
Conversation
Use numeric_limits for precision comparison, plot out of bounds points at the clip boundary so we can still see that they're there.
@NAThompson : A quick question:
Other than that this fixes the case where PreciseReal is a multiprecision type. |
// Got to think on what to do about it. | ||
static_assert(sizeof(PreciseReal) >= sizeof(CoarseReal), "PreciseReal must have larger size than CoarseReal"); | ||
// Use digits10 for this comparison in case the two types have differeing radixes: | ||
static_assert(std::numeric_limits<PreciseReal>::digits10 >= std::numeric_limits<CoarseReal>::digits10, "PreciseReal must have higher precision that CoarseReal"); |
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.
Yes, I've noticed this problem before for MPFR types; since the sizeof
operator returns the size of a pointer. Thanks!
continue; | ||
CoarseReal x = x_scale(plot.coarse_abscissas_[j]); | ||
PreciseReal y = y_scale(static_cast<PreciseReal>(ulp[j] < 0 ? -plot.clip_ : plot.clip_)); | ||
fs << "<circle cx='" << x << "' cy='" << y << "' r='1' fill='" << color << "'/>\n"; |
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 we maybe color the clipped values differently? Suppose red for all clips?
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.
One further point: If the condition number goes infinite somewhere, which is very common, the top of the plot is going to be a bloodbath, even if there's really nothing wrong with the implementation.
I'm not sure what to do about this, since it seems like something no one wants an option for!
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.
+1 on red for clipped values, and yes the top of the plot may be a bloodbath, but my feeling is it's better to know than not about this stuff.
Yeah, but it could be a natural value to return at both precisions; e.g. sin(1/x) at x = 0. In this case there is no problem with the ulps plot, you just don't plot that value. So the only problem is when only one of the two precisions is a nan. In this case, maybe put it at the clip? But if there is no clip specified, then I would probably do nothing; or a message to |
OK yes, I see that we need to support NaN's when the function goes out of domain or whatever. It's tough to do the right thing in all cases here! |
Add more docs.
actually a helper function which returns Then I wouldn't make that one lgamma mistake in boostorg/multiprecision#264 :-)) |
@jzmaddock : I like these diffs; should I squash merge them? |
Yes please do, thanks! |
Use numeric_limits for precision comparison, plot out of bounds points at the clip boundary so we can still see that they're there.