]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/numeric/odeint/examples/lorenz.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / numeric / odeint / examples / lorenz.cpp
1 #include <iostream>
2 #include <boost/array.hpp>
3
4 #include <boost/numeric/odeint.hpp>
5
6 using namespace std;
7 using namespace boost::numeric::odeint;
8
9 const double sigma = 10.0;
10 const double R = 28.0;
11 const double b = 8.0 / 3.0;
12
13 typedef boost::array< double , 3 > state_type;
14
15 void lorenz( const state_type &x , state_type &dxdt , double t )
16 {
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];
20 }
21
22 void write_lorenz( const state_type &x , const double t )
23 {
24 cout << t << '\t' << x[0] << '\t' << x[1] << '\t' << x[2] << endl;
25 }
26
27 int main(int argc, char **argv)
28 {
29 state_type x = {{ 10.0 , 1.0 , 1.0 }}; // initial conditions
30 integrate( lorenz , x , 0.0 , 25.0 , 0.1 , write_lorenz );
31 }