]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | |
2 | /* | |
3 | [auto_generated] | |
4 | boost/numeric/odeint/iterator/n_step_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 | [end_description] | |
9 | ||
10 | Copyright 2009-2013 Karsten Ahnert | |
11 | Copyright 2009-2013 Mario Mulansky | |
12 | ||
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) | |
16 | */ | |
17 | ||
18 | ||
19 | #ifndef BOOST_NUMERIC_ODEINT_ITERATOR_N_STEP_ITERATOR_HPP_INCLUDED | |
20 | #define BOOST_NUMERIC_ODEINT_ITERATOR_N_STEP_ITERATOR_HPP_INCLUDED | |
21 | ||
22 | ||
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/n_step_iterator_impl.hpp> | |
27 | ||
28 | ||
29 | namespace boost { | |
30 | namespace numeric { | |
31 | namespace odeint { | |
32 | ||
33 | ||
34 | /* use the n_step_iterator_impl with the right tags */ | |
35 | template< class Stepper , class System , class State | |
36 | #ifndef DOXYGEN_SKIP | |
37 | , class StepperTag = typename base_tag< typename traits::stepper_category< Stepper >::type >::type | |
38 | #endif | |
39 | > | |
40 | class n_step_iterator : public n_step_iterator_impl< | |
41 | n_step_iterator< Stepper , System , State , StepperTag > , | |
42 | Stepper , System , State , detail::ode_state_iterator_tag , StepperTag | |
43 | > | |
44 | { | |
45 | typedef typename traits::time_type< Stepper >::type time_type; | |
46 | typedef n_step_iterator< Stepper , System , State , StepperTag > iterator_type; | |
47 | ||
48 | public: | |
49 | n_step_iterator( Stepper stepper , System sys , State &s , time_type t , time_type dt , size_t num_of_steps ) | |
50 | : n_step_iterator_impl< iterator_type , Stepper , System , State , detail::ode_state_iterator_tag , StepperTag >( stepper , sys , s , t , dt , num_of_steps ) | |
51 | {} | |
52 | ||
53 | n_step_iterator( Stepper stepper , System sys , State &s ) | |
54 | : n_step_iterator_impl< iterator_type , Stepper , System , State , detail::ode_state_iterator_tag , StepperTag >( stepper , sys , s ) | |
55 | {} | |
56 | }; | |
57 | ||
58 | /* make functions */ | |
59 | ||
60 | template< class Stepper , class System , class State > | |
61 | n_step_iterator< Stepper , System, State > make_n_step_iterator_begin( | |
62 | Stepper stepper , | |
63 | System system , | |
64 | State &x , | |
65 | typename traits::time_type< Stepper >::type t , | |
66 | typename traits::time_type< Stepper >::type dt , | |
67 | size_t num_of_steps ) | |
68 | { | |
69 | return n_step_iterator< Stepper , System , State >( stepper , system , x , t , dt , num_of_steps ); | |
70 | } | |
71 | ||
72 | template< class Stepper , class System , class State > | |
73 | n_step_iterator< Stepper , System , State > make_n_step_iterator_end( | |
74 | Stepper stepper , | |
75 | System system , | |
76 | State &x ) | |
77 | { | |
78 | return n_step_iterator< Stepper , System , State >( stepper , system , x ); | |
79 | } | |
80 | ||
81 | template< class Stepper , class System , class State > | |
82 | std::pair< n_step_iterator< Stepper , System , State > , n_step_iterator< Stepper , System , State > > | |
83 | make_n_step_range( | |
84 | Stepper stepper , | |
85 | System system , | |
86 | State &x , | |
87 | typename traits::time_type< Stepper >::type t , | |
88 | typename traits::time_type< Stepper >::type dt , | |
89 | size_t num_of_steps ) | |
90 | { | |
91 | return std::make_pair( | |
92 | n_step_iterator< Stepper , System , State >( stepper , system , x , t , dt , num_of_steps ) , | |
93 | n_step_iterator< Stepper , System , State >( stepper , system , x ) | |
94 | ); | |
95 | } | |
96 | ||
97 | ||
98 | /** | |
99 | * \class n_step_iterator | |
100 | * | |
101 | * \brief ODE Iterator with constant step size. The value type of this iterator is the state type of the stepper. | |
102 | * | |
103 | * Implements an iterator representing the solution of an ODE starting from t | |
104 | * with n steps and a constant step size dt. | |
105 | * After each iteration the iterator dereferences to the state x at the next | |
106 | * time t+dt. | |
107 | * This iterator can be used with Steppers and | |
108 | * DenseOutputSteppers and it always makes use of the all the given steppers | |
109 | * capabilities. A for_each over such an iterator range behaves similar to | |
110 | * the integrate_n_steps routine. | |
111 | * | |
112 | * n_step_iterator is a model of single-pass iterator. | |
113 | * | |
114 | * 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. | |
115 | * | |
116 | * \tparam Stepper The stepper type which should be used during the iteration. | |
117 | * \tparam System The type of the system function (ODE) which should be solved. | |
118 | * \tparam State The state type of the ODE. | |
119 | */ | |
120 | ||
121 | ||
122 | /** | |
123 | * \fn make_n_step_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 ) | |
124 | * | |
125 | * \brief Factory function for n_step_iterator. Constructs a begin iterator. | |
126 | * | |
127 | * \param stepper The stepper to use during the iteration. | |
128 | * \param system The system function (ODE) to solve. | |
129 | * \param x The initial state. const_step_iterator stores a reference of s and changes its value during the iteration. | |
130 | * \param t The initial time. | |
131 | * \param dt The initial time step. | |
132 | * \param num_of_steps The number of steps to be executed. | |
133 | * \returns The n-step iterator. | |
134 | */ | |
135 | ||
136 | ||
137 | /** | |
138 | * \fn make_n_step_iterator_end( Stepper stepper , System system , State &x ) | |
139 | * \brief Factory function for n_step_iterator. Constructs an end iterator. | |
140 | * | |
141 | * \param stepper The stepper to use during the iteration. | |
142 | * \param system The system function (ODE) to solve. | |
143 | * \param x The initial state. const_step_iterator stores a reference of s and changes its value during the iteration. | |
144 | * \returns The const_step_iterator. | |
145 | */ | |
146 | ||
147 | ||
148 | /** | |
149 | * \fn make_n_step_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 ) | |
150 | * | |
151 | * \brief Factory function to construct a single pass range of n-step iterators. A range is here a pair | |
152 | * of n_step_iterator. | |
153 | * | |
154 | * \param stepper The stepper to use during the iteration. | |
155 | * \param system The system function (ODE) to solve. | |
156 | * \param x The initial state. const_step_iterator store a reference of s and changes its value during the iteration. | |
157 | * \param t The initial time. | |
158 | * \param dt The initial time step. | |
159 | * \param num_of_steps The number of steps to be executed. | |
160 | * \returns The n-step range. | |
161 | */ | |
162 | ||
163 | ||
164 | } // namespace odeint | |
165 | } // namespace numeric | |
166 | } // namespace boost | |
167 | ||
168 | #endif // BOOST_NUMERIC_ODEINT_ITERATOR_CONST_N_STEP_ITERATOR_HPP_INCLUDED |