]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/numeric/odeint/examples/integrate_times.cpp
1 /* Boost libs/numeric/odeint/examples/integrate_times.cpp
3 Copyright 2009-2014 Karsten Ahnert
4 Copyright 2009-2014 Mario Mulansky
6 example for the use of integrate_times
8 Distributed under the Boost Software License, Version 1.0.
9 (See accompanying file LICENSE_1_0.txt or
10 copy at http://www.boost.org/LICENSE_1_0.txt)
15 #include <boost/numeric/odeint.hpp>
18 using namespace boost::numeric::odeint
;
25 void rhs( const double x
, double &dxdt
, const double t
)
27 dxdt
= 3.0/(2.0*t
*t
) + x
/(2.0*t
);
30 void write_cout( const double &x
, const double t
)
32 cout
<< t
<< '\t' << x
<< endl
;
35 // state_type = double
36 typedef runge_kutta_dopri5
< double > stepper_type
;
38 const double dt
= 0.1;
42 // create a vector with observation time points
43 std::vector
<double> times( 91 );
44 for( size_t i
=0 ; i
<times
.size() ; ++i
)
45 times
[i
] = 1.0 + dt
*i
;
47 double x
= 0.0; //initial value x(1) = 0
48 // we can provide the observation time as a boost range (i.e. the vector)
49 integrate_times( make_controlled( 1E-12 , 1E-12 , stepper_type() ) , rhs
,
50 x
, times
, dt
, write_cout
);
51 // or as two iterators
52 //integrate_times( make_controlled( 1E-12 , 1E-12 , stepper_type() ) , rhs ,
53 // x , times.begin() , times.end() , dt , write_cout );