Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Class template explicit_error_generic_rk

boost::numeric::odeint::explicit_error_generic_rk — 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 estimation.

Synopsis

// In header: <boost/numeric/odeint/stepper/explicit_error_generic_rk.hpp>

template<size_t StageCount, size_t Order, size_t StepperOrder, 
         size_t ErrorOrder, typename State, typename Value = double, 
         typename Deriv = State, typename Time = Value, 
         typename Algebra = range_algebra, 
         typename Operations = default_operations, 
         typename Resizer = initially_resizer> 
class explicit_error_generic_rk : public boost::numeric::odeint::explicit_error_stepper_base< Stepper, Order, StepperOrder, ErrorOrder, State, Value, Deriv, Time, Algebra, Operations, Resizer >
{
public:
  // types
  typedef explicit_stepper_base< ... >          stepper_base_type; 
  typedef stepper_base_type::state_type         state_type;        
  typedef stepper_base_type::wrapped_state_type wrapped_state_type;
  typedef stepper_base_type::value_type         value_type;        
  typedef stepper_base_type::deriv_type         deriv_type;        
  typedef stepper_base_type::wrapped_deriv_type wrapped_deriv_type;
  typedef stepper_base_type::time_type          time_type;         
  typedef stepper_base_type::algebra_type       algebra_type;      
  typedef stepper_base_type::operations_type    operations_type;   
  typedef stepper_base_type::resizer_type       resizer_type;      
  typedef unspecified                           rk_algorithm_type; 
  typedef rk_algorithm_type::coef_a_type        coef_a_type;       
  typedef rk_algorithm_type::coef_b_type        coef_b_type;       
  typedef rk_algorithm_type::coef_c_type        coef_c_type;       

  // construct/copy/destruct
  explicit_error_generic_rk(const coef_a_type &, const coef_b_type &, 
                            const coef_b_type &, const coef_c_type &, 
                            const algebra_type & = algebra_type());

  // public member functions
  template<typename System, typename StateIn, typename DerivIn, 
           typename StateOut, typename Err> 
    void do_step_impl(System, const StateIn &, const DerivIn &, time_type, 
                      StateOut &, time_type, Err &);
  template<typename System, typename StateIn, typename DerivIn, 
           typename StateOut> 
    void do_step_impl(System, const StateIn &, const DerivIn &, time_type, 
                      StateOut &, time_type);
  template<typename StateIn> void adjust_size(const StateIn &);
  order_type stepper_order(void) const;
  order_type error_order(void) const;
  template<typename System, typename StateInOut> 
    void do_step(System, StateInOut &, time_type, time_type);
  template<typename System, typename StateInOut> 
    void do_step(System, const StateInOut &, time_type, time_type);
  template<typename System, typename StateInOut, typename DerivIn> 
    boost::disable_if< boost::is_same< DerivIn, time_type >, void >::type 
    do_step(System, StateInOut &, const DerivIn &, time_type, time_type);
  template<typename System, typename StateIn, typename StateOut> 
    boost::disable_if< boost::is_same< StateIn, time_type >, void >::type 
    do_step(System, const StateIn &, time_type, StateOut &, time_type);
  template<typename System, typename StateIn, typename DerivIn, 
           typename StateOut> 
    boost::disable_if< boost::is_same< DerivIn, time_type >, void >::type 
    do_step(System, const StateIn &, const DerivIn &, time_type, StateOut &, 
            time_type);
  template<typename System, typename StateInOut, typename Err> 
    void do_step(System, StateInOut &, time_type, time_type, Err &);
  template<typename System, typename StateInOut, typename Err> 
    void do_step(System, const StateInOut &, time_type, time_type, Err &);
  template<typename System, typename StateInOut, typename DerivIn, 
           typename Err> 
    boost::disable_if< boost::is_same< DerivIn, time_type >, void >::type 
    do_step(System, StateInOut &, const DerivIn &, time_type, time_type, 
            Err &);
  template<typename System, typename StateIn, typename StateOut, typename Err> 
    void do_step(System, const StateIn &, time_type, StateOut &, time_type, 
                 Err &);
  template<typename System, typename StateIn, typename DerivIn, 
           typename StateOut, typename Err> 
    void do_step(System, const StateIn &, const DerivIn &, time_type, 
                 StateOut &, time_type, Err &);
  const algebra_type & algebra() const;

  // private member functions
  template<typename StateIn> bool resize_impl(const StateIn &);

  // public data members
  static const size_t stage_count;
};

Description

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.

Template Parameters

  1. size_t StageCount

    The number of stages of the Runge-Kutta algorithm.

  2. size_t Order

    The order of a stepper if the stepper is used without error estimation.

  3. size_t StepperOrder

    The order of a step if the stepper is used with error estimation. Usually Order and StepperOrder have the same value.

  4. size_t ErrorOrder

    The order of the error step if the stepper is used with error estimation.

  5. typename State

    The type representing the state of the ODE.

  6. typename Value = double

    The floating point type which is used in the computations.

  7. typename Deriv = State
  8. typename Time = Value

    The type representing the independent variable - the time - of the ODE.

  9. typename Algebra = range_algebra

    The algebra type.

  10. typename Operations = default_operations

    The operations type.

  11. typename Resizer = initially_resizer

    The resizer policy type.

explicit_error_generic_rk public construct/copy/destruct

  1. explicit_error_generic_rk(const coef_a_type & a, const coef_b_type & b, 
                              const coef_b_type & b2, const coef_c_type & c, 
                              const algebra_type & algebra = algebra_type());
    Constructs the explicit_error_generik_rk class with the given parameters a, b, b2 and c. See examples section for details on the coefficients.

    Parameters:

    a

    Triangular matrix of parameters b in the Butcher tableau.

    algebra

    A copy of algebra is made and stored inside explicit_stepper_base.

    b

    Last row of the butcher tableau.

    b2

    Parameters for lower-order evaluation to estimate the error.

    c

    Parameters to calculate the time points in the Butcher tableau.

explicit_error_generic_rk public member functions

  1. template<typename System, typename StateIn, typename DerivIn, 
             typename StateOut, typename Err> 
      void do_step_impl(System system, const StateIn & in, const DerivIn & dxdt, 
                        time_type t, StateOut & out, time_type dt, Err & xerr);
    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.

    Parameters:

    dt

    The step size.

    dxdt

    The derivative of x at t.

    in

    The state of the ODE which should be solved. in is not modified in this method

    out

    The result of the step is written in out.

    system

    The system function to solve, hence the r.h.s. of the ODE. It must fulfill the Simple System concept.

    t

    The value of the time, at which the step should be performed.

    xerr

    The result of the error estimation is written in xerr.

  2. template<typename System, typename StateIn, typename DerivIn, 
             typename StateOut> 
      void do_step_impl(System system, const StateIn & in, const DerivIn & dxdt, 
                        time_type t, StateOut & out, time_type dt);
    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. Access to this step functionality is provided by explicit_stepper_base and do_step_impl should not be called directly.

    Parameters:

    dt

    The step size.

    dxdt

    The derivative of x at t.

    in

    The state of the ODE which should be solved. in is not modified in this method

    out

    The result of the step is written in out.

    system

    The system function to solve, hence the r.h.s. of the ODE. It must fulfill the Simple System concept.

    t

    The value of the time, at which the step should be performed.

  3. template<typename StateIn> void adjust_size(const StateIn & x);
    Adjust the size of all temporaries in the stepper manually.

    Parameters:

    x

    A state from which the size of the temporaries to be resized is deduced.

  4. order_type stepper_order(void) const;

    Returns:

    Returns the order of a step if the stepper is used without error estimation.

  5. order_type error_order(void) const;

    Returns:

    Returns the order of an error step if the stepper is used without error estimation.

  6. template<typename System, typename StateInOut> 
      void do_step(System system, StateInOut & x, time_type t, time_type dt);
    This method performs one step. It transforms the result in-place.

    Parameters:

    dt

    The step size.

    system

    The system function to solve, hence the r.h.s. of the ordinary differential equation. It must fulfill the Simple System concept.

    t

    The value of the time, at which the step should be performed.

    x

    The state of the ODE which should be solved. After calling do_step the result is updated in x.

  7. template<typename System, typename StateInOut> 
      void do_step(System system, const StateInOut & x, time_type t, time_type dt);
    Second version to solve the forwarding problem, can be called with Boost.Range as StateInOut.
  8. template<typename System, typename StateInOut, typename DerivIn> 
      boost::disable_if< boost::is_same< DerivIn, time_type >, void >::type 
      do_step(System system, StateInOut & x, const DerivIn & dxdt, time_type t, 
              time_type dt);
    The method performs one step with the stepper passed by Stepper. Additionally to the other method the derivative of x is also passed to this method. It is supposed to be used in the following way:
    * sys( x , dxdt , t );
    * stepper.do_step( sys , x , dxdt , t , dt );
    * 
    

    The result is updated in place in x. This method is disabled if Time and Deriv are of the same type. In this case the method could not be distinguished from other do_step versions.

    [Note] Note

    This method does not solve the forwarding problem.

    Parameters:

    dt

    The step size.

    dxdt

    The derivative of x at t.

    system

    The system function to solve, hence the r.h.s. of the ODE. It must fulfill the Simple System concept.

    t

    The value of the time, at which the step should be performed.

    x

    The state of the ODE which should be solved. After calling do_step the result is updated in x.

  9. template<typename System, typename StateIn, typename StateOut> 
      boost::disable_if< boost::is_same< StateIn, time_type >, void >::type 
      do_step(System system, const StateIn & in, time_type t, StateOut & out, 
              time_type dt);
    The method performs one step with the stepper passed by Stepper. The state of the ODE is updated out-of-place. This method is disabled if StateIn and Time are the same type. In this case the method can not be distinguished from other do_step variants.
    [Note] Note

    This method does not solve the forwarding problem.

    Parameters:

    dt

    The step size.

    in

    The state of the ODE which should be solved. in is not modified in this method

    out

    The result of the step is written in out.

    system

    The system function to solve, hence the r.h.s. of the ODE. It must fulfill the Simple System concept.

    t

    The value of the time, at which the step should be performed.

  10. template<typename System, typename StateIn, typename DerivIn, 
             typename StateOut> 
      boost::disable_if< boost::is_same< DerivIn, time_type >, void >::type 
      do_step(System system, const StateIn & in, const DerivIn & dxdt, 
              time_type t, StateOut & out, time_type dt);
    The method performs one step with the stepper passed by Stepper. The state of the ODE is updated out-of-place. Furthermore, the derivative of x at t is passed to the stepper. It is supposed to be used in the following way:
    * sys( in , dxdt , t );
    * stepper.do_step( sys , in , dxdt , t , out , dt );
    * 
    

    This method is disabled if DerivIn and Time are of same type.

    [Note] Note

    This method does not solve the forwarding problem.

    Parameters:

    dt

    The step size.

    dxdt

    The derivative of x at t.

    in

    The state of the ODE which should be solved. in is not modified in this method

    out

    The result of the step is written in out.

    system

    The system function to solve, hence the r.h.s. of the ODE. It must fulfill the Simple System concept.

    t

    The value of the time, at which the step should be performed.

  11. template<typename System, typename StateInOut, typename Err> 
      void do_step(System system, StateInOut & x, time_type t, time_type dt, 
                   Err & xerr);
    The method performs one step with the stepper passed by Stepper and estimates the error. The state of the ODE is updated in-place.

    Parameters:

    dt

    The step size.

    system

    The system function to solve, hence the r.h.s. of the ODE. It must fulfill the Simple System concept.

    t

    The value of the time, at which the step should be performed.

    x

    The state of the ODE which should be solved. x is updated by this method.

    xerr

    The estimation of the error is stored in xerr.

  12. template<typename System, typename StateInOut, typename Err> 
      void do_step(System system, const StateInOut & x, time_type t, time_type dt, 
                   Err & xerr);
    Second version to solve the forwarding problem, can be called with Boost.Range as StateInOut.
  13. template<typename System, typename StateInOut, typename DerivIn, typename Err> 
      boost::disable_if< boost::is_same< DerivIn, time_type >, void >::type 
      do_step(System system, StateInOut & x, const DerivIn & dxdt, time_type t, 
              time_type dt, Err & xerr);
    The method performs one step with the stepper passed by Stepper. Additionally to the other method the derivative of x is also passed to this method. It is supposed to be used in the following way:
    * sys( x , dxdt , t );
    * stepper.do_step( sys , x , dxdt , t , dt , xerr );
    * 
    

    The result is updated in place in x. This method is disabled if Time and DerivIn are of the same type. In this case the method could not be distinguished from other do_step versions.

    [Note] Note

    This method does not solve the forwarding problem.

    Parameters:

    dt

    The step size.

    dxdt

    The derivative of x at t.

    system

    The system function to solve, hence the r.h.s. of the ODE. It must fulfill the Simple System concept.

    t

    The value of the time, at which the step should be performed.

    x

    The state of the ODE which should be solved. After calling do_step the result is updated in x.

    xerr

    The error estimate is stored in xerr.

  14. template<typename System, typename StateIn, typename StateOut, typename Err> 
      void do_step(System system, const StateIn & in, time_type t, StateOut & out, 
                   time_type dt, Err & xerr);
    The method performs one step with the stepper passed by Stepper. The state of the ODE is updated out-of-place. Furthermore, the error is estimated.
    [Note] Note

    This method does not solve the forwarding problem.

    Parameters:

    dt

    The step size.

    in

    The state of the ODE which should be solved. in is not modified in this method

    out

    The result of the step is written in out.

    system

    The system function to solve, hence the r.h.s. of the ODE. It must fulfill the Simple System concept.

    t

    The value of the time, at which the step should be performed.

    xerr

    The error estimate.

  15. template<typename System, typename StateIn, typename DerivIn, 
             typename StateOut, typename Err> 
      void do_step(System system, const StateIn & in, const DerivIn & dxdt, 
                   time_type t, StateOut & out, time_type dt, Err & xerr);
    The method performs one step with the stepper passed by Stepper. The state of the ODE is updated out-of-place. Furthermore, the derivative of x at t is passed to the stepper and the error is estimated. It is supposed to be used in the following way:
    * sys( in , dxdt , t );
    * stepper.do_step( sys , in , dxdt , t , out , dt );
    * 
    

    This method is disabled if DerivIn and Time are of same type.

    [Note] Note

    This method does not solve the forwarding problem.

    Parameters:

    dt

    The step size.

    dxdt

    The derivative of x at t.

    in

    The state of the ODE which should be solved. in is not modified in this method

    out

    The result of the step is written in out.

    system

    The system function to solve, hence the r.h.s. of the ODE. It must fulfill the Simple System concept.

    t

    The value of the time, at which the step should be performed.

    xerr

    The error estimate.

  16. const algebra_type & algebra() const;

    Returns:

    A reference to the algebra which is held by this class.

    A const reference to the algebra which is held by this class.

explicit_error_generic_rk private member functions

  1. template<typename StateIn> bool resize_impl(const StateIn & x);

PrevUpHomeNext