integrate_n_steps.hpp 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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 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_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/iterator/integrate/null_observer.hpp>
  17. #include <boost/numeric/odeint/iterator/integrate/detail/integrate_n_steps.hpp>
  18. namespace boost {
  19. namespace numeric {
  20. namespace odeint {
  21. /*
  22. * Integrates n steps
  23. *
  24. * the two overloads are needed in order to solve the forwarding problem
  25. */
  26. template< class Stepper , class System , class State , class Time , class Observer>
  27. Time integrate_n_steps(
  28. Stepper stepper , System system , State &start_state ,
  29. Time start_time , Time dt , size_t num_of_steps ,
  30. Observer observer )
  31. {
  32. typedef typename odeint::unwrap_reference< Stepper >::type::stepper_category stepper_category;
  33. return detail::integrate_n_steps(
  34. stepper , system , start_state ,
  35. start_time , dt , num_of_steps ,
  36. observer , stepper_category() );
  37. }
  38. /**
  39. * \brief Solves the forwarding problem, can be called with Boost.Range as start_state.
  40. */
  41. template< class Stepper , class System , class State , class Time , class Observer >
  42. Time integrate_n_steps(
  43. Stepper stepper , System system , const State &start_state ,
  44. Time start_time , Time dt , size_t num_of_steps ,
  45. Observer observer )
  46. {
  47. typedef typename odeint::unwrap_reference< Stepper >::type::stepper_category stepper_category;
  48. return detail::integrate_n_steps(
  49. stepper , system , start_state ,
  50. start_time , dt , num_of_steps ,
  51. observer , stepper_category() );
  52. }
  53. /**
  54. * \brief The same function as above, but without observer calls.
  55. */
  56. template< class Stepper , class System , class State , class Time >
  57. Time integrate_n_steps(
  58. Stepper stepper , System system , State &start_state ,
  59. Time start_time , Time dt , size_t num_of_steps )
  60. {
  61. return integrate_n_steps( stepper , system , start_state , start_time , dt , num_of_steps , null_observer() );
  62. }
  63. /**
  64. * \brief Solves the forwarding problem, can be called with Boost.Range as start_state.
  65. */
  66. template< class Stepper , class System , class State , class Time >
  67. Time integrate_n_steps(
  68. Stepper stepper , System system , const State &start_state ,
  69. Time start_time , Time dt , size_t num_of_steps )
  70. {
  71. return integrate_n_steps( stepper , system , start_state , start_time , dt , num_of_steps , null_observer() );
  72. }
  73. /************* DOXYGEN *************/
  74. /**
  75. * \fn Time integrate_n_steps( Stepper stepper , System system , State &start_state , Time start_time , Time dt , size_t num_of_steps , Observer observer )
  76. * \brief Integrates the ODE with constant step size.
  77. *
  78. * This function is similar to integrate_const. The observer is called at
  79. * equidistant time intervals t0 + n*dt.
  80. * If the Stepper is a normal stepper without step size control, dt is also
  81. * used for the numerical scheme. If a ControlledStepper is provided, the
  82. * algorithm might reduce the step size to meet the error bounds, but it is
  83. * ensured that the observer is always called at equidistant time points
  84. * t0 + n*dt. If a DenseOutputStepper is used, the step size also may vary
  85. * and the dense output is used to call the observer at equidistant time
  86. * points. The final integration time is always t0 + num_of_steps*dt.
  87. *
  88. * \param stepper The stepper to be used for numerical integration.
  89. * \param system Function/Functor defining the rhs of the ODE.
  90. * \param start_state The initial condition x0.
  91. * \param start_time The initial time t0.
  92. * \param dt The time step between observer calls, _not_ necessarily the
  93. * time step of the integration.
  94. * \param num_of_steps Number of steps to be performed
  95. * \param observer Function/Functor called at equidistant time intervals.
  96. * \return The number of steps performed.
  97. */
  98. } // namespace odeint
  99. } // namespace numeric
  100. } // namespace boost
  101. #endif // BOOST_NUMERIC_ODEINT_INTEGRATE_INTEGRATE_N_STEPS_HPP_INCLUDED