make_controlled.hpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. [auto_generated]
  3. boost/numeric/odeint/stepper/generation/make_controlled.hpp
  4. [begin_description]
  5. Factory function to simplify the creation of controlled steppers from error steppers.
  6. [end_description]
  7. Copyright 2009-2011 Karsten Ahnert
  8. Copyright 2009-2011 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. #ifndef BOOST_NUMERIC_ODEINT_STEPPER_GENERATION_MAKE_CONTROLLED_HPP_INCLUDED
  14. #define BOOST_NUMERIC_ODEINT_STEPPER_GENERATION_MAKE_CONTROLLED_HPP_INCLUDED
  15. namespace boost {
  16. namespace numeric {
  17. namespace odeint {
  18. // default template for the controller
  19. template< class Stepper > struct get_controller { };
  20. // default controller factory
  21. template< class Stepper , class Controller >
  22. struct controller_factory
  23. {
  24. Controller operator()(
  25. typename Stepper::value_type abs_error ,
  26. typename Stepper::value_type rel_error ,
  27. const Stepper &stepper )
  28. {
  29. return Controller( abs_error , rel_error , stepper );
  30. }
  31. };
  32. namespace result_of
  33. {
  34. template< class Stepper >
  35. struct make_controlled
  36. {
  37. typedef typename get_controller< Stepper >::type type;
  38. };
  39. }
  40. template< class Stepper >
  41. typename result_of::make_controlled< Stepper >::type make_controlled(
  42. typename Stepper::value_type abs_error ,
  43. typename Stepper::value_type rel_error ,
  44. const Stepper & stepper = Stepper() )
  45. {
  46. typedef Stepper stepper_type;
  47. typedef typename result_of::make_controlled< stepper_type >::type controller_type;
  48. typedef controller_factory< stepper_type , controller_type > factory_type;
  49. factory_type factory;
  50. return factory( abs_error , rel_error , stepper );
  51. }
  52. } // odeint
  53. } // numeric
  54. } // boost
  55. #endif // BOOST_NUMERIC_ODEINT_STEPPER_GENERATION_MAKE_CONTROLLED_HPP_INCLUDED