Boost logo

Boost :

From: Guillaume Melquiond (guillaume.melquiond_at_[hidden])
Date: 2005-12-08 13:25:19


Le jeudi 08 décembre 2005 à 07:23 -0500, David Abrahams a écrit :

> > The documentation means that empty() generates the empty subset and
> > whole() generates the subset
>
> Of what? The universe of all possible intervals? This is a static
> function!
>
> > that is the whole set. Maybe the documentation should stress that
> > something empty does not contain any element

As I said, intervals are a subset of a given set. This set is implicitly
described by the template arguments of the interval type. For example,
with the default interval<double>, the set is the field of real numbers
(and not just the set of double-precision floating-point numbers). So
interval<double>::whole() contains all the real numbers.

> > If you want to express these intervals as pair of bounds [l,u], for the
> > empty subset there must be no x such that l <= x <= u (by having !(l <=
> > u) for example), and for the whole set, any x must verify l <= x <= u
> > (by having l = -infinity and u = +infinity for example).
>
> ... okay, then you do mean the universe. So why don't you just tell
> us that empty() includes no values of the underlying type while
> whole() includes all non-NAN values of the underlying type?

Because this is false. To continue with the example of interval<double>,
there are intervals of real numbers that do not contain any value of the
underlying type (I assume you meant the type of the bounds), yet they
are not empty. So interval<double>::empty() is not just empty with
respect to floating-point numbers, it is also empty with respect to the
set of real numbers.

This distinction is important, because we are not just looking if
elements are in intervals, we are doing arithmetic on intervals. If
interval<double>::empty() was simply defined as not containing any
double-precision number, then the sum of two empty intervals would have
to return the whole set, in order to respect the inclusion property.

In conclusion, empty() still represents the set (properly typed for the
sake of C++) that contains no elements. And whole() represents the whole
set as implied by the policies of the interval type.

Best regards,

Guillaume


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk