Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-18 09:59:09

0001 /*
0002  [auto_generated]
0003  boost/numeric/odeint/integrate/detail/integrate_n_steps.hpp
0004 
0005  [begin_description]
0006  integrate steps implementation
0007  [end_description]
0008 
0009  Copyright 2009-2012 Karsten Ahnert
0010  Copyright 2009-2012 Mario Mulansky
0011 
0012  Distributed under the Boost Software License, Version 1.0.
0013  (See accompanying file LICENSE_1_0.txt or
0014  copy at http://www.boost.org/LICENSE_1_0.txt)
0015  */
0016 
0017 #ifndef BOOST_NUMERIC_ODEINT_INTEGRATE_DETAIL_INTEGRATE_N_STEPS_HPP_INCLUDED
0018 #define BOOST_NUMERIC_ODEINT_INTEGRATE_DETAIL_INTEGRATE_N_STEPS_HPP_INCLUDED
0019 
0020 #include <boost/numeric/odeint/util/unwrap_reference.hpp>
0021 #include <boost/numeric/odeint/stepper/stepper_categories.hpp>
0022 #include <boost/numeric/odeint/iterator/integrate/detail/integrate_adaptive.hpp>
0023 #include <boost/numeric/odeint/iterator/integrate/detail/functors.hpp>
0024 #include <boost/numeric/odeint/iterator/n_step_time_iterator.hpp>
0025 #include <boost/numeric/odeint/util/unit_helper.hpp>
0026 
0027 #include <boost/numeric/odeint/util/detail/less_with_sign.hpp>
0028 
0029 namespace boost {
0030 namespace numeric {
0031 namespace odeint {
0032 namespace detail {
0033 
0034 // forward declaration
0035 template< class Stepper , class System , class State , class Time , class Observer >
0036 size_t integrate_adaptive(
0037         Stepper stepper , System system , State &start_state ,
0038         Time &start_time , Time end_time , Time &dt ,
0039         Observer observer , controlled_stepper_tag
0040 );
0041 
0042 
0043 /* basic version */
0044 template< class Stepper , class System , class State , class Time , class Observer>
0045 Time integrate_n_steps(
0046         Stepper stepper , System system , State &start_state ,
0047         Time start_time , Time dt , size_t num_of_steps ,
0048         Observer observer , stepper_tag )
0049 {
0050     // ToDo: is there a better way to extract the final time?
0051     Time t = start_time; // Assignment is only here to avoid warnings.
0052     boost::for_each( make_n_step_time_range( stepper , system , start_state ,
0053                                              start_time , dt , num_of_steps ) ,
0054                      obs_caller_time< Observer , Time >( t , observer ) );
0055     return t;
0056 }
0057 
0058 
0059 /* controlled version */
0060 template< class Stepper , class System , class State , class Time , class Observer>
0061 Time integrate_n_steps(
0062         Stepper stepper , System system , State &start_state ,
0063         Time start_time , Time dt , size_t num_of_steps ,
0064         Observer observer , controlled_stepper_tag )
0065 {
0066     typename odeint::unwrap_reference< Observer >::type &obs = observer;
0067 
0068     Time time = start_time;
0069     Time time_step = dt;
0070 
0071     for( size_t step = 0; step < num_of_steps ; ++step )
0072     {
0073         obs( start_state , time );
0074         detail::integrate_adaptive( stepper , system , start_state , time , static_cast<Time>(time+time_step) , dt ,
0075                 null_observer() , controlled_stepper_tag() );
0076         // direct computation of the time avoids error propagation happening when using time += dt
0077         // we need clumsy type analysis to get boost units working here
0078         time = start_time + static_cast< typename unit_value_type<Time>::type >(step+1) * time_step;
0079     }
0080     obs( start_state , time );
0081 
0082     return time;
0083 }
0084 
0085 
0086 /* dense output version */
0087 template< class Stepper , class System , class State , class Time , class Observer>
0088 Time integrate_n_steps(
0089         Stepper stepper , System system , State &start_state ,
0090         Time start_time , Time dt , size_t num_of_steps ,
0091         Observer observer , dense_output_stepper_tag )
0092 {
0093     // ToDo: is there a better way to extract the final time?
0094     Time t = start_time;  // Assignment is only here to avoid warnings.
0095     boost::for_each( make_n_step_time_range( stepper , system , start_state ,
0096                                              start_time , dt , num_of_steps ) ,
0097                      obs_caller_time< Observer , Time >( t , observer ) );
0098     return t;
0099 }
0100 
0101 
0102 }
0103 }
0104 }
0105 }
0106 
0107 #endif /* BOOST_NUMERIC_ODEINT_INTEGRATE_DETAIL_INTEGRATE_N_STEPS_HPP_INCLUDED */