2017-03-20 150 views
1

有人可以幫我整合,我試圖用boostodeint庫來計算。這是我有:boost odeint integration

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' 

回答

0

你可以嘗試將integrate線更改爲

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