#include <cell.hh>
Public Member Functions | |
suretest () | |
~suretest () | |
void | init (fpoint x, fpoint y, fpoint z, fpoint rsq) |
int | test (int n, fpoint &ans) |
Public Attributes | |
fpoint * | p |
Floating point comparisons can be unreliable on some processor architectures, and can produce unpredictable results. On a number of popular Intel processors, floating point numbers are held to higher precision when in registers than when in memory. When a register is swapped from a register to memory, a truncation error, and in some situations this can create circumstances where for two numbers c and d, the program finds c>d first, but later c<d. The programmer has no control over when the swaps between memory and registers occur, and recompiling with slightly different code can give different results. One solution to avoid this is to force the compiler to evaluate everything in memory (e.g. by using the -ffloat-store option in the GNU C++ compiler) but this could be viewed overkill, since it slows the code down, and the extra register precision is useful.
In the plane cutting routine of the voronoicell class, we need to reliably know whether a vertex lies inside, outside, or on the cutting plane, since if it changed during the tracing process there would be confusion. This class makes these tests reliable, by storing the results of marginal cases, where the vertex lies within tolerance2 of the cutting plane. If that vertex is tested again, then code looks up the value of the table in a buffer, rather than doing the floating point comparison again. Only vertices which are close to the plane are stored and tested, so this routine should create minimal computational overhead.
Definition at line 52 of file cell.hh.
suretest::suretest | ( | ) |
suretest::~suretest | ( | ) |
void suretest::init | ( | fpoint | x, | |
fpoint | y, | |||
fpoint | z, | |||
fpoint | rsq | |||
) | [inline] |
fpoint* suretest::p |