From 452ca84cf8d3940177e3709cdcfaebb2d64b0a51 Mon Sep 17 00:00:00 2001 From: Karsten Ahnert Date: Fri, 19 Oct 2012 15:47:22 +0200 Subject: [PATCH] continues with reference --- .../base/explicit_error_stepper_base.hpp | 32 ++++++-- .../stepper/base/explicit_stepper_base.hpp | 27 +++++-- boost/numeric/odeint/stepper/euler.hpp | 72 ++++++++++++++++-- .../stepper/explicit_error_generic_rk.hpp | 59 ++++++++++++++ boost/numeric/odeint/stepper/runge_kutta4.hpp | 13 ++-- .../odeint/stepper/runge_kutta4_classic.hpp | 20 +++-- .../stepper/runge_kutta_cash_karp54.hpp | 32 ++++++++ .../runge_kutta_cash_karp54_classic.hpp | 76 +++++++++++++++++-- libs/numeric/odeint/doc/Jamfile | 14 ++-- 9 files changed, 304 insertions(+), 41 deletions(-) diff --git a/boost/numeric/odeint/stepper/base/explicit_error_stepper_base.hpp b/boost/numeric/odeint/stepper/base/explicit_error_stepper_base.hpp index 3bb59383..80094321 100644 --- a/boost/numeric/odeint/stepper/base/explicit_error_stepper_base.hpp +++ b/boost/numeric/odeint/stepper/base/explicit_error_stepper_base.hpp @@ -69,6 +69,30 @@ namespace odeint { * `do_step_impl( system , in , dxdt_in , t , out , dt , xerr )`. * explicit_error_stepper_base derives from algebra_stepper_base. * + * explicit_error_stepper_base provides several overloaded `do_step` methods, see the list below. Only two of them are needed + * to fullfil the Error Stepper concept. The other one are for convenience and for performance. Some of them simply update the + * state out-of-place, while other expect that the first derivative at `t` is passed to the stepper. + * + * - `do_step( sys , x , t , dt )` - The classical `do_step` method needed to fullfil the Error Stepper concept. The state is updated in-place. + * A type modelling a Boost.Range can be used for x. + * - `do_step( sys , x , dxdt , t , dt )` - This method updates the state in-place, but the derivative at the point `t` must be + * explicitely passed in `dxdt`. + * - `do_step( sys , in , t , out , dt )` - This method updates the state out-of-place, hence the result of the step is stored in `out`. + * - `do_step( sys , in , dxdt , t , out , dt )` - This method update the state out-of-place and expects that the derivative at the point + * `t` is explicitely passed in `dxdt`. It is a combination of the two `do_step` methods above. + * - `do_step( sys , x , t , dt , xerr )` - This `do_step` method is needed to fullfil the Error Stepper concept. The state is updated in-place + * and an error estimate is calculated. A type modelling a Boost.Range can be used for x. + * - `do_step( sys , x , dxdt , t , dt , xerr )` - This method updates the state in-place, but the derivative at the point `t` must be passed + * in `dxdt`. An error estimate is calculated. + * - `do_step( sys , in , t , out , dt , xerr )` - This method updates the state out-of-place and estimates the error during the step. + * - `do_step( sys , in , dxdt , t , out , dt , xerr )` - This methods updates the state out-of-place and estimates the error during the step. + * Furthermore, the derivative at `t` must be passed in `dxdt`. + * + * \note The system is always passed as value, which might result in poor performance if it contains data. In this case it can be used with `boost::ref` + * or `std::ref`, for example `stepper.do_step( boost::ref( sys ) , x , t , dt );` + * + * \note The time `t` is not advanced by the stepper. This has to done manually, or by the appropriate `integrate` routines or `iterator`s. + * * \tparam Stepper The stepper on which this class should work. It is used via CRTP, hence explicit_stepper_base * provides the interface for the Stepper. * \tparam Order The order of a stepper if the stepper is used without error estimation. @@ -321,10 +345,8 @@ public: * * \param system The system function to solve, hence the r.h.s. of the ODE. It must fullfil the * Simple System concept. - * \param in The state of the ODE which should be solved. in is not modified in this method - * \param dxdt The derivative of x at t. + * \param x The state of the ODE which should be solved. x is updated by this method. * \param t The value of the time, at which the step should be performed. - * \param out The result of the step is written in out. * \param dt The step size. * \param xerr The estimation of the error is stored in xerr. */ @@ -342,10 +364,8 @@ public: * * \param system The system function to solve, hence the r.h.s. of the ODE. It must fullfil the * Simple System concept. - * \param in The state of the ODE which should be solved. in is not modified in this method - * \param dxdt The derivative of x at t. + * \param x The state of the ODE which should be solved. x is updated by this method. * \param t The value of the time, at which the step should be performed. - * \param out The result of the step is written in out. * \param dt The step size. * \param xerr The estimation of the error is stored in xerr. */ diff --git a/boost/numeric/odeint/stepper/base/explicit_stepper_base.hpp b/boost/numeric/odeint/stepper/base/explicit_stepper_base.hpp index fc991753..1a7bf463 100644 --- a/boost/numeric/odeint/stepper/base/explicit_stepper_base.hpp +++ b/boost/numeric/odeint/stepper/base/explicit_stepper_base.hpp @@ -90,15 +90,23 @@ namespace odeint { * * \code * sys( x , dxdt , t ); - * stepper.do_step( sys , x , dxdt , t , dt ); // the value of dxdt is used in the performance of the step + * stepper.do_step( sys , x , dxdt , t , dt ); // the value of dxdt is used here * t += dt; * \endcode * * In detail explicit_stepper_base provides the following `do_step` variants - * - `do_step( sys , x , t , dt )` - bla - * - `do_step( sys , in , t , out , dt )` - blub - * - `do_step( sys , x , dxdt , t , dt )` - bla - * - `do_step( sys , in , dxdt , t , out , dt )` -blub + * - `do_step( sys , x , t , dt )` - The classical `do_step` method needed to fullfil the Stepper concept. The state is updated in-place. + * A type modelling a Boost.Range can be used for x. + * - `do_step( sys , in , t , out , dt )` - This method updates the state out-of-place, hence the result of the step is stored in `out`. + * - `do_step( sys , x , dxdt , t , dt )` - This method updates the state in-place, but the derivative at the point `t` must be + * explicitely passed in `dxdt`. For an example see the code snippet above. + * - `do_step( sys , in , dxdt , t , out , dt )` - This method update the state out-of-place and expects that the derivative at the point + * `t` is explicitely passed in `dxdt`. It is a combination of the two `do_step` methods above. + * + * \note The system is always passed as value, which might result in poor performance if it contains data. In this case it can be used with `boost::ref` + * or `std::ref`, for example `stepper.do_step( boost::ref( sys ) , x , t , dt );` + * + * \note The time `t` is not advanced by the stepper. This has to done manually, or by the appropriate `integrate` routines or `iterator`s. * * \tparam Stepper The stepper on which this class should work. It is used via CRTP, hence explicit_stepper_base * provides the interface for the Stepper. @@ -308,6 +316,15 @@ public: } + /** + * \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 StateIn > + void adjust_size( const StateIn &x ) + { + resize_impl( x ); + } private: diff --git a/boost/numeric/odeint/stepper/euler.hpp b/boost/numeric/odeint/stepper/euler.hpp index 8ddcba0f..aee64e63 100644 --- a/boost/numeric/odeint/stepper/euler.hpp +++ b/boost/numeric/odeint/stepper/euler.hpp @@ -29,9 +29,27 @@ namespace boost { namespace numeric { namespace odeint { -template< class State , class Value , class Deriv , class Time , class Algebra , class Operations , class Resizer > -class dense_output_explicit_euler; + +/** + * \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 , class Value = double , @@ -41,31 +59,58 @@ class Algebra = range_algebra , class Operations = default_operations , class Resizer = initially_resizer > +#ifndef DOXYGEN_SKIP class euler : public explicit_stepper_base< euler< State , Value , Deriv , Time , Algebra , Operations , Resizer > , 1 , State , Value , Deriv , Time , Algebra , Operations , Resizer > +#else +class euler : public explicit_stepper_base< euler< ... > , ... > +#endif { public : - friend class dense_output_explicit_euler< State , Value , Deriv , Time , Algebra , Operations , Resizer >; - + #ifndef DOXYGEN_SKIP typedef explicit_stepper_base< euler< State , Value , Deriv , Time , Algebra , Operations , Resizer > , 1 , State , Value , Deriv , Time , Algebra , Operations , Resizer > stepper_base_type; + #else + typedef explicit_stepper_base< euler< ... > , ... > stepper_base_type; + #endif typedef typename stepper_base_type::state_type state_type; - typedef typename stepper_base_type::wrapped_state_type wrapped_state_type; typedef typename stepper_base_type::value_type value_type; typedef typename stepper_base_type::deriv_type deriv_type; - typedef typename stepper_base_type::wrapped_deriv_type wrapped_deriv_type; typedef typename stepper_base_type::time_type time_type; typedef typename stepper_base_type::algebra_type algebra_type; typedef typename stepper_base_type::operations_type operations_type; typedef typename stepper_base_type::resizer_type resizer_type; + + #ifndef DOXYGEN_SKIP typedef typename stepper_base_type::stepper_type stepper_type; + typedef typename stepper_base_type::wrapped_state_type wrapped_state_type; + typedef typename stepper_base_type::wrapped_deriv_type wrapped_deriv_type; + #endif + /** + * \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 ) { } + /** + * \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. + * + * \param system The system function to solve, hence the r.h.s. of the ODE. It must fullfil the + * Simple System concept. + * \param in The state of the ODE which should be solved. in is not modified in this method + * \param dxdt The derivative of x at t. + * \param t The value of the time, at which the step should be performed. + * \param out The result of the step is written in out. + * \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 ) { @@ -74,6 +119,11 @@ public : } + + /** + * \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 ) { @@ -82,7 +132,15 @@ public : typename operations_type::template scale_sum2< value_type , time_type >( 1.0 , delta ) ); } - + /** + * \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 ); + } }; diff --git a/boost/numeric/odeint/stepper/explicit_error_generic_rk.hpp b/boost/numeric/odeint/stepper/explicit_error_generic_rk.hpp index 1ff5ad8f..139a5af0 100644 --- a/boost/numeric/odeint/stepper/explicit_error_generic_rk.hpp +++ b/boost/numeric/odeint/stepper/explicit_error_generic_rk.hpp @@ -36,6 +36,30 @@ namespace boost { namespace numeric { namespace odeint { + +/** + * \class explicit_error_generic_rk + * \brief A generic implementation of explicit Runge-Kutta algorithms with error estimation. This class is as a + * base class for all explicit Runge-Kutta steppers with error estimateion. + * + * This class implements the explicit Runge-Kutta algorithms with error estimation in a generic way. + * The Butcher tableau is passed to the stepper which constructs the stepper scheme with the help of a + * template-metaprogramming algorithm. ToDo : Add example! + * + * This class derives explicit_error_stepper_base which provides the stepper interface. + * + * \tparam StageCount The number of stages of the Runge-Kutta algorithm. + * \tparam Order The order of a stepper if the stepper is used without error estimation. + * \tparam StepperOrder The order of a step if the stepper is used with error estimation. Usually Order and StepperOrder have + * the same value. + * \tparam ErrorOrder The order of the error step if the stepper is used with error estimation. + * \tparam State The type representing the state of the ODE. + * \tparam Value The floating point type which is used in the computations. + * \tparam Time The type representing the independent variable - the time - of the ODE. + * \tparam Algebra The algebra type. + * \tparam Operations The operations type. + * \tparam Resizer The resizer policy type. + */ template< size_t StageCount, size_t Order, @@ -102,6 +126,21 @@ public: { } + /** + * \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`. Futhermore, an + * estimation of the error is stored in `xerr`. `do_step_impl` is used by explicit_error_stepper_base. + * + * \param system The system function to solve, hence the r.h.s. of the ODE. It must fullfil the + * Simple System concept. + * \param in The state of the ODE which should be solved. in is not modified in this method + * \param dxdt The derivative of x at t. + * \param t The value of the time, at which the step should be performed. + * \param out The result of the step is written in out. + * \param dt The step size. + * \param xerr The result of the error estimation is written in xerr. + */ + template< class System , class StateIn , class DerivIn , class StateOut , class Err > void do_step_impl( System system , const StateIn &in , const DerivIn &dxdt , time_type t , StateOut &out , time_type dt , Err &xerr ) @@ -114,6 +153,20 @@ public: xerr , dxdt , m_F , detail::generic_rk_scale_sum_err< StageCount , operations_type , value_type , time_type >( m_b2 , 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_error_stepper_base. + * + * \param system The system function to solve, hence the r.h.s. of the ODE. It must fullfil the + * Simple System concept. + * \param in The state of the ODE which should be solved. in is not modified in this method + * \param dxdt The derivative of x at t. + * \param t The value of the time, at which the step should be performed. + * \param out The result of the step is written in out. + * \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 ) @@ -124,6 +177,12 @@ public: m_rk_algorithm.do_step( stepper_base_type::m_algebra , system , in , dxdt , t , out , dt , m_x_tmp.m_v , m_F ); } + + + /** + * \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 ) { diff --git a/boost/numeric/odeint/stepper/runge_kutta4.hpp b/boost/numeric/odeint/stepper/runge_kutta4.hpp index 8f3d454a..2852c582 100644 --- a/boost/numeric/odeint/stepper/runge_kutta4.hpp +++ b/boost/numeric/odeint/stepper/runge_kutta4.hpp @@ -102,12 +102,13 @@ struct rk4_coefficients_c : boost::array< Value , 4 > * \brief The classical Runge-Kutta stepper of fourth order. * * The Runge-Kutta method of fourth order is one standard method for - * solving ordinary differential equations and is widely used. The method is - * explicit and fullfils the Stepper concept. Step size control or continous - * output are not provided. This class uses the generic Runge-Kutta algorithm. + * solving ordinary differential equations and is widely used, see also + * en.wikipedia.org/wiki/Runge-Kutta_methods + * The method is explicit and fullfils the Stepper concept. Step size control + * or continous output are not provided. * - * This class derives from explicit_stepper_base and explicit_generic_rk and inherits - * its interface via CRTP (current recurring template pattern). For more details see + * This class derives from explicit_stepper_base and inherits its interface via CRTP (current recurring template pattern). + * Furthermore, it derivs from explicit_generic_rk which is a generic Runge-Kutta algorithm. For more details see * explicit_stepper_base and explicit_generic_rk. * * \tparam State The state type. @@ -116,7 +117,7 @@ struct rk4_coefficients_c : boost::array< Value , 4 > * \tparam Time The time representing the independent variable - the time. * \tparam Algebra The algebra type. * \tparam Operations The operations type. - * \tparam The resizer policy type. + * \tparam Resizer The resizer policy type. */ template< class State , diff --git a/boost/numeric/odeint/stepper/runge_kutta4_classic.hpp b/boost/numeric/odeint/stepper/runge_kutta4_classic.hpp index 55208cfb..f64af81f 100644 --- a/boost/numeric/odeint/stepper/runge_kutta4_classic.hpp +++ b/boost/numeric/odeint/stepper/runge_kutta4_classic.hpp @@ -37,9 +37,10 @@ namespace odeint { * \brief The classical Runge-Kutta stepper of fourth order. * * The Runge-Kutta method of fourth order is one standard method for - * solving ordinary differential equations and is widely used. The method is - * explicit and fullfils the Stepper concept. Step size control or continous - * output are not provided. This class implements the method directly, hence the + * solving ordinary differential equations and is widely used, see also + * en.wikipedia.org/wiki/Runge-Kutta_methods + * The method is explicit and fullfils the Stepper concept. Step size control + * or continous output are not provided. This class implements the method directly, hence the * generic Runge-Kutta algorithm is not used. * * This class derives from explicit_stepper_base and inherits its interface via @@ -52,7 +53,7 @@ namespace odeint { * \tparam Time The time representing the independent variable - the time. * \tparam Algebra The algebra type. * \tparam Operations The operations type. - * \tparam The resizer policy type. + * \tparam Resizer The resizer policy type. */ template< class State , @@ -63,17 +64,26 @@ class Algebra = range_algebra , class Operations = default_operations , class Resizer = initially_resizer > +#ifndef DOXYGEN_SKIP class runge_kutta4_classic : public explicit_stepper_base< runge_kutta4_classic< State , Value , Deriv , Time , Algebra , Operations , Resizer > , 4 , State , Value , Deriv , Time , Algebra , Operations , Resizer > +#else +class runge_kutta4_classic + : public explicit_stepper_base< runge_kutta4_classic< ... > , ... > +#endif { public : + #ifndef DOXYGEN_SKIP typedef explicit_stepper_base< runge_kutta4_classic< State , Value , Deriv , Time , Algebra , Operations , Resizer > , 4 , State , Value , Deriv , Time , Algebra , Operations , Resizer > stepper_base_type; + #else + typedef explicit_stepper_base< runge_kutta4_classic< ... > , ... > stepper_base_type; + #endif typedef typename stepper_base_type::state_type state_type; typedef typename stepper_base_type::value_type value_type; @@ -82,9 +92,9 @@ public : typedef typename stepper_base_type::algebra_type algebra_type; typedef typename stepper_base_type::operations_type operations_type; typedef typename stepper_base_type::resizer_type resizer_type; - typedef typename stepper_base_type::stepper_type stepper_type; #ifndef DOXYGEN_SKIP + typedef typename stepper_base_type::stepper_type stepper_type; typedef typename stepper_base_type::wrapped_state_type wrapped_state_type; typedef typename stepper_base_type::wrapped_deriv_type wrapped_deriv_type; #endif // DOXYGEN_SKIP diff --git a/boost/numeric/odeint/stepper/runge_kutta_cash_karp54.hpp b/boost/numeric/odeint/stepper/runge_kutta_cash_karp54.hpp index 6ed387aa..fe1bfa6a 100644 --- a/boost/numeric/odeint/stepper/runge_kutta_cash_karp54.hpp +++ b/boost/numeric/odeint/stepper/runge_kutta_cash_karp54.hpp @@ -38,6 +38,8 @@ namespace boost { namespace numeric { namespace odeint { + +#ifndef DOXYGEN_SKIP template< class Value = double > struct rk54_ck_coefficients_a1 : boost::array< Value , 1 > { @@ -136,7 +138,31 @@ struct rk54_ck_coefficients_c : boost::array< Value , 6 > (*this)[5] = static_cast( 7 )/static_cast( 8 ); } }; +#endif + +/** + * \class runge_kutta_cash_karp54 + * \brief The Runge-Kutta Cash-Karp method. + * + * The Runge-Kutta Cash-Karp method is one of the standard methods for + * solving ordinary differential equations, see + * en.wikipedia.org/wiki/Cash-Karp_methods. + * The method is explicit and fullfils the Error Stepper concept. Step size control + * is provided but continous output is not available for this method. + * + * This class derives from explicit_error_stepper_base and inherits its interface via CRTP (current recurring template pattern). + * Furthermore, it derivs from explicit_error_generic_rk which is a generic Runge-Kutta algorithm with error estimation. + * For more details see explicit_error_stepper_base and explicit_error_generic_rk. + * + * \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 , class Value = double , @@ -166,6 +192,12 @@ public: typedef typename stepper_base_type::resizer_type resizer_typ; typedef typename stepper_base_type::stepper_type stepper_type; + + /** + * \brief Constructs the runge_kutta_cash_karp54 class. This constructor can be used as a default + * constructor if the algebra has a default constructor. + * \param algebra A copy of algebra is made and stored inside explicit_stepper_base. + */ runge_kutta_cash_karp54( const algebra_type &algebra = algebra_type() ) : stepper_base_type( boost::fusion::make_vector( rk54_ck_coefficients_a1() , rk54_ck_coefficients_a2() , diff --git a/boost/numeric/odeint/stepper/runge_kutta_cash_karp54_classic.hpp b/boost/numeric/odeint/stepper/runge_kutta_cash_karp54_classic.hpp index 762cf1f0..079ccb0d 100644 --- a/boost/numeric/odeint/stepper/runge_kutta_cash_karp54_classic.hpp +++ b/boost/numeric/odeint/stepper/runge_kutta_cash_karp54_classic.hpp @@ -36,9 +36,26 @@ namespace odeint { - -/* - * ToDo: Check orders rk_ckc +/** + * \class runge_kutta_cash_karp54_classic + * \brief The Runge-Kutta Cash-Karp method implemented without the generic Runge-Kutta algorithm. + * + * The Runge-Kutta Cash-Karp method is one of the standard methods for + * solving ordinary differential equations, see + * en.wikipedia.org/wiki/Cash-Karp_method. + * The method is explicit and fullfils the Error Stepper concept. Step size control + * is provided but continous output is not available for this method. + * + * This class derives from explicit_error_stepper_base and inherits its interface via CRTP (current recurring + * template pattern). This class implements the method directly, hence the generic Runge-Kutta algorithm is not used. + * + * \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 , @@ -49,35 +66,67 @@ class Algebra = range_algebra , class Operations = default_operations , class Resizer = initially_resizer > +#ifndef DOXYGEN_SKIP class runge_kutta_cash_karp54_classic : public explicit_error_stepper_base< runge_kutta_cash_karp54_classic< State , Value , Deriv , Time , Algebra , Operations , Resizer > , 5 , 5 , 4 , State , Value , Deriv , Time , Algebra , Operations , Resizer > +#else +class runge_kutta_cash_karp54_classic + : public explicit_error_stepper_base< runge_kutta_cash_karp54_classic< ... > , ... > +#endif { public : + #ifndef DOXYGEN_SKIP typedef explicit_error_stepper_base< runge_kutta_cash_karp54_classic< State , Value , Deriv , Time , Algebra , Operations , Resizer > , 5 , 5 , 4 , State , Value , Deriv , Time , Algebra , Operations , Resizer > stepper_base_type; + #else + typedef explicit_error_stepper_base< runge_kutta_cash_karp54_classic< ... > , ... > stepper_base_type; + #endif typedef typename stepper_base_type::state_type state_type; - typedef typename stepper_base_type::wrapped_state_type wrapped_state_type; typedef typename stepper_base_type::value_type value_type; typedef typename stepper_base_type::deriv_type deriv_type; - typedef typename stepper_base_type::wrapped_deriv_type wrapped_deriv_type; typedef typename stepper_base_type::time_type time_type; typedef typename stepper_base_type::algebra_type algebra_type; typedef typename stepper_base_type::operations_type operations_type; typedef typename stepper_base_type::resizer_type resizer_type; + + #ifndef DOXYGEN_SKIP + typedef typename stepper_base_type::wrapped_state_type wrapped_state_type; + typedef typename stepper_base_type::wrapped_deriv_type wrapped_deriv_type; typedef typename stepper_base_type::stepper_type stepper_type; + #endif + /** + * \brief Constructs the runge_kutta_cash_karp54_classic class. This constructor can be used as a default + * constructor if the algebra has a default constructor. + * \param algebra A copy of algebra is made and stored inside explicit_stepper_base. + */ runge_kutta_cash_karp54_classic( const algebra_type &algebra = algebra_type() ) : stepper_base_type( algebra ) { } + + /** + * \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`. Futhermore, an + * estimation of the error is stored in `xerr`. `do_step_impl` is used by explicit_error_stepper_base. + * + * \param system The system function to solve, hence the r.h.s. of the ODE. It must fullfil the + * Simple System concept. + * \param in The state of the ODE which should be solved. in is not modified in this method + * \param dxdt The derivative of x at t. + * \param t The value of the time, at which the step should be performed. + * \param out The result of the step is written in out. + * \param dt The step size. + * \param xerr The result of the error estimation is written in xerr. + */ template< class System , class StateIn , class DerivIn , class StateOut , class Err > void do_step_impl( System system , const StateIn &in , const DerivIn &dxdt , time_type t , StateOut &out , time_type dt , Err &xerr ) { @@ -102,6 +151,19 @@ public : + /** + * \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_error_stepper_base. + * + * \param system The system function to solve, hence the r.h.s. of the ODE. It must fullfil the + * Simple System concept. + * \param in The state of the ODE which should be solved. in is not modified in this method + * \param dxdt The derivative of x at t. + * \param t The value of the time, at which the step should be performed. + * \param out The result of the step is written in out. + * \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 ) { @@ -164,6 +226,10 @@ public : } + /** + * \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 StateIn > void adjust_size( const StateIn &x ) { diff --git a/libs/numeric/odeint/doc/Jamfile b/libs/numeric/odeint/doc/Jamfile index f4c5b460..1ede8d9c 100644 --- a/libs/numeric/odeint/doc/Jamfile +++ b/libs/numeric/odeint/doc/Jamfile @@ -49,15 +49,15 @@ else doxygen reference : - [ glob ../../../../boost/numeric/odeint/*.hpp ] +# [ glob ../../../../boost/numeric/odeint/*.hpp ] [ glob ../../../../boost/numeric/odeint/stepper/*.hpp ] [ glob ../../../../boost/numeric/odeint/stepper/base/*.hpp ] - [ glob ../../../../boost/numeric/odeint/stepper/generation/*.hpp ] - [ glob ../../../../boost/numeric/odeint/integrate/*.hpp ] - [ glob ../../../../boost/numeric/odeint/iterator/*.hpp ] - [ glob ../../../../boost/numeric/odeint/algebra/*.hpp ] - [ glob ../../../../boost/numeric/odeint/util/*.hpp ] - ../../../../boost/numeric/odeint.hpp +# [ glob ../../../../boost/numeric/odeint/stepper/generation/*.hpp ] +# [ glob ../../../../boost/numeric/odeint/integrate/*.hpp ] +# [ glob ../../../../boost/numeric/odeint/iterator/*.hpp ] +# [ glob ../../../../boost/numeric/odeint/algebra/*.hpp ] +# [ glob ../../../../boost/numeric/odeint/util/*.hpp ] +# ../../../../boost/numeric/odeint.hpp : # Lots of parameters passed to Doxygen. You can see these in the doxygen docs, or the Wizard Expert tab displays them.