Chris@16: /* Chris@16: [auto_generated] Chris@16: boost/numeric/odeint/stepper/runge_kutta_fehlberg87.hpp Chris@16: Chris@16: [begin_description] Chris@16: Implementation of the Runge-Kutta-Fehlberg stepper with the generic stepper. Chris@16: [end_description] Chris@16: Chris@101: Copyright 2011-2013 Mario Mulansky Chris@101: Copyright 2012-2013 Karsten Ahnert Chris@16: Chris@16: Distributed under the Boost Software License, Version 1.0. Chris@16: (See accompanying file LICENSE_1_0.txt or Chris@16: copy at http://www.boost.org/LICENSE_1_0.txt) Chris@16: */ Chris@16: Chris@16: Chris@16: #ifndef BOOST_NUMERIC_ODEINT_STEPPER_RUNGE_KUTTA_FEHLBERG87_HPP_INCLUDED Chris@16: #define BOOST_NUMERIC_ODEINT_STEPPER_RUNGE_KUTTA_FEHLBERG87_HPP_INCLUDED Chris@16: Chris@16: Chris@16: #include Chris@16: #include Chris@16: Chris@101: #include Chris@16: #include Chris@16: #include Chris@101: #include Chris@101: #include Chris@16: Chris@16: #include Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: Chris@16: Chris@16: Chris@16: namespace boost { Chris@16: namespace numeric { Chris@16: namespace odeint { Chris@16: Chris@16: Chris@16: #ifndef DOXYGEN_SKIP Chris@16: template< class Value = double > Chris@16: struct rk78_coefficients_a1 : boost::array< Value , 1 > Chris@16: { Chris@16: rk78_coefficients_a1( void ) Chris@16: { Chris@16: (*this)[0] = static_cast< Value >( 2 )/static_cast< Value >( 27 ); Chris@16: } Chris@16: }; Chris@16: Chris@16: template< class Value = double > Chris@16: struct rk78_coefficients_a2 : boost::array< Value , 2 > Chris@16: { Chris@16: rk78_coefficients_a2( void ) Chris@16: { Chris@16: (*this)[0] = static_cast< Value >( 1 )/static_cast< Value >( 36 ); Chris@16: (*this)[1] = static_cast< Value >( 1 )/static_cast< Value >( 12 ); Chris@16: } Chris@16: }; Chris@16: Chris@16: Chris@16: template< class Value = double > Chris@16: struct rk78_coefficients_a3 : boost::array< Value , 3 > Chris@16: { Chris@16: rk78_coefficients_a3( void ) Chris@16: { Chris@16: (*this)[0] = static_cast< Value >( 1 )/static_cast< Value >( 24 ); Chris@16: (*this)[1] = static_cast< Value >( 0 ); Chris@16: (*this)[2] = static_cast< Value >( 1 )/static_cast< Value >( 8 ); Chris@16: } Chris@16: }; Chris@16: Chris@16: template< class Value = double > Chris@16: struct rk78_coefficients_a4 : boost::array< Value , 4 > Chris@16: { Chris@16: rk78_coefficients_a4( void ) Chris@16: { Chris@16: (*this)[0] = static_cast< Value >( 5 )/static_cast< Value >( 12 ); Chris@16: (*this)[1] = static_cast< Value >( 0 ); Chris@16: (*this)[2] = static_cast< Value >( -25 )/static_cast< Value >( 16 ); Chris@16: (*this)[3] = static_cast< Value >( 25 )/static_cast< Value >( 16 ); Chris@16: } Chris@16: }; Chris@16: Chris@16: template< class Value = double > Chris@16: struct rk78_coefficients_a5 : boost::array< Value , 5 > Chris@16: { Chris@16: rk78_coefficients_a5( void ) Chris@16: { Chris@16: (*this)[0] = static_cast< Value >( 1 )/static_cast< Value >( 20 ); Chris@16: (*this)[1] = static_cast< Value >( 0 ); Chris@16: (*this)[2] = static_cast< Value >( 0 ); Chris@16: (*this)[3] = static_cast< Value >( 1 )/static_cast< Value >( 4 ); Chris@16: (*this)[4] = static_cast< Value >( 1 )/static_cast< Value >( 5 ); Chris@16: } Chris@16: }; Chris@16: Chris@16: Chris@16: template< class Value = double > Chris@16: struct rk78_coefficients_a6 : boost::array< Value , 6 > Chris@16: { Chris@16: rk78_coefficients_a6( void ) Chris@16: { Chris@16: (*this)[0] = static_cast< Value >( -25 )/static_cast< Value >( 108 ); Chris@16: (*this)[1] = static_cast< Value >( 0 ); Chris@16: (*this)[2] = static_cast< Value >( 0 ); Chris@16: (*this)[3] = static_cast< Value >( 125 )/static_cast< Value >( 108 ); Chris@16: (*this)[4] = static_cast< Value >( -65 )/static_cast< Value >( 27 ); Chris@16: (*this)[5] = static_cast< Value >( 125 )/static_cast< Value >( 54 ); Chris@16: } Chris@16: }; Chris@16: Chris@16: template< class Value = double > Chris@16: struct rk78_coefficients_a7 : boost::array< Value , 7 > Chris@16: { Chris@16: rk78_coefficients_a7( void ) Chris@16: { Chris@16: (*this)[0] = static_cast< Value >( 31 )/static_cast< Value >( 300 ); Chris@16: (*this)[1] = static_cast< Value >( 0 ); Chris@16: (*this)[2] = static_cast< Value >( 0 ); Chris@16: (*this)[3] = static_cast< Value >( 0 ); Chris@16: (*this)[4] = static_cast< Value >( 61 )/static_cast< Value >( 225 ); Chris@16: (*this)[5] = static_cast< Value >( -2 )/static_cast< Value >( 9 ); Chris@16: (*this)[6] = static_cast< Value >( 13 )/static_cast< Value >( 900 ); Chris@16: } Chris@16: }; Chris@16: Chris@16: template< class Value = double > Chris@16: struct rk78_coefficients_a8 : boost::array< Value , 8 > Chris@16: { Chris@16: rk78_coefficients_a8( void ) Chris@16: { Chris@16: (*this)[0] = static_cast< Value >( 2 ); Chris@16: (*this)[1] = static_cast< Value >( 0 ); Chris@16: (*this)[2] = static_cast< Value >( 0 ); Chris@16: (*this)[3] = static_cast< Value >( -53 )/static_cast< Value >( 6 ); Chris@16: (*this)[4] = static_cast< Value >( 704 )/static_cast< Value >( 45 ); Chris@16: (*this)[5] = static_cast< Value >( -107 )/static_cast< Value >( 9 ); Chris@16: (*this)[6] = static_cast< Value >( 67 )/static_cast< Value >( 90 ); Chris@16: (*this)[7] = static_cast< Value >( 3 ); Chris@16: } Chris@16: }; Chris@16: Chris@16: template< class Value = double > Chris@16: struct rk78_coefficients_a9 : boost::array< Value , 9 > Chris@16: { Chris@16: rk78_coefficients_a9( void ) Chris@16: { Chris@16: (*this)[0] = static_cast< Value >( -91 )/static_cast< Value >( 108 ); Chris@16: (*this)[1] = static_cast< Value >( 0 ); Chris@16: (*this)[2] = static_cast< Value >( 0 ); Chris@16: (*this)[3] = static_cast< Value >( 23 )/static_cast< Value >( 108 ); Chris@16: (*this)[4] = static_cast< Value >( -976 )/static_cast< Value >( 135 ); Chris@16: (*this)[5] = static_cast< Value >( 311 )/static_cast< Value >( 54 ); Chris@16: (*this)[6] = static_cast< Value >( -19 )/static_cast< Value >( 60 ); Chris@16: (*this)[7] = static_cast< Value >( 17 )/static_cast< Value >( 6 ); Chris@16: (*this)[8] = static_cast< Value >( -1 )/static_cast< Value >( 12 ); Chris@16: } Chris@16: }; Chris@16: Chris@16: template< class Value = double > Chris@16: struct rk78_coefficients_a10 : boost::array< Value , 10 > Chris@16: { Chris@16: rk78_coefficients_a10( void ) Chris@16: { Chris@16: (*this)[0] = static_cast< Value >( 2383 )/static_cast< Value >( 4100 ); Chris@16: (*this)[1] = static_cast< Value >( 0 ); Chris@16: (*this)[2] = static_cast< Value >( 0 ); Chris@16: (*this)[3] = static_cast< Value >( -341 )/static_cast< Value >( 164 ); Chris@16: (*this)[4] = static_cast< Value >( 4496 )/static_cast< Value >( 1025 ); Chris@16: (*this)[5] = static_cast< Value >( -301 )/static_cast< Value >( 82 ); Chris@16: (*this)[6] = static_cast< Value >( 2133 )/static_cast< Value >( 4100 ); Chris@16: (*this)[7] = static_cast< Value >( 45 )/static_cast< Value >( 82 ); Chris@16: (*this)[8] = static_cast< Value >( 45 )/static_cast< Value >( 164 ); Chris@16: (*this)[9] = static_cast< Value >( 18 )/static_cast< Value >( 41 ); Chris@16: } Chris@16: }; Chris@16: Chris@16: template< class Value = double > Chris@16: struct rk78_coefficients_a11 : boost::array< Value , 11 > Chris@16: { Chris@16: rk78_coefficients_a11( void ) Chris@16: { Chris@16: (*this)[0] = static_cast< Value >( 3 )/static_cast< Value >( 205 ); Chris@16: (*this)[1] = static_cast< Value >( 0 ); Chris@16: (*this)[2] = static_cast< Value >( 0 ); Chris@16: (*this)[3] = static_cast< Value >( 0 ); Chris@16: (*this)[4] = static_cast< Value >( 0 ); Chris@16: (*this)[5] = static_cast< Value >( -6 )/static_cast< Value >( 41 ); Chris@16: (*this)[6] = static_cast< Value >( -3 )/static_cast< Value >( 205 ); Chris@16: (*this)[7] = static_cast< Value >( -3 )/static_cast< Value >( 41 ); Chris@16: (*this)[8] = static_cast< Value >( 3 )/static_cast< Value >( 41 ); Chris@16: (*this)[9] = static_cast< Value >( 6 )/static_cast< Value >( 41 ); Chris@16: (*this)[10] = static_cast< Value >( 0 ); Chris@16: } Chris@16: }; Chris@16: Chris@16: template< class Value = double > Chris@16: struct rk78_coefficients_a12 : boost::array< Value , 12 > Chris@16: { Chris@16: rk78_coefficients_a12( void ) Chris@16: { Chris@16: (*this)[0] = static_cast< Value >( -1777 )/static_cast< Value >( 4100 ); Chris@16: (*this)[1] = static_cast< Value >( 0 ); Chris@16: (*this)[2] = static_cast< Value >( 0 ); Chris@16: (*this)[3] = static_cast< Value >( -341 )/static_cast< Value >( 164 ); Chris@16: (*this)[4] = static_cast< Value >( 4496 )/static_cast< Value >( 1025 ); Chris@16: (*this)[5] = static_cast< Value >( -289 )/static_cast< Value >( 82 ); Chris@16: (*this)[6] = static_cast< Value >( 2193 )/static_cast< Value >( 4100 ); Chris@16: (*this)[7] = static_cast< Value >( 51 )/static_cast< Value >( 82 ); Chris@16: (*this)[8] = static_cast< Value >( 33 )/static_cast< Value >( 164 ); Chris@16: (*this)[9] = static_cast< Value >( 12 )/static_cast< Value >( 41 ); Chris@16: (*this)[10] = static_cast< Value >( 0 ); Chris@16: (*this)[11] = static_cast< Value >( 1 ); Chris@16: } Chris@16: }; Chris@16: Chris@16: template< class Value = double > Chris@16: struct rk78_coefficients_b : boost::array< Value , 13 > Chris@16: { Chris@16: rk78_coefficients_b( void ) Chris@16: { Chris@16: (*this)[0] = static_cast< Value >( 0 ); Chris@16: (*this)[1] = static_cast< Value >( 0 ); Chris@16: (*this)[2] = static_cast< Value >( 0 ); Chris@16: (*this)[3] = static_cast< Value >( 0 ); Chris@16: (*this)[4] = static_cast< Value >( 0 ); Chris@16: (*this)[5] = static_cast< Value >( 34 )/static_cast( 105 ); Chris@16: (*this)[6] = static_cast< Value >( 9 )/static_cast( 35 ); Chris@16: (*this)[7] = static_cast< Value >( 9 )/static_cast( 35 ); Chris@16: (*this)[8] = static_cast< Value >( 9 )/static_cast( 280 ); Chris@16: (*this)[9] = static_cast< Value >( 9 )/static_cast( 280 ); Chris@16: (*this)[10] = static_cast< Value >( 0 ); Chris@16: (*this)[11] = static_cast< Value >( 41 )/static_cast( 840 ); Chris@16: (*this)[12] = static_cast< Value >( 41 )/static_cast( 840 ); Chris@16: } Chris@16: }; Chris@16: Chris@16: template< class Value = double > Chris@16: struct rk78_coefficients_db : boost::array< Value , 13 > Chris@16: { Chris@16: rk78_coefficients_db( void ) Chris@16: { Chris@16: (*this)[0] = static_cast< Value >( 0 ) - static_cast< Value >( 41 )/static_cast( 840 ); Chris@16: (*this)[1] = static_cast< Value >( 0 ); Chris@16: (*this)[2] = static_cast< Value >( 0 ); Chris@16: (*this)[3] = static_cast< Value >( 0 ); Chris@16: (*this)[4] = static_cast< Value >( 0 ); Chris@16: (*this)[5] = static_cast< Value >( 0 ); Chris@16: (*this)[6] = static_cast< Value >( 0 ); Chris@16: (*this)[7] = static_cast< Value >( 0 ); Chris@16: (*this)[8] = static_cast< Value >( 0 ); Chris@16: (*this)[9] = static_cast< Value >( 0 ); Chris@16: (*this)[10] = static_cast< Value >( 0 ) - static_cast< Value >( 41 )/static_cast( 840 ); Chris@16: (*this)[11] = static_cast< Value >( 41 )/static_cast( 840 ); Chris@16: (*this)[12] = static_cast< Value >( 41 )/static_cast( 840 ); Chris@16: } Chris@16: }; Chris@16: Chris@16: Chris@16: template< class Value = double > Chris@16: struct rk78_coefficients_c : boost::array< Value , 13 > Chris@16: { Chris@16: rk78_coefficients_c( void ) Chris@16: { Chris@16: (*this)[0] = static_cast< Value >( 0 ); Chris@16: (*this)[1] = static_cast< Value >( 2 )/static_cast< Value >( 27 ); Chris@16: (*this)[2] = static_cast< Value >( 1 )/static_cast< Value >( 9 ); Chris@16: (*this)[3] = static_cast< Value >( 1 )/static_cast( 6 ); Chris@16: (*this)[4] = static_cast< Value >( 5 )/static_cast( 12 ); Chris@16: (*this)[5] = static_cast< Value >( 1 )/static_cast( 2 ); Chris@16: (*this)[6] = static_cast< Value >( 5 )/static_cast( 6 ); Chris@16: (*this)[7] = static_cast< Value >( 1 )/static_cast( 6 ); Chris@16: (*this)[8] = static_cast< Value >( 2 )/static_cast( 3 ); Chris@16: (*this)[9] = static_cast< Value >( 1 )/static_cast( 3 ); Chris@16: (*this)[10] = static_cast< Value >( 1 ); Chris@16: (*this)[11] = static_cast< Value >( 0 ); Chris@16: (*this)[12] = static_cast< Value >( 1 ); Chris@16: } Chris@16: }; Chris@16: #endif // DOXYGEN_SKIP Chris@16: Chris@16: Chris@16: Chris@16: Chris@16: Chris@16: template< Chris@16: class State , Chris@16: class Value = double , Chris@16: class Deriv = State , Chris@16: class Time = Value , Chris@101: class Algebra = typename algebra_dispatcher< State >::algebra_type , Chris@101: class Operations = typename operations_dispatcher< State >::operations_type , Chris@16: class Resizer = initially_resizer Chris@16: > Chris@16: #ifndef DOXYGEN_SKIP Chris@16: class runge_kutta_fehlberg78 : public explicit_error_generic_rk< 13 , 8 , 8 , 7 , State , Value , Deriv , Time , Chris@16: Algebra , Operations , Resizer > Chris@16: #else Chris@16: class runge_kutta_fehlberg78 : public explicit_error_generic_rk Chris@16: #endif Chris@16: { Chris@16: Chris@16: public: Chris@16: #ifndef DOXYGEN_SKIP Chris@16: typedef explicit_error_generic_rk< 13 , 8 , 8 , 7 , State , Value , Deriv , Time , Chris@16: Algebra , Operations , Resizer > stepper_base_type; Chris@16: #endif Chris@16: typedef typename stepper_base_type::state_type state_type; Chris@16: typedef typename stepper_base_type::value_type value_type; Chris@16: typedef typename stepper_base_type::deriv_type deriv_type; Chris@16: typedef typename stepper_base_type::time_type time_type; Chris@16: typedef typename stepper_base_type::algebra_type algebra_type; Chris@16: typedef typename stepper_base_type::operations_type operations_type; Chris@16: typedef typename stepper_base_type::resizer_type resizer_type; Chris@16: Chris@16: #ifndef DOXYGEN_SKIP Chris@16: typedef typename stepper_base_type::stepper_type stepper_type; Chris@16: typedef typename stepper_base_type::wrapped_state_type wrapped_state_type; Chris@16: typedef typename stepper_base_type::wrapped_deriv_type wrapped_deriv_type; Chris@16: #endif // DOXYGEN_SKIP Chris@16: Chris@16: Chris@16: runge_kutta_fehlberg78( const algebra_type &algebra = algebra_type() ) : stepper_base_type( Chris@16: boost::fusion::make_vector( rk78_coefficients_a1() , rk78_coefficients_a2() , rk78_coefficients_a3() , Chris@16: rk78_coefficients_a4() , rk78_coefficients_a5() , rk78_coefficients_a6() , Chris@16: rk78_coefficients_a7() , rk78_coefficients_a8() , rk78_coefficients_a9() , Chris@16: rk78_coefficients_a10() , rk78_coefficients_a11() , rk78_coefficients_a12() ) , Chris@16: rk78_coefficients_b() , rk78_coefficients_db() , rk78_coefficients_c() , algebra ) Chris@16: { } Chris@16: }; Chris@16: Chris@16: Chris@16: Chris@16: /************* DOXYGEN *************/ Chris@16: Chris@16: /** Chris@16: * \class runge_kutta_fehlberg78 Chris@16: * \brief The Runge-Kutta Fehlberg 78 method. Chris@16: * Chris@16: * The Runge-Kutta Fehlberg 78 method is a standard method for high-precision applications. Chris@16: * The method is explicit and fulfills the Error Stepper concept. Step size control Chris@16: * is provided but continuous output is not available for this method. Chris@16: * Chris@16: * This class derives from explicit_error_stepper_base and inherits its interface via CRTP (current recurring template pattern). Chris@16: * Furthermore, it derivs from explicit_error_generic_rk which is a generic Runge-Kutta algorithm with error estimation. Chris@16: * For more details see explicit_error_stepper_base and explicit_error_generic_rk. Chris@16: * Chris@16: * \tparam State The state type. Chris@16: * \tparam Value The value type. Chris@16: * \tparam Deriv The type representing the time derivative of the state. Chris@16: * \tparam Time The time representing the independent variable - the time. Chris@16: * \tparam Algebra The algebra type. Chris@16: * \tparam Operations The operations type. Chris@16: * \tparam Resizer The resizer policy type. Chris@16: */ Chris@16: Chris@16: Chris@16: /** Chris@16: * \fn runge_kutta_fehlberg78::runge_kutta_fehlberg78( const algebra_type &algebra ) Chris@16: * \brief Constructs the runge_kutta_cash_fehlberg78 class. This constructor can be used as a default Chris@16: * constructor if the algebra has a default constructor. Chris@16: * \param algebra A copy of algebra is made and stored inside explicit_stepper_base. Chris@16: */ Chris@16: Chris@16: } Chris@16: } Chris@16: } Chris@16: Chris@16: #endif //BOOST_NUMERIC_ODEINT_STEPPER_RUNGE_KUTTA_FEHLBERG87_HPP_INCLUDED