【问题标题】:boost odeint integration提升 odeint 集成
【发布时间】:2017-08-12 00:23:00
【问题描述】:

有人可以帮我解决我正在尝试使用 boost odeint 库计算的集成。这就是我所拥有的:

    double z0 = -1.6;
    double z1 = -1.0;
    double dz = (z1 - z0) / 100;
    double P(0.);
    size_t xx = boost::numeric::odeint::integrate(my_integrand, P, z0, z1, dz);

其中my_integrand 是一个定义为的函数(注意,目前我还没有完全定义函数计算,因为我希望它首先正确编译):

   void my_integrand(const double& P, double& dPdz, double z) { dPdz = 0.; };

我在编译时收到以下错误:

3>C:\boost\boost_1_61_0\boost/numeric/odeint/integrate/integrate.hpp(68):error C2780: 'size_t boost::numeric::odeint::integrate(System,State &,Time,Time,Time)' : expects 5 arguments - 6 provided
3>C:\boost\boost_1_61_0\boost/numeric/odeint/integrate/integrate.hpp(72) : see declaration of 'boost::numeric::odeint::integrate'
3>..\..\test.cpp(36) : see reference to function template instantiation 'size_t boost::numeric::odeint::integrate<void(__cdecl *)(const double &,double &,double),double,double>(System,State &,Time,Time,Time)' being compiled
3>          with
3>          [
3>              System=void (__cdecl *)(const double &,double &,double)
3>  ,            State=double
3>  ,            Time=double
3>          ]
3>C:\boost\boost_1_61_0\boost/numeric/odeint/integrate/integrate.hpp(66) : see declaration of 'boost::numeric::odeint::integrate'
3>C:\boost\boost_1_61_0\boost/numeric/odeint/integrate/integrate.hpp(68): error C2783: 'size_t boost::numeric::odeint::integrate(System,State &,Time,Time,Time,Observer)' : could not deduce template argument for 'Value'
3>C:\boost\boost_1_61_0\boost/numeric/odeint/integrate/integrate.hpp(53) : see declaration of 'boost::numeric::odeint::integrate'
3>C:\boost\boost_1_61_0\boost/numeric/odeint/integrate/integrate.hpp(68): error C2893: Failed to specialize function template 'boost::enable_if<has_value_type<State,boost::mpl::bool_<false>>::type,size_t>::type boost::numeric::odeint::integrate(System,State &,Time,Time,Time,Observer)'
3>          With the following template arguments:
3>          'System=void (__cdecl *)(const double &,double &,double)'
3>          'State=double'
3>          'Time=double'
3>          'Observer=boost::numeric::odeint::null_observer'

【问题讨论】:

    标签: c++ c++11 templates boost


    【解决方案1】:

    您可以尝试将integrate 行更改为

    size_t xx = boost::numeric::odeint::integrate<double>my_integrand, P, z0, z1, dz);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-16
      • 2011-03-12
      相关资源
      最近更新 更多