3 boost/numeric/odeint/integrate/detail/integrate_adaptive.hpp
6 Default Integrate adaptive implementation.
9 Copyright 2009-2011 Karsten Ahnert
10 Copyright 2009-2011 Mario Mulansky
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)
18 #ifndef BOOST_NUMERIC_ODEINT_INTEGRATE_DETAIL_INTEGRATE_ADAPTIVE_HPP_INCLUDED
19 #define BOOST_NUMERIC_ODEINT_INTEGRATE_DETAIL_INTEGRATE_ADAPTIVE_HPP_INCLUDED
23 #include <boost/numeric/odeint/stepper/stepper_categories.hpp>
24 #include <boost/numeric/odeint/stepper/controlled_step_result.hpp>
25 #include <boost/numeric/odeint/iterator/integrate/detail/integrate_const.hpp>
26 #include <boost/numeric/odeint/iterator/adaptive_time_iterator.hpp>
27 #include <boost/numeric/odeint/iterator/integrate/detail/functors.hpp>
28 #include <boost/numeric/odeint/util/bind.hpp>
29 #include <boost/numeric/odeint/util/unwrap_reference.hpp>
30 #include <boost/numeric/odeint/util/copy.hpp>
32 #include <boost/numeric/odeint/util/detail/less_with_sign.hpp>
39 // forward declaration
40 template< class Stepper , class System , class State , class Time , class Observer>
41 size_t integrate_const(
42 Stepper stepper , System system , State &start_state ,
43 Time start_time , Time end_time , Time dt ,
44 Observer observer , stepper_tag );
47 * integrate_adaptive for simple stepper is basically an integrate_const + some last step
49 template< class Stepper , class System , class State , class Time , class Observer >
50 size_t integrate_adaptive(
51 Stepper stepper , System system , State &start_state ,
52 Time start_time , Time end_time , Time dt ,
53 Observer observer , stepper_tag
56 size_t steps = detail::integrate_const( stepper , system , start_state , start_time ,
57 end_time , dt , observer , stepper_tag() );
58 typename odeint::unwrap_reference< Observer >::type &obs = observer;
59 typename odeint::unwrap_reference< Stepper >::type &st = stepper;
61 Time end = start_time + dt*steps;
62 if( less_with_sign( end , end_time , dt ) )
63 { //make a last step to end exactly at end_time
64 st.do_step( system , start_state , end , end_time - end );
66 obs( start_state , end_time );
73 * classical integrate adaptive
75 template< class Stepper , class System , class State , class Time , class Observer >
76 size_t integrate_adaptive(
77 Stepper stepper , System system , State &start_state ,
78 Time &start_time , Time end_time , Time &dt ,
79 Observer observer , controlled_stepper_tag
84 boost::for_each( make_adaptive_time_range( stepper , system , start_state ,
85 start_time , end_time , dt ) ,
86 obs_caller< Observer >( obs_calls , observer ) );
93 * integrate adaptive for dense output steppers
95 * step size control is used if the stepper supports it
97 template< class Stepper , class System , class State , class Time , class Observer >
98 size_t integrate_adaptive(
99 Stepper stepper , System system , State &start_state ,
100 Time start_time , Time end_time , Time dt ,
101 Observer observer , dense_output_stepper_tag )
103 size_t obs_calls = 0;
105 boost::for_each( make_adaptive_time_range( stepper , system , start_state ,
106 start_time , end_time , dt ) ,
107 obs_caller< Observer >( obs_calls , observer ) );
115 } // namespace detail
116 } // namespace odeint
117 } // namespace numeric
121 #endif // BOOST_NUMERIC_ODEINT_INTEGRATE_DETAIL_INTEGRATE_ADAPTIVE_HPP_INCLUDED