| Home | Libraries | People | FAQ | More

## Class template adams_bashforth

boost::numeric::odeint::adams_bashforth — The Adams-Bashforth multistep algorithm.

## Synopsis

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

    template<size_t Steps, typename State, typename Value = double,
             typename Deriv = State, typename Time = Value,
             typename Algebra = range_algebra,
             typename Operations = default_operations,
             typename Resizer = initially_resizer,
             typename InitializingStepper = runge_kutta4< State , Value , Deriv , Time , Algebra , Operations, Resizer > >
    class adams_bashforth :
      public boost::numeric::odeint::algebra_stepper_base< Algebra, Operations >
    {
    public:
      // types
      typedef State                                                        state_type;
      typedef state_wrapper< state_type >                                  wrapped_state_type;
      typedef Value                                                        value_type;
      typedef Deriv                                                        deriv_type;
      typedef state_wrapper< deriv_type >                                  wrapped_deriv_type;
      typedef Time                                                         time_type;
      typedef Resizer                                                      resizer_type;
      typedef stepper_tag                                                  stepper_category;
      typedef InitializingStepper                                          initializing_stepper_type;
      typedef algebra_stepper_base< Algebra, Operations >::algebra_type    algebra_type;
      typedef algebra_stepper_base< Algebra, Operations >::operations_type operations_type;
      typedef unsigned short                                               order_type;
      typedef unspecified                                                  step_storage_type;

      // construct/copy/destruct
      adams_bashforth(const adams_bashforth &);
      adams_bashforth& operator=(const adams_bashforth &);

      // public member functions
      order_type order(void) const;
       m_resizer();
       m_coefficients();
       m_steps_initialized(0);
       m_initializing_stepper();
       m_algebra(algebra);
      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 StateIn, typename StateOut>
        void do_step(System, const StateIn &, time_type, StateOut &, time_type);
      template<typename System, typename StateIn, typename StateOut>
        void do_step(System, const StateIn &, time_type, const StateOut &,
                     time_type);
      template<typename StateType> void adjust_size(const StateType &);
      const step_storage_type & step_storage(void) const;
      step_storage_type & step_storage(void);
      template<typename ExplicitStepper, typename System, typename StateIn>
        void initialize(ExplicitStepper, System, StateIn &, time_type &,
                        time_type);
      template<typename System, typename StateIn>
        void initialize(System, StateIn &, time_type &, time_type);
      void reset(void);
      bool is_initialized(void) const;
      const initializing_stepper_type & initializing_stepper(void) const;
      initializing_stepper_type & initializing_stepper(void);
      const algebra_type & algebra() const;

      // private member functions
      template<typename System, typename StateIn, typename StateOut>
        void do_step_impl(System, const StateIn &, time_type, StateOut &,
                          time_type);
      template<typename StateIn> bool resize_impl(const StateIn &);

      // public data members
      static const size_t steps;
      static const order_type order_value;
       __pad0__;
    };

## Description

The Adams-Bashforth method is a multi-step algorithm with configurable step number. The step number is specified as template parameter Steps and it then uses the result from the previous Steps steps. See also en.wikipedia.org/wiki/Linear_multistep_method. Currently, a maximum of Steps=8 is supported. The method is explicit and fulfills the Stepper concept. Step size control or continuous output are not provided.

This class derives from algebra_base and inherits its interface via CRTP (current recurring template pattern). For more details see algebra_stepper_base.

### Template Parameters

1.     size_t Steps

   The number of steps (maximal 8).

2.     typename State

   The state type.

3.     typename Value = double

   The value type.

4.     typename Deriv = State

   The type representing the time derivative of the state.

5.     typename Time = Value

   The time representing the independent variable - the time.

6.     typename Algebra = range_algebra

   The algebra type.

7.     typename Operations = default_operations

   The operations type.

8.     typename Resizer = initially_resizer

   The resizer policy type.

9.     typename InitializingStepper = runge_kutta4< State , Value , Deriv , Time , Algebra , Operations, Resizer >

   The stepper for the first two steps.

### `adams_bashforth` public construct/copy/destruct

1.     adams_bashforth(const adams_bashforth & stepper);

   Constructs the `adams_bashforth` class. This constructor can be used as a default constructor if the algebra has a default constructor.

2.     adams_bashforth& operator=(const adams_bashforth & stepper);

### `adams_bashforth` public member functions

1.     order_type order(void) const;

   Returns the order of the algorithm, which is equal to the number of steps.

   Returns: | order of the method.

2.      m_resizer();

3.      m_coefficients();

4.      m_steps_initialized(0);

5.      m_initializing_stepper();

6.      m_algebra(algebra);

7.     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.

8.     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.

9.     template<typename System, typename StateIn, typename StateOut>
         void 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.

   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 StateOut>
          void do_step(System system, const StateIn & in, time_type t,
                       const StateOut & out, time_type dt);

    Second version to solve the forwarding problem, can be called with Boost.Range as StateOut.

11.     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.

12.     const step_storage_type & step_storage(void) const;

    Returns the storage of intermediate results.

    Returns: | The storage of intermediate results.

13.     step_storage_type & step_storage(void);

    Returns the storage of intermediate results.

    Returns: | The storage of intermediate results.

14.     template<typename ExplicitStepper, typename System, typename StateIn>
          void initialize(ExplicitStepper explicit_stepper, System system,
                          StateIn & x, time_type & t, time_type dt);

    Initialized the stepper. Does Steps-1 steps with the explicit_stepper to fill the buffer.

    Parameters: |
    `dt` | The step size.
    `explicit_stepper` | the stepper used to fill the buffer of previous step results
    `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.

15.     template<typename System, typename StateIn>
          void initialize(System system, StateIn & x, time_type & t, time_type dt);

    Initialized the stepper. Does Steps-1 steps with an internal instance of InitializingStepper to fill the buffer.

    | Note
    The state x and time t are updated to the values after Steps-1 initial steps.

    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 initial value of the time, updated in this method.
    `x` | The initial state of the ODE which should be solved, updated in this method.

16.     void reset(void);

    Resets the internal buffer of the stepper.

17.     bool is_initialized(void) const;

    Returns true if the stepper has been initialized.

    Returns: | bool true if stepper is initialized, false otherwise

18.     const initializing_stepper_type & initializing_stepper(void) const;

    Returns the internal initializing stepper instance.

    Returns: | initializing_stepper

19.     initializing_stepper_type & initializing_stepper(void);

    Returns the internal initializing stepper instance.

    Returns: | initializing_stepper

20.     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.

### `adams_bashforth` private member functions

1.     template<typename System, typename StateIn, typename StateOut>
         void do_step_impl(System system, const StateIn & in, time_type t,
                           StateOut & out, time_type dt);

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