Page MenuHomec4science

mtest.cpp~
No OneTemporary

File Metadata

Created
Sun, Aug 4, 17:16

mtest.cpp~

#include <iostream>
#include <boost/range/algorithm.hpp>
#include <boost/numeric/odeint.hpp>
using namespace std;
using namespace boost::numeric::odeint;
typedef double state_type;
typedef runge_kutta_cash_karp54< state_type > error_stepper_type;
class Myode{
public:
void operator()(const state_type& x, state_type& dxdt, const double t){dxdt=-1-x;}
static bool done(const state_type &x){return x<=0.0;}
};
int main(int argc, char* argv[]){
Myode ode;
state_type x=10.0;
auto stepper = make_controlled< error_stepper_type >( 1.0e-10 , 1.0e-6 );
auto iter= boost::find_if(make_adaptive_range(stepper,ode,x, 0.0 , 20.0 , 0.01 ),
Myode::done);
cout<<"integration stopped at"<<x<<endl;
return 1;
}

Event Timeline