suretest Class Reference

A class to reliably carry out floating point comparisons, storing marginal cases for future reference. More...

#include <cell.hh>

List of all members.

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


Detailed Description

A class to reliably carry out floating point comparisons, storing marginal cases for future reference.

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.


Constructor & Destructor Documentation

suretest::suretest (  ) 

Initializes the suretest class and creates a buffer for marginal points.

Definition at line 1679 of file cell.cc.

suretest::~suretest (  ) 

Suretest destructor to free memory allocation.

Definition at line 1684 of file cell.cc.


Member Function Documentation

void suretest::init ( fpoint  x,
fpoint  y,
fpoint  z,
fpoint  rsq 
) [inline]

Sets up the suretest class with a particular test plane, and removes any special cases from the table.

Definition at line 1690 of file cell.cc.

int suretest::test ( int  n,
fpoint &  ans 
) [inline]

Definition at line 1695 of file cell.cc.


Member Data Documentation

fpoint* suretest::p

This is a pointer to the array in the voronoicell class which holds the vertex coordinates.

Definition at line 55 of file cell.hh.


The documentation for this class was generated from the following files:

Generated on Wed Dec 10 11:55:46 2008 for Voro++ by  doxygen 1.5.7