times_time_iterator.hpp 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. /*
  2. [auto_generated]
  3. boost/numeric/odeint/iterator/times_time_iterator.hpp
  4. [begin_description]
  5. Iterator for iterating through the solution of an ODE with oscillator calls at times from a given sequence.
  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_TIMES_TIME_ITERATOR_HPP_INCLUDED
  15. #define BOOST_NUMERIC_ODEINT_ITERATOR_TIMES_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/times_iterator_impl.hpp>
  20. namespace boost {
  21. namespace numeric {
  22. namespace odeint {
  23. /* use the times_iterator_impl with the right tags */
  24. template< class Stepper , class System , class State , class TimeIterator
  25. #ifndef DOXYGEN_SKIP
  26. , class StepperTag = typename base_tag< typename traits::stepper_category< Stepper >::type >::type
  27. #endif
  28. >
  29. class times_time_iterator : public times_iterator_impl<
  30. times_time_iterator< Stepper , System , State , TimeIterator , StepperTag > ,
  31. Stepper , System , State , TimeIterator , detail::ode_state_time_iterator_tag , StepperTag
  32. >
  33. {
  34. typedef typename traits::time_type< Stepper >::type time_type;
  35. typedef times_time_iterator< Stepper , System , State , TimeIterator , StepperTag > iterator_type;
  36. public:
  37. times_time_iterator( Stepper stepper , System sys , State &s ,
  38. TimeIterator t_start , TimeIterator t_end , time_type dt )
  39. : times_iterator_impl< iterator_type , Stepper , System , State , TimeIterator, detail::ode_state_time_iterator_tag , StepperTag >( stepper , sys , s , t_start , t_end , dt )
  40. {}
  41. times_time_iterator( Stepper stepper , System sys , State &s )
  42. : times_iterator_impl< iterator_type , Stepper , System , State , TimeIterator , detail::ode_state_time_iterator_tag , StepperTag >( stepper , sys , s )
  43. {}
  44. };
  45. /* make functions */
  46. template< class Stepper , class System , class State , class TimeIterator >
  47. times_time_iterator< Stepper , System, State , TimeIterator > make_times_time_iterator_begin(
  48. Stepper stepper ,
  49. System system ,
  50. State &x ,
  51. TimeIterator t_start ,
  52. TimeIterator t_end ,
  53. typename traits::time_type< Stepper >::type dt )
  54. {
  55. return times_time_iterator< Stepper , System , State , TimeIterator >( stepper , system , x , t_start , t_end , dt );
  56. }
  57. // ToDo: requires to specifically provide the TimeIterator template parameter, can this be improved?
  58. template< class TimeIterator , class Stepper , class System , class State >
  59. times_time_iterator< Stepper , System , State , TimeIterator > make_times_time_iterator_end(
  60. Stepper stepper ,
  61. System system ,
  62. State &x )
  63. //TimeIterator t_end )
  64. {
  65. return times_time_iterator< Stepper , System , State , TimeIterator >( stepper , system , x );
  66. }
  67. template< class Stepper , class System , class State , class TimeIterator >
  68. std::pair< times_time_iterator< Stepper , System , State , TimeIterator > ,
  69. times_time_iterator< Stepper , System , State , TimeIterator > >
  70. make_times_time_range(
  71. Stepper stepper ,
  72. System system ,
  73. State &x ,
  74. TimeIterator t_start ,
  75. TimeIterator t_end ,
  76. typename traits::time_type< Stepper >::type dt )
  77. {
  78. return std::make_pair(
  79. times_time_iterator< Stepper , System , State , TimeIterator >( stepper , system , x , t_start , t_end , dt ) ,
  80. times_time_iterator< Stepper , System , State , TimeIterator >( stepper , system , x )
  81. );
  82. }
  83. /**
  84. * \class times_time_iterator
  85. *
  86. * \brief ODE Iterator with given evaluation points. The value type of this iterator is a std::pair containing state and time.
  87. *
  88. * Implements an iterator representing the solution of an ODE from *t_start
  89. * to *t_end evaluated at time points given by the sequence t_start to t_end.
  90. * t_start and t_end are iterators representing a sequence of time points
  91. * where the solution of the ODE should be evaluated.
  92. * After each iteration the iterator dereferences to a pair with the state
  93. * and the time at the next evaluation point *t_start++ until t_end is reached.
  94. * This iterator can be used with Steppers, ControlledSteppers and
  95. * DenseOutputSteppers and it always makes use of the all the given steppers
  96. * capabilities. A for_each over such an iterator range behaves similar to
  97. * the integrate_times routine.
  98. *
  99. * times_time_iterator is a model of single-pass iterator.
  100. *
  101. * The value type of this iterator is a pair of state and time type.
  102. *
  103. * \tparam Stepper The stepper type which should be used during the iteration.
  104. * \tparam System The type of the system function (ODE) which should be solved.
  105. * \tparam State The state type of the ODE.
  106. * \tparam TimeIterator The iterator type for the sequence of time points.
  107. */
  108. /**
  109. * \fn make_times_time_iterator_begin( Stepper stepper ,
  110. System system ,
  111. State &x ,
  112. TimeIterator t_start ,
  113. TimeIterator t_end ,
  114. typename traits::time_type< Stepper >::type dt )
  115. *
  116. * \brief Factory function for times_time_iterator. Constructs a begin 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. * \param t_start Begin iterator of the sequence of evaluation time points.
  122. * \param t_end End iterator of the sequence of evaluation time points.
  123. * \param dt The initial time step.
  124. * \returns The times_time iterator.
  125. */
  126. /**
  127. * \fn make_times_time_iterator_end( Stepper stepper , System system , State &x )
  128. * \brief Factory function for times_time_iterator. Constructs an end iterator.
  129. *
  130. * \tparam TimesIterator The iterator type of the time sequence, must be specifically provided.
  131. *
  132. * \param stepper The stepper to use during the iteration.
  133. * \param system The system function (ODE) to solve.
  134. * \param x The initial state. const_step_iterator stores a reference of s and changes its value during the iteration.
  135. * \returns The times_time iterator.
  136. *
  137. * This function needs the TimeIterator type specifically defined as a
  138. * template parameter.
  139. */
  140. /**
  141. * \fn make_times_time_range( Stepper stepper , System system , State &x ,
  142. TimeIterator t_start ,
  143. TimeIterator t_end ,
  144. typename traits::time_type< Stepper >::type dt )
  145. *
  146. * \brief Factory function to construct a single pass range of times_time iterators. A range is here a pair
  147. * of times_iterator.
  148. *
  149. * \param stepper The stepper to use during the iteration.
  150. * \param system The system function (ODE) to solve.
  151. * \param x The initial state. const_step_iterator store a reference of s and changes its value during the iteration.
  152. * \param t_start Begin iterator of the sequence of evaluation time points.
  153. * \param t_end End iterator of the sequence of evaluation time points.
  154. * \param dt The initial time step.
  155. * \returns The times_time iterator range.
  156. */
  157. } // namespace odeint
  158. } // namespace numeric
  159. } // namespace boost
  160. #endif // BOOST_NUMERIC_ODEINT_ITERATOR_TIMES_TIME_ITERATOR_HPP_INCLUDED