n_step_time_iterator.hpp 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /*
  2. [auto_generated]
  3. boost/numeric/odeint/iterator/n_step_time_iterator.hpp
  4. [begin_description]
  5. Iterator for iterating through the solution of an ODE with constant step size performing exactly n steps.
  6. The dereferenced type contains also the time.
  7. [end_description]
  8. Copyright 2009-2013 Karsten Ahnert
  9. Copyright 2009-2013 Mario Mulansky
  10. Distributed under the Boost Software License, Version 1.0.
  11. (See accompanying file LICENSE_1_0.txt or
  12. copy at http://www.boost.org/LICENSE_1_0.txt)
  13. */
  14. #ifndef BOOST_NUMERIC_ODEINT_ITERATOR_N_STEP_TIME_ITERATOR_HPP_INCLUDED
  15. #define BOOST_NUMERIC_ODEINT_ITERATOR_N_STEP_TIME_ITERATOR_HPP_INCLUDED
  16. #include <boost/numeric/odeint/util/stepper_traits.hpp>
  17. #include <boost/numeric/odeint/stepper/stepper_categories.hpp>
  18. #include <boost/numeric/odeint/iterator/detail/ode_iterator_base.hpp>
  19. #include <boost/numeric/odeint/iterator/impl/n_step_iterator_impl.hpp>
  20. namespace boost {
  21. namespace numeric {
  22. namespace odeint {
  23. /* use the n_step_iterator_impl with the right tags */
  24. template< class Stepper , class System , class State
  25. #ifndef DOXYGEN_SKIP
  26. , class StepperTag = typename base_tag< typename traits::stepper_category< Stepper >::type >::type
  27. #endif
  28. >
  29. class n_step_time_iterator : public n_step_iterator_impl<
  30. n_step_time_iterator< Stepper , System , State , StepperTag > ,
  31. Stepper , System , State , detail::ode_state_time_iterator_tag , StepperTag
  32. >
  33. {
  34. typedef typename traits::time_type< Stepper >::type time_type;
  35. typedef n_step_time_iterator< Stepper , System , State , StepperTag > iterator_type;
  36. public:
  37. n_step_time_iterator( Stepper stepper , System sys , State &s , time_type t , time_type dt , size_t num_of_steps )
  38. : n_step_iterator_impl< iterator_type , Stepper , System , State , detail::ode_state_time_iterator_tag , StepperTag >( stepper , sys , s , t , dt , num_of_steps )
  39. {}
  40. n_step_time_iterator( Stepper stepper , System sys , State &s )
  41. : n_step_iterator_impl< iterator_type , Stepper , System , State , detail::ode_state_time_iterator_tag , StepperTag >( stepper , sys , s )
  42. {}
  43. };
  44. /* make functions */
  45. template< class Stepper , class System , class State >
  46. n_step_time_iterator< Stepper , System, State > make_n_step_time_iterator_begin(
  47. Stepper stepper ,
  48. System system ,
  49. State &x ,
  50. typename traits::time_type< Stepper >::type t ,
  51. typename traits::time_type< Stepper >::type dt ,
  52. size_t num_of_steps )
  53. {
  54. return n_step_time_iterator< Stepper , System , State >( stepper , system , x , t , dt , num_of_steps );
  55. }
  56. template< class Stepper , class System , class State >
  57. n_step_time_iterator< Stepper , System , State > make_n_step_time_iterator_end(
  58. Stepper stepper ,
  59. System system ,
  60. State &x )
  61. {
  62. return n_step_time_iterator< Stepper , System , State >( stepper , system , x );
  63. }
  64. template< class Stepper , class System , class State >
  65. std::pair< n_step_time_iterator< Stepper , System , State > , n_step_time_iterator< Stepper , System , State > >
  66. make_n_step_time_range(
  67. Stepper stepper ,
  68. System system ,
  69. State &x ,
  70. typename traits::time_type< Stepper >::type t ,
  71. typename traits::time_type< Stepper >::type dt ,
  72. size_t num_of_steps )
  73. {
  74. return std::make_pair(
  75. n_step_time_iterator< Stepper , System , State >( stepper , system , x , t , dt , num_of_steps ) ,
  76. n_step_time_iterator< Stepper , System , State >( stepper , system , x )
  77. );
  78. }
  79. /**
  80. * \class n_step_time_iterator
  81. *
  82. * \brief ODE Iterator with constant step size. The value type of this iterator is a std::pair containing state and time.
  83. *
  84. * Implements an iterator representing the solution of an ODE starting from t
  85. * with n steps and a constant step size dt.
  86. * After each iteration the iterator dereferences to a pair of state and time at the next
  87. * time t+dt.
  88. * This iterator can be used with Steppers and
  89. * DenseOutputSteppers and it always makes use of the all the given steppers
  90. * capabilities. A for_each over such an iterator range behaves similar to
  91. * the integrate_n_steps routine.
  92. *
  93. * n_step_time_iterator is a model of single-pass iterator.
  94. *
  95. * The value type of this iterator is pair of state and time.
  96. *
  97. * \tparam Stepper The stepper type which should be used during the iteration.
  98. * \tparam System The type of the system function (ODE) which should be solved.
  99. * \tparam State The state type of the ODE.
  100. */
  101. /**
  102. * \fn make_n_step_time_iterator_begin( Stepper stepper , System system , State &x , typename traits::time_type< Stepper >::type t , typename traits::time_type< Stepper >::type dt , size_t num_of_steps )
  103. *
  104. * \brief Factory function for n_step_time_iterator. Constructs a begin iterator.
  105. *
  106. * \param stepper The stepper to use during the iteration.
  107. * \param system The system function (ODE) to solve.
  108. * \param x The initial state. const_step_iterator stores a reference of s and changes its value during the iteration.
  109. * \param t The initial time.
  110. * \param dt The initial time step.
  111. * \param num_of_steps The number of steps to be executed.
  112. * \returns The n-step iterator.
  113. */
  114. /**
  115. * \fn make_n_step_time_iterator_end( Stepper stepper , System system , State &x )
  116. * \brief Factory function for n_step_time_iterator. Constructs an end iterator.
  117. *
  118. * \param stepper The stepper to use during the iteration.
  119. * \param system The system function (ODE) to solve.
  120. * \param x The initial state. const_step_iterator stores a reference of s and changes its value during the iteration.
  121. * \returns The const_step_iterator.
  122. */
  123. /**
  124. * \fn make_n_step_time_range( Stepper stepper , System system , State &x , typename traits::time_type< Stepper >::type t , typename traits::time_type< Stepper >::type dt , size_t num_of_steps )
  125. *
  126. * \brief Factory function to construct a single pass range of n-step iterators. A range is here a pair
  127. * of n_step_time_iterator.
  128. *
  129. * \param stepper The stepper to use during the iteration.
  130. * \param system The system function (ODE) to solve.
  131. * \param x The initial state. const_step_iterator store a reference of s and changes its value during the iteration.
  132. * \param t The initial time.
  133. * \param dt The initial time step.
  134. * \param num_of_steps The number of steps to be executed.
  135. * \returns The n-step range.
  136. */
  137. } // namespace odeint
  138. } // namespace numeric
  139. } // namespace boost
  140. #endif // BOOST_NUMERIC_ODEINT_ITERATOR_CONST_N_STEP_TIME_ITERATOR_HPP_INCLUDED