3

我尝试在 Debian Squeeze g++4.4 上的 boost_1_54_0 中运行odeint 示例

Lorenz 系统工作正常,但简单的一维颂歌

#include <iostream>
#include <boost/numeric/odeint.hpp>


using namespace std;
using namespace boost::numeric::odeint;


/* we solve the simple ODE x' = 3/(2t^2) + x/(2t)
 * with initial condition x(1) = 0.
 * Analytic solution is x(t) = sqrt(t) - 1/t
 */

void rhs( const double x , double &dxdt , const double t )
{
    dxdt = 3.0/(2.0*t*t) + x/(2.0*t);
}

void write_cout( const double &x , const double t )
{
    cout << t << '\t' << x << endl;
}

// state_type = double
typedef runge_kutta_dopri5< double > stepper_type;

int main()
{
    double x = 0.0; 
    //with the following line commented the program compiles
    integrate_adaptive( make_controlled( 1E-12 , 1E-12 , stepper_type() ) ,
                        rhs , x , 1.0 , 10.0 , 0.1 , write_cout );
}

不编译。有 192 行错误以以下结尾:

/usr/local/include/boost/numeric/odeint/algebra/range_algebra.hpp:76: error: no matching function for call to ‘begin(double&)’
/usr/local/include/boost/numeric/odeint/algebra/range_algebra.hpp:76: error: no matching function for call to ‘end(double&)’
/usr/local/include/boost/numeric/odeint/algebra/range_algebra.hpp:76: error: no matching function for call to ‘begin(const double&)’
/usr/local/include/boost/numeric/odeint/algebra/range_algebra.hpp:76: error: no matching function for call to ‘begin(const double&)’
/usr/local/include/boost/numeric/odeint/algebra/range_algebra.hpp:76: error: no matching function for call to ‘begin(double&)’
/usr/local/include/boost/numeric/odeint/algebra/range_algebra.hpp:76: error: no matching function for call to ‘begin(double&)’
/usr/local/include/boost/numeric/odeint/algebra/range_algebra.hpp:76: error: no matching function for call to ‘begin(double&)’
/usr/local/include/boost/numeric/odeint/algebra/range_algebra.hpp:76: error: no matching function for call to ‘begin(double&)’

有什么问题?

4

1 回答 1

6

网页上的示例仅使用 odeint 的 github 版本运行。如果将步进器类型更改为

typedef runge_kutta_dopri5< double , double , double , double , vector_space_algebra > stepper_type;

它应该运行。我们已经包含了一个自动代数检测机制,它不在官方的 boost 版本中,但很快就会包含在内。

于 2013-09-15T06:55:10.130 回答