integrate_n_steps.hpp 4.6 KB

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