bind_member_functions_cpp11.cpp 1.3 KB

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