2016-09-06 22 views
1

我有一個問題,這是可用在這裏的問題(和答案): 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 

我使用升壓1.54.0和gcc 4.8.4。 你知道我在做什麼錯嗎?

非常感謝你的幫助。

+1

它在gcc 5.4和1.58版本上都很好。 –

+0

謝謝阿美。我使用boost 1.54.0和gcc 4.8.4,這是我遇到這個問題的地方 – user47459

+1

然後,你可能想把這個問題添加到問題中。祝你好運! –

回答