odeint复杂状态类型示例不编译。

时间:2021-02-01 15:29:03

I try to run [odeint complex state type example code in boost_1_55_0 on Mac OS X 10.9.2 g++ 5.1.

我尝试在Mac OS X 10.9.2 g++ 5.1中运行[odeint复杂的状态类型示例代码,在boost_1_55_0中。

The code below is the copy on the website which solves the Stuart-Landau oscillator

下面的代码是网站上的一份拷贝,它解决了斯图亚特-兰多振荡器。

#include <iostream>
#include <complex>
#include <boost/array.hpp>

#include <boost/numeric/odeint.hpp>

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

//[ stuart_landau_system_function
typedef complex< double > state_type;

struct stuart_landau
{
    double m_eta;
    double m_alpha;

    stuart_landau( double eta = 1.0 , double alpha = 1.0 )
    : m_eta( eta ) , m_alpha( alpha ) { }

    void operator()( const state_type &x , state_type &dxdt , double t ) const
    {
        const complex< double > I( 0.0 , 1.0 );
        dxdt = ( 1.0 + m_eta * I ) * x - ( 1.0 + m_alpha * I ) * norm( x ) * x;
    }
};
//]


/*
//[ stuart_landau_system_function_alternative
double eta = 1.0;
double alpha = 1.0;

void stuart_landau( const state_type &x , state_type &dxdt , double t )
{
    const complex< double > I( 0.0 , 1.0 );
    dxdt = ( 1.0 + m_eta * I ) * x - ( 1.0 + m_alpha * I ) * norm( x ) * x;
}
//]
*/


struct streaming_observer
{
    std::ostream& m_out;

    streaming_observer( std::ostream &out ) : m_out( out ) { }

    template< class State >
    void operator()( const State &x , double t ) const
    {
        m_out << t;
        m_out << "\t" << x.real() << "\t" << x.imag() ;
        m_out << "\n";
    }
};




int main( int argc , char **argv )
{
    //[ stuart_landau_integration
    state_type x = complex< double >( 1.0 , 0.0 );

    const double dt = 0.1;

    typedef runge_kutta4< state_type > stepper_type;

    integrate_const( stepper_type() , stuart_landau( 2.0 , 1.0 ) , x , 0.0 , 10.0 , dt , streaming_observer( cout ) );
    //]

    return 0;
}

The sample code above doesn't compile. 9 errors generates and ends with:

上面的示例代码没有编译。9错误产生和结束:

'boost::numeric::odeint::explicit_stepper_base<boost::numeric::odeint::explicit_generic_rk<4, 4, std::__1::complex<double>, double, std::__1::complex<double>, double,
      boost::numeric::odeint::range_algebra, boost::numeric::odeint::default_operations, boost::numeric::odeint::initially_resizer>, 4, std::__1::complex<double>, double, std::__1::complex<double>,
      double, boost::numeric::odeint::range_algebra, boost::numeric::odeint::default_operations, boost::numeric::odeint::initially_resizer>::do_step_v1<stuart_landau, std::__1::complex<double> >'
      requested here
        do_step_v1( system , x , t , dt );
        ^
/usr/include/boost/numeric/odeint/integrate/detail/integrate_adaptive.hpp:62:17: note: in instantiation of function template specialization
      'boost::numeric::odeint::explicit_stepper_base<boost::numeric::odeint::explicit_generic_rk<4, 4, std::__1::complex<double>, double, std::__1::complex<double>, double,
      boost::numeric::odeint::range_algebra, boost::numeric::odeint::default_operations, boost::numeric::odeint::initially_resizer>, 4, std::__1::complex<double>, double, std::__1::complex<double>,
      double, boost::numeric::odeint::range_algebra, boost::numeric::odeint::default_operations, boost::numeric::odeint::initially_resizer>::do_step<stuart_landau, std::__1::complex<double> >' requested
      here
        stepper.do_step( system , start_state , end , end_time - end );
                ^
/usr/include/boost/numeric/odeint/integrate/integrate_const.hpp:50:24: note: in instantiation of function template specialization
      'boost::numeric::odeint::detail::integrate_adaptive<boost::numeric::odeint::runge_kutta4<std::__1::complex<double>, double, std::__1::complex<double>, double, boost::numeric::odeint::range_algebra,
      boost::numeric::odeint::default_operations, boost::numeric::odeint::initially_resizer>, stuart_landau, std::__1::complex<double>, double, streaming_observer>' requested here
        return detail::integrate_adaptive(
                       ^
main.cpp:84:5: note: in instantiation of function template specialization 'boost::numeric::odeint::integrate_const<boost::numeric::odeint::runge_kutta4<std::__1::complex<double>, double,
      std::__1::complex<double>, double, boost::numeric::odeint::range_algebra, boost::numeric::odeint::default_operations, boost::numeric::odeint::initially_resizer>, stuart_landau,
      std::__1::complex<double>, double, streaming_observer>' requested here
    integrate_const( stepper_type() , stuart_landau( 2.0 , 1.0 ) , x , 0.0 , 10.0 , dt , streaming_observer( cout ) );
^

What is the bug?

这个错误是什么?

1 个解决方案

#1


2  

You use a feature which only exist in the github version of odeint. Replace the typedef for the stepper with

您使用的特性仅存在于odeint的github版本中。替换为stepper的typedef。

typedef runge_kutta4< state_type , double ,
                      state_type , double ,
                      vector_space_algebra > stepper_type;

Automatic algebra detection currently works only in the github version of odeint. We try to get this feature into the next official boost version.

自动代数检测目前只适用于odeint的github版本。我们试图将这个特性引入到下一个官方版本中。

#1


2  

You use a feature which only exist in the github version of odeint. Replace the typedef for the stepper with

您使用的特性仅存在于odeint的github版本中。替换为stepper的typedef。

typedef runge_kutta4< state_type , double ,
                      state_type , double ,
                      vector_space_algebra > stepper_type;

Automatic algebra detection currently works only in the github version of odeint. We try to get this feature into the next official boost version.

自动代数检测目前只适用于odeint的github版本。我们试图将这个特性引入到下一个官方版本中。