Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/129.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ C++;升压间隔与cos_C++_Boost_Boost Interval - Fatal编程技术网

C++ C++;升压间隔与cos

C++ C++;升压间隔与cos,c++,boost,boost-interval,C++,Boost,Boost Interval,我在使用Boost的间隔库时遇到问题 #include <boost/numeric/interval.hpp> void test() { typedef boost::numeric::interval<double> Interval; Interval i1(1.0, 2.0); auto i2 = cos(i1); } #包括 无效测试() { typedef boost::numeric::interval; 区间i1(1.0,

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

#include <boost/numeric/interval.hpp>

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

    Interval i1(1.0, 2.0);

    auto i2 = cos(i1);
}
#包括
无效测试()
{
typedef boost::numeric::interval;
区间i1(1.0,2.0);
自动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>'
transc.hpp(73):错误C2039:“cos\u down”:不是“boost::numeric::interval\u lib::rounded\u math”的成员
transc.hpp(73):错误C2039:“cos\u up”:不是“boost::numeric::interval\u lib::rounded\u math”的成员
transc.hpp(75):错误C2039:“cos\u up”:不是“boost::numeric::interval\u lib::rounded\u math”的成员

我尝试了几种
interval_lib::policies
组合,但未能编译示例。我不追求很高的精度。我想要的基本上是,添加两个区间相当于添加两个
double
s.

interval类需要舍入和检查策略。将interval typedef更改为以下值,它应该可以编译。您需要通读文档,以准确了解您的案例需要哪些策略

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

Vladimir,不幸的是,这并不能解决这个问题。下面是一个关于如何基于多精度库为超越函数创建舍入策略的示例:这将编译--谢谢。我以前试过你写的东西,但是用了
四舍五入\u-arith\u-exact
。这就产生了同样的错误。我应该使用的是
四舍五入\u transc\u exact
。我明白了。Trascental函数没有默认的舍入策略,尽管库提供了许多现成的策略类。