[std-interval] Interval comparison operators

Fernando Cacciola fernando_cacciola at datafull.com
Wed Apr 26 18:48:50 PDT 2006


Guillaume Melquiond wrote:
> Le mercredi 26 avril 2006 à 16:42 -0300, Fernando Cacciola a écrit :
>
>>> I really meant "certainly(X < Y)". And yes, this presumably requires
>>> the use of some kind of an expression template as the return type of
>>> operator<. So "certainly" will do the actual comparison and return a
>>> boolean (and it will _never_ throw an exception).
>>>
>> FWIW the operator doesn't "have to" return an expression template
>> letting "certainly" do the actual comparison.
>> It could also be that the operator returns a tribool, or a discrete
>> interval over 'bool', so that "certainly" just turns that into a
>> true/false.
>
> Right. And a discrete interval over bool is actually used in the
> original draft and in our toy implementation :-). I just missed a part
> of my sentence: I wanted to say that, _for performance reasons_, the
> return type will presumably be an expression template. A discrete
> interval works well, but since the comparison is not delayed, it
> requires some more tests (usually three instead of one floating-point
> comparison) and a compiler cannot optimize them away without some
> interval arithmetic related knowledge. We also intended for the
> comparison operators to produce such a discrete interval (originally
> called interval<bool>, but there was a lot of complains about the
> name)
> when needed.
>
Ineed.
I knew about interval<bool> and I also figured you were just considering an 
optimal implementation.

The goal of my post was to propose that you DO NOT include interval<bool> or 
any form of tribool in the proposal to make room for such clever 
implementations. Just state the requirements on suh a tribool type or branch 
out a separate "tribool CONCEPT" proposal (I know the std doesn't specfic 
mere concepts yet, but this one seems like a good candidate to start)

Best

Fernando Cacciola
SciSoft
http://fcacciola.50webs.com/ 




More information about the Std-interval mailing list