Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:42:57

0001 /*
0002  [auto_generated]
0003  boost/numeric/odeint/stepper/runge_kutta_cash_karp54.hpp
0004  
0005  [begin_description]
0006  Implementation of the Runge Kutta Cash Karp 5(4) method. It uses the generic error stepper.
0007  [end_description]
0008  
0009  Copyright 2011-2013 Mario Mulansky
0010  Copyright 2011-2013 Karsten Ahnert
0011  
0012  Distributed under the Boost Software License, Version 1.0.
0013  (See accompanying file LICENSE_1_0.txt or
0014  copy at http://www.boost.org/LICENSE_1_0.txt)
0015 */
0016 
0017 
0018 #ifndef BOOST_NUMERIC_ODEINT_STEPPER_RUNGE_KUTTA_CASH_KARP54_HPP_INCLUDED
0019 #define BOOST_NUMERIC_ODEINT_STEPPER_RUNGE_KUTTA_CASH_KARP54_HPP_INCLUDED
0020 
0021 #include <boost/fusion/container/vector.hpp>
0022 #include <boost/fusion/container/generation/make_vector.hpp>
0023 
0024 #include <boost/numeric/odeint/stepper/explicit_error_generic_rk.hpp>
0025 #include <boost/numeric/odeint/algebra/range_algebra.hpp>
0026 #include <boost/numeric/odeint/algebra/default_operations.hpp>
0027 #include <boost/numeric/odeint/algebra/algebra_dispatcher.hpp>
0028 #include <boost/numeric/odeint/algebra/operations_dispatcher.hpp>
0029 
0030 #include <boost/numeric/odeint/util/state_wrapper.hpp>
0031 #include <boost/numeric/odeint/util/is_resizeable.hpp>
0032 #include <boost/numeric/odeint/util/resizer.hpp>
0033 
0034 #include <boost/array.hpp>
0035 
0036 
0037 
0038 
0039 namespace boost {
0040 namespace numeric {
0041 namespace odeint {
0042 
0043 
0044 #ifndef DOXYGEN_SKIP
0045 template< class Value = double >
0046 struct rk54_ck_coefficients_a1 : boost::array< Value , 1 >
0047 {
0048     rk54_ck_coefficients_a1( void )
0049     {
0050         (*this)[0] = static_cast< Value >( 1 )/static_cast< Value >( 5 );
0051     }
0052 };
0053 
0054 template< class Value = double >
0055 struct rk54_ck_coefficients_a2 : boost::array< Value , 2 >
0056 {
0057     rk54_ck_coefficients_a2( void )
0058     {
0059         (*this)[0] = static_cast<Value>( 3 )/static_cast<Value>( 40 );
0060         (*this)[1] = static_cast<Value>( 9 )/static_cast<Value>( 40 );
0061     }
0062 };
0063 
0064 
0065 template< class Value = double >
0066 struct rk54_ck_coefficients_a3 : boost::array< Value , 3 >
0067 {
0068     rk54_ck_coefficients_a3( void )
0069     {
0070         (*this)[0] = static_cast<Value>( 3 )/static_cast<Value>( 10 );
0071         (*this)[1] = static_cast<Value>( -9 )/static_cast<Value>( 10 );
0072         (*this)[2] = static_cast<Value>( 6 )/static_cast<Value>( 5 );
0073     }
0074 };
0075 
0076 template< class Value = double >
0077 struct rk54_ck_coefficients_a4 : boost::array< Value , 4 >
0078 {
0079     rk54_ck_coefficients_a4( void )
0080     {
0081         (*this)[0] = static_cast<Value>( -11 )/static_cast<Value>( 54 );
0082         (*this)[1] = static_cast<Value>( 5 )/static_cast<Value>( 2 );
0083         (*this)[2] = static_cast<Value>( -70 )/static_cast<Value>( 27 );
0084         (*this)[3] = static_cast<Value>( 35 )/static_cast<Value>( 27 );
0085     }
0086 };
0087 
0088 template< class Value = double >
0089 struct rk54_ck_coefficients_a5 : boost::array< Value , 5 >
0090 {
0091     rk54_ck_coefficients_a5( void )
0092     {
0093         (*this)[0] = static_cast<Value>( 1631 )/static_cast<Value>( 55296 );
0094         (*this)[1] = static_cast<Value>( 175 )/static_cast<Value>( 512 );
0095         (*this)[2] = static_cast<Value>( 575 )/static_cast<Value>( 13824 );
0096         (*this)[3] = static_cast<Value>( 44275 )/static_cast<Value>( 110592 );
0097         (*this)[4] = static_cast<Value>( 253 )/static_cast<Value>( 4096 );
0098     }
0099 };
0100 
0101 template< class Value = double >
0102 struct rk54_ck_coefficients_b : boost::array< Value , 6 >
0103 {
0104     rk54_ck_coefficients_b( void )
0105     {
0106         (*this)[0] = static_cast<Value>( 37 )/static_cast<Value>( 378 );
0107         (*this)[1] = static_cast<Value>( 0 );
0108         (*this)[2] = static_cast<Value>( 250 )/static_cast<Value>( 621 );
0109         (*this)[3] = static_cast<Value>( 125 )/static_cast<Value>( 594 );
0110         (*this)[4] = static_cast<Value>( 0 );
0111         (*this)[5] = static_cast<Value>( 512 )/static_cast<Value>( 1771 );
0112     }
0113 };
0114 
0115 template< class Value = double >
0116 struct rk54_ck_coefficients_db : boost::array< Value , 6 >
0117 {
0118     rk54_ck_coefficients_db( void )
0119     {
0120         (*this)[0] = static_cast<Value>( 37 )/static_cast<Value>( 378 ) - static_cast<Value>( 2825 )/static_cast<Value>( 27648 );
0121         (*this)[1] = static_cast<Value>( 0 );
0122         (*this)[2] = static_cast<Value>( 250 )/static_cast<Value>( 621 ) - static_cast<Value>( 18575 )/static_cast<Value>( 48384 );
0123         (*this)[3] = static_cast<Value>( 125 )/static_cast<Value>( 594 ) - static_cast<Value>( 13525 )/static_cast<Value>( 55296 );
0124         (*this)[4] = static_cast<Value>( -277 )/static_cast<Value>( 14336 );
0125         (*this)[5] = static_cast<Value>( 512 )/static_cast<Value>( 1771 ) - static_cast<Value>( 1 )/static_cast<Value>( 4 );
0126     }
0127 };
0128 
0129 
0130 template< class Value = double >
0131 struct rk54_ck_coefficients_c : boost::array< Value , 6 >
0132 {
0133     rk54_ck_coefficients_c( void )
0134     {
0135         (*this)[0] = static_cast<Value>(0);
0136         (*this)[1] = static_cast<Value>( 1 )/static_cast<Value>( 5 );
0137         (*this)[2] = static_cast<Value>( 3 )/static_cast<Value>( 10 );
0138         (*this)[3] = static_cast<Value>( 3 )/static_cast<Value>( 5 );
0139         (*this)[4] = static_cast<Value>( 1 );
0140         (*this)[5] = static_cast<Value>( 7 )/static_cast<Value>( 8 );
0141     }
0142 };
0143 #endif
0144 
0145 
0146 template<
0147     class State ,
0148     class Value = double ,
0149     class Deriv = State ,
0150     class Time = Value ,
0151     class Algebra = typename algebra_dispatcher< State >::algebra_type ,
0152     class Operations = typename operations_dispatcher< State >::operations_type ,
0153     class Resizer = initially_resizer
0154     >
0155 #ifndef DOXYGEN_SKIP
0156 class runge_kutta_cash_karp54 : public explicit_error_generic_rk< 6 , 5 , 5 , 4 ,
0157         State , Value , Deriv , Time , Algebra , Operations , Resizer >
0158 #else 
0159 class runge_kutta_cash_karp54 : public explicit_error_generic_rk
0160 #endif
0161 {
0162 
0163 public:
0164 #ifndef DOXYGEN_SKIP
0165     typedef explicit_error_generic_rk< 6 , 5 , 5 , 4 , State , Value , Deriv , Time ,
0166                                Algebra , Operations , Resizer > stepper_base_type;
0167 #endif
0168     typedef typename stepper_base_type::state_type state_type;
0169     typedef typename stepper_base_type::value_type value_type;
0170     typedef typename stepper_base_type::deriv_type deriv_type;
0171     typedef typename stepper_base_type::time_type time_type;
0172     typedef typename stepper_base_type::algebra_type algebra_type;
0173     typedef typename stepper_base_type::operations_type operations_type;
0174     typedef typename stepper_base_type::resizer_type resizer_typ;
0175 
0176     #ifndef DOXYGEN_SKIP
0177     typedef typename stepper_base_type::stepper_type stepper_type;
0178     typedef typename stepper_base_type::wrapped_state_type wrapped_state_type;
0179     typedef typename stepper_base_type::wrapped_deriv_type wrapped_deriv_type;
0180     #endif
0181 
0182 
0183     runge_kutta_cash_karp54( const algebra_type &algebra = algebra_type() ) : stepper_base_type(
0184         boost::fusion::make_vector( rk54_ck_coefficients_a1<Value>() ,
0185                                  rk54_ck_coefficients_a2<Value>() ,
0186                                  rk54_ck_coefficients_a3<Value>() ,
0187                                  rk54_ck_coefficients_a4<Value>() ,
0188                                  rk54_ck_coefficients_a5<Value>() ) ,
0189             rk54_ck_coefficients_b<Value>() , rk54_ck_coefficients_db<Value>() , rk54_ck_coefficients_c<Value>() ,
0190             algebra )
0191     { }
0192 };
0193 
0194 
0195 /********** DOXYGEN **********/
0196 
0197 /**
0198  * \class runge_kutta_cash_karp54
0199  * \brief The Runge-Kutta Cash-Karp method.
0200  *
0201  * The Runge-Kutta Cash-Karp method is one of the standard methods for
0202  * solving ordinary differential equations, see
0203  * <a href="http://en.wikipedia.org/wiki/Cash%E2%80%93Karp_methods">en.wikipedia.org/wiki/Cash-Karp_methods</a>.
0204  * The method is explicit and fulfills the Error Stepper concept. Step size control
0205  * is provided but continuous output is not available for this method.
0206  * 
0207  * This class derives from explicit_error_stepper_base and inherits its interface via CRTP (current recurring template pattern).
0208  * Furthermore, it derivs from explicit_error_generic_rk which is a generic Runge-Kutta algorithm with error estimation.
0209  * For more details see explicit_error_stepper_base and explicit_error_generic_rk.
0210  *
0211  * \tparam State The state type.
0212  * \tparam Value The value type.
0213  * \tparam Deriv The type representing the time derivative of the state.
0214  * \tparam Time The time representing the independent variable - the time.
0215  * \tparam Algebra The algebra type.
0216  * \tparam Operations The operations type.
0217  * \tparam Resizer The resizer policy type.
0218  */
0219 
0220 
0221     /**
0222      * \fn runge_kutta_cash_karp54::runge_kutta_cash_karp54( const algebra_type &algebra )
0223      * \brief Constructs the runge_kutta_cash_karp54 class. This constructor can be used as a default
0224      * constructor if the algebra has a default constructor.
0225      * \param algebra A copy of algebra is made and stored inside explicit_stepper_base.
0226      */
0227 }
0228 }
0229 }
0230 
0231 #endif // BOOST_NUMERIC_ODEINT_STEPPER_RUNGE_KUTTA_CASH_KARP54_HPP_INCLUDED