PrevUpHomeNext

Class template euler

boost::numeric::odeint::euler — An implementation of the Euler method.

Synopsis

// In header: <boost/numeric/odeint/stepper/euler.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 euler : public explicit_stepper_base {
public:
  // types
  typedef explicit_stepper_base< euler< ... >,... > stepper_base_type;
  typedef stepper_base_type::state_type             state_type;       
  typedef stepper_base_type::value_type             value_type;       
  typedef stepper_base_type::deriv_type             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;     

  // construct/copy/destruct
  euler(const algebra_type & = algebra_type());

  // public member functions
  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 StateOut, typename StateIn1, typename StateIn2> 
    void calc_state(StateOut &, time_type, const StateIn1 &, time_type, 
                    const StateIn2 &, time_type) const;
  template<typename StateType> void adjust_size(const StateType &);
};

Description

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 continuous output is available.

This class derives from explicit_stepper_base and inherits its interface via CRTP (current recurring template pattern), see explicit_stepper_base

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.

euler public construct/copy/destruct

  1. euler(const algebra_type & algebra = algebra_type());
    Constructs the euler class. This constructor can be used as a default constructor of the algebra has a default constructor.

    Parameters:

    algebra

    A copy of algebra is made and stored inside explicit_stepper_base.

euler public member functions

  1. template<typename System, typename StateIn, typename DerivIn, 
             typename StateOut> 
      void do_step_impl(System, const StateIn & in, const DerivIn & dxdt, 
                        time_type, 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.

  2. template<typename StateOut, typename StateIn1, typename StateIn2> 
      void calc_state(StateOut & x, time_type t, const StateIn1 & old_state, 
                      time_type t_old, const StateIn2 &, time_type) const;
    This method is used for continuous 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.
  3. template<typename StateType> void adjust_size(const StateType & 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.


PrevUpHomeNext