4 boost/numeric/odeint/iterator/const_step_time_iterator.hpp
7 Iterator for iterating throught the solution of an ODE with constant step size. The dereferences types containes also the time.
10 Copyright 2012-2013 Karsten Ahnert
11 Copyright 2013 Mario Mulansky
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)
19 #ifndef BOOST_NUMERIC_ODEINT_ITERATOR_CONST_STEP_TIME_ITERATOR_HPP_INCLUDED
20 #define BOOST_NUMERIC_ODEINT_ITERATOR_CONST_STEP_TIME_ITERATOR_HPP_INCLUDED
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>
31 /* use the const_step_iterator_impl with the right tags */
32 template< class Stepper , class System , class State
34 , class StepperTag = typename base_tag< typename traits::stepper_category< Stepper >::type >::type
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
42 typedef typename traits::time_type< Stepper >::type time_type;
43 typedef const_step_time_iterator< Stepper , System , State , StepperTag > iterator_type;
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 )
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 )
55 template< class Stepper , class System , class State >
56 const_step_time_iterator< Stepper , System , State > make_const_step_time_iterator_begin(
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 )
64 return const_step_time_iterator< Stepper , System , State >( stepper , system , x , t_start , t_end , dt );
67 template< class Stepper , class System , class State >
68 const_step_time_iterator< Stepper , System , State > make_const_step_time_iterator_end(
73 return const_step_time_iterator< Stepper , System , State >( stepper , system , x );
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 > >
79 make_const_step_time_range(
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 )
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 ) );
93 * \class const_step_time_iterator
95 * \brief ODE Iterator with constant step size. The value type of this iterator is a std::pair containing state and time.
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.
106 * const_step_time_iterator is a model of single-pass iterator.
108 * The value type of this iterator is a pair with the state type and time type of the stepper.
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.
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 )
122 * \brief Factory function for const_step_time_iterator. Constructs a begin iterator.
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.
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.
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.
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)
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.
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.
168 } // namespace odeint
169 } // namespace numeric
173 #endif // BOOST_NUMERIC_ODEINT_ITERATOR_CONST_STEP_TIME_ITERATOR_HPP_INCLUDED