Navigation: Up, Table of Contents, Bibliography, Index, Title Page

Advanced Interval Arithmetic (CGAL_Interval_nt_advanced )

CGAL_Interval_nt derives from CGAL_Interval_nt_advanced. The advanced class allows you to make faster computations, but you need to set the rounding mode of the FPU to 'round to infinity' (see below for how to do that) before doing any computation with this number type, and each function (arithmetic operators and conversion functions) leaves the rounding mode in this state if it needs to modify it internally. See below for details.

The function CGAL_convert_to<CGAL_Interval_nt>() is replaced by the function CGAL_convert_to<CGAL_Interval_nt_advanced>() and has the same requirements concerning the rounding mode as other functions.

#include <CGAL/Interval_arithmetic.h>

We provide the following functions to change the rounding mode:

Implementation

The basic idea is to use the directed rounding modes specified by the IEEE 754 standard, which are implemented by almost all processors nowadays. It states that you have the possibility, concerning the basic floating point operations (+,-,*,/,sqrt()) to specify the rounding mode of each operation instead of using the default, which is set to 'round to the nearest'. This feature allows us to compute easily on intervals. For example, to add the two intervals [a.i;a.s] and [b.i;b.s], compute c.i=a.i+b.i rounded towards minus infinity, and c.s=a.s+b.s rounded towards plus infinity, and the result is the interval [c.i;c.s]. This method can be extended easily to the other operations.

The problem is that we have to change the rounding mode very often, and the functions of the C library doing this operation are slow and not portable. That's why assembly versions are used as often as possible. Another trick is to store the opposite of the lower bound, instead of the lower bound itself, which allows us to never change the rounding mode inside simple operations. Therefore, all basic operations, which are in the class CGAL_Interval_nt_advanced assume that the rounding mode is set to 'round to infinity', and everything works with this correctly set. The class CGAL_Interval_nt takes care of this, but is a bit slower.

So, if the user needs the speed of CGAL_Interval_nt_advanced, he must take care of setting the rounding mode to 'round to infinity' before each operations on this number type. And if other operations might be affected by this, he must take care to reset it to 'round to the nearest' before them.

Platform support:
This part of CGAL must be explicitly ported to each non yet supported platform. For Intel, Sparc and Mips, only the GNU compilers use assembly code. SunPro and MipsPro compilers use the slow C code instead, and do not support the construction CGAL_convert_to<>() right now.


Next: Class declaration of CGAL_Filtered_exact<CT,ET>
Navigation: Up, Table of Contents, Bibliography, Index, Title Page
The CGAL Project. 22 January 1999.