问题
In my last question I asked whether it is possible or not to use the adaptive integrators from boost odeint together with complex datatypes.
Do controlled error steppers in boost odeint support complex data types?
The answer worked with double precision. Now I am highly interested in the same calculation with multiprecision complex numbers. I already managed to implement this over the reals but not in the complex numbers. I tried this piece of code:
#include <iostream>
#include <complex>
#include <boost/multiprecision/mpc.hpp>
#include <boost/array.hpp>
#include <boost/numeric/odeint.hpp>
using namespace std;
using namespace boost::numeric::odeint;
//[ stuart_landau_system_function
typedef boost::multiprecision::mpc_complex_100 mpc;
typedef mpc 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 mpc 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.precision(10);
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 = mpc( 1.0 , 0.0 );
runge_kutta_dopri5< state_type , mpc > stepper;
auto c_stepper = make_controlled(1.E-12, 1.E-12, stepper);
const double dt = 0.1;
//]
integrate_adaptive(c_stepper, stuart_landau( 2.0 , 1.0 ) , x , 0.0 , 10.0 , dt , streaming_observer( cout ) );
return 0;
}
which results in a bunch of errors. Does anyone know how to implement multiprecision complex numbers in this example problem? That would make my day. Thank you in advance!
来源:https://stackoverflow.com/questions/58306832/boost-odeint-is-it-possible-to-perform-an-adaptive-integration-with-multiprecis