integrate_n_steps.hpp 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. /*
  2. [auto_generated]
  3. boost/numeric/odeint/integrate/integrate_n_steps.hpp
  4. [begin_description]
  5. Integration of n steps with constant time size. Adaptive and dense-output methods are fully supported.
  6. [end_description]
  7. Copyright 2011-2013 Karsten Ahnert
  8. Copyright 2011-2015 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_N_STEPS_HPP_INCLUDED
  14. #define BOOST_NUMERIC_ODEINT_INTEGRATE_INTEGRATE_N_STEPS_HPP_INCLUDED
  15. #include <boost/numeric/odeint/stepper/stepper_categories.hpp>
  16. #include <boost/numeric/odeint/integrate/null_observer.hpp>
  17. #include <boost/numeric/odeint/integrate/detail/integrate_n_steps.hpp>
  18. #include <boost/numeric/odeint/integrate/check_adapter.hpp>
  19. namespace boost {
  20. namespace numeric {
  21. namespace odeint {
  22. /*
  23. * Integrates n steps
  24. *
  25. * the two overloads are needed in order to solve the forwarding problem
  26. */
  27. template< class Stepper , class System , class State , class Time , class Observer , class StepOverflowChecker >
  28. Time integrate_n_steps(
  29. Stepper stepper , System system , State &start_state ,
  30. Time start_time , Time dt , size_t num_of_steps ,
  31. Observer observer , StepOverflowChecker checker )
  32. {
  33. // unwrap references
  34. typedef typename odeint::unwrap_reference< Stepper >::type stepper_type;
  35. typedef typename odeint::unwrap_reference< Observer >::type observer_type;
  36. typedef typename odeint::unwrap_reference< StepOverflowChecker >::type checker_type;
  37. typedef typename stepper_type::stepper_category stepper_category;
  38. return detail::integrate_n_steps(
  39. checked_stepper<stepper_type, checker_type>(stepper, checker),
  40. system , start_state ,
  41. start_time , dt , num_of_steps ,
  42. checked_observer<observer_type, checker_type>(observer, checker),
  43. stepper_category() );
  44. }
  45. /**
  46. * \brief Solves the forwarding problem, can be called with Boost.Range as start_state.
  47. */
  48. template< class Stepper , class System , class State , class Time , class Observer , class StepOverflowChecker >
  49. Time integrate_n_steps(
  50. Stepper stepper , System system , const State &start_state ,
  51. Time start_time , Time dt , size_t num_of_steps ,
  52. Observer observer , StepOverflowChecker checker )
  53. {
  54. typedef typename odeint::unwrap_reference< Stepper >::type stepper_type;
  55. typedef typename odeint::unwrap_reference< Observer >::type observer_type;
  56. typedef typename odeint::unwrap_reference< StepOverflowChecker >::type checker_type;
  57. typedef typename stepper_type::stepper_category stepper_category;
  58. return detail::integrate_n_steps(
  59. checked_stepper<stepper_type, checker_type>(stepper, checker),
  60. system , start_state ,
  61. start_time , dt , num_of_steps ,
  62. checked_observer<observer_type, checker_type>(observer, checker),
  63. stepper_category() );
  64. }
  65. /**
  66. * \brief The same function as above, but without checker.
  67. */
  68. template< class Stepper , class System , class State , class Time , class Observer >
  69. Time integrate_n_steps(
  70. Stepper stepper , System system , State &start_state ,
  71. Time start_time , Time dt , size_t num_of_steps , Observer observer )
  72. {
  73. typedef typename odeint::unwrap_reference<Stepper>::type::stepper_category stepper_category;
  74. return detail::integrate_n_steps(
  75. stepper , system , start_state ,
  76. start_time , dt , num_of_steps ,
  77. observer , stepper_category() );
  78. }
  79. /**
  80. * \brief Solves the forwarding problem, can be called with Boost.Range as start_state.
  81. */
  82. template< class Stepper , class System , class State , class Time , class Observer >
  83. Time integrate_n_steps(
  84. Stepper stepper , System system , const State &start_state ,
  85. Time start_time , Time dt , size_t num_of_steps , Observer observer )
  86. {
  87. typedef typename odeint::unwrap_reference<Stepper>::type::stepper_category stepper_category;
  88. return detail::integrate_n_steps(
  89. stepper , system , start_state ,
  90. start_time , dt , num_of_steps ,
  91. observer , stepper_category() );
  92. }
  93. /**
  94. * \brief The same function as above, but without observer calls.
  95. */
  96. template< class Stepper , class System , class State , class Time >
  97. Time integrate_n_steps(
  98. Stepper stepper , System system , State &start_state ,
  99. Time start_time , Time dt , size_t num_of_steps )
  100. {
  101. return integrate_n_steps(stepper, system, start_state, start_time,
  102. dt, num_of_steps, null_observer());
  103. }
  104. /**
  105. * \brief Solves the forwarding problem, can be called with Boost.Range as start_state.
  106. */
  107. template< class Stepper , class System , class State , class Time >
  108. Time integrate_n_steps(
  109. Stepper stepper , System system , const State &start_state ,
  110. Time start_time , Time dt , size_t num_of_steps )
  111. {
  112. return integrate_n_steps(stepper, system, start_state, start_time,
  113. dt, num_of_steps, null_observer());
  114. }
  115. /************* DOXYGEN *************/
  116. /**
  117. * \fn Time integrate_n_steps( Stepper stepper , System system , State &start_state , Time start_time , Time dt , size_t num_of_steps , Observer observer )
  118. * \brief Integrates the ODE with constant step size.
  119. *
  120. * This function is similar to integrate_const. The observer is called at
  121. * equidistant time intervals t0 + n*dt.
  122. * If the Stepper is a normal stepper without step size control, dt is also
  123. * used for the numerical scheme. If a ControlledStepper is provided, the
  124. * algorithm might reduce the step size to meet the error bounds, but it is
  125. * ensured that the observer is always called at equidistant time points
  126. * t0 + n*dt. If a DenseOutputStepper is used, the step size also may vary
  127. * and the dense output is used to call the observer at equidistant time
  128. * points. The final integration time is always t0 + num_of_steps*dt.
  129. * If a max_step_checker is provided as StepOverflowChecker, a
  130. * no_progress_errror is thrown if too many steps (default: 500) are
  131. * performed without progress, i.e. in between observer calls. If no
  132. * checker is provided, no such overflow check is performed.
  133. *
  134. * \param stepper The stepper to be used for numerical integration.
  135. * \param system Function/Functor defining the rhs of the ODE.
  136. * \param start_state The initial condition x0.
  137. * \param start_time The initial time t0.
  138. * \param dt The time step between observer calls, _not_ necessarily the
  139. * time step of the integration.
  140. * \param num_of_steps Number of steps to be performed
  141. * \param observer Function/Functor called at equidistant time intervals.
  142. * \param checker [optional] Functor to check for step count overflows, if no
  143. * checker is provided, no exception is thrown.
  144. * \return The number of steps performed.
  145. */
  146. } // namespace odeint
  147. } // namespace numeric
  148. } // namespace boost
  149. #endif // BOOST_NUMERIC_ODEINT_INTEGRATE_INTEGRATE_N_STEPS_HPP_INCLUDED