我在从BOOST odeint库中获取Adams-Bashforth-Moulton方法时遇到了一些麻烦.我已经成功完成了Bulirsch-Stoer,但出于某种原因Adams-Bashforth-Moulton只要我尝试使用> 2的订单就返回nan.如果我使用1或2的顺序,我会得到真正答案的两倍.我已将代码缩减为:
#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; …
Run Code Online (Sandbox Code Playgroud)