4 boost/numeric/odeint/iterator/n_step_time_iterator.hpp
7 Iterator for iterating through the solution of an ODE with constant step size performing exactly n steps.
8 The dereferenced type contains also the time.
11 Copyright 2009-2013 Karsten Ahnert
12 Copyright 2009-2013 Mario Mulansky
14 Distributed under the Boost Software License, Version 1.0.
15 (See accompanying file LICENSE_1_0.txt or
16 copy at http://www.boost.org/LICENSE_1_0.txt)
20 #ifndef BOOST_NUMERIC_ODEINT_ITERATOR_N_STEP_TIME_ITERATOR_HPP_INCLUDED
21 #define BOOST_NUMERIC_ODEINT_ITERATOR_N_STEP_TIME_ITERATOR_HPP_INCLUDED
24 #include <boost/numeric/odeint/util/stepper_traits.hpp>
25 #include <boost/numeric/odeint/stepper/stepper_categories.hpp>
26 #include <boost/numeric/odeint/iterator/detail/ode_iterator_base.hpp>
27 #include <boost/numeric/odeint/iterator/impl/n_step_iterator_impl.hpp>
35 /* use the n_step_iterator_impl with the right tags */
36 template< class Stepper , class System , class State
38 , class StepperTag = typename base_tag< typename traits::stepper_category< Stepper >::type >::type
41 class n_step_time_iterator : public n_step_iterator_impl<
42 n_step_time_iterator< Stepper , System , State , StepperTag > ,
43 Stepper , System , State , detail::ode_state_time_iterator_tag , StepperTag
46 typedef typename traits::time_type< Stepper >::type time_type;
47 typedef n_step_time_iterator< Stepper , System , State , StepperTag > iterator_type;
50 n_step_time_iterator( Stepper stepper , System sys , State &s , time_type t , time_type dt , size_t num_of_steps )
51 : n_step_iterator_impl< iterator_type , Stepper , System , State , detail::ode_state_time_iterator_tag , StepperTag >( stepper , sys , s , t , dt , num_of_steps )
54 n_step_time_iterator( Stepper stepper , System sys , State &s )
55 : n_step_iterator_impl< iterator_type , Stepper , System , State , detail::ode_state_time_iterator_tag , StepperTag >( stepper , sys , s )
61 template< class Stepper , class System , class State >
62 n_step_time_iterator< Stepper , System, State > make_n_step_time_iterator_begin(
66 typename traits::time_type< Stepper >::type t ,
67 typename traits::time_type< Stepper >::type dt ,
70 return n_step_time_iterator< Stepper , System , State >( stepper , system , x , t , dt , num_of_steps );
73 template< class Stepper , class System , class State >
74 n_step_time_iterator< Stepper , System , State > make_n_step_time_iterator_end(
79 return n_step_time_iterator< Stepper , System , State >( stepper , system , x );
82 template< class Stepper , class System , class State >
83 std::pair< n_step_time_iterator< Stepper , System , State > , n_step_time_iterator< Stepper , System , State > >
84 make_n_step_time_range(
88 typename traits::time_type< Stepper >::type t ,
89 typename traits::time_type< Stepper >::type dt ,
92 return std::make_pair(
93 n_step_time_iterator< Stepper , System , State >( stepper , system , x , t , dt , num_of_steps ) ,
94 n_step_time_iterator< Stepper , System , State >( stepper , system , x )
100 * \class n_step_time_iterator
102 * \brief ODE Iterator with constant step size. The value type of this iterator is a std::pair containing state and time.
104 * Implements an iterator representing the solution of an ODE starting from t
105 * with n steps and a constant step size dt.
106 * After each iteration the iterator dereferences to a pair of state and time 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_n_steps routine.
113 * n_step_time_iterator is a model of single-pass iterator.
115 * The value type of this iterator is pair of state and 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_n_step_time_iterator_begin( Stepper stepper , System system , State &x , typename traits::time_type< Stepper >::type t , typename traits::time_type< Stepper >::type dt , size_t num_of_steps )
126 * \brief Factory function for n_step_time_iterator. Constructs a begin iterator.
128 * \param stepper The stepper to use during the iteration.
129 * \param system The system function (ODE) to solve.
130 * \param x The initial state. const_step_iterator stores a reference of s and changes its value during the iteration.
131 * \param t The initial time.
132 * \param dt The initial time step.
133 * \param num_of_steps The number of steps to be executed.
134 * \returns The n-step iterator.
139 * \fn make_n_step_time_iterator_end( Stepper stepper , System system , State &x )
140 * \brief Factory function for n_step_time_iterator. Constructs an end iterator.
142 * \param stepper The stepper to use during the iteration.
143 * \param system The system function (ODE) to solve.
144 * \param x The initial state. const_step_iterator stores a reference of s and changes its value during the iteration.
145 * \returns The const_step_iterator.
150 * \fn make_n_step_time_range( Stepper stepper , System system , State &x , typename traits::time_type< Stepper >::type t , typename traits::time_type< Stepper >::type dt , size_t num_of_steps )
152 * \brief Factory function to construct a single pass range of n-step iterators. A range is here a pair
153 * of n_step_time_iterator.
155 * \param stepper The stepper to use during the iteration.
156 * \param system The system function (ODE) to solve.
157 * \param x The initial state. const_step_iterator store a reference of s and changes its value during the iteration.
158 * \param t The initial time.
159 * \param dt The initial time step.
160 * \param num_of_steps The number of steps to be executed.
161 * \returns The n-step range.
165 } // namespace odeint
166 } // namespace numeric
169 #endif // BOOST_NUMERIC_ODEINT_ITERATOR_CONST_N_STEP_TIME_ITERATOR_HPP_INCLUDED