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