C++ 带odeint的简单2d系统(使用数组)不编译

C++ 带odeint的简单2d系统(使用数组)不编译,c++,arrays,boost,vector,odeint,C++,Arrays,Boost,Vector,Odeint,我在mint12上运行g++4.7,boost1.55。我试图用odeint解决一个简单的2d ode系统——下面是1d示例:。1d示例在原始版本和答案的修订版本中都可以编译。现在,如果我想要一个2d系统,并且我使用了双[2]系统,那么它不起作用: #include <iostream> #include <boost/numeric/odeint.hpp> using namespace std; using namespace boost::numeric::ode

我在mint12上运行g++4.7,boost1.55。我试图用odeint解决一个简单的2d ode系统——下面是1d示例:。1d示例在原始版本和答案的修订版本中都可以编译。现在,如果我想要一个2d系统,并且我使用了双[2]系统,那么它不起作用:

#include <iostream>
#include <boost/numeric/odeint.hpp>

using namespace std;
using namespace boost::numeric::odeint;

void rhs( const double *x, double *dxdt, const double t )
{
    dxdt[0] = 3.0/(2.0*t*t) + x[0]/(2.0*t);
    dxdt[1] = 3.0/(2.0*t*t) + x[1]/(2.0*t);
}

void write_cout( double *x, const double t )
{
    cout << t << '\t' << x[0] << '\t' << 2*x[1] << endl;
}

typedef runge_kutta_cash_karp54< double[2] > stepper_type;

int main()
{
    double x[2] = {0.0,0.0};
    integrate_adaptive( make_controlled( 1E-12, 1E-12, stepper_type() ), rhs, x, 1.0, 10.0, 0.1, write_cout );
}
#包括
#包括
使用名称空间std;
使用名称空间boost::numeric::odeint;
无效rhs(常数双*x,常数双*dxdt,常数双t)
{
dxdt[0]=3.0/(2.0*t*t)+x[0]/(2.0*t);
dxdt[1]=3.0/(2.0*t*t)+x[1]/(2.0*t);
}
无效写入系数(双*x,常数双t)
{

不能使用std::array

#include <array>

typedef std::array< double , 2 > state_type;
void rhs( state_type const &x, state_type &dxdt, const double t )
{
    dxdt[0] = 3.0/(2.0*t*t) + x[0]/(2.0*t);
    dxdt[1] = 3.0/(2.0*t*t) + x[1]/(2.0*t);
}

void write_cout( state_type const& x, const double t )
{
    cout << t << '\t' << x[0] << '\t' << 2*x[1] << endl;
}

typedef runge_kutta_cash_karp54< state_type > stepper_type;
#包括
typedef std::数组状态类型;
无效rhs(状态类型常量和x、状态类型和dxdt、常量双t)
{
dxdt[0]=3.0/(2.0*t*t)+x[0]/(2.0*t);
dxdt[1]=3.0/(2.0*t*t)+x[1]/(2.0*t);
}
无效写入(状态类型常量和x,常量双t)
{
库特
#include <array>

typedef std::array< double , 2 > state_type;
void rhs( state_type const &x, state_type &dxdt, const double t )
{
    dxdt[0] = 3.0/(2.0*t*t) + x[0]/(2.0*t);
    dxdt[1] = 3.0/(2.0*t*t) + x[1]/(2.0*t);
}

void write_cout( state_type const& x, const double t )
{
    cout << t << '\t' << x[0] << '\t' << 2*x[1] << endl;
}

typedef runge_kutta_cash_karp54< state_type > stepper_type;