首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >odeint简单的一维ode示例不编译

odeint简单的一维ode示例不编译
EN

Stack Overflow用户
提问于 2013-09-15 04:33:07
回答 1查看 740关注 0票数 3

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

Lorenz系统工作良好,但简单的一维ode

代码语言:javascript
复制
#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行错误,结尾为:

代码语言:javascript
复制
/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&)’

有什么问题吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-09-15 06:55:10

该网页上的示例仅与odeint的github版本一起运行。如果将步骤类型更改为

代码语言:javascript
复制
typedef runge_kutta_dopri5< double , double , double , double , vector_space_algebra > stepper_type;

它应该跑了。我们已经包括了一个自动代数检测机制,这不是在官方的boost版本,但它将很快包括在内。

票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18808931

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档