• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 /*
3  [auto_generated]
4  boost/numeric/odeint/iterator/n_step_time_iterator.hpp
5 
6  [begin_description]
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.
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_N_STEP_TIME_ITERATOR_HPP_INCLUDED
21 #define BOOST_NUMERIC_ODEINT_ITERATOR_N_STEP_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/n_step_iterator_impl.hpp>
28 
29 
30 namespace boost {
31 namespace numeric {
32 namespace odeint {
33 
34 
35     /* use the n_step_iterator_impl with the right tags */
36     template< class Stepper , class System , class State
37 #ifndef DOXYGEN_SKIP
38         , class StepperTag = typename base_tag< typename traits::stepper_category< Stepper >::type >::type
39 #endif
40     >
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
44         >
45     {
46         typedef typename traits::time_type< Stepper >::type time_type;
47         typedef n_step_time_iterator< Stepper , System , State , StepperTag > iterator_type;
48 
49     public:
n_step_time_iterator(Stepper stepper,System sys,State & s,time_type t,time_type dt,size_t num_of_steps)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 )
52         {}
53 
n_step_time_iterator(Stepper stepper,System sys,State & s)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 )
56         {}
57     };
58 
59     /* make functions */
60 
61     template< class Stepper , class System , class State >
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)62     n_step_time_iterator< Stepper , System, State > make_n_step_time_iterator_begin(
63         Stepper stepper ,
64         System system ,
65         State &x ,
66         typename traits::time_type< Stepper >::type t ,
67         typename traits::time_type< Stepper >::type dt ,
68         size_t num_of_steps )
69     {
70         return n_step_time_iterator< Stepper , System , State >( stepper , system , x , t , dt , num_of_steps );
71     }
72 
73     template< class Stepper , class System , class State >
make_n_step_time_iterator_end(Stepper stepper,System system,State & x)74     n_step_time_iterator< Stepper , System , State > make_n_step_time_iterator_end(
75         Stepper stepper ,
76         System system ,
77         State &x )
78     {
79         return n_step_time_iterator< Stepper , System , State >( stepper , system , x );
80     }
81 
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 > >
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)84     make_n_step_time_range(
85         Stepper stepper ,
86         System system ,
87         State &x ,
88         typename traits::time_type< Stepper >::type t ,
89         typename traits::time_type< Stepper >::type dt ,
90         size_t num_of_steps )
91     {
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 )
95             );
96     }
97 
98 
99     /**
100      * \class n_step_time_iterator
101      *
102      * \brief ODE Iterator with constant step size. The value type of this iterator is a std::pair containing state and time.
103      *
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
107      * time t+dt.
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.
112      *
113      * n_step_time_iterator is a model of single-pass iterator.
114      *
115      * The value type of this iterator is pair of state and time.
116      *
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.
120      */
121 
122 
123     /**
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 )
125      *
126      * \brief Factory function for n_step_time_iterator. Constructs a begin iterator.
127      *
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.
135      */
136 
137 
138     /**
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.
141      *
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.
146      */
147 
148 
149     /**
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 )
151      *
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.
154      *
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.
162      */
163 
164 
165 } // namespace odeint
166 } // namespace numeric
167 } // namespace boost
168 
169 #endif // BOOST_NUMERIC_ODEINT_ITERATOR_CONST_N_STEP_TIME_ITERATOR_HPP_INCLUDED
170