Problems with boost::interval
Saturday, May 23rd, 2009I need to work with exponentiation and logarithms with boost interval arithmetic, but nothing seems to work for me.
Here’s a simple little test program:
#include <iostream>
#include <boost/numeric/interval.hpp>
using namespace boost::numeric;
using namespace interval_lib;
int main()
{
interval<double> a = 1, b = 1;
std::cout << width(exp(a + b)) << std::endl;
return 0;
}
If I try to compile this,I get the errors:
/usr/include/boost/numeric/interval/transc.hpp: In function ‘boost::numeric::interval<T, Policies> boost::numeric::exp(const boost::numeric::interval<T, Policies>&) [with T = double, Policies = boost::numeric::interval_lib::policies<boost::numeric::interval_lib::rounded_math<double>, boost::numeric::interval_lib::checking_strict<double> >]‘:
foo.cc:9: instantiated from here
/usr/include/boost/numeric/interval/transc.hpp:34: error: ‘struct boost::numeric::interval_lib::rounded_math<double>’ has no member named ‘exp_down’
/usr/include/boost/numeric/interval/transc.hpp:34: error: ‘struct boost::numeric::interval_lib::rounded_math<double>’ has no member named ‘exp_up’
Why aren’t exp_down and exp_up defined? According to the documentation, they should be defined for the built in types:
By default, it is interval_lib::rounded_math<T>. The class interval_lib::rounded_math is already specialized for the standard floating types (float , double and long double). So if the base type of your intervals is not one of these, a good solution would probably be to provide a specialization of this class. But if the default specialization of rounded_math<T> for float, double, or long double is not what you seek, or you do not want to specialize interval_lib::rounded_math<T> (say because you prefer to work in your own namespace) you can also define your own rounding policy and pass it directly to interval_lib::policies.
This is really annoying me, ’cause I have no idea what I am doing wrong or how to fix it. No idea whatsoever, and I cannot continue with my project before figuring it out.
Sometimes, the boost library is just a little too complex for me, I guess…
–
142-152=-10