Interval Arithmetic Tribool
Dear list, I hope I am writing to the correct place, and that this isn't a frequently asked question.. but I'd like to know alittle about comparisons and the Interval library. I am using intervals in a search algorithm to take advantage of the natural inclusion function as proposed in a paper I'm trying to implement. So far so good, except that I'm a little unhappy that I have to use "try" and "catch" to detect the indeterminate case. I'd like to use the boost::logic::tribool to identify the semi-frequent indeterminant case. For example: tribool cmp = interval1 < interval2; if (!indeterminate(cmp)) { if (cmp) { // something } else { // something else } else { // something } When I do this and the indeterminate case happens, an exception triggers and the function quits. This could be an error on my behalf, but it seems like this the default behavior. Its not that I can't do the try, catch, its just a matter of style. Can I have my cake and eat it too? Best, Robert Ferguson
Le mercredi 16 février 2005 à 15:50 -0500, Robert Ferguson a écrit :
Dear list,
I hope I am writing to the correct place, and that this isn't a frequently asked question.. but I'd like to know a little about comparisons and the Interval library.
[...]
I'd like to use the boost::logic::tribool to identify the semi-frequent indeterminant case.
You are right in expecting such an implementation. Mapping interval comparisons to tribool is natural enough to warrant it.
When I do this and the indeterminate case happens, an exception triggers and the function quits. This could be an error on my behalf, but it seems like this the default behavior.
Yes, the default behavior is to mimic the behavior of the real comparison. And since there is no such thing as an indeterminate case in the real comparison, an exception is thrown.
Its not that I can't do the try, catch, its just a matter of style. Can I have my cake and eat it too?
You can. You just have to ask for another comparison operator.
Long version:
- libs/numeric/interval/examples/tribool.cpp
- libs/numeric/interval/doc/comparisons.htm
Short version:
- #include
participants (2)
-
Guillaume Melquiond
-
Robert Ferguson