]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/numeric/odeint/examples/lorenz.cpp
2 #include <boost/array.hpp>
4 #include <boost/numeric/odeint.hpp>
7 using namespace boost::numeric::odeint
;
9 const double sigma
= 10.0;
10 const double R
= 28.0;
11 const double b
= 8.0 / 3.0;
13 typedef boost::array
< double , 3 > state_type
;
15 void lorenz( const state_type
&x
, state_type
&dxdt
, double t
)
17 dxdt
[0] = sigma
* ( x
[1] - x
[0] );
18 dxdt
[1] = R
* x
[0] - x
[1] - x
[0] * x
[2];
19 dxdt
[2] = -b
* x
[2] + x
[0] * x
[1];
22 void write_lorenz( const state_type
&x
, const double t
)
24 cout
<< t
<< '\t' << x
[0] << '\t' << x
[1] << '\t' << x
[2] << endl
;
27 int main(int argc
, char **argv
)
29 state_type x
= {{ 10.0 , 1.0 , 1.0 }}; // initial conditions
30 integrate( lorenz
, x
, 0.0 , 25.0 , 0.1 , write_lorenz
);