• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2011-2013 Mario Mulansky
3  * Copyright 2012 Karsten Ahnert
4  *
5  * Distributed under the Boost Software License, Version 1.0.
6  * (See accompanying file LICENSE_1_0.txt or
7  * copy at http://www.boost.org/LICENSE_1_0.txt)
8  */
9 
10 
11 #include <iostream>
12 
13 #include <boost/numeric/odeint.hpp>
14 #include <boost/numeric/ublas/vector.hpp>
15 
16 typedef boost::numeric::ublas::vector< double > state_type;
17 
lorenz(const state_type & x,state_type & dxdt,const double t)18 void lorenz( const state_type &x , state_type &dxdt , const double t )
19 {
20     const double sigma( 10.0 );
21     const double R( 28.0 );
22     const double b( 8.0 / 3.0 );
23 
24     dxdt[0] = sigma * ( x[1] - x[0] );
25     dxdt[1] = R * x[0] - x[1] - x[0] * x[2];
26     dxdt[2] = -b * x[2] + x[0] * x[1];
27 }
28 
29 using namespace boost::numeric::odeint;
30 
31 //[ublas_main
main()32 int main()
33 {
34     state_type x(3);
35     x[0] = 10.0; x[1] = 5.0 ; x[2] = 0.0;
36     typedef runge_kutta_dopri5< state_type > stepper;
37     integrate_const( make_dense_output< stepper >( 1E-6 , 1E-6 ) , lorenz , x ,
38                      0.0 , 10.0 , 0.1 );
39 }
40 //]
41