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

Are predicates used in CDT safe? #100

Closed
artem-ogre opened this issue Aug 10, 2022 Discussed in #99 · 0 comments
Closed

Are predicates used in CDT safe? #100

artem-ogre opened this issue Aug 10, 2022 Discussed in #99 · 0 comments
Labels
bug Something isn't working

Comments

@artem-ogre
Copy link
Owner

Discussed in #99

Originally posted by msokalski August 10, 2022
It seams to me that predicates library can be easily fooled by flipping sign and/or swapping x,y coordinates of a point to form 4 exactly concyclic set of points. Results are not very optimistic ... any thoughts? Do you reproduce same behaviour?

// example where adaptive differs from exact predicate
// adaptive seams to be wrong (I think rising xxx_errbound could fix this)

ax	-1.4048103911580639e-11	const double
ay	5.3534412196824579e-12	const double
bx	1.4048103911580639e-11	const double
by	-5.3534412196824579e-12	const double
cx	-1.4048103911580639e-11	const double
cy	-5.3534412196824579e-12	const double
dx	-5.3534412196824579e-12	const double
dy	-1.4048103911580639e-11	const double

predicates::adaptive::incircle<double> returned	1.5785423408550432e-75	double
predicates::exact::incircle<double> returned	0.0000000000000000	double
crude_xa::incircle<double> returned 		0.0000000000000000	double
// ---------------------------------------------------
// example where adaptive & exact predicates seams to be both wrong!

ax	-9.1428964336885931e-10	const double
ay	-5.2844166345548637e-19	const double
bx	-5.2844166345548637e-19	const double
by	-9.1428964336885931e-10	const double
cx	5.2844166345548637e-19	const double
cy	-9.1428964336885931e-10	const double
dx	-5.2844166345548637e-19	const double
dy	9.1428964336885931e-10	const double

predicates::adaptive::incircle<double> returned	1.2392294127517818e-119	double
predicates::exact::incircle<double> returned	1.2392294127517818e-119	double
crude_xa::incircle<double> returned 		0.0000000000000000	double

EDIT:
adding a more representative set of 4 points (both adaptive and exact predicates seams to be wrong here):

	double ax = -1.00;
	double ay = -0.01;
	double bx = -0.01;
	double by = -1.00;
	double cx =  0.01;
	double cy = -1.00;
	double dx = -0.01;
	double dy =  1.00;

I've narrowed the problem to the Dekker's product function. Forcing use of std::fma() solves the problem, probably at the cost of performance drop on platforms not having fma in hardware.

artem-ogre added a commit that referenced this issue Aug 10, 2022
- Splitter constant was wrong. Must be double:2^27+1, float: 2^13+1
- Always prefer FMA to Dekker product when c++11 is available
@artem-ogre artem-ogre added the bug Something isn't working label Aug 10, 2022
artem-ogre added a commit that referenced this issue Aug 10, 2022
- Splitter constant was wrong. Must be double:2^27+1, float: 2^13+1
- Always prefer FMA to Dekker product when c++11 is available
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant