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