C ++ Boost间隔和cos [英] C++ Boost Interval and cos

查看:173
本文介绍了C ++ Boost间隔和cos的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法使用Boost的Interval库

I have trouble using the Interval library from Boost

#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>'


$ b b

我已经尝试过 interval_lib :: policies 的几个组合,但是没有能够编译一个例子。我不是在非常高的精度。我想要的基本上是添加两个间隔等效于添加两个 double

I have tried several combinations of interval_lib::policies but have not been able to compile an example. I am not after very high precision. What I want is basically that adding two intervals is equivalent of adding two doubles.

推荐答案

interval类期望舍入和检查策略。更改您的间隔typedef到以下,它应该编译。您需要仔细阅读相关文档,以了解您的案例中需要哪些政策。

The interval class expects rounding and checking policies. Change your interval typedef to the following and it should compile. You'll need to read through the documentation to understand exactly what policies you need in your case.

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

这篇关于C ++ Boost间隔和cos的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆