integrate_times.hpp 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*
  2. [auto_generated]
  3. boost/numeric/odeint/integrate/integrate_times.hpp
  4. [begin_description]
  5. Integration of ODEs with observation at user defined points
  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_TIMES_HPP_INCLUDED
  14. #define BOOST_NUMERIC_ODEINT_INTEGRATE_INTEGRATE_TIMES_HPP_INCLUDED
  15. #include <boost/type_traits/is_same.hpp>
  16. #include <boost/range.hpp>
  17. #include <boost/numeric/odeint/stepper/stepper_categories.hpp>
  18. #include <boost/numeric/odeint/iterator/integrate/null_observer.hpp>
  19. #include <boost/numeric/odeint/iterator/integrate/detail/integrate_times.hpp>
  20. namespace boost {
  21. namespace numeric {
  22. namespace odeint {
  23. /*
  24. * the two overloads are needed in order to solve the forwarding problem
  25. */
  26. template< class Stepper , class System , class State , class TimeIterator , class Time , class Observer >
  27. size_t integrate_times(
  28. Stepper stepper , System system , State &start_state ,
  29. TimeIterator times_start , TimeIterator times_end , Time dt ,
  30. Observer observer )
  31. {
  32. typedef typename odeint::unwrap_reference< Stepper >::type::stepper_category stepper_category;
  33. return detail::integrate_times(
  34. stepper , system , start_state ,
  35. times_start , times_end , dt ,
  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 TimeIterator , class Time , class Observer >
  42. size_t integrate_times(
  43. Stepper stepper , System system , const State &start_state ,
  44. TimeIterator times_start , TimeIterator times_end , Time dt ,
  45. Observer observer )
  46. {
  47. typedef typename odeint::unwrap_reference< Stepper >::type::stepper_category stepper_category;
  48. return detail::integrate_times(
  49. stepper , system , start_state ,
  50. times_start , times_end , dt ,
  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 TimeRange , class Time , class Observer >
  57. size_t integrate_times(
  58. Stepper stepper , System system , State &start_state ,
  59. const TimeRange &times , Time dt ,
  60. Observer observer )
  61. {
  62. return integrate_times(
  63. stepper , system , start_state ,
  64. boost::begin( times ) , boost::end( times ) , dt , observer );
  65. }
  66. /**
  67. * \brief Solves the forwarding problem, can be called with Boost.Range as start_state.
  68. */
  69. template< class Stepper , class System , class State , class TimeRange , class Time , class Observer >
  70. size_t integrate_times(
  71. Stepper stepper , System system , const State &start_state ,
  72. const TimeRange &times , Time dt ,
  73. Observer observer )
  74. {
  75. return integrate_times(
  76. stepper , system , start_state ,
  77. boost::begin( times ) , boost::end( times ) , dt , observer );
  78. }
  79. /********* DOXYGEN ***********/
  80. /**
  81. * \fn size_t integrate_times( Stepper stepper , System system , State &start_state , TimeIterator times_start , TimeIterator times_end , Time dt , Observer observer )
  82. * \brief Integrates the ODE with observer calls at given time points.
  83. *
  84. * Integrates the ODE given by system using the given stepper. This function
  85. * does observer calls at the subsequent time points given by the range
  86. * times_start, times_end. If the stepper has not step size control, the
  87. * step size might be reduced occasionally to ensure observer calls exactly
  88. * at the time points from the given sequence. If the stepper is a
  89. * ControlledStepper, the step size is adjusted to meet the error bounds,
  90. * but also might be reduced occasionally to ensure correct observer calls.
  91. * If a DenseOutputStepper is provided, the dense output functionality is
  92. * used to call the observer at the given times. The end time of the
  93. * integration is always *(end_time-1).
  94. *
  95. * \param stepper The stepper to be used for numerical integration.
  96. * \param system Function/Functor defining the rhs of the ODE.
  97. * \param start_state The initial condition x0.
  98. * \param times_start Iterator to the start time
  99. * \param times_end Iterator to the end time
  100. * \param dt The time step between observer calls, _not_ necessarily the
  101. * time step of the integration.
  102. * \param observer Function/Functor called at equidistant time intervals.
  103. * \return The number of steps performed.
  104. */
  105. } // namespace odeint
  106. } // namespace numeric
  107. } // namespace boost
  108. #endif // BOOST_NUMERIC_ODEINT_INTEGRATE_INTEGRATE_TIMES_HPP_INCLUDED