4 boost/numeric/odeint/iterator/const_step_iterator.hpp
7 Iterator for iterating through the solution of an ODE with constant step size.
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_ODE_ITERATOR_HPP_INCLUDED
20 #define BOOST_NUMERIC_ODEINT_ITERATOR_CONST_STEP_ODE_ITERATOR_HPP_INCLUDED
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>
34 /* use the const_step_iterator_impl with the right tags */
35 template< class Stepper , class System , class State
37 , class StepperTag = typename base_tag< typename traits::stepper_category< Stepper >::type >::type
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
45 typedef typename traits::time_type< Stepper >::type time_type;
46 typedef const_step_iterator< Stepper , System , State , StepperTag > iterator_type;
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 )
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 )
60 template< class Stepper , class System , class State >
61 const_step_iterator< Stepper , System, State > make_const_step_iterator_begin(
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 )
69 return const_step_iterator< Stepper , System , State >( stepper , system , x , t_start , t_end , dt );
72 template< class Stepper , class System , class State >
73 const_step_iterator< Stepper , System , State > make_const_step_iterator_end(
78 return const_step_iterator< Stepper , System , State >( stepper , system , x );
81 template< class Stepper , class System , class State >
82 std::pair< const_step_iterator< Stepper , System , State > , const_step_iterator< Stepper , System , State > >
83 make_const_step_range(
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 )
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 )
100 * \class const_step_iterator
102 * \brief ODE Iterator with constant step size. The value type of this iterator is the state type of the stepper.
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
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.
113 * const_step_iterator is a model of single-pass iterator.
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.
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.
124 * \fn make_const_step_iterator_begin(
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 )
132 * \brief Factory function for const_step_iterator. Constructs a begin iterator.
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.
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.
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.
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 )
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.
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.
174 } // namespace odeint
175 } // namespace numeric
178 //#include <boost/numeric/odeint/iterator/impl/const_step_iterator_dense_output_impl.hpp>
180 #endif // BOOST_NUMERIC_ODEINT_ITERATOR_CONST_STEP_ODE_ITERATOR_HPP_INCLUDED