headmyshoulder / odeint-v2

odeint - solving ordinary differential equations in c++ v2
http://headmyshoulder.github.com/odeint-v2/
Other
337 stars 102 forks source link

odeint incompatible with multiple precision types in boost v1.68? #247

Open niggetiedt opened 4 years ago

niggetiedt commented 4 years ago

Hi there,

First of all, I really appreciate this library and its powerful methods. However, I managed to compile the following code within boost version 1.67 but not with version >= 1.68. In the newer versions they included multiple precision support for complex numbers, which I would also like to use with odeint. Is it a problem of the stepper? Thank you in advance!

#include <iostream>

#include <boost/array.hpp>
#include <boost/numeric/odeint.hpp>
#include <boost/multiprecision/gmp.hpp>

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

typedef boost::multiprecision::mpf_float_100 mpf;
typedef boost::array< mpf , 1 > state_type;

void rhs( const state_type &x , state_type &dxdt , const mpf t )
{
    dxdt[0] = ( - x[0] * sin( t ) + 2.0 * tan( t ) ) * x[0];
}

void write_out( const state_type &x , const mpf t )
{
    cout.precision(50);
    cout << t << '\t' << x[0] << endl;
}

int main()
{
    bulirsch_stoer< state_type , mpf > stepper( 1E-20 , 0 , 0 , 0 );

    state_type x;

    mpf t = mpf("0.2");
    mpf dt = mpf("0.01");
    mpf t_end = mpf("1.5");

    x[0] = 1.15;

    integrate_adaptive( stepper , rhs , x , t , t_end , dt , write_out );
}
ds283 commented 4 years ago

This is no help, but I have a similar issue with #245 with no response from the developers. It's unfortunate because In the past they have been very responsive.

ds283 commented 4 years ago

See https://github.com/headmyshoulder/odeint-v2/issues/245#issuecomment-560039039.

Currently the workaround seems to be to revert to commit https://github.com/boostorg/multiprecision/commit/339085567bcc3911b0c194bf5afc13f60c388831 in Boost::Multiprecision or earlier.