integrate_adaptive.hpp 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /*
  2. [auto_generated]
  3. boost/numeric/odeint/integrate/integrate_adaptive.hpp
  4. [begin_description]
  5. Adaptive integration of ODEs.
  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_INTEGRATE_INTEGRATE_ADAPTIVE_HPP_INCLUDED
  14. #define BOOST_NUMERIC_ODEINT_INTEGRATE_INTEGRATE_ADAPTIVE_HPP_INCLUDED
  15. #include <boost/type_traits/is_same.hpp>
  16. #include <boost/numeric/odeint/stepper/stepper_categories.hpp>
  17. #include <boost/numeric/odeint/integrate/null_observer.hpp>
  18. #include <boost/numeric/odeint/integrate/detail/integrate_adaptive.hpp>
  19. namespace boost {
  20. namespace numeric {
  21. namespace odeint {
  22. /*
  23. * the two overloads are needed in order to solve the forwarding problem
  24. */
  25. template< class Stepper , class System , class State , class Time , class Observer >
  26. size_t integrate_adaptive(
  27. Stepper stepper , System system , State &start_state ,
  28. Time start_time , Time end_time , Time dt ,
  29. Observer observer )
  30. {
  31. return detail::integrate_adaptive(
  32. stepper , system , start_state ,
  33. start_time , end_time , dt ,
  34. observer , typename Stepper::stepper_category() );
  35. /*
  36. * Suggestion for a new extendable version:
  37. *
  38. * integrator_adaptive< Stepper , System, State , Time , Observer , typename Stepper::stepper_category > integrator;
  39. * return integrator.run( stepper , system , start_state , start_time , end_time , dt , observer );
  40. */
  41. }
  42. /**
  43. * \brief Second version to solve the forwarding problem,
  44. * can be called with Boost.Range as start_state.
  45. */
  46. template< class Stepper , class System , class State , class Time , class Observer >
  47. size_t integrate_adaptive(
  48. Stepper stepper , System system , const State &start_state ,
  49. Time start_time , Time end_time , Time dt ,
  50. Observer observer )
  51. {
  52. return detail::integrate_adaptive(
  53. stepper , system , start_state ,
  54. start_time , end_time , dt ,
  55. observer , typename Stepper::stepper_category() );
  56. }
  57. /**
  58. * \brief integrate_adaptive without an observer.
  59. */
  60. template< class Stepper , class System , class State , class Time >
  61. size_t integrate_adaptive(
  62. Stepper stepper , System system , State &start_state ,
  63. Time start_time , Time end_time , Time dt )
  64. {
  65. return integrate_adaptive( stepper , system , start_state , start_time , end_time , dt , null_observer() );
  66. }
  67. /**
  68. * \brief Second version to solve the forwarding problem,
  69. * can be called with Boost.Range as start_state.
  70. */
  71. template< class Stepper , class System , class State , class Time >
  72. size_t integrate_adaptive(
  73. Stepper stepper , System system , const State &start_state ,
  74. Time start_time , Time end_time , Time dt )
  75. {
  76. return integrate_adaptive( stepper , system , start_state , start_time , end_time , dt , null_observer() );
  77. }
  78. /************* DOXYGEN ************/
  79. /**
  80. * \fn integrate_adaptive( Stepper stepper , System system , State &start_state , Time start_time , Time end_time , Time dt , Observer observer )
  81. * \brief Integrates the ODE with adaptive step size.
  82. *
  83. * This function integrates the ODE given by system with the given stepper.
  84. * The observer is called after each step. If the stepper has no error
  85. * control, the step size remains constant and the observer is called at
  86. * equidistant time points t0+n*dt. If the stepper is a ControlledStepper,
  87. * the step size is adjusted and the observer is called in non-equidistant
  88. * intervals.
  89. *
  90. * \param stepper The stepper to be used for numerical integration.
  91. * \param system Function/Functor defining the rhs of the ODE.
  92. * \param start_state The initial condition x0.
  93. * \param start_time The initial time t0.
  94. * \param end_time The final integration time tend.
  95. * \param dt The time step between observer calls, _not_ necessarily the
  96. * time step of the integration.
  97. * \param observer Function/Functor called at equidistant time intervals.
  98. * \return The number of steps performed.
  99. */
  100. } // namespace odeint
  101. } // namespace numeric
  102. } // namespace boost
  103. #endif // BOOST_NUMERIC_ODEINT_INTEGRATE_INTEGRATE_ADAPTIVE_HPP_INCLUDED