4 boost/numeric/odeint/iterator/times_time_iterator.hpp
7 Iterator for iterating through the solution of an ODE with oscillator calls at times from a given sequence.
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_TIMES_TIME_ITERATOR_HPP_INCLUDED
21 #define BOOST_NUMERIC_ODEINT_ITERATOR_TIMES_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/times_iterator_impl.hpp>
35 /* use the times_iterator_impl with the right tags */
36 template< class Stepper , class System , class State , class TimeIterator
38 , class StepperTag = typename base_tag< typename traits::stepper_category< Stepper >::type >::type
41 class times_time_iterator : public times_iterator_impl<
42 times_time_iterator< Stepper , System , State , TimeIterator , StepperTag > ,
43 Stepper , System , State , TimeIterator , detail::ode_state_time_iterator_tag , StepperTag
46 typedef typename traits::time_type< Stepper >::type time_type;
47 typedef times_time_iterator< Stepper , System , State , TimeIterator , StepperTag > iterator_type;
50 times_time_iterator( Stepper stepper , System sys , State &s ,
51 TimeIterator t_start , TimeIterator t_end , time_type dt )
52 : times_iterator_impl< iterator_type , Stepper , System , State , TimeIterator, detail::ode_state_time_iterator_tag , StepperTag >( stepper , sys , s , t_start , t_end , dt )
55 times_time_iterator( Stepper stepper , System sys , State &s )
56 : times_iterator_impl< iterator_type , Stepper , System , State , TimeIterator , detail::ode_state_time_iterator_tag , StepperTag >( stepper , sys , s )
62 template< class Stepper , class System , class State , class TimeIterator >
63 times_time_iterator< Stepper , System, State , TimeIterator > make_times_time_iterator_begin(
67 TimeIterator t_start ,
69 typename traits::time_type< Stepper >::type dt )
71 return times_time_iterator< Stepper , System , State , TimeIterator >( stepper , system , x , t_start , t_end , dt );
74 // ToDo: requires to specifically provide the TimeIterator template parameter, can this be improved?
75 template< class TimeIterator , class Stepper , class System , class State >
76 times_time_iterator< Stepper , System , State , TimeIterator > make_times_time_iterator_end(
80 //TimeIterator t_end )
82 return times_time_iterator< Stepper , System , State , TimeIterator >( stepper , system , x );
85 template< class Stepper , class System , class State , class TimeIterator >
86 std::pair< times_time_iterator< Stepper , System , State , TimeIterator > ,
87 times_time_iterator< Stepper , System , State , TimeIterator > >
88 make_times_time_range(
92 TimeIterator t_start ,
94 typename traits::time_type< Stepper >::type dt )
96 return std::make_pair(
97 times_time_iterator< Stepper , System , State , TimeIterator >( stepper , system , x , t_start , t_end , dt ) ,
98 times_time_iterator< Stepper , System , State , TimeIterator >( stepper , system , x )
107 * \class times_time_iterator
109 * \brief ODE Iterator with given evaluation points. The value type of this iterator is a std::pair containing state and time.
111 * Implements an iterator representing the solution of an ODE from *t_start
112 * to *t_end evaluated at time points given by the sequence t_start to t_end.
113 * t_start and t_end are iterators representing a sequence of time points
114 * where the solution of the ODE should be evaluated.
115 * After each iteration the iterator dereferences to a pair with the state
116 * and the time at the next evaluation point *t_start++ until t_end is reached.
117 * This iterator can be used with Steppers, ControlledSteppers and
118 * DenseOutputSteppers and it always makes use of the all the given steppers
119 * capabilities. A for_each over such an iterator range behaves similar to
120 * the integrate_times routine.
122 * times_time_iterator is a model of single-pass iterator.
124 * The value type of this iterator is a pair of state and time type.
126 * \tparam Stepper The stepper type which should be used during the iteration.
127 * \tparam System The type of the system function (ODE) which should be solved.
128 * \tparam State The state type of the ODE.
129 * \tparam TimeIterator The iterator type for the sequence of time points.
135 * \fn make_times_time_iterator_begin( Stepper stepper ,
138 TimeIterator t_start ,
140 typename traits::time_type< Stepper >::type dt )
142 * \brief Factory function for times_time_iterator. Constructs a begin iterator.
144 * \param stepper The stepper to use during the iteration.
145 * \param system The system function (ODE) to solve.
146 * \param x The initial state. const_step_iterator stores a reference of s and changes its value during the iteration.
147 * \param t_start Begin iterator of the sequence of evaluation time points.
148 * \param t_end End iterator of the sequence of evaluation time points.
149 * \param dt The initial time step.
150 * \returns The times_time iterator.
155 * \fn make_times_time_iterator_end( Stepper stepper , System system , State &x )
156 * \brief Factory function for times_time_iterator. Constructs an end iterator.
158 * \tparam TimesIterator The iterator type of the time sequence, must be specifically provided.
160 * \param stepper The stepper to use during the iteration.
161 * \param system The system function (ODE) to solve.
162 * \param x The initial state. const_step_iterator stores a reference of s and changes its value during the iteration.
163 * \returns The times_time iterator.
165 * This function needs the TimeIterator type specifically defined as a
166 * template parameter.
171 * \fn make_times_time_range( Stepper stepper , System system , State &x ,
172 TimeIterator t_start ,
174 typename traits::time_type< Stepper >::type dt )
176 * \brief Factory function to construct a single pass range of times_time iterators. A range is here a pair
179 * \param stepper The stepper to use during the iteration.
180 * \param system The system function (ODE) to solve.
181 * \param x The initial state. const_step_iterator store a reference of s and changes its value during the iteration.
182 * \param t_start Begin iterator of the sequence of evaluation time points.
183 * \param t_end End iterator of the sequence of evaluation time points.
184 * \param dt The initial time step.
185 * \returns The times_time iterator range.
189 } // namespace odeint
190 } // namespace numeric
193 #endif // BOOST_NUMERIC_ODEINT_ITERATOR_TIMES_TIME_ITERATOR_HPP_INCLUDED