提升区间算术和三角函数

boost interval arithmetic and trigonometric functions

我有一个与此处提供的问题(和答案)相关的问题: C++ Boost Interval and cos 我也在尝试使用区间算法来计算三角函数,我面临着与上述问题的作者提出的问题类似的问题。我尝试使用上面链接的问题的答案并生成了下面的代码。但它不编译。这是代码:

#include <boost/numeric/interval.hpp> 
using namespace boost::numeric;
using namespace interval_lib;
typedef interval<double, policies<save_state<rounded_transc_std<double> >, checking_base<double> >   > Interval;
int main()
{  
    Interval i1(1.0, 2.0);
    Interval i2 = cos(i1);
    return 0;
}

我收到的错误如下:

In file included from /usr/include/boost/numeric/interval/hw_rounding.hpp:15:0,
         from /usr/include/boost/numeric/interval.hpp:18,
         from interval_test.cpp:34:
/usr/include/boost/numeric/interval/rounded_arith.hpp: In instantiation of ‘T boost::numeric::interval_lib::rounded_arith_std<T,        Rounding>::int_down(const T&) [with T = double; Rounding =        boost::numeric::interval_lib::rounding_control<double>]’:
/usr/include/boost/numeric/interval/arith2.hpp:40:49:   required from       ‘boost::numeric::interval<T, Policies> boost::numeric::fmod(const       boost::numeric::interval<T, Policies>&, const boost::numeric::interval<T,       Policies>&) [with T = double; Policies =         boost::numeric::interval_lib::policies<boost::numeric::interval_lib::detal ::save_state_unprotected<boost::numeric::interval_lib::rounded_transc_std     <double> >, boost::numeric::interval_lib::checking_base<double> >]’
/usr/include/boost/numeric/interval/transc.hpp:62:32:   required from     ‘boost::numeric::interval<T, Policies> boost::numeric::cos(const       boost::numeric::interval<T, Policies>&) [with T = double; Policies =       boost::numeric::interval_lib::policies<boost::numeric::interval_lib::save_    state<boost::numeric::interval_lib::rounded_transc_std<double> >,            boost::numeric::interval_lib::checking_base<double> >]’
interval_test.cpp:44:25:   required from here
/usr/include/boost/numeric/interval/rounded_arith.hpp:71:61: error:        ‘to_int’ was not declared in this scope, and no declarations were found by         argument-dependent lookup at the point of instantiation [-fpermissive]
 T int_down(const T& x) { this->downward(); return to_int(x); }
                                                     ^
/usr/include/boost/numeric/interval/rounded_arith.hpp:71:61: note:    declarations in dependent base    ‘boost::numeric::interval_lib::detail::c99_rounding_control’ are not found    by unqualified lookup
/usr/include/boost/numeric/interval/rounded_arith.hpp:71:61: note: use ‘this->to_int’ instead

我正在使用 boost 1.54.0 和 gcc 4.8.4。 你知道我做错了什么吗?

非常感谢您的帮助。

此问题已在 2014/2015 中修复:请参阅 https://github.com/boostorg/interval/pull/1

此修复在 boost 1.58 中可用,因此您必须将 boost 版本至少升级到 1.58。