c++ - boost 软件集成

标签 c++ c++11 templates boost

有人可以帮助我进行集成,我正在尝试使用 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'

最佳答案

你能否尝试将 integrate 行更改为

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

关于c++ - boost 软件集成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42908426/

相关文章:

java - 为什么要避免在 Java 中使用 C++ 关键字?

c++ linux ifstream 读取csv文件

c++ - 跨线程原子变量更新反射的延迟

c++ - SFINAE 意想不到的结果

c++ - 遍历 function_traits 参数

c++ - 从 C 编译器更改为 C++ 编译器会导致 MSP430 固件出现编译器错误

c++ - 如何使用 std::array 模拟 C 数组初始化 "int arr[] = { e1, e2, e3, ... }"行为?

c++ - 带有 std::string 的文字类仅适用于模板特化?

c++ - 模板函数给出编译错误

c++ - 根据模板参数将函数标记为 noexcept