# Changeset 81754

Ignore:
Timestamp:
Dec 7, 2012, 12:26:55 PM (6 years ago)
Message:

removing iterators from odeint, updating the documentation for odeint

Location:
trunk
Files:
9 deleted
37 edited

Unmodified
Removed
• ## trunk/boost/numeric/odeint/integrate/integrate.hpp

 r81491 * determine type of dxdt for units * * the two overloads are needed in order to solve the forwarding problem */ template< class System , class State , class Time , class Observer > return integrate_adaptive( controlled_runge_kutta< runge_kutta_dopri5< State > >() , system , start_state , start_time , end_time , dt , observer ); } template< class System , class State , class Time , class Observer > size_t integrate( System system , const State &start_state , Time start_time , Time end_time , Time dt , Observer observer ) { return integrate_adaptive( controlled_runge_kutta< runge_kutta_dopri5< State > >() , system , start_state , start_time , end_time , dt , observer ); } } template< class System , class State , class Time > size_t integrate( System system , const State &start_state , Time start_time , Time end_time , Time dt ) { return integrate( system , start_state , start_time , end_time , dt , null_observer() ); } /** * \fn integrate( System system , State &start_state , Time start_time , Time end_time , Time dt , Observer observer ) * \brief Integrates the ODE. * * Integrates the ODE given by system from start_time to end_time starting * with start_state as initial condtition and dt as initial time step. * This function uses a dense output dopri5 stepper and performs an adaptive * integration with step size control, thus dt changes during the integration. * This method uses standard error bounds of 1E-6. * After each step, the observer is called. * * \param system The system function to solve, hence the r.h.s. of the * ordinary differential equation. * \param start_state The initial state. * \param start_time Start time of the integration. * \param end_time End time of the integration. * \param dt Initial step size, will be adjusted durinf the integration. * \param observer Observer that will be called after each time step. * \return The number of steps performed. */ /** * \fn integrate( System system , State &start_state , Time start_time , Time end_time , Time dt ) * \brief Integrates the ODE without observer calls. * * Integrates the ODE given by system from start_time to end_time starting * with start_state as initial condtition and dt as initial time step. * This function uses a dense output dopri5 stepper and performs an adaptive * integration with step size control, thus dt changes during the integration. * This method uses standard error bounds of 1E-6. * No observer is called. * * \param system The system function to solve, hence the r.h.s. of the * ordinary differential equation. * \param start_state The initial state. * \param start_time Start time of the integration. * \param end_time End time of the integration. * \param dt Initial step size, will be adjusted durinf the integration. * \return The number of steps performed. */ } // namespace odeint

 r81491 } /** * \brief Second version to solve the forwarding problem, * can be called with Boost.Range as start_state. */ template< class Stepper , class System , class State , class Time , class Observer > size_t integrate_adaptive( /* * the two overloads are needed in order to solve the forwarding problem /** * \brief integrate_adaptive without an observer. */ template< class Stepper , class System , class State , class Time > } /** * \brief Second version to solve the forwarding problem, * can be called with Boost.Range as start_state. */ template< class Stepper , class System , class State , class Time > size_t integrate_adaptive( /************* DOXYGEN ************/ /** * \fn integrate_adaptive( Stepper stepper , System system , State &start_state , Time start_time , Time end_time , Time dt , Observer observer ) * \brief Integrates the ODE with adaptive step size. * * This function integrates the ODE given by system with the given stepper. * The observer is called after each step. If the stepper has no error * control, the step size remains constant and the observer is calleda at * equidistant time points t0+n*dt. If the stepper is a ControlledStepper, * the step size is adjusted and the observer is called in non-equidistant * intervals. * * \param stepper The stepper to be used for numerical integration. * \param system Function/Functor defining the rhs of the ODE. * \param start_state The initial condition x0. * \param start_time The initial time t0. * \param end_time The final integration time tend. * \param dt The time step between observer calls, _not_ neccessarily the * time step of the integration. * \param observer Function/Functor called at equidistant time intervals. * \return The number of steps performed. */ } // namespace odeint } // namespace numeric
• ## trunk/boost/numeric/odeint/integrate/integrate_const.hpp

 r81491 } /** * \brief Second version to solve the forwarding problem, * can be called with Boost.Range as start_state. */ template< class Stepper , class System , class State , class Time , class Observer > size_t integrate_const( /* * Without observers /** * \brief integrate_const without observer calls */ template< class Stepper , class System , class State , class Time > } /** * \brief Second version to solve the forwarding problem, * can be called with Boost.Range as start_state. */ template< class Stepper , class System , class State , class Time > size_t integrate_const( /********* DOXYGEN *********/ /** * \fn integrate_const( Stepper stepper , System system , State &start_state , Time start_time , Time end_time , Time dt , Observer observer ) * \brief Integrates the ODE with constant step size. * * Integrates the ODE defined by system using the given stepper. * This method ensures that the observer is called at constant intervals dt. * If the Stepper is a normal stepper without step size control, dt is also * used for the numerical scheme. If a ControlledStepper is provided, the * algorithm might reduce the step size to meet the error bounds, but it is * ensured that the observer is always called at equidistant time points * t0 + n*dt. If a DenseOutputStepper is used, the step size also may vary * and the dense output is used to call the observer at equidistant time * points. * * \param stepper The stepper to be used for numerical integration. * \param system Function/Functor defining the rhs of the ODE. * \param start_state The initial condition x0. * \param start_time The initial time t0. * \param end_time The final integration time tend. * \param dt The time step between observer calls, _not_ neccessarily the * time step of the integration. * \param observer Function/Functor called at equidistant time intervals. * \return The number of steps performed. */ } // namespace odeint
• ## trunk/boost/numeric/odeint/integrate/integrate_n_steps.hpp

 r81491 } /** * \brief Solves the forwarding problem, can be called with Boost.Range as start_state. */ template< class Stepper , class System , class State , class Time , class Observer > Time integrate_n_steps( /* * the two overloads are needed in order to solve the forwarding problem /** * \brief The same function as above, but without observer calls. */ template< class Stepper , class System , class State , class Time > } /** * \brief Solves the forwarding problem, can be called with Boost.Range as start_state. */ template< class Stepper , class System , class State , class Time > Time integrate_n_steps( /************* DOXYGEN *************/ /** * \fn Time integrate_n_steps( Stepper stepper , System system , State &start_state , Time start_time , Time dt , size_t num_of_steps , Observer observer ) * \brief Integrates the ODE with constant step size. * * This function is similar to integrate_const. The observer is called at * equidistant time intervals t0 + n*dt. * If the Stepper is a normal stepper without step size control, dt is also * used for the numerical scheme. If a ControlledStepper is provided, the * algorithm might reduce the step size to meet the error bounds, but it is * ensured that the observer is always called at equidistant time points * t0 + n*dt. If a DenseOutputStepper is used, the step size also may vary * and the dense output is used to call the observer at equidistant time * points. The final integration time is always t0 + num_of_steps*dt. * * \param stepper The stepper to be used for numerical integration. * \param system Function/Functor defining the rhs of the ODE. * \param start_state The initial condition x0. * \param start_time The initial time t0. * \param dt The time step between observer calls, _not_ neccessarily the * time step of the integration. * \param num_of_steps Number of steps to be performed * \param observer Function/Functor called at equidistant time intervals. * \return The number of steps performed. */ } // namespace odeint
• ## trunk/boost/numeric/odeint/integrate/integrate_times.hpp

 r81491 } /** * \brief Solves the forwarding problem, can be called with Boost.Range as start_state. */ template< class Stepper , class System , class State , class TimeIterator , class Time , class Observer > size_t integrate_times( } /* * Range Version: * the two overloads are needed in order to solve the forwarding problem /** * \brief The same function as above, but without observer calls. */ template< class Stepper , class System , class State , class TimeRange , class Time , class Observer > } /** * \brief Solves the forwarding problem, can be called with Boost.Range as start_state. */ template< class Stepper , class System , class State , class TimeRange , class Time , class Observer > size_t integrate_times( } /********* DOXYGEN ***********/ /** * \fn size_t integrate_times( Stepper stepper , System system , State &start_state , TimeIterator times_start , TimeIterator times_end , Time dt , Observer observer ) * \brief Integrates the ODE with observer calls at given time points. * * Integrates the ODE given by system using the given stepper. This function * does observer calls at the subsequent time points given by the range * times_start, times_end. If the stepper has not step size control, the * step size might be reduced occasionally to ensure observer calls exactly * at the time points from the given sequence. If the stepper is a * ControlledStepper, the step size is adjusted to meet the error bounds, * but also might be reduced occasionally to ensure correct observer calls. * If a DenseOutputStepper is provided, the dense output functionality is * used to call the observer at the given times. The end time of the * integration is always *(end_time-1). * * \param stepper The stepper to be used for numerical integration. * \param system Function/Functor defining the rhs of the ODE. * \param start_state The initial condition x0. * \param times_start Iterator to the start time * \param times_end Iterator to the end time * \param dt The time step between observer calls, _not_ neccessarily the * time step of the integration. * \param observer Function/Functor called at equidistant time intervals. * \return The number of steps performed. */ } // namespace odeint } // namespace numeric

• ## trunk/boost/numeric/odeint/stepper/base/algebra_stepper_base.hpp

 r81491 namespace odeint { template< class Algebra , class Operations > class algebra_stepper_base { public: typedef Algebra algebra_type; typedef Operations operations_type; algebra_stepper_base( const algebra_type &algebra = algebra_type() ) : m_algebra( algebra ) { } algebra_type& algebra() { return m_algebra; } const algebra_type& algebra() const { return m_algebra; } protected: algebra_type m_algebra; }; /******* DOXYGEN *******/ /** * \class algebra_stepper_base * to work with the stepper. */ template< class Algebra , class Operations > class algebra_stepper_base { public: typedef Algebra algebra_type; typedef Operations operations_type; /** * \fn algebra_stepper_base::algebra_stepper_base( const algebra_type &algebra = algebra_type() ) * \brief Constructs a algebra_stepper_base and creates the algebra. This constructor can be used as a default * constructor if the algebra has a default constructor. * \param algebra The algebra_stepper_base stores and uses a copy of algebra. */ algebra_stepper_base( const algebra_type &algebra = algebra_type() ) : m_algebra( algebra ) { } /** * \fn algebra_type& algebra_stepper_base::algebra() * \return A reference to the algebra which is held by this class. */ algebra_type& algebra() { return m_algebra; } /** * \fn const algebra_type& algebra_stepper_base::algebra() const * \return A const reference to the algebra which is held by this class. */ const algebra_type& algebra() const { return m_algebra; } protected: algebra_type m_algebra; }; } // odeint

• ## trunk/boost/numeric/odeint/stepper/controlled_step_result.hpp

 r81491 /** * \enum Enum representing the return values of the controlled steppers. * \enum controlled_step_result * * \brief Enum representing the return values of the controlled steppers. */ typedef enum { success , /**
• ## trunk/boost/numeric/odeint/stepper/dense_output_runge_kutta.hpp

 r81491 /** * \brief The class representing dense-output Runge-Kutta steppers. * \note In this stepper, the initialize method has to be called before using * the do_step method. * * The dense-output functionality allows to interpolate the solution between * subsequent integration points using intermediate results obtained during the * computation. This version works based on a normal stepper without step-size * control. * * * \tparam Stepper The stepper type of the underlying algorithm. */ template< class Stepper > class dense_output_runge_kutta< Stepper , stepper_tag > /** * \brief Constructs the dense_output_runge_kutta class. An instance of the * underlying stepper can be provided. * \param stepper An instance of the underlying stepper. */ dense_output_runge_kutta( const stepper_type &stepper = stepper_type() ) : m_stepper( stepper ) , m_resizer() , /** * \brief Initializes the stepper. Has to be called before do_step can be * used to set the initial conditions and the step size. * \param x0 The inital state of the ODE which should be solved. * \param t0 The initial time, at which the step should be performed. * \param dt0 The step size. */ template< class StateType > void initialize( const StateType &x0 , time_type t0 , time_type dt0 ) } /** * \brief Does one time step. * \note initialize has to be called before using this method to set the * inital conditions x,t and the stepsize. * \param system The system function to solve, hence the r.h.s. of the ordinary differential equation. It must fullfil the *               Simple System concept. * \return Pair with start and end time of the integration step. */ template< class System > std::pair< time_type , time_type > do_step( System system ) * The next two overloads are needed to solve the forwarding problem */ /** * \brief Calculates the solution at an intermediate point. * \param t The time at which the solution should be calculated, has to be * in the current time interval. * \param x The output variable where the result is written into. */ template< class StateOut > void calc_state( time_type t , StateOut &x ) const } /** * \brief Calculates the solution at an intermediate point. Solves the forwarding problem * \param t The time at which the solution should be calculated, has to be * in the current time interval. * \param x The output variable where the result is written into, can be a boost range. */ template< class StateOut > void calc_state( time_type t , const StateOut &x ) const } /** * \brief Adjust the size of all temporaries in the stepper manually. * \param x A state from which the size of the temporaries to be resized is deduced. */ template< class StateType > void adjust_size( const StateType &x ) } /** * \brief Returns the current state of the solution. * \return The current state of the solution x(t). */ const state_type& current_state( void ) const { } /** * \brief Returns the current time of the solution. * \return The current time of the solution t. */ time_type current_time( void ) const { } /** * \brief Returns the last state of the solution. * \return The last state of the solution x(t-dt). */ const state_type& previous_state( void ) const { } /** * \brief Returns the last time of the solution. * \return The last time of the solution t-dt. */ time_type previous_time( void ) const { /** * \brief The class representing dense-output Runge-Kutta steppers with FSAL property. * * The interface is the same as for dense_output_runge_kutta< Stepper , stepper_tag >. * This class provides dense output functionality based on methods with step size controlled * * * \tparam Stepper The stepper type of the underlying algorithm. */ template< class Stepper > class dense_output_runge_kutta< Stepper , explicit_controlled_stepper_fsal_tag >
• ## trunk/boost/numeric/odeint/stepper/euler.hpp

 r81491 /** * \class euler * \brief An implementation of the Euler method. * * The Euler method is a very simply solver for ordinary differential equations. This method should not be used * for real applications. It is only useful for demonstration purposes. Step size control is not provided but * trivial continous output is available. * * This class derives from explicit_stepper_base and inherits its interface via CRTP (current recurring template pattern), * see explicit_stepper_base * * \tparam State The state type. * \tparam Value The value type. * \tparam Deriv The type representing the time derivative of the state. * \tparam Time The time representing the independent variable - the time. * \tparam Algebra The algebra type. * \tparam Operations The operations type. * \tparam Resizer The resizer policy type. */ template< class State , 1 , State , Value , Deriv , Time , Algebra , Operations , Resizer > #else class euler : public explicit_stepper_base< euler< ... > , ... > class euler : public explicit_stepper_base #endif { euler( const algebra_type &algebra = algebra_type() ) : stepper_base_type( algebra ) { } template< class System , class StateIn , class DerivIn , class StateOut > void do_step_impl( System system , const StateIn &in , const DerivIn &dxdt , time_type t , StateOut &out , time_type dt ) { stepper_base_type::m_algebra.for_each3( out , in , dxdt , typename operations_type::template scale_sum2< value_type , time_type >( 1.0 , dt ) ); } template< class StateOut , class StateIn1 , class StateIn2 > void calc_state( StateOut &x , time_type t ,  const StateIn1 &old_state , time_type t_old , const StateIn2 ¤t_state , time_type t_new ) const { const time_type delta = t - t_old; stepper_base_type::m_algebra.for_each3( x , old_state , stepper_base_type::m_dxdt.m_v , typename operations_type::template scale_sum2< value_type , time_type >( 1.0 , delta ) ); } template< class StateType > void adjust_size( const StateType &x ) { stepper_base_type::adjust_size( x ); } }; /********** DOXYGEN ***********/ /** * \class euler * \brief An implementation of the Euler method. * * The Euler method is a very simply solver for ordinary differential equations. This method should not be used * for real applications. It is only useful for demonstration purposes. Step size control is not provided but * trivial continous output is available. * * This class derives from explicit_stepper_base and inherits its interface via CRTP (current recurring template pattern), * see explicit_stepper_base * * \tparam State The state type. * \tparam Value The value type. * \tparam Deriv The type representing the time derivative of the state. * \tparam Time The time representing the independent variable - the time. * \tparam Algebra The algebra type. * \tparam Operations The operations type. * \tparam Resizer The resizer policy type. */ /** * \fn euler::euler( const algebra_type &algebra ) * \brief Constructs the euler class. This constructor can be used as a default * constructor of the algebra has a default constructor. * \param algebra A copy of algebra is made and stored inside explicit_stepper_base. */ euler( const algebra_type &algebra = algebra_type() ) : stepper_base_type( algebra ) { } /** * \fn euler::do_step_impl( System system , const StateIn &in , const DerivIn &dxdt , time_type t , StateOut &out , time_type dt ) * \brief This method performs one step. The derivative `dxdt` of `in` at the time `t` is passed to the method. * The result is updated out of place, hence the input is in `in` and the output in `out`. `do_step_impl` is * used by explicit_stepper_base. * The result is updated out of place, hence the input is in `in` and the output in `out`. * Access to this step functionality is provided by explicit_stepper_base and * `do_step_impl` should not be called directly. * * \param system The system function to solve, hence the r.h.s. of the ODE. It must fullfil the * \param dt The step size. */ template< class System , class StateIn , class DerivIn , class StateOut > void do_step_impl( System system , const StateIn &in , const DerivIn &dxdt , time_type t , StateOut &out , time_type dt ) { stepper_base_type::m_algebra.for_each3( out , in , dxdt , typename operations_type::template scale_sum2< value_type , time_type >( 1.0 , dt ) ); } /** * \fn euler::calc_state( StateOut &x , time_type t ,  const StateIn1 &old_state , time_type t_old , const StateIn2 ¤t_state , time_type t_new ) const * \brief This method is used for continous output and it calculates the state `x` at a time `t` from the * knowledge of two states `old_state` and `current_state` at time points `t_old` and `t_new`. */ template< class StateOut , class StateIn1 , class StateIn2 > void calc_state( StateOut &x , time_type t ,  const StateIn1 &old_state , time_type t_old , const StateIn2 ¤t_state , time_type t_new ) const { const time_type delta = t - t_old; stepper_base_type::m_algebra.for_each3( x , old_state , stepper_base_type::m_dxdt.m_v , typename operations_type::template scale_sum2< value_type , time_type >( 1.0 , delta ) ); } /** * \fn euler::adjust_size( const StateType &x ) * \brief Adjust the size of all temporaries in the stepper manually. * \param x A state from which the size of the temporaries to be resized is deduced. */ template< class StateType > void adjust_size( const StateType &x ) { stepper_base_type::adjust_size( x ); } }; } // odeint