Opened 12 years ago
Last modified 7 years ago
#5498 new Bugs
Issues with the Interval Library
Reported by: | Owned by: | Boris Gubenko | |
---|---|---|---|
Milestone: | Boost 1.46.0 | Component: | interval |
Version: | Boost 1.46.0 | Severity: | Problem |
Keywords: | Interval | Cc: |
Description
I am trying to compile some examples; in particular, the trigonometric, hyperbolic trig and transendental (exp, log!!)functions don't compile with default roudning policy (see file I included). It's a kind of show-stopper.
Some user requests as well are:
- Instead of bool when comparing interval, use TriBool (a result can be _indeterminate_)
- Interval is missing midpoint() (same as median()).
- Interval analysis is highly specialised; more user examples would be very welcome.
I have the books by R.E. Moore but it takes some time to map his results to Interval.
best regards
Daniel
Code
TestInterval101.cpp Tests for Interval arithmetic. (C) Datasim Education BV 2009-2011
#include <boost/numeric/interval.hpp>
template<class T, class Policies> std::ostream &operator<<(std::ostream &os,
const boost::numeric::interval<T, Policies> &x) {
os << "[" << x.lower() << ", " << x.upper() << "]"; return os;
}
typedef boost::numeric::interval<double> Range;
int main() {
using namespace boost::numeric;
Create and manipulate some numbers. Range r1(0.0, 1,0);
Range rTmp(2.0, 3.0); r1 += rTmp; r1 -= rTmp; r1 *= rTmp; r1 /= rTmp;
Numeric operations. Range r4 = r1 + r2; Range r5 = r1 - r2; Range r6 = r1 * r2; Range r7 = r1 / r2;
More numeric operations. t = 3.0; r4 = r1 + t; r5 = r1 - t; r6 = r1 * t; r7 = r1 / t;
Algebraic functions. r4 = abs(r1); r5 = sqrt(r2); r6 = square(r3); r7 = pow(r1, 2); r12 Range r8 = nth_root(r1, 4);
NONE COMPILES Transcendental functions
r4 = exp(r1); boost::numeric::interval<double, boost::numeric::interval_lib::default_policies<double> > myI; myI = boost::numeric::exp(myI);
Trigonometric functions
r5 = cos(r1); r6 = tan(r1); r7 = asin(r2); r7 = acos(r2); r7 = atan(r2);
Hyperbolic trigonometric functions r4 = sinh(r1); r5 = cosh(r1); r6 = tanh(r1); r7 = asinh(r2); r8 = acosh(r2); r6 = atanh(r2);*/
return 0;
}
Attachments (1)
Change History (9)
by , 12 years ago
Attachment: | TestBug.cc added |
---|
comment:1 by , 11 years ago
comment:2 by , 11 years ago
class DDPolicy : public rounded_math<double> { public:
double exp_up(double x) { return ::exp(x);} double exp_down(double x) { return ::exp(x);}
etc.
};
Transcendental functions boost::numeric::interval<double, policies<DDPolicy, checking_strict<double> > > rA; boost::numeric::interval<double, policies<DDPolicy, checking_strict<double> > > rB;
rB = exp(rA);
comment:4 by , 9 years ago
Severity: | Showstopper → Problem |
---|
comment:5 by , 9 years ago
Well. IMO is still a show stopper and it has not been solved.
Daniel Duffy
comment:6 by , 9 years ago
It's a show stopper because you can't <cmath> functionality on Interval. But +, -, * and / do work.
comment:7 by , 8 years ago
We are now 4 years on. You conventiently changed status to PROBLEM...
Has this show stopper been resolved? IMO it's easy to fix.
thanks
Daniel J. Duffy
I (Daniel Duffy) discovered the cause: Interval does not provide default implementation of up and down rounding policies. As a POC, I created a simple policy that I tested with interval Newton Raphson