Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/numeric/odeint/integrate/detail/integrate_const.hpp @ 16:2665513ce2d3
Add boost headers
author | Chris Cannam |
---|---|
date | Tue, 05 Aug 2014 11:11:38 +0100 |
parents | |
children | c530137014c0 |
comparison
equal
deleted
inserted
replaced
15:663ca0da4350 | 16:2665513ce2d3 |
---|---|
1 /* | |
2 [auto_generated] | |
3 boost/numeric/odeint/integrate/detail/integrate_const.hpp | |
4 | |
5 [begin_description] | |
6 integrate const implementation | |
7 [end_description] | |
8 | |
9 Copyright 2009-2012 Karsten Ahnert | |
10 Copyright 2009-2012 Mario Mulansky | |
11 | |
12 Distributed under the Boost Software License, Version 1.0. | |
13 (See accompanying file LICENSE_1_0.txt or | |
14 copy at http://www.boost.org/LICENSE_1_0.txt) | |
15 */ | |
16 | |
17 #ifndef BOOST_NUMERIC_ODEINT_INTEGRATE_DETAIL_INTEGRATE_CONST_HPP_INCLUDED | |
18 #define BOOST_NUMERIC_ODEINT_INTEGRATE_DETAIL_INTEGRATE_CONST_HPP_INCLUDED | |
19 | |
20 #include <boost/numeric/odeint/util/unwrap_reference.hpp> | |
21 #include <boost/numeric/odeint/stepper/stepper_categories.hpp> | |
22 #include <boost/numeric/odeint/util/unit_helper.hpp> | |
23 #include <boost/numeric/odeint/integrate/detail/integrate_adaptive.hpp> | |
24 | |
25 #include <boost/numeric/odeint/util/detail/less_with_sign.hpp> | |
26 | |
27 namespace boost { | |
28 namespace numeric { | |
29 namespace odeint { | |
30 namespace detail { | |
31 | |
32 // forward declaration | |
33 template< class Stepper , class System , class State , class Time , class Observer > | |
34 size_t integrate_adaptive( | |
35 Stepper stepper , System system , State &start_state , | |
36 Time &start_time , Time end_time , Time &dt , | |
37 Observer observer , controlled_stepper_tag | |
38 ); | |
39 | |
40 | |
41 template< class Stepper , class System , class State , class Time , class Observer > | |
42 size_t integrate_const( | |
43 Stepper stepper , System system , State &start_state , | |
44 Time start_time , Time end_time , Time dt , | |
45 Observer observer , stepper_tag | |
46 ) | |
47 { | |
48 typename odeint::unwrap_reference< Observer >::type &obs = observer; | |
49 | |
50 Time time = start_time; | |
51 int step = 0; | |
52 | |
53 while( less_eq_with_sign( time+dt , end_time , dt ) ) | |
54 { | |
55 obs( start_state , time ); | |
56 stepper.do_step( system , start_state , time , dt ); | |
57 // direct computation of the time avoids error propagation happening when using time += dt | |
58 // we need clumsy type analysis to get boost units working here | |
59 ++step; | |
60 time = start_time + static_cast< typename unit_value_type<Time>::type >(step) * dt; | |
61 } | |
62 obs( start_state , time ); | |
63 | |
64 return step; | |
65 } | |
66 | |
67 | |
68 | |
69 template< class Stepper , class System , class State , class Time , class Observer > | |
70 size_t integrate_const( | |
71 Stepper stepper , System system , State &start_state , | |
72 Time start_time , Time end_time , Time dt , | |
73 Observer observer , controlled_stepper_tag | |
74 ) | |
75 { | |
76 typename odeint::unwrap_reference< Observer >::type &obs = observer; | |
77 | |
78 Time time = start_time; | |
79 const Time time_step = dt; | |
80 int step = 0; | |
81 | |
82 while( less_eq_with_sign( time+time_step , end_time , dt ) ) | |
83 { | |
84 obs( start_state , time ); | |
85 detail::integrate_adaptive( stepper , system , start_state , time , time+time_step , dt , | |
86 null_observer() , controlled_stepper_tag() ); | |
87 // direct computation of the time avoids error propagation happening when using time += dt | |
88 // we need clumsy type analysis to get boost units working here | |
89 ++step; | |
90 time = start_time + static_cast< typename unit_value_type<Time>::type >(step) * time_step; | |
91 } | |
92 obs( start_state , time ); | |
93 | |
94 return step; | |
95 } | |
96 | |
97 | |
98 template< class Stepper , class System , class State , class Time , class Observer > | |
99 size_t integrate_const( | |
100 Stepper stepper , System system , State &start_state , | |
101 Time start_time , Time end_time , Time dt , | |
102 Observer observer , dense_output_stepper_tag | |
103 ) | |
104 { | |
105 typename odeint::unwrap_reference< Observer >::type &obs = observer; | |
106 | |
107 Time time = start_time; | |
108 | |
109 stepper.initialize( start_state , time , dt ); | |
110 obs( start_state , time ); | |
111 time += dt; | |
112 | |
113 int obs_step( 1 ); | |
114 int real_step( 0 ); | |
115 | |
116 while( less_with_sign( time+dt , end_time , dt ) ) | |
117 { | |
118 while( less_eq_with_sign( time , stepper.current_time() , dt ) ) | |
119 { | |
120 stepper.calc_state( time , start_state ); | |
121 obs( start_state , time ); | |
122 ++obs_step; | |
123 // direct computation of the time avoids error propagation happening when using time += dt | |
124 // we need clumsy type analysis to get boost units working here | |
125 time = start_time + static_cast< typename unit_value_type<Time>::type >(obs_step) * dt; | |
126 } | |
127 // we have not reached the end, do another real step | |
128 if( less_with_sign( stepper.current_time()+stepper.current_time_step() , | |
129 end_time , | |
130 stepper.current_time_step() ) ) | |
131 { | |
132 while( less_eq_with_sign( stepper.current_time() , time , dt ) ) | |
133 { | |
134 stepper.do_step( system ); | |
135 ++real_step; | |
136 } | |
137 } | |
138 else if( less_with_sign( stepper.current_time() , end_time , stepper.current_time_step() ) ) | |
139 { // do the last step ending exactly on the end point | |
140 stepper.initialize( stepper.current_state() , stepper.current_time() , end_time - stepper.current_time() ); | |
141 stepper.do_step( system ); | |
142 ++real_step; | |
143 } | |
144 | |
145 } | |
146 // last observation, if we are still in observation interval | |
147 if( less_eq_with_sign( time , end_time , dt ) ) | |
148 { | |
149 stepper.calc_state( time , start_state ); | |
150 obs( start_state , time ); | |
151 } | |
152 | |
153 return real_step; | |
154 } | |
155 | |
156 | |
157 } } } } | |
158 | |
159 #endif |