【问题标题】:boost interval arithmetic and trigonometric functions升压区间算术和三角函数
【发布时间】:2017-01-14 07:38:48
【问题描述】:

我有一个与此处提供的问题(和答案)相关的问题: 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。 你知道我做错了什么吗?

非常感谢您的帮助。

【问题讨论】:

  • 它在 gcc 5.4 和 boost 1.58 上构建良好。
  • 谢谢阿米。我正在使用 boost 1.54.0 和 gcc 4.8.4,这就是我遇到这个问题的地方
  • 那么您可能希望将其添加到问题中。祝你好运!
  • 这已在 2014/2015 年修复:github.com/boostorg/interval/pull/1 此修复在 boost 1.58 中可用,因此您必须升级您的 boost 版本
  • @m.s.或 OP 请添加一个(自我)答案,以便此解决方案在评论之外可见。干得好+1

标签: c++ math boost intervals trigonometry


【解决方案1】:

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

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

【讨论】:

  • 再次感谢您,它适用于当前版本的 Boost。
猜你喜欢
  • 2015-03-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-05-21
相关资源
最近更新 更多