...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
Home | Libraries | People | FAQ | More |
boost::numeric::odeint::runge_kutta_cash_karp54_classic — The Runge-Kutta Cash-Karp method implemented without the generic Runge-Kutta algorithm.
// In header: <boost/numeric/odeint/stepper/runge_kutta_cash_karp54_classic.hpp> template<typename State, typename Value = double, typename Deriv = State, typename Time = double, typename Algebra = range_algebra, typename Operations = default_operations, typename Resizer = initially_resizer> class runge_kutta_cash_karp54_classic : public boost::numeric::odeint::explicit_error_stepper_base< Stepper, Order, StepperOrder, ErrorOrder, State, Value, Deriv, Time, Algebra, Operations, Resizer > { public: // types typedef explicit_error_stepper_base< runge_kutta_cash_karp54_classic< ... >,... > 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 runge_kutta_cash_karp54_classic(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 order(void) const; 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 &); algebra_type & algebra(); const algebra_type & algebra() const; // private member functions template<typename StateIn> bool resize_impl(const StateIn &); };
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 fulfills the Error Stepper concept. Step size control is provided but continuous 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.
typename State
The state type.
typename Value = double
The value type.
typename Deriv = State
The type representing the time derivative of the state.
typename Time = double
The time representing the independent variable - the time.
typename Algebra = range_algebra
The algebra type.
typename Operations = default_operations
The operations type.
typename Resizer = initially_resizer
The resizer policy type.
runge_kutta_cash_karp54_classic
public
construct/copy/destructrunge_kutta_cash_karp54_classic(const algebra_type & algebra = algebra_type());Constructs the
runge_kutta_cash_karp54_classic
class. This constructor can be used as a default constructor if the algebra has a default constructor.
Parameters: |
|
runge_kutta_cash_karp54_classic
public member functionstemplate<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`. Access to this step functionality is provided by explicit_error_stepper_base
and `do_step_impl` should not be called directly.
Parameters: |
|
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_error_stepper_base
and `do_step_impl` should not be called directly.
Parameters: |
|
template<typename StateIn> void adjust_size(const StateIn & x);Adjust the size of all temporaries in the stepper manually.
Parameters: |
|
order_type order(void) const;
Returns: |
Returns the order of the stepper if it used without error estimation. |
order_type stepper_order(void) const;
Returns: |
Returns the order of a step if the stepper is used without error estimation. |
order_type error_order(void) const;
Returns: |
Returns the order of an error step if the stepper is used without error estimation. |
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: |
|
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.
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 | |
---|---|
This method does not solve the forwarding problem. |
Parameters: |
|
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 | |
---|---|
This method does not solve the forwarding problem. |
Parameters: |
|
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 | |
---|---|
This method does not solve the forwarding problem. |
Parameters: |
|
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: |
|
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.
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 | |
---|---|
This method does not solve the forwarding problem. |
Parameters: |
|
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 | |
---|---|
This method does not solve the forwarding problem. |
Parameters: |
|
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 | |
---|---|
This method does not solve the forwarding problem. |
Parameters: |
|
algebra_type & algebra();
Returns: |
A reference to the algebra which is held by this class. |
const algebra_type & algebra() const;
Returns: |
A const reference to the algebra which is held by this class. |