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_kutta4.hpp
0004 
0005  [begin_description]
0006  Implementation of the classical Runge-Kutta stepper with the generic 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_KUTTA4_HPP_INCLUDED
0019 #define BOOST_NUMERIC_ODEINT_STEPPER_RUNGE_KUTTA4_HPP_INCLUDED
0020 
0021 
0022 
0023 
0024 #include <boost/fusion/container/vector.hpp>
0025 #include <boost/fusion/container/generation/make_vector.hpp>
0026 
0027 #include <boost/numeric/odeint/stepper/explicit_generic_rk.hpp>
0028 #include <boost/numeric/odeint/algebra/range_algebra.hpp>
0029 #include <boost/numeric/odeint/algebra/default_operations.hpp>
0030 #include <boost/numeric/odeint/algebra/algebra_dispatcher.hpp>
0031 #include <boost/numeric/odeint/algebra/operations_dispatcher.hpp>
0032 
0033 #include <boost/array.hpp>
0034 
0035 #include <boost/numeric/odeint/util/resizer.hpp>
0036 
0037 
0038 
0039 namespace boost {
0040 namespace numeric {
0041 namespace odeint {
0042 
0043 #ifndef DOXYGEN_SKIP
0044 template< class Value = double >
0045 struct rk4_coefficients_a1 : boost::array< Value , 1 >
0046 {
0047     rk4_coefficients_a1( void )
0048     {
0049         (*this)[0] = static_cast< Value >( 1 ) / static_cast< Value >( 2 );
0050     }
0051 };
0052 
0053 template< class Value = double >
0054 struct rk4_coefficients_a2 : boost::array< Value , 2 >
0055 {
0056     rk4_coefficients_a2( void )
0057     {
0058         (*this)[0] = static_cast<Value>(0);
0059         (*this)[1] = static_cast< Value >( 1 ) / static_cast< Value >( 2 );
0060     }
0061 };
0062 
0063 
0064 template< class Value = double >
0065 struct rk4_coefficients_a3 : boost::array< Value , 3 >
0066 {
0067     rk4_coefficients_a3( void )
0068             {
0069         (*this)[0] = static_cast<Value>(0);
0070         (*this)[1] = static_cast<Value>(0);
0071         (*this)[2] = static_cast<Value>(1);
0072             }
0073 };
0074 
0075 template< class Value = double >
0076 struct rk4_coefficients_b : boost::array< Value , 4 >
0077 {
0078     rk4_coefficients_b( void )
0079     {
0080         (*this)[0] = static_cast<Value>(1)/static_cast<Value>(6);
0081         (*this)[1] = static_cast<Value>(1)/static_cast<Value>(3);
0082         (*this)[2] = static_cast<Value>(1)/static_cast<Value>(3);
0083         (*this)[3] = static_cast<Value>(1)/static_cast<Value>(6);
0084     }
0085 };
0086 
0087 template< class Value = double >
0088 struct rk4_coefficients_c : boost::array< Value , 4 >
0089 {
0090     rk4_coefficients_c( void )
0091     {
0092         (*this)[0] = static_cast<Value>(0);
0093         (*this)[1] = static_cast< Value >( 1 ) / static_cast< Value >( 2 );
0094         (*this)[2] = static_cast< Value >( 1 ) / static_cast< Value >( 2 );
0095         (*this)[3] = static_cast<Value>(1);
0096     }
0097 };
0098 #endif
0099 
0100 
0101 
0102 template<
0103 class State ,
0104 class Value = double ,
0105 class Deriv = State ,
0106 class Time = Value ,
0107 class Algebra = typename algebra_dispatcher< State >::algebra_type ,
0108 class Operations = typename operations_dispatcher< State >::operations_type ,
0109 class Resizer = initially_resizer
0110 >
0111 #ifndef DOXYGEN_SKIP
0112 class runge_kutta4 : public explicit_generic_rk< 4 , 4 , State , Value , Deriv , Time ,
0113 Algebra , Operations , Resizer >
0114 #else
0115 class runge_kutta4 : public explicit_generic_rk
0116 #endif
0117 {
0118 
0119 public:
0120 
0121 #ifndef DOXYGEN_SKIP
0122     typedef explicit_generic_rk< 4 , 4 , State , Value , Deriv , Time ,
0123             Algebra , Operations , Resizer > stepper_base_type;
0124 #endif
0125     typedef typename stepper_base_type::state_type state_type;
0126     typedef typename stepper_base_type::value_type value_type;
0127     typedef typename stepper_base_type::deriv_type deriv_type;
0128     typedef typename stepper_base_type::time_type time_type;
0129     typedef typename stepper_base_type::algebra_type algebra_type;
0130     typedef typename stepper_base_type::operations_type operations_type;
0131     typedef typename stepper_base_type::resizer_type resizer_type;
0132 
0133     #ifndef DOXYGEN_SKIP
0134     typedef typename stepper_base_type::wrapped_state_type wrapped_state_type;
0135     typedef typename stepper_base_type::wrapped_deriv_type wrapped_deriv_type;
0136     typedef typename stepper_base_type::stepper_type stepper_type;
0137     #endif
0138 
0139     runge_kutta4( const algebra_type &algebra = algebra_type() ) : stepper_base_type(
0140             boost::fusion::make_vector( rk4_coefficients_a1<Value>() , rk4_coefficients_a2<Value>() , rk4_coefficients_a3<Value>() ) ,
0141             rk4_coefficients_b<Value>() , rk4_coefficients_c<Value>() , algebra )
0142     { }
0143 
0144 };
0145 
0146 /**
0147  * \class runge_kutta4
0148  * \brief The classical Runge-Kutta stepper of fourth order.
0149  *
0150  * The Runge-Kutta method of fourth order is one standard method for
0151  * solving ordinary differential equations and is widely used, see also
0152  * <a href="http://en.wikipedia.org/wiki/Runge%E2%80%93Kutta_methods">en.wikipedia.org/wiki/Runge-Kutta_methods</a>
0153  * The method is  explicit and fulfills the Stepper concept. Step size control
0154  * or continuous output are not provided.
0155  * 
0156  * This class derives from explicit_stepper_base and inherits its interface via CRTP (current recurring template pattern).
0157  * Furthermore, it derivs from explicit_generic_rk which is a generic Runge-Kutta algorithm. For more details see
0158  * explicit_stepper_base and explicit_generic_rk.
0159  *
0160  * \tparam State The state type.
0161  * \tparam Value The value type.
0162  * \tparam Deriv The type representing the time derivative of the state.
0163  * \tparam Time The time representing the independent variable - the time.
0164  * \tparam Algebra The algebra type.
0165  * \tparam Operations The operations type.
0166  * \tparam Resizer The resizer policy type.
0167  */
0168 
0169 /**
0170  * \fn runge_kutta4::runge_kutta4( const algebra_type &algebra = algebra_type() )
0171  * \brief Constructs the runge_kutta4 class. This constructor can be used as a default
0172  * constructor if the algebra has a default constructor.
0173  * \param algebra A copy of algebra is made and stored inside explicit_stepper_base.
0174  */
0175 
0176 }
0177 }
0178 }
0179 
0180 
0181 #endif // BOOST_NUMERIC_ODEINT_STEPPER_RUNGE_KUTTA4_HPP_INCLUDED