summaryrefslogtreecommitdiff
path: root/boost/numeric/odeint/integrate/detail/integrate_n_steps.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/numeric/odeint/integrate/detail/integrate_n_steps.hpp')
-rw-r--r--boost/numeric/odeint/integrate/detail/integrate_n_steps.hpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/boost/numeric/odeint/integrate/detail/integrate_n_steps.hpp b/boost/numeric/odeint/integrate/detail/integrate_n_steps.hpp
index 3c1d171620..2ef490d592 100644
--- a/boost/numeric/odeint/integrate/detail/integrate_n_steps.hpp
+++ b/boost/numeric/odeint/integrate/detail/integrate_n_steps.hpp
@@ -6,7 +6,7 @@
integrate steps implementation
[end_description]
- Copyright 2012 Mario Mulansky
+ Copyright 2012-2015 Mario Mulansky
Copyright 2012 Christoph Koke
Copyright 2012 Karsten Ahnert
@@ -32,10 +32,10 @@ namespace detail {
// forward declaration
template< class Stepper , class System , class State , class Time , class Observer >
-size_t integrate_adaptive(
+size_t integrate_adaptive_checked(
Stepper stepper , System system , State &start_state ,
Time &start_time , Time end_time , Time &dt ,
- Observer observer , controlled_stepper_tag
+ Observer observer, controlled_stepper_tag
);
@@ -66,7 +66,7 @@ Time integrate_n_steps(
/* controlled version */
-template< class Stepper , class System , class State , class Time , class Observer>
+template< class Stepper , class System , class State , class Time , class Observer >
Time integrate_n_steps(
Stepper stepper , System system , State &start_state ,
Time start_time , Time dt , size_t num_of_steps ,
@@ -80,8 +80,9 @@ Time integrate_n_steps(
for( size_t step = 0; step < num_of_steps ; ++step )
{
obs( start_state , time );
- detail::integrate_adaptive( stepper , system , start_state , time , static_cast<Time>(time+time_step) , dt ,
- null_observer() , controlled_stepper_tag() );
+ // integrate_adaptive_checked uses the given checker to throw if an overflow occurs
+ detail::integrate_adaptive(stepper, system, start_state, time, static_cast<Time>(time + time_step), dt,
+ null_observer(), controlled_stepper_tag());
// direct computation of the time avoids error propagation happening when using time += dt
// we need clumsy type analysis to get boost units working here
time = start_time + static_cast< typename unit_value_type<Time>::type >(step+1) * time_step;
@@ -93,7 +94,7 @@ Time integrate_n_steps(
/* dense output version */
-template< class Stepper , class System , class State , class Time , class Observer>
+template< class Stepper , class System , class State , class Time , class Observer >
Time integrate_n_steps(
Stepper stepper , System system , State &start_state ,
Time start_time , Time dt , size_t num_of_steps ,
@@ -135,6 +136,7 @@ Time integrate_n_steps(
}
}
+ // make sure we really end exactly where we should end
while( st.current_time() < end_time )
{
if( less_with_sign( end_time ,
@@ -144,7 +146,7 @@ Time integrate_n_steps(
st.do_step( system );
}
- // observation at end point, only if we ended exactly on the end-point (or above due to finite precision)
+ // observation at final point
obs( st.current_state() , end_time );
return time;