Boost 使用带推力复合体的助推odeint

Boost 使用带推力复合体的助推odeint,boost,thrust,odeint,Boost,Thrust,Odeint,我试图在boost odeint中使用受控步进器,它带有推力::主机向量容器和推力::复杂数据类型。当我使用std::vector和std::complex时,以下代码会编译,但是当我使用推力容器和/或数据类型时,编译器会抛出一个错误 其次,只有当我使用受控步进器并且简单步进器使用推力时,才会发生错误(您可以取消注释代码的适当部分)。我的代码中有错误还是来自odeint #include <iostream> #include <vector> #include <

我试图在boost odeint中使用受控步进器,它带有
推力::主机向量
容器和
推力::复杂
数据类型。当我使用
std::vector
std::complex
时,以下代码会编译,但是当我使用推力容器和/或数据类型时,编译器会抛出一个错误

其次,只有当我使用受控步进器并且简单步进器使用推力时,才会发生错误(您可以取消注释代码的适当部分)。我的代码中有错误还是来自odeint

#include <iostream>
#include <vector>
#include <complex>

#include <thrust/host_vector.h>
#include <thrust/for_each.h>
#include <thrust/transform.h>
#include <thrust/complex.h>

#include <boost/numeric/odeint.hpp>
#include <boost/numeric/odeint/external/thrust/thrust.hpp>

using namespace boost::numeric::odeint;

typedef std::complex<double> c_type;
typedef std::vector<c_type> state_vec;
//typedef thrust::complex<double> c_type;
//typedef thrust::host_vector<c_type> state_vec;

template<typename data_type, typename complex_type>
struct multiply {
    data_type a;
    multiply (data_type a): a(a) {}

    complex_type operator()(const complex_type& x){
        return -a*x;
    }
};

template<typename state_type, typename data_type>
struct exp_system {
    const data_type gamma;
    exp_system (data_type gamma): gamma(gamma) {}
    void operator()(const state_type &x, state_type &dxdt, const data_type){
        thrust::transform(x.begin(), x.end(), dxdt.begin(),
                          multiply<data_type, c_type>(gamma));
    }
};

int main()
{
    state_vec x(2);
    x[0] = c_type(1.0, 0.0);
    x[1] = c_type(0.10, 0.0);
    double gamma = 0.15;
    double t_final = 10.0;

    runge_kutta_dopri5<state_vec> stepper;
    auto c_stepper = make_controlled(1.E-5, 1.E-5, stepper);
    auto n_steps = integrate_adaptive(c_stepper,
                                      exp_system<state_vec, double>(gamma),
                                      x , 0.0 , t_final, 0.01 );
    //auto n_steps = integrate_adaptive(stepper,
    //                                  exp_system<state_vec, double>(gamma),
    //                                  x, 0.0, t_final, 0.01);

    std::cout << n_steps << std::endl;

    return 0;
}
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
使用名称空间boost::numeric::odeint;
typedef std::复杂c_类型;
typedef std::向量状态_vec;
//类型定义推力:复杂c_类型;
//typedef推力::主机向量状态向量;
模板
结构乘法{
数据类型a;
乘法(数据类型a):a(a){
复杂类型运算符()(常量复杂类型&x){
返回-a*x;
}
};
模板
结构扩展系统{
常数数据类型γ;
exp_系统(数据类型gamma):gamma(gamma){}
void运算符()(常数状态类型&x,状态类型&dxdt,常数数据类型){
推力::变换(x.begin(),x.end(),dxdt.begin(),
乘(伽马);
}
};
int main()
{
状态向量x(2);
x[0]=c_型(1.0,0.0);
x[1]=c_型(0.10,0.0);
双伽马=0.15;
双t_最终值=10.0;
runge_kutta_dopri5步进机;
自动c_步进器=使_受控(1.E-5,1.E-5,步进器);
自动n_步进=集成自适应(c_步进,
exp_系统(伽马),
x,0.0,t_最终,0.01);
//自动n_步=集成自适应(步进,
//exp_系统(伽马),
//x,0.0,t_最终,0.01);
标准::cout