123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- /*
- [auto_generated]
- boost/numeric/odeint/integrate/detail/integrate_adaptive.hpp
- [begin_description]
- Default Integrate adaptive implementation.
- [end_description]
- Copyright 2009-2011 Karsten Ahnert
- Copyright 2009-2011 Mario Mulansky
- Distributed under the Boost Software License, Version 1.0.
- (See accompanying file LICENSE_1_0.txt or
- copy at http://www.boost.org/LICENSE_1_0.txt)
- */
- #ifndef BOOST_NUMERIC_ODEINT_INTEGRATE_DETAIL_INTEGRATE_ADAPTIVE_HPP_INCLUDED
- #define BOOST_NUMERIC_ODEINT_INTEGRATE_DETAIL_INTEGRATE_ADAPTIVE_HPP_INCLUDED
- #include <stdexcept>
- #include <boost/numeric/odeint/stepper/stepper_categories.hpp>
- #include <boost/numeric/odeint/stepper/controlled_step_result.hpp>
- #include <boost/numeric/odeint/iterator/integrate/detail/integrate_const.hpp>
- #include <boost/numeric/odeint/iterator/adaptive_time_iterator.hpp>
- #include <boost/numeric/odeint/iterator/integrate/detail/functors.hpp>
- #include <boost/numeric/odeint/util/bind.hpp>
- #include <boost/numeric/odeint/util/unwrap_reference.hpp>
- #include <boost/numeric/odeint/util/copy.hpp>
- #include <boost/numeric/odeint/util/detail/less_with_sign.hpp>
- namespace boost {
- namespace numeric {
- namespace odeint {
- namespace detail {
- // forward declaration
- template< class Stepper , class System , class State , class Time , class Observer>
- size_t integrate_const(
- Stepper stepper , System system , State &start_state ,
- Time start_time , Time end_time , Time dt ,
- Observer observer , stepper_tag );
- /*
- * integrate_adaptive for simple stepper is basically an integrate_const + some last step
- */
- template< class Stepper , class System , class State , class Time , class Observer >
- size_t integrate_adaptive(
- Stepper stepper , System system , State &start_state ,
- Time start_time , Time end_time , Time dt ,
- Observer observer , stepper_tag
- )
- {
- size_t steps = detail::integrate_const( stepper , system , start_state , start_time ,
- end_time , dt , observer , stepper_tag() );
- typename odeint::unwrap_reference< Observer >::type &obs = observer;
- typename odeint::unwrap_reference< Stepper >::type &st = stepper;
- Time end = start_time + dt*steps;
- if( less_with_sign( end , end_time , dt ) )
- { //make a last step to end exactly at end_time
- st.do_step( system , start_state , end , end_time - end );
- steps++;
- obs( start_state , end_time );
- }
- return steps;
- }
- /*
- * classical integrate adaptive
- */
- template< class Stepper , class System , class State , class Time , class Observer >
- size_t integrate_adaptive(
- Stepper stepper , System system , State &start_state ,
- Time &start_time , Time end_time , Time &dt ,
- Observer observer , controlled_stepper_tag
- )
- {
- size_t obs_calls = 0;
- boost::for_each( make_adaptive_time_range( stepper , system , start_state ,
- start_time , end_time , dt ) ,
- obs_caller< Observer >( obs_calls , observer ) );
- return obs_calls-1;
- }
- /*
- * integrate adaptive for dense output steppers
- *
- * step size control is used if the stepper supports it
- */
- template< class Stepper , class System , class State , class Time , class Observer >
- size_t integrate_adaptive(
- Stepper stepper , System system , State &start_state ,
- Time start_time , Time end_time , Time dt ,
- Observer observer , dense_output_stepper_tag )
- {
- size_t obs_calls = 0;
- boost::for_each( make_adaptive_time_range( stepper , system , start_state ,
- start_time , end_time , dt ) ,
- obs_caller< Observer >( obs_calls , observer ) );
- return obs_calls-1;
- }
- } // namespace detail
- } // namespace odeint
- } // namespace numeric
- } // namespace boost
- #endif // BOOST_NUMERIC_ODEINT_INTEGRATE_DETAIL_INTEGRATE_ADAPTIVE_HPP_INCLUDED
|