123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231 |
- #ifndef BOOST_NUMERIC_ODEINT_STEPPER_RUNGE_KUTTA_CASH_KARP54_HPP_INCLUDED
- #define BOOST_NUMERIC_ODEINT_STEPPER_RUNGE_KUTTA_CASH_KARP54_HPP_INCLUDED
- #include <boost/fusion/container/vector.hpp>
- #include <boost/fusion/container/generation/make_vector.hpp>
- #include <boost/numeric/odeint/stepper/explicit_error_generic_rk.hpp>
- #include <boost/numeric/odeint/algebra/range_algebra.hpp>
- #include <boost/numeric/odeint/algebra/default_operations.hpp>
- #include <boost/numeric/odeint/algebra/algebra_dispatcher.hpp>
- #include <boost/numeric/odeint/algebra/operations_dispatcher.hpp>
- #include <boost/numeric/odeint/util/state_wrapper.hpp>
- #include <boost/numeric/odeint/util/is_resizeable.hpp>
- #include <boost/numeric/odeint/util/resizer.hpp>
- #include <array>
- namespace boost {
- namespace numeric {
- namespace odeint {
- #ifndef DOXYGEN_SKIP
- template< class Value = double >
- struct rk54_ck_coefficients_a1 : std::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 : std::array< Value , 2 >
- {
- rk54_ck_coefficients_a2( void )
- {
- (*this)[0] = static_cast<Value>( 3 )/static_cast<Value>( 40 );
- (*this)[1] = static_cast<Value>( 9 )/static_cast<Value>( 40 );
- }
- };
- template< class Value = double >
- struct rk54_ck_coefficients_a3 : std::array< Value , 3 >
- {
- rk54_ck_coefficients_a3( void )
- {
- (*this)[0] = static_cast<Value>( 3 )/static_cast<Value>( 10 );
- (*this)[1] = static_cast<Value>( -9 )/static_cast<Value>( 10 );
- (*this)[2] = static_cast<Value>( 6 )/static_cast<Value>( 5 );
- }
- };
- template< class Value = double >
- struct rk54_ck_coefficients_a4 : std::array< Value , 4 >
- {
- rk54_ck_coefficients_a4( void )
- {
- (*this)[0] = static_cast<Value>( -11 )/static_cast<Value>( 54 );
- (*this)[1] = static_cast<Value>( 5 )/static_cast<Value>( 2 );
- (*this)[2] = static_cast<Value>( -70 )/static_cast<Value>( 27 );
- (*this)[3] = static_cast<Value>( 35 )/static_cast<Value>( 27 );
- }
- };
- template< class Value = double >
- struct rk54_ck_coefficients_a5 : std::array< Value , 5 >
- {
- rk54_ck_coefficients_a5( void )
- {
- (*this)[0] = static_cast<Value>( 1631 )/static_cast<Value>( 55296 );
- (*this)[1] = static_cast<Value>( 175 )/static_cast<Value>( 512 );
- (*this)[2] = static_cast<Value>( 575 )/static_cast<Value>( 13824 );
- (*this)[3] = static_cast<Value>( 44275 )/static_cast<Value>( 110592 );
- (*this)[4] = static_cast<Value>( 253 )/static_cast<Value>( 4096 );
- }
- };
- template< class Value = double >
- struct rk54_ck_coefficients_b : std::array< Value , 6 >
- {
- rk54_ck_coefficients_b( void )
- {
- (*this)[0] = static_cast<Value>( 37 )/static_cast<Value>( 378 );
- (*this)[1] = static_cast<Value>( 0 );
- (*this)[2] = static_cast<Value>( 250 )/static_cast<Value>( 621 );
- (*this)[3] = static_cast<Value>( 125 )/static_cast<Value>( 594 );
- (*this)[4] = static_cast<Value>( 0 );
- (*this)[5] = static_cast<Value>( 512 )/static_cast<Value>( 1771 );
- }
- };
- template< class Value = double >
- struct rk54_ck_coefficients_db : std::array< Value , 6 >
- {
- rk54_ck_coefficients_db( void )
- {
- (*this)[0] = static_cast<Value>( 37 )/static_cast<Value>( 378 ) - static_cast<Value>( 2825 )/static_cast<Value>( 27648 );
- (*this)[1] = static_cast<Value>( 0 );
- (*this)[2] = static_cast<Value>( 250 )/static_cast<Value>( 621 ) - static_cast<Value>( 18575 )/static_cast<Value>( 48384 );
- (*this)[3] = static_cast<Value>( 125 )/static_cast<Value>( 594 ) - static_cast<Value>( 13525 )/static_cast<Value>( 55296 );
- (*this)[4] = static_cast<Value>( -277 )/static_cast<Value>( 14336 );
- (*this)[5] = static_cast<Value>( 512 )/static_cast<Value>( 1771 ) - static_cast<Value>( 1 )/static_cast<Value>( 4 );
- }
- };
- template< class Value = double >
- struct rk54_ck_coefficients_c : std::array< Value , 6 >
- {
- rk54_ck_coefficients_c( void )
- {
- (*this)[0] = static_cast<Value>(0);
- (*this)[1] = static_cast<Value>( 1 )/static_cast<Value>( 5 );
- (*this)[2] = static_cast<Value>( 3 )/static_cast<Value>( 10 );
- (*this)[3] = static_cast<Value>( 3 )/static_cast<Value>( 5 );
- (*this)[4] = static_cast<Value>( 1 );
- (*this)[5] = static_cast<Value>( 7 )/static_cast<Value>( 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<Value>() ,
- rk54_ck_coefficients_a2<Value>() ,
- rk54_ck_coefficients_a3<Value>() ,
- rk54_ck_coefficients_a4<Value>() ,
- rk54_ck_coefficients_a5<Value>() ) ,
- rk54_ck_coefficients_b<Value>() , rk54_ck_coefficients_db<Value>() , rk54_ck_coefficients_c<Value>() ,
- algebra )
- { }
- };
-
- }
- }
- }
- #endif
|