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 for the latest Boost documentation.
Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Class template bulirsch_stoer_dense_out

boost::numeric::odeint::bulirsch_stoer_dense_out — The Bulirsch-Stoer algorithm.

Synopsis

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

template<typename State, typename Value = double, typename Deriv = State, 
         typename Time = Value, 
         typename Algebra = typename algebra_dispatcher< State >::algebra_type, 
         typename Operations = typename operations_dispatcher< State >::operations_type, 
         typename Resizer = initially_resizer> 
class bulirsch_stoer_dense_out {
public:
  // types
  typedef State                    state_type;      
  typedef Value                    value_type;      
  typedef Deriv                    deriv_type;      
  typedef Time                     time_type;       
  typedef Algebra                  algebra_type;    
  typedef Operations               operations_type; 
  typedef Resizer                  resizer_type;    
  typedef dense_output_stepper_tag stepper_category;

  // construct/copy/destruct
  bulirsch_stoer_dense_out(value_type = 1E-6, value_type = 1E-6, 
                           value_type = 1.0, value_type = 1.0, 
                           time_type = static_cast< time_type >(0), 
                           bool = false);

  // public member functions
  template<typename System, typename StateIn, typename DerivIn, 
           typename StateOut, typename DerivOut> 
    controlled_step_result 
    try_step(System, const StateIn &, const DerivIn &, time_type &, 
             StateOut &, DerivOut &, time_type &);
  template<typename StateType> 
    void initialize(const StateType &, const time_type &, const time_type &);
  template<typename System> std::pair< time_type, time_type > do_step(System);
  template<typename StateOut> void calc_state(time_type, StateOut &) const;
  const state_type & current_state(void) const;
  time_type current_time(void) const;
  const state_type & previous_state(void) const;
  time_type previous_time(void) const;
  time_type current_time_step(void) const;
  void reset();
  template<typename StateIn> void adjust_size(const StateIn &);

  // private member functions
  template<typename StateInOut, typename StateVector> 
    void extrapolate(size_t, StateVector &, const value_matrix &, 
                     StateInOut &, size_t = 0);
  template<typename StateVector> 
    void extrapolate_dense_out(size_t, StateVector &, const value_matrix &, 
                               size_t = 0);
  time_type calc_h_opt(time_type, value_type, size_t) const;
  bool in_convergence_window(size_t) const;
  bool should_reject(value_type, size_t) const;
  template<typename StateIn1, typename DerivIn1, typename StateIn2, 
           typename DerivIn2> 
    value_type prepare_dense_output(int, const StateIn1 &, const DerivIn1 &, 
                                    const StateIn2 &, const DerivIn2 &, 
                                    time_type);
  template<typename DerivIn> 
    void calculate_finite_difference(size_t, size_t, value_type, 
                                     const DerivIn &);
  template<typename StateOut> 
    void do_interpolation(time_type, StateOut &) const;
  template<typename StateIn> bool resize_impl(const StateIn &);
  state_type & get_current_state(void);
  const state_type & get_current_state(void) const;
  state_type & get_old_state(void);
  const state_type & get_old_state(void) const;
  deriv_type & get_current_deriv(void);
  const deriv_type & get_current_deriv(void) const;
  deriv_type & get_old_deriv(void);
  const deriv_type & get_old_deriv(void) const;
  void toggle_current_state(void);

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

Description

The Bulirsch-Stoer is a controlled stepper that adjusts both step size and order of the method. The algorithm uses the modified midpoint and a polynomial extrapolation compute the solution. This class also provides dense output facility.

Template Parameters

  1. typename State

    The state type.

  2. typename Value = double

    The value type.

  3. typename Deriv = State

    The type representing the time derivative of the state.

  4. typename Time = Value

    The time representing the independent variable - the time.

  5. typename Algebra = typename algebra_dispatcher< State >::algebra_type

    The algebra type.

  6. typename Operations = typename operations_dispatcher< State >::operations_type

    The operations type.

  7. typename Resizer = initially_resizer

    The resizer policy type.

bulirsch_stoer_dense_out public construct/copy/destruct

  1. bulirsch_stoer_dense_out(value_type eps_abs = 1E-6, value_type eps_rel = 1E-6, 
                             value_type factor_x = 1.0, 
                             value_type factor_dxdt = 1.0, 
                             time_type max_dt = static_cast< time_type >(0), 
                             bool control_interpolation = false);
    Constructs the bulirsch_stoer class, including initialization of the error bounds.

    Parameters:

    control_interpolation

    Set true to additionally control the error of the interpolation.

    eps_abs

    Absolute tolerance level.

    eps_rel

    Relative tolerance level.

    factor_dxdt

    Factor for the weight of the derivative.

    factor_x

    Factor for the weight of the state.

bulirsch_stoer_dense_out public member functions

  1. template<typename System, typename StateIn, typename DerivIn, 
             typename StateOut, typename DerivOut> 
      controlled_step_result 
      try_step(System system, const StateIn & in, const DerivIn & dxdt, 
               time_type & t, StateOut & out, DerivOut & dxdt_new, 
               time_type & dt);
    Tries to perform one step.

    This method tries to do one step with step size dt. If the error estimate is to large, the step is rejected and the method returns fail and the step size dt is reduced. If the error estimate is acceptably small, the step is performed, success is returned and dt might be increased to make the steps as large as possible. This method also updates t if a step is performed. Also, the internal order of the stepper is adjusted if required.

    Parameters:

    dt

    The step size. Updated.

    dxdt

    The derivative of state.

    in

    The state of the ODE which should be solved.

    out

    Used to store the result of the step.

    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. Updated if the step is successful.

    Returns:

    success if the step was accepted, fail otherwise.

  2. template<typename StateType> 
      void initialize(const StateType & x0, const time_type & t0, 
                      const time_type & dt0);
    Initializes the dense output stepper.

    Parameters:

    dt0

    The initial time step.

    t0

    The initial time.

    x0

    The initial state.

  3. template<typename System> 
      std::pair< time_type, time_type > do_step(System system);
    Does one time step. This is the main method that should be used to integrate an ODE with this stepper.
    [Note] Note

    initialize has to be called before using this method to set the initial conditions x,t and the stepsize.

    Parameters:

    system

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

    Returns:

    Pair with start and end time of the integration step.

  4. template<typename StateOut> void calc_state(time_type t, StateOut & x) const;
    Calculates the solution at an intermediate point within the last step.

    Parameters:

    t

    The time at which the solution should be calculated, has to be in the current time interval.

    x

    The output variable where the result is written into.

  5. const state_type & current_state(void) const;
    Returns the current state of the solution.

    Returns:

    The current state of the solution x(t).

  6. time_type current_time(void) const;
    Returns the current time of the solution.

    Returns:

    The current time of the solution t.

  7. const state_type & previous_state(void) const;
    Returns the last state of the solution.

    Returns:

    The last state of the solution x(t-dt).

  8. time_type previous_time(void) const;
    Returns the last time of the solution.

    Returns:

    The last time of the solution t-dt.

  9. time_type current_time_step(void) const;
    Returns the current step size.

    Returns:

    The current step size.

  10. void reset();
    Resets the internal state of the stepper.
  11. 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.

bulirsch_stoer_dense_out private member functions

  1. template<typename StateInOut, typename StateVector> 
      void extrapolate(size_t k, StateVector & table, const value_matrix & coeff, 
                       StateInOut & xest, size_t order_start_index = 0);
  2. template<typename StateVector> 
      void extrapolate_dense_out(size_t k, StateVector & table, 
                                 const value_matrix & coeff, 
                                 size_t order_start_index = 0);
  3. time_type calc_h_opt(time_type h, value_type error, size_t k) const;
  4. bool in_convergence_window(size_t k) const;
  5. bool should_reject(value_type error, size_t k) const;
  6. template<typename StateIn1, typename DerivIn1, typename StateIn2, 
             typename DerivIn2> 
      value_type prepare_dense_output(int k, const StateIn1 & x_start, 
                                      const DerivIn1 & dxdt_start, 
                                      const StateIn2 &, const DerivIn2 &, 
                                      time_type dt);
  7. template<typename DerivIn> 
      void calculate_finite_difference(size_t j, size_t kappa, value_type fac, 
                                       const DerivIn & dxdt);
  8. template<typename StateOut> 
      void do_interpolation(time_type t, StateOut & out) const;
  9. template<typename StateIn> bool resize_impl(const StateIn & x);
  10. state_type & get_current_state(void);
  11. const state_type & get_current_state(void) const;
  12. state_type & get_old_state(void);
  13. const state_type & get_old_state(void) const;
  14. deriv_type & get_current_deriv(void);
  15. const deriv_type & get_current_deriv(void) const;
  16. deriv_type & get_old_deriv(void);
  17. const deriv_type & get_old_deriv(void) const;
  18. void toggle_current_state(void);

PrevUpHomeNext