Unable to get BOOST odeint to work with Adams-Bashforth-Moulton

I'm having trouble getting the Adams-Bashforth-Moulton method from the BOOST odeint library to work. I succeeded with the Buliers Stour, but for some reason Adams-Bashfort-Moulton just returns to NATO when I try to use order> 2. If I use order 1 or 2, I get a double answer. I shortened my code to:

#include <iostream> #include <boost/array.hpp> #include <boost/numeric/odeint.hpp> #include <boost/version.hpp> typedef boost::array<long double, 2> state_type; using namespace boost::numeric::odeint; class Boost_odeint_rhs{ public: Boost_odeint_rhs(){ } void operator() (const state_type &x, state_type &dxdt, const double t) { dxdt[0] = 1; dxdt[1] = 2; } }; int main() { std::cout << "using boost " << BOOST_VERSION / 100000 << "." << BOOST_VERSION / 100 % 1000 << "." << BOOST_VERSION % 100 << std::endl; std::cout << "integrating vector [1,2] over (0,1)" << std::endl; Boost_odeint_rhs rhs; state_type Bint; Bint[0] = 0.0; Bint[1] = 0.0; adams_bashforth_moulton< 2 , state_type > stepper; //bulirsch_stoer< state_type > stepper( 1e-5 , 0.0 , 0.0 , 1.0 ); integrate_adaptive( stepper , rhs , Bint , 0.0 , 1.0 , 1e-3 ); std::cout << "returned integral = " << Bint[0] << " "<< Bint[1] << std::endl; } 

I am using BOOST 1.54.0 and GCC 4.8.2 on Ubuntu 14.04

Thanks in advance.

+6
source share
1 answer

Looks like a weird mistake. When i change

 typedef boost::array< long double , 2 > state_type 

to

 typedef boost::array< double , 2 > state_type 

it works. But, of course, this is not a real solution, but perhaps this is a workaround for you. However, I am trying to find the problem and provide a solution.

Update: This is a bug in odeint. But it has already been fixed, and the fix will be available in the next version of boost (which should appear very soon). You can also use the current version from the odeint github repository .

+2
source

Source: https://habr.com/ru/post/973436/


All Articles