2016-09-06 6 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

Возможно, вы захотите добавить это к вопросу. Удачи! –

ответ

0

Эта проблема была исправлена ​​в 2014/2015: см https://github.com/boostorg/interval/pull/1

Это исправление доступно в наддува 1,58, так что вы должны обновить версию повысить, по крайней мере, 1,58.

+0

Еще раз спасибо, он работает с текущей версией Boost. – user47459