adaptive_iterator.hpp 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. /*
  2. [auto_generated]
  3. boost/numeric/odeint/iterator/adaptive_iterator.hpp
  4. [begin_description]
  5. Iterator for iterating throught the solution of an ODE with adaptive step size. The dereferenced types containes also the time.
  6. [end_description]
  7. Copyright 2012-2013 Karsten Ahnert
  8. Copyright 2012 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_ADAPTIVE_ITERATOR_HPP_INCLUDED
  14. #define BOOST_NUMERIC_ODEINT_ITERATOR_ADAPTIVE_ITERATOR_HPP_INCLUDED
  15. #include <boost/numeric/odeint/util/stepper_traits.hpp>
  16. #include <boost/numeric/odeint/util/unit_helper.hpp>
  17. #include <boost/numeric/odeint/stepper/stepper_categories.hpp>
  18. #include <boost/numeric/odeint/stepper/controlled_step_result.hpp>
  19. #include <boost/numeric/odeint/iterator/impl/adaptive_iterator_impl.hpp>
  20. namespace boost {
  21. namespace numeric {
  22. namespace odeint {
  23. /* use the adaptive_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 adaptive_iterator : public adaptive_iterator_impl<
  30. adaptive_iterator< Stepper , System , State , StepperTag > ,
  31. Stepper , System , State , detail::ode_state_iterator_tag , StepperTag
  32. >
  33. {
  34. typedef typename traits::time_type< Stepper >::type time_type;
  35. typedef adaptive_iterator< Stepper , System , State , StepperTag > iterator_type;
  36. public:
  37. adaptive_iterator( Stepper stepper , System sys , State &s , time_type t_start , time_type t_end , time_type dt )
  38. : adaptive_iterator_impl< iterator_type , Stepper , System , State , detail::ode_state_iterator_tag , StepperTag >( stepper , sys , s , t_start , t_end , dt )
  39. {}
  40. adaptive_iterator( Stepper stepper , System sys , State &s )
  41. : adaptive_iterator_impl< iterator_type , Stepper , System , State , detail::ode_state_iterator_tag , StepperTag >( stepper , sys , s )
  42. {}
  43. };
  44. template< class Stepper , class System , class State >
  45. adaptive_iterator< Stepper , System , State > make_adaptive_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 adaptive_iterator< Stepper , System , State >( stepper , system , x , t_start , t_end , dt );
  54. }
  55. template< class Stepper , class System , class State >
  56. adaptive_iterator< Stepper , System , State > make_adaptive_iterator_end(
  57. Stepper stepper ,
  58. System system ,
  59. State &x )
  60. {
  61. return adaptive_iterator< Stepper , System , State >( stepper , system , x );
  62. }
  63. template< class Stepper , class System , class State >
  64. std::pair< adaptive_iterator< Stepper , System , State > , adaptive_iterator< Stepper , System , State > >
  65. make_adaptive_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. adaptive_iterator< Stepper , System , State >( stepper , system , x , t_start , t_end , dt ) ,
  75. adaptive_iterator< Stepper , System , State >( stepper , system , x )
  76. );
  77. }
  78. /**
  79. * \class adaptive_iterator
  80. *
  81. * \brief ODE Iterator with adaptive 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 an adaptive step size dt.
  85. * After each iteration the iterator dereferences to the state x at the next
  86. * time t+dt where dt is controlled by the stepper.
  87. * This iterator can be used with ControlledSteppers 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_adaptive routine.
  91. *
  92. * adaptive_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_adaptive_iterator_begin( Stepper stepper , System system , State &x ,
  102. typename traits::time_type< Stepper >::type t_start ,
  103. typename traits::time_type< Stepper >::type t_end ,
  104. typename traits::time_type< Stepper >::type dt )
  105. *
  106. * \brief Factory function for adaptive_iterator. Constructs a begin iterator.
  107. *
  108. * \param stepper The stepper to use during the iteration.
  109. * \param system The system function (ODE) to solve.
  110. * \param x The initial state.
  111. * \param t_start The initial time.
  112. * \param t_end The end time, at which the iteration should stop.
  113. * \param dt The initial time step.
  114. * \returns The adaptive iterator.
  115. */
  116. /**
  117. * \fn make_adaptive_iterator_end( Stepper stepper , System system , State &x )
  118. * \brief Factory function for adaptive_iterator. Constructs a end iterator.
  119. *
  120. * \param stepper The stepper to use during the iteration.
  121. * \param system The system function (ODE) to solve.
  122. * \param x The initial state.
  123. * \returns The adaptive iterator.
  124. */
  125. /**
  126. * \fn make_adaptive_range( Stepper stepper , System system , State &x ,
  127. typename traits::time_type< Stepper >::type t_start ,
  128. typename traits::time_type< Stepper >::type t_end ,
  129. typename traits::time_type< Stepper >::type dt )
  130. *
  131. * \brief Factory function to construct a single pass range of adaptive iterators. A range is here a pair of adaptive_iterator.
  132. *
  133. * \param stepper The stepper to use during the iteration.
  134. * \param system The system function (ODE) to solve.
  135. * \param x The initial state.
  136. * \param t_start The initial time.
  137. * \param t_end The end time, at which the iteration should stop.
  138. * \param dt The initial time step.
  139. * \returns The adaptive range.
  140. */
  141. } // namespace odeint
  142. } // namespace numeric
  143. } // namespace boost
  144. #endif // BOOST_NUMERIC_ODEINT_ITERATOR_ADAPTIVE_ITERATOR_HPP_INCLUDED