31.01.2014 Views

Version 5.0 The LEDA User Manual

Version 5.0 The LEDA User Manual

Version 5.0 The LEDA User Manual

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

5.5 Interval Arithmetic in <strong>LEDA</strong> ( interval )<br />

1. Definition<br />

An instance of the data type interval represents a real interval I = [a, b]. <strong>The</strong> basic<br />

interval operations +, −, ∗, /, √ are available. Type interval can be used to approximate<br />

exact real arithmetic operations by inexact interval operations, as follows. Each input<br />

number x i is converted into the interval {x i } and all real operations are replaced by<br />

interval operations. If x is the result of the exact real calculation and I the interval<br />

computed by type interval, it is guaranteed that I contains x. I can be seen as a more or<br />

less accurate approximation of x. In many cases the computed interval I is small enough<br />

to provide a useful approximation of x and the exact sign of x. <strong>The</strong>re are four different<br />

implementations of intervals (consult the implementation section below for details):<br />

• Class interval bound absolute<br />

• Class interval bound relative<br />

• Class interval round inside<br />

• Class interval round outside, which is usually the fastest but requires that the<br />

IEEE754 rounding mode ieee positive is activated, e.g. by using the <strong>LEDA</strong> class<br />

fpu.<br />

<strong>The</strong> interface of all interval variants are identical. However, note that the types<br />

interval round inside and interval round outside are only available on some explicitly supported<br />

UNIX platforms, currently including SPARC, MIPS, i386 (PC’s compatible to<br />

80386 or higher), and ALPHA. For all platforms, the name interval stands for the default<br />

implementation interval bound absolute.<br />

#include < <strong>LEDA</strong>/numbers/interval.h ><br />

interval x; creates an instance x of type interval and initializes it with the<br />

interval {0}<br />

interval<br />

x(VOLATILE I double a);<br />

creates an instance x of type interval and initializes it with {a}<br />

interval x(int a); creates an instance x of type interval and initializes it with {a}<br />

interval x(long a); creates an instance x of type interval and initializes it with {a}<br />

interval<br />

x(const integer& a);<br />

creates an instance x of type interval and initializes it with the<br />

smallest possible interval containing a

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!