1
2/*
3 [auto_generated]
4 boost/numeric/odeint/iterator/times_time_iterator.hpp
5
6 [begin_description]
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.
9 [end_description]
10
11 Copyright 2009-2013 Karsten Ahnert
12 Copyright 2009-2013 Mario Mulansky
13
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)
17 */
18
19
20#ifndef BOOST_NUMERIC_ODEINT_ITERATOR_TIMES_TIME_ITERATOR_HPP_INCLUDED
21#define BOOST_NUMERIC_ODEINT_ITERATOR_TIMES_TIME_ITERATOR_HPP_INCLUDED
22
23
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>
28
29
30namespace boost {
31namespace numeric {
32namespace odeint {
33
34
35 /* use the times_iterator_impl with the right tags */
36 template< class Stepper , class System , class State , class TimeIterator
37#ifndef DOXYGEN_SKIP
38 , class StepperTag = typename base_tag< typename traits::stepper_category< Stepper >::type >::type
39#endif
40 >
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
44 >
45 {
46 typedef typename traits::time_type< Stepper >::type time_type;
47 typedef times_time_iterator< Stepper , System , State , TimeIterator , StepperTag > iterator_type;
48
49 public:
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 )
53 {}
54
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 )
57 {}
58 };
59
60 /* make functions */
61
62 template< class Stepper , class System , class State , class TimeIterator >
63 times_time_iterator< Stepper , System, State , TimeIterator > make_times_time_iterator_begin(
64 Stepper stepper ,
65 System system ,
66 State &x ,
67 TimeIterator t_start ,
68 TimeIterator t_end ,
69 typename traits::time_type< Stepper >::type dt )
70 {
71 return times_time_iterator< Stepper , System , State , TimeIterator >( stepper , system , x , t_start , t_end , dt );
72 }
73
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(
77 Stepper stepper ,
78 System system ,
79 State &x )
80 //TimeIterator t_end )
81 {
82 return times_time_iterator< Stepper , System , State , TimeIterator >( stepper , system , x );
83 }
84
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(
89 Stepper stepper ,
90 System system ,
91 State &x ,
92 TimeIterator t_start ,
93 TimeIterator t_end ,
94 typename traits::time_type< Stepper >::type dt )
95 {
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 )
99 );
100 }
101
102
103
104
105
106 /**
107 * \class times_time_iterator
108 *
109 * \brief ODE Iterator with given evaluation points. The value type of this iterator is a std::pair containing state and time.
110 *
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.
121 *
122 * times_time_iterator is a model of single-pass iterator.
123 *
124 * The value type of this iterator is a pair of state and time type.
125 *
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.
130 */
131
132
133
134 /**
135 * \fn make_times_time_iterator_begin( Stepper stepper ,
136 System system ,
137 State &x ,
138 TimeIterator t_start ,
139 TimeIterator t_end ,
140 typename traits::time_type< Stepper >::type dt )
141 *
142 * \brief Factory function for times_time_iterator. Constructs a begin iterator.
143 *
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.
151 */
152
153
154 /**
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.
157 *
158 * \tparam TimesIterator The iterator type of the time sequence, must be specifically provided.
159 *
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.
164 *
165 * This function needs the TimeIterator type specifically defined as a
166 * template parameter.
167 */
168
169
170 /**
171 * \fn make_times_time_range( Stepper stepper , System system , State &x ,
172 TimeIterator t_start ,
173 TimeIterator t_end ,
174 typename traits::time_type< Stepper >::type dt )
175 *
176 * \brief Factory function to construct a single pass range of times_time iterators. A range is here a pair
177 * of times_iterator.
178 *
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.
186 */
187
188
189} // namespace odeint
190} // namespace numeric
191} // namespace boost
192
193#endif // BOOST_NUMERIC_ODEINT_ITERATOR_TIMES_TIME_ITERATOR_HPP_INCLUDED
194

source code of boost/libs/numeric/odeint/include/boost/numeric/odeint/iterator/times_time_iterator.hpp