简体   繁体   English

增强区间算术和三角函数

[英]boost interval arithmetic and trigonometric functions

I have a question which is related to the question (and answers) available over here: C++ Boost Interval and cos I am also trying to use the interval arithmetic to compute trigonometric functions, and I am facing similar problems to the one presented by the Author of the question above. 我有一个问题与这里提供的问题(和答案)有关: C ++ Boost Interval和cos我也试图使用区间算法来计算三角函数,我面临的问题与作者提出的问题相似上面的问题。 I tried to use the answer for the question linked above and have produced the code below. 我尝试使用上面链接的问题的答案,并生成下面的代码。 But it do not compile. 但它不编译。 Here is the code: 这是代码:

#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;
}

The error I am getting is the following: 我得到的错误如下:

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

I am using boost 1.54.0 and gcc 4.8.4. 我使用的是boost 1.54.0和gcc 4.8.4。 Do you have any idea what I am doing wrong? 你知道我做错了什么吗?

Thanks a lot for your help. 非常感谢你的帮助。

This issue has been fixed in 2014/2015: see https://github.com/boostorg/interval/pull/1 此问题已于2014/2015修复:请参阅https://github.com/boostorg/interval/pull/1

This fix is available in boost 1.58, so you have to upgrade your boost version to at least 1.58. 此修复程序在boost 1.58中可用,因此您必须将升级版本升级到至少1.58。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM