n_step_iterator.hpp 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /*
  2. [auto_generated]
  3. boost/numeric/odeint/iterator/n_step_iterator.hpp
  4. [begin_description]
  5. Iterator for iterating through the solution of an ODE with constant step size performing exactly n steps.
  6. [end_description]
  7. Copyright 2009-2013 Karsten Ahnert
  8. Copyright 2009-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_N_STEP_ITERATOR_HPP_INCLUDED
  14. #define BOOST_NUMERIC_ODEINT_ITERATOR_N_STEP_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/n_step_iterator_impl.hpp>
  19. namespace boost {
  20. namespace numeric {
  21. namespace odeint {
  22. /* use the n_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 n_step_iterator : public n_step_iterator_impl<
  29. n_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 n_step_iterator< Stepper , System , State , StepperTag > iterator_type;
  35. public:
  36. n_step_iterator( Stepper stepper , System sys , State &s , time_type t , time_type dt , size_t num_of_steps )
  37. : n_step_iterator_impl< iterator_type , Stepper , System , State , detail::ode_state_iterator_tag , StepperTag >( stepper , sys , s , t , dt , num_of_steps )
  38. {}
  39. n_step_iterator( Stepper stepper , System sys , State &s )
  40. : n_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. n_step_iterator< Stepper , System, State > make_n_step_iterator_begin(
  46. Stepper stepper ,
  47. System system ,
  48. State &x ,
  49. typename traits::time_type< Stepper >::type t ,
  50. typename traits::time_type< Stepper >::type dt ,
  51. size_t num_of_steps )
  52. {
  53. return n_step_iterator< Stepper , System , State >( stepper , system , x , t , dt , num_of_steps );
  54. }
  55. template< class Stepper , class System , class State >
  56. n_step_iterator< Stepper , System , State > make_n_step_iterator_end(
  57. Stepper stepper ,
  58. System system ,
  59. State &x )
  60. {
  61. return n_step_iterator< Stepper , System , State >( stepper , system , x );
  62. }
  63. template< class Stepper , class System , class State >
  64. std::pair< n_step_iterator< Stepper , System , State > , n_step_iterator< Stepper , System , State > >
  65. make_n_step_range(
  66. Stepper stepper ,
  67. System system ,
  68. State &x ,
  69. typename traits::time_type< Stepper >::type t ,
  70. typename traits::time_type< Stepper >::type dt ,
  71. size_t num_of_steps )
  72. {
  73. return std::make_pair(
  74. n_step_iterator< Stepper , System , State >( stepper , system , x , t , dt , num_of_steps ) ,
  75. n_step_iterator< Stepper , System , State >( stepper , system , x )
  76. );
  77. }
  78. /**
  79. * \class n_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 starting from t
  84. * with n steps and a 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_n_steps routine.
  91. *
  92. * n_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_n_step_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 )
  102. *
  103. * \brief Factory function for n_step_iterator. Constructs a begin iterator.
  104. *
  105. * \param stepper The stepper to use during the iteration.
  106. * \param system The system function (ODE) to solve.
  107. * \param x The initial state. const_step_iterator stores a reference of s and changes its value during the iteration.
  108. * \param t The initial time.
  109. * \param dt The initial time step.
  110. * \param num_of_steps The number of steps to be executed.
  111. * \returns The n-step iterator.
  112. */
  113. /**
  114. * \fn make_n_step_iterator_end( Stepper stepper , System system , State &x )
  115. * \brief Factory function for n_step_iterator. Constructs an end iterator.
  116. *
  117. * \param stepper The stepper to use during the iteration.
  118. * \param system The system function (ODE) to solve.
  119. * \param x The initial state. const_step_iterator stores a reference of s and changes its value during the iteration.
  120. * \returns The const_step_iterator.
  121. */
  122. /**
  123. * \fn make_n_step_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 )
  124. *
  125. * \brief Factory function to construct a single pass range of n-step iterators. A range is here a pair
  126. * of n_step_iterator.
  127. *
  128. * \param stepper The stepper to use during the iteration.
  129. * \param system The system function (ODE) to solve.
  130. * \param x The initial state. const_step_iterator store a reference of s and changes its value during the iteration.
  131. * \param t The initial time.
  132. * \param dt The initial time step.
  133. * \param num_of_steps The number of steps to be executed.
  134. * \returns The n-step range.
  135. */
  136. } // namespace odeint
  137. } // namespace numeric
  138. } // namespace boost
  139. #endif // BOOST_NUMERIC_ODEINT_ITERATOR_CONST_N_STEP_ITERATOR_HPP_INCLUDED