与升压make_dense_output编译错误C2440 odeint
问题描述:
我收到以下错误为state_type ublas::vector<std::complex<double>>
以“密集产出”,但 只是runge_kutta_dopri5步进编译。与升压make_dense_output编译错误C2440 odeint
C2440 '回归':从升压\数字\ odeint \步进\ controlled_runge_kutta.hpp不能转换 '的std ::复杂' 到 '双' 89
#include <iostream>
#include <complex>
#include <boost/numeric/ublas/blas.hpp>
#include <boost/numeric/ublas/vector.hpp>
#include <boost/numeric/ublas/vector_proxy.hpp>
#include <boost/numeric/ublas/assignment.hpp>
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/io.hpp>
#include <boost/numeric/odeint.hpp>
using namespace boost::numeric::odeint;
namespace bnu = boost::numeric::ublas;
typedef bnu::vector<std::complex<double>> state_type;
struct solver_test
{
state_type & m_a;
solver_test(state_type& a): m_a(a) { }
void operator()(const state_type &x, state_type &dxdt, double t) const
{
// dummy!
dxdt = element_prod(x, m_a);
}
};
struct observer
{
std::vector<double> & m_tm;
std::vector<state_type> & m_out;
observer(std::vector<double>& tm, std::vector<state_type> & out)
:m_tm(tm), m_out(out) { }
template< class State >
void operator()(const State &x, double t) const
{
m_tm.push_back(t);
m_out.push_back(x);
}
};
int main(int argc, char **argv)
{
std::vector<double> tm;
std::vector<state_type> out;
state_type a_vec(10);
std::fill_n(a_vec.begin(), 10, std::complex<double>(1.0, 0.5));
state_type noise(10);
std::fill_n(noise.begin(), 10, std::complex<double>(1.5, 1.5));
const double dt = 0.1;
typedef runge_kutta_dopri5<state_type> dp_stepper_type;
integrate_const(make_dense_output(1.0e-6, 1.0e-3, dp_stepper_type()),
solver_test(a_vec), noise, 0.0, 10.0, dt, observer(tm, out));
// This works
//integrate_const(dp_stepper_type(),
// solver_test(a_vec), noise, 0.0, 10.0, dt, observer(tm, out));
return 0;
}
我使用升压1_64_0与微软的Visual Studio Community 2017. 我错过了什么?
答
为了解决这个问题,我为state_type
变量使用了以下解决方法。
typedef std::vector<std::complex<double>> state_type;
我用boost::numeric::ublas
里面的求解器(函数对象)来利用矩阵运算。这不是完美的,但它的工作。