Skip to content
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

Merged
merged 3 commits into from
Aug 11, 2020
Merged

Improve ulps plot: #417

merged 3 commits into from
Aug 11, 2020

Conversation

jzmaddock
Copy link
Collaborator

Use numeric_limits for precision comparison, plot out of bounds points at the clip boundary so we can still see that they're there.

Use numeric_limits for precision comparison, plot out of bounds points at the clip boundary so we can still see that they're there.
@jzmaddock
Copy link
Collaborator Author

@NAThompson : A quick question:

  • What should we do with errors that are NaN's? Don't these reflect a possible bug in the function?

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");
Copy link
Collaborator

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";
Copy link
Collaborator

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?

Copy link
Collaborator

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!

Copy link
Collaborator Author

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.

@NAThompson
Copy link
Collaborator

What should we do with errors that are NaN's? Don't these reflect a possible bug in the function?

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 std::cerr. Graphical techniques can't be expected to ergonomically represent all classes of errors.

@jzmaddock
Copy link
Collaborator Author

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!

@cosurgi
Copy link

cosurgi commented Aug 10, 2020

function goes out of domain

actually a helper function which returns true, false about whether given x is in a function domain would be awesome.

Then I wouldn't make that one lgamma mistake in boostorg/multiprecision#264 :-))

@NAThompson
Copy link
Collaborator

@jzmaddock : I like these diffs; should I squash merge them?

@jzmaddock
Copy link
Collaborator Author

I like these diffs; should I squash merge them?

Yes please do, thanks!

@NAThompson NAThompson merged commit 6d1d467 into develop Aug 11, 2020
@NAThompson NAThompson deleted the ulps_improve branch August 11, 2020 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants