【问题标题】:C++ Boost Interval and cosC++ Boost Interval 和 cos
【发布时间】:2013-04-07 09:12:34
【问题描述】:

我在使用 Boost 的 Interval 库时遇到问题

#include <boost/numeric/interval.hpp>

void test()
{
    typedef boost::numeric::interval<double> Interval;

    Interval i1(1.0, 2.0);

    auto i2 = cos(i1);
}

我收到以下编译错误:

transc.hpp(73): error C2039: 'cos_down' : is not a member of 'boost::numeric::interval_lib::rounded_math<double>'
transc.hpp(73): error C2039: 'cos_up' : is not a member of 'boost::numeric::interval_lib::rounded_math<double>'
transc.hpp(75): error C2039: 'cos_up' : is not a member of 'boost::numeric::interval_lib::rounded_math<double>'

我尝试了interval_lib::policies 的几种组合,但无法编译示例。我不追求非常高的精度。我想要的基本上是添加两个间隔相当于添加两个doubles。

【问题讨论】:

标签: c++ boost boost-interval


【解决方案1】:

interval 类需要舍入和检查策略。将您的区间类型定义更改为以下内容,它应该可以编译。您需要通读文档以准确了解您的案例需要哪些政策。

typedef interval<double, policies<save_state<rounded_transc_std<double> >,
                    checking_base<double> > > Interval;

【讨论】:

  • 这个编译——谢谢。我以前试过你写的东西,但是用rounded_arith_exact代替。这给出了同样的错误。
  • 我应该使用的是rounded_transc_exact。我明白了。
  • 超越函数没有默认的舍入策略,尽管库确实提供了许多现成的策略类。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2022-01-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-02-21
  • 1970-01-01
相关资源
最近更新 更多