-
Notifications
You must be signed in to change notification settings - Fork 39
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
Provide round_up
and round_down
for converting double to float
#621
Comments
Did you check whether it actually helps? |
No. I do think that it should be possible to design an example producing false negative. For example, you could set use a double point (e, 0, 0), where e is the first non-zero double. It will be rounded to 0 in floats. If you use intersection with a sphere (0, 1) that does not include the surface itself (
Is it? I was not sure.
I'm not sure there is a rush on this. This is simply to start the discussion. I'm not ready to have a detailed analysis of exactly how it may work, and whether it absolutely must be |
It means that if it turns out it is useful we will need workarounds in Arborx until we require Kokkos 3.7 |
I think that's fine. I am not ready to devote enough time to it prior to 3.6 anyway. If anybody wants to take a crack, go ahead. |
|
The main issue issue (implicit conversion of double to float in I still think it is a good idea if ArborX provides these. One use case I can see if someone write an indexable getter that returns some double data, while explicitly specifying that the bounding volume is based on floats. |
In some situations, it is helpful when we can control which way the rounding of a number is done. For example, right now, given data in double precision (like, points) we simply do
float()
conversion to the single precision. This is subject to round off errors and may lead to false negatives during the intersection tests. If we want to be conservative (i.e., only allow false positives but do not allow false negatives), the data should be rounded down for the minimum corner, and rounded up for the maximum corner, as to include the original data.One of the ways to achieve that is using
nextafterf
functions. I'm thinking something like this:(This may need to be changed slightly to account for nan, inf, etc).
Some papers do it informally (i.e., without using
nextafterf
) by rounding a positive number up by one ulp through multiplying it with1 + 2^(-23)
and down by multiplying with1 - 2^(-23)
(see pages 73-74 in Woop et al paper).There are also some other situations where we may want to use
nextafterf
even for floats to account for losing precision using floating point operations. For example, this may help #560 (see this comment).The text was updated successfully, but these errors were encountered: