1 /*
2  [auto_generated]
3  libs/numeric/odeint/examples/bind_member_functions.hpp
4 
5  [begin_description]
6  tba.
7  [end_description]
8 
9  Copyright 2012 Karsten Ahnert
10  Copyright 2012 Mario Mulansky
11 
12  Distributed under the Boost Software License, Version 1.0.
13  (See accompanying file LICENSE_1_0.txt or
14  copy at http://www.boost.org/LICENSE_1_0.txt)
15  */
16 
17 #include <iostream>
18 #include <array>
19 #include <type_traits>
20 
21 #include <boost/numeric/odeint.hpp>
22 
23 namespace odeint = boost::numeric::odeint;
24 
25 
26 
27 typedef std::array< double , 3 > state_type;
28 
29 struct lorenz
30 {
odelorenz31     void ode( const state_type &x , state_type &dxdt , double t ) const
32     {
33         const double sigma = 10.0;
34         const double R = 28.0;
35         const double b = 8.0 / 3.0;
36 
37         dxdt[0] = sigma * ( x[1] - x[0] );
38         dxdt[1] = R * x[0] - x[1] - x[0] * x[2];
39         dxdt[2] = -b * x[2] + x[0] * x[1];
40     }
41 };
42 
main(int argc,char * argv[])43 int main( int argc , char *argv[] )
44 {
45     using namespace boost::numeric::odeint;
46     //[ bind_member_function_cpp11
47     namespace pl = std::placeholders;
48 
49     state_type x = {{ 10.0 , 10.0 , 10.0 }};
50     integrate_const( runge_kutta4< state_type >() ,
51                      std::bind( &lorenz::ode , lorenz() , pl::_1 , pl::_2 , pl::_3 ) ,
52                      x , 0.0 , 10.0 , 0.01  );
53     //]
54     return 0;
55 }
56 
57