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

Support using float instead of double #11

Open
ubruhin opened this issue Apr 19, 2020 · 8 comments
Open

Support using float instead of double #11

ubruhin opened this issue Apr 19, 2020 · 8 comments

Comments

@ubruhin
Copy link

ubruhin commented Apr 19, 2020

Hi,

It looks like the library currently only supports double. But for platforms with only a single-precision FPU it would be nice to allow using float for performance reasons. From usability point of view, it would be great to make the classes a template so we could pass either float or double as template argument. Alternatively it would also be OK to replace all occurrences of double with an own typedef and e.g. allow switching to float with a define passed to the compiler, or something like that.

Are there any plans in this direction, or would this be totally out of scope of this library?

@abellgithub
Copy link
Owner

I'm not sure I understand. Are you working on a system that only has single-precision floating-point? Or do you just want the input to be single-precision? Or do you want processing on the GPU itself?

@ubruhin
Copy link
Author

ubruhin commented Apr 19, 2020

Are you working on a system that only has single-precision floating-point?

Yes, basically that's what I mean. But I'm not "working" on such a system - I develop an application which is intended to be portable. When compiling for a typical x86 platform, the application should use double for all floating point operations. But when compiling for an ARM platform which only has a single-precision FPU, the application should use float for all floating point operations. For this library it would mean that input data should be single-precision, and all operations should be performed with single precision (often that's easy, since the functions from <cmath> are overloaded for both float and double, so it will choose the corresponding overload depending on the argument type).

To be more clear, I develop an application using Qt. And Qt provides the typedef qreal which is usually defined as double, but on some platforms it might be defined as float. That's handy for application developers since I don't have to care about the underlying platform. But I'd also need this library to be configurable that way.

@abellgithub
Copy link
Owner

The issue is that getting decent (and correct) triangulation depends on an appropriate level of precision. I'm not sure that just replacing double with float will yield decent results and behavior. When I've worked on systems without native double-precision, it was emulated by the compiler. This seems like it might be an application where you need that added precision, though it's highly dependent on the actual data.

@ubruhin
Copy link
Author

ubruhin commented Apr 19, 2020

The issue is that getting decent (and correct) triangulation depends on an appropriate level of precision.

But if the input data also has reduced precision, do you think this is still an issue?

When I've worked on systems without native double-precision, it was emulated by the compiler.

Yes of course, but the problem is that this could be very inefficient compared to using float instead. So I'm not sure if the slogan "Probably the fastest C++ open source 2D Delaunay implementation" in your readme is still true on such platforms 🙂

@abellgithub
Copy link
Owner

abellgithub commented Apr 20, 2020

The issue is that getting decent (and correct) triangulation depends on an appropriate level of precision.

But if the input data also has reduced precision, do you think this is still an issue?

Absolutely

@ubruhin
Copy link
Author

ubruhin commented Apr 22, 2020

OK so of course I leave it up to you to decide whether the library should also perform well on single-precision FPU or if that's out of scope. At least you now know that there are potential users which would be interested in that feature 🙂 I don't need the library immediately (currently I use another one), but I might reconsider using this library some day in future...

Thanks!

@abellgithub
Copy link
Owner

Have you tried:

sed/double/float/g

to see if you get results that are OK?

@ubruhin
Copy link
Author

ubruhin commented Apr 22, 2020

Not yet - I might do that once I seriously start evaluating this library for my application 🙂

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

No branches or pull requests

2 participants