/* [auto_generated] boost/numeric/odeint/stepper/runge_kutta_cash_karp54.hpp [begin_description] Implementation of the Runge Kutta Cash Karp 5(4) method. It uses the generic error stepper. [end_description] Copyright 2011-2013 Mario Mulansky Copyright 2011-2013 Karsten Ahnert Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_NUMERIC_ODEINT_STEPPER_RUNGE_KUTTA_CASH_KARP54_HPP_INCLUDED #define BOOST_NUMERIC_ODEINT_STEPPER_RUNGE_KUTTA_CASH_KARP54_HPP_INCLUDED #include #include #include #include #include #include #include #include #include #include #include namespace boost { namespace numeric { namespace odeint { #ifndef DOXYGEN_SKIP template< class Value = double > struct rk54_ck_coefficients_a1 : boost::array< Value , 1 > { rk54_ck_coefficients_a1( void ) { (*this)[0] = static_cast< Value >( 1 )/static_cast< Value >( 5 ); } }; template< class Value = double > struct rk54_ck_coefficients_a2 : boost::array< Value , 2 > { rk54_ck_coefficients_a2( void ) { (*this)[0] = static_cast( 3 )/static_cast( 40 ); (*this)[1] = static_cast( 9 )/static_cast( 40 ); } }; template< class Value = double > struct rk54_ck_coefficients_a3 : boost::array< Value , 3 > { rk54_ck_coefficients_a3( void ) { (*this)[0] = static_cast( 3 )/static_cast( 10 ); (*this)[1] = static_cast( -9 )/static_cast( 10 ); (*this)[2] = static_cast( 6 )/static_cast( 5 ); } }; template< class Value = double > struct rk54_ck_coefficients_a4 : boost::array< Value , 4 > { rk54_ck_coefficients_a4( void ) { (*this)[0] = static_cast( -11 )/static_cast( 54 ); (*this)[1] = static_cast( 5 )/static_cast( 2 ); (*this)[2] = static_cast( -70 )/static_cast( 27 ); (*this)[3] = static_cast( 35 )/static_cast( 27 ); } }; template< class Value = double > struct rk54_ck_coefficients_a5 : boost::array< Value , 5 > { rk54_ck_coefficients_a5( void ) { (*this)[0] = static_cast( 1631 )/static_cast( 55296 ); (*this)[1] = static_cast( 175 )/static_cast( 512 ); (*this)[2] = static_cast( 575 )/static_cast( 13824 ); (*this)[3] = static_cast( 44275 )/static_cast( 110592 ); (*this)[4] = static_cast( 253 )/static_cast( 4096 ); } }; template< class Value = double > struct rk54_ck_coefficients_b : boost::array< Value , 6 > { rk54_ck_coefficients_b( void ) { (*this)[0] = static_cast( 37 )/static_cast( 378 ); (*this)[1] = static_cast( 0 ); (*this)[2] = static_cast( 250 )/static_cast( 621 ); (*this)[3] = static_cast( 125 )/static_cast( 594 ); (*this)[4] = static_cast( 0 ); (*this)[5] = static_cast( 512 )/static_cast( 1771 ); } }; template< class Value = double > struct rk54_ck_coefficients_db : boost::array< Value , 6 > { rk54_ck_coefficients_db( void ) { (*this)[0] = static_cast( 37 )/static_cast( 378 ) - static_cast( 2825 )/static_cast( 27648 ); (*this)[1] = static_cast( 0 ); (*this)[2] = static_cast( 250 )/static_cast( 621 ) - static_cast( 18575 )/static_cast( 48384 ); (*this)[3] = static_cast( 125 )/static_cast( 594 ) - static_cast( 13525 )/static_cast( 55296 ); (*this)[4] = static_cast( -277 )/static_cast( 14336 ); (*this)[5] = static_cast( 512 )/static_cast( 1771 ) - static_cast( 1 )/static_cast( 4 ); } }; template< class Value = double > struct rk54_ck_coefficients_c : boost::array< Value , 6 > { rk54_ck_coefficients_c( void ) { (*this)[0] = static_cast(0); (*this)[1] = static_cast( 1 )/static_cast( 5 ); (*this)[2] = static_cast( 3 )/static_cast( 10 ); (*this)[3] = static_cast( 3 )/static_cast( 5 ); (*this)[4] = static_cast( 1 ); (*this)[5] = static_cast( 7 )/static_cast( 8 ); } }; #endif template< class State , class Value = double , class Deriv = State , class Time = Value , class Algebra = typename algebra_dispatcher< State >::algebra_type , class Operations = typename operations_dispatcher< State >::operations_type , class Resizer = initially_resizer > #ifndef DOXYGEN_SKIP class runge_kutta_cash_karp54 : public explicit_error_generic_rk< 6 , 5 , 5 , 4 , State , Value , Deriv , Time , Algebra , Operations , Resizer > #else class runge_kutta_cash_karp54 : public explicit_error_generic_rk #endif { public: #ifndef DOXYGEN_SKIP typedef explicit_error_generic_rk< 6 , 5 , 5 , 4 , State , Value , Deriv , Time , Algebra , Operations , Resizer > stepper_base_type; #endif typedef typename stepper_base_type::state_type state_type; typedef typename stepper_base_type::value_type value_type; typedef typename stepper_base_type::deriv_type deriv_type; typedef typename stepper_base_type::time_type time_type; typedef typename stepper_base_type::algebra_type algebra_type; typedef typename stepper_base_type::operations_type operations_type; typedef typename stepper_base_type::resizer_type resizer_typ; #ifndef DOXYGEN_SKIP typedef typename stepper_base_type::stepper_type stepper_type; typedef typename stepper_base_type::wrapped_state_type wrapped_state_type; typedef typename stepper_base_type::wrapped_deriv_type wrapped_deriv_type; #endif runge_kutta_cash_karp54( const algebra_type &algebra = algebra_type() ) : stepper_base_type( boost::fusion::make_vector( rk54_ck_coefficients_a1() , rk54_ck_coefficients_a2() , rk54_ck_coefficients_a3() , rk54_ck_coefficients_a4() , rk54_ck_coefficients_a5() ) , rk54_ck_coefficients_b() , rk54_ck_coefficients_db() , rk54_ck_coefficients_c() , algebra ) { } }; /********** DOXYGEN **********/ /** * \class runge_kutta_cash_karp54 * \brief The Runge-Kutta Cash-Karp method. * * The Runge-Kutta Cash-Karp method is one of the standard methods for * solving ordinary differential equations, see * en.wikipedia.org/wiki/Cash-Karp_methods. * 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). * Furthermore, it derivs from explicit_error_generic_rk which is a generic Runge-Kutta algorithm with error estimation. * For more details see explicit_error_stepper_base and explicit_error_generic_rk. * * \tparam State The state type. * \tparam Value The value type. * \tparam Deriv The type representing the time derivative of the state. * \tparam Time The time representing the independent variable - the time. * \tparam Algebra The algebra type. * \tparam Operations The operations type. * \tparam Resizer The resizer policy type. */ /** * \fn runge_kutta_cash_karp54::runge_kutta_cash_karp54( const algebra_type &algebra ) * \brief Constructs the runge_kutta_cash_karp54 class. This constructor can be used as a default * constructor if the algebra has a default constructor. * \param algebra A copy of algebra is made and stored inside explicit_stepper_base. */ } } } #endif // BOOST_NUMERIC_ODEINT_STEPPER_RUNGE_KUTTA_CASH_KARP54_HPP_INCLUDED