const_step_iterator.hpp 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. /*
  2. [auto_generated]
  3. boost/numeric/odeint/iterator/const_step_iterator.hpp
  4. [begin_description]
  5. Iterator for iterating through the solution of an ODE with constant step size.
  6. [end_description]
  7. Copyright 2012-2013 Karsten Ahnert
  8. Copyright 2013 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_ITERATOR_CONST_STEP_ODE_ITERATOR_HPP_INCLUDED
  14. #define BOOST_NUMERIC_ODEINT_ITERATOR_CONST_STEP_ODE_ITERATOR_HPP_INCLUDED
  15. #include <boost/numeric/odeint/util/stepper_traits.hpp>
  16. #include <boost/numeric/odeint/stepper/stepper_categories.hpp>
  17. #include <boost/numeric/odeint/iterator/detail/ode_iterator_base.hpp>
  18. #include <boost/numeric/odeint/iterator/impl/const_step_iterator_impl.hpp>
  19. namespace boost {
  20. namespace numeric {
  21. namespace odeint {
  22. /* use the const_step_iterator_impl with the right tags */
  23. template< class Stepper , class System , class State
  24. #ifndef DOXYGEN_SKIP
  25. , class StepperTag = typename base_tag< typename traits::stepper_category< Stepper >::type >::type
  26. #endif
  27. >
  28. class const_step_iterator : public const_step_iterator_impl<
  29. const_step_iterator< Stepper , System , State , StepperTag > ,
  30. Stepper , System , State , detail::ode_state_iterator_tag , StepperTag
  31. >
  32. {
  33. typedef typename traits::time_type< Stepper >::type time_type;
  34. typedef const_step_iterator< Stepper , System , State , StepperTag > iterator_type;
  35. public:
  36. const_step_iterator( Stepper stepper , System sys , State &s , time_type t_start , time_type t_end , time_type dt )
  37. : const_step_iterator_impl< iterator_type , Stepper , System , State , detail::ode_state_iterator_tag , StepperTag >( stepper , sys , s , t_start , t_end , dt )
  38. {}
  39. const_step_iterator( Stepper stepper , System sys , State &s )
  40. : const_step_iterator_impl< iterator_type , Stepper , System , State , detail::ode_state_iterator_tag , StepperTag >( stepper , sys , s )
  41. {}
  42. };
  43. /* make functions */
  44. template< class Stepper , class System , class State >
  45. const_step_iterator< Stepper , System, State > make_const_step_iterator_begin(
  46. Stepper stepper ,
  47. System system ,
  48. State &x ,
  49. typename traits::time_type< Stepper >::type t_start ,
  50. typename traits::time_type< Stepper >::type t_end ,
  51. typename traits::time_type< Stepper >::type dt )
  52. {
  53. return const_step_iterator< Stepper , System , State >( stepper , system , x , t_start , t_end , dt );
  54. }
  55. template< class Stepper , class System , class State >
  56. const_step_iterator< Stepper , System , State > make_const_step_iterator_end(
  57. Stepper stepper ,
  58. System system ,
  59. State &x )
  60. {
  61. return const_step_iterator< Stepper , System , State >( stepper , system , x );
  62. }
  63. template< class Stepper , class System , class State >
  64. std::pair< const_step_iterator< Stepper , System , State > , const_step_iterator< Stepper , System , State > >
  65. make_const_step_range(
  66. Stepper stepper ,
  67. System system ,
  68. State &x ,
  69. typename traits::time_type< Stepper >::type t_start ,
  70. typename traits::time_type< Stepper >::type t_end ,
  71. typename traits::time_type< Stepper >::type dt )
  72. {
  73. return std::make_pair(
  74. const_step_iterator< Stepper , System , State >( stepper , system , x , t_start , t_end , dt ) ,
  75. const_step_iterator< Stepper , System , State >( stepper , system , x )
  76. );
  77. }
  78. /**
  79. * \class const_step_iterator
  80. *
  81. * \brief ODE Iterator with constant step size. The value type of this iterator is the state type of the stepper.
  82. *
  83. * Implements an iterator representing the solution of an ODE from t_start
  84. * to t_end evaluated at steps with constant step size dt.
  85. * After each iteration the iterator dereferences to the state x at the next
  86. * time t+dt.
  87. * This iterator can be used with Steppers and
  88. * DenseOutputSteppers and it always makes use of the all the given steppers
  89. * capabilities. A for_each over such an iterator range behaves similar to
  90. * the integrate_const routine.
  91. *
  92. * const_step_iterator is a model of single-pass iterator.
  93. *
  94. * The value type of this iterator is the state type of the stepper. Hence one can only access the state and not the current time.
  95. *
  96. * \tparam Stepper The stepper type which should be used during the iteration.
  97. * \tparam System The type of the system function (ODE) which should be solved.
  98. * \tparam State The state type of the ODE.
  99. */
  100. /**
  101. * \fn make_const_step_iterator_begin(
  102. Stepper stepper ,
  103. System system ,
  104. State &x ,
  105. typename traits::time_type< Stepper >::type t_start ,
  106. typename traits::time_type< Stepper >::type t_end ,
  107. typename traits::time_type< Stepper >::type dt )
  108. *
  109. * \brief Factory function for const_step_iterator. Constructs a begin iterator.
  110. *
  111. * \param stepper The stepper to use during the iteration.
  112. * \param system The system function (ODE) to solve.
  113. * \param x The initial state. const_step_iterator stores a reference of s and changes its value during the iteration.
  114. * \param t_start The initial time.
  115. * \param t_end The end time, at which the iteration should stop.
  116. * \param dt The initial time step.
  117. * \returns The const step iterator.
  118. */
  119. /**
  120. * \fn make_const_step_iterator_end( Stepper stepper , System system , State &x )
  121. * \brief Factory function for const_step_iterator. Constructs a end iterator.
  122. *
  123. * \param stepper The stepper to use during the iteration.
  124. * \param system The system function (ODE) to solve.
  125. * \param x The initial state. const_step_iterator stores a reference of s and changes its value during the iteration.
  126. * \returns The const_step_iterator.
  127. */
  128. /**
  129. * \fn make_const_step_range( Stepper stepper , System system , State &x ,
  130. typename traits::time_type< Stepper >::type t_start ,
  131. typename traits::time_type< Stepper >::type t_end ,
  132. typename traits::time_type< Stepper >::type dt )
  133. *
  134. * \brief Factory function to construct a single pass range of const step iterators. A range is here a pair
  135. * of const_step_iterator.
  136. *
  137. * \param stepper The stepper to use during the iteration.
  138. * \param system The system function (ODE) to solve.
  139. * \param x The initial state. const_step_iterator store a reference of s and changes its value during the iteration.
  140. * \param t_start The initial time.
  141. * \param t_end The end time, at which the iteration should stop.
  142. * \param dt The initial time step.
  143. * \returns The const step range.
  144. */
  145. } // namespace odeint
  146. } // namespace numeric
  147. } // namespace boost
  148. //#include <boost/numeric/odeint/iterator/impl/const_step_iterator_dense_output_impl.hpp>
  149. #endif // BOOST_NUMERIC_ODEINT_ITERATOR_CONST_STEP_ODE_ITERATOR_HPP_INCLUDED