annotate DEPENDENCIES/generic/include/boost/numeric/odeint/stepper/runge_kutta_fehlberg78.hpp @ 125:34e428693f5d vext

Vext -> Repoint
author Chris Cannam
date Thu, 14 Jun 2018 11:15:39 +0100
parents c530137014c0
children
rev   line source
Chris@16 1 /*
Chris@16 2 [auto_generated]
Chris@16 3 boost/numeric/odeint/stepper/runge_kutta_fehlberg87.hpp
Chris@16 4
Chris@16 5 [begin_description]
Chris@16 6 Implementation of the Runge-Kutta-Fehlberg stepper with the generic stepper.
Chris@16 7 [end_description]
Chris@16 8
Chris@101 9 Copyright 2011-2013 Mario Mulansky
Chris@101 10 Copyright 2012-2013 Karsten Ahnert
Chris@16 11
Chris@16 12 Distributed under the Boost Software License, Version 1.0.
Chris@16 13 (See accompanying file LICENSE_1_0.txt or
Chris@16 14 copy at http://www.boost.org/LICENSE_1_0.txt)
Chris@16 15 */
Chris@16 16
Chris@16 17
Chris@16 18 #ifndef BOOST_NUMERIC_ODEINT_STEPPER_RUNGE_KUTTA_FEHLBERG87_HPP_INCLUDED
Chris@16 19 #define BOOST_NUMERIC_ODEINT_STEPPER_RUNGE_KUTTA_FEHLBERG87_HPP_INCLUDED
Chris@16 20
Chris@16 21
Chris@16 22 #include <boost/fusion/container/vector.hpp>
Chris@16 23 #include <boost/fusion/container/generation/make_vector.hpp>
Chris@16 24
Chris@101 25 #include <boost/numeric/odeint/stepper/explicit_error_generic_rk.hpp>
Chris@16 26 #include <boost/numeric/odeint/algebra/range_algebra.hpp>
Chris@16 27 #include <boost/numeric/odeint/algebra/default_operations.hpp>
Chris@101 28 #include <boost/numeric/odeint/algebra/algebra_dispatcher.hpp>
Chris@101 29 #include <boost/numeric/odeint/algebra/operations_dispatcher.hpp>
Chris@16 30
Chris@16 31 #include <boost/array.hpp>
Chris@16 32
Chris@16 33 #include <boost/numeric/odeint/util/state_wrapper.hpp>
Chris@16 34 #include <boost/numeric/odeint/util/is_resizeable.hpp>
Chris@16 35 #include <boost/numeric/odeint/util/resizer.hpp>
Chris@16 36
Chris@16 37
Chris@16 38
Chris@16 39
Chris@16 40 namespace boost {
Chris@16 41 namespace numeric {
Chris@16 42 namespace odeint {
Chris@16 43
Chris@16 44
Chris@16 45 #ifndef DOXYGEN_SKIP
Chris@16 46 template< class Value = double >
Chris@16 47 struct rk78_coefficients_a1 : boost::array< Value , 1 >
Chris@16 48 {
Chris@16 49 rk78_coefficients_a1( void )
Chris@16 50 {
Chris@16 51 (*this)[0] = static_cast< Value >( 2 )/static_cast< Value >( 27 );
Chris@16 52 }
Chris@16 53 };
Chris@16 54
Chris@16 55 template< class Value = double >
Chris@16 56 struct rk78_coefficients_a2 : boost::array< Value , 2 >
Chris@16 57 {
Chris@16 58 rk78_coefficients_a2( void )
Chris@16 59 {
Chris@16 60 (*this)[0] = static_cast< Value >( 1 )/static_cast< Value >( 36 );
Chris@16 61 (*this)[1] = static_cast< Value >( 1 )/static_cast< Value >( 12 );
Chris@16 62 }
Chris@16 63 };
Chris@16 64
Chris@16 65
Chris@16 66 template< class Value = double >
Chris@16 67 struct rk78_coefficients_a3 : boost::array< Value , 3 >
Chris@16 68 {
Chris@16 69 rk78_coefficients_a3( void )
Chris@16 70 {
Chris@16 71 (*this)[0] = static_cast< Value >( 1 )/static_cast< Value >( 24 );
Chris@16 72 (*this)[1] = static_cast< Value >( 0 );
Chris@16 73 (*this)[2] = static_cast< Value >( 1 )/static_cast< Value >( 8 );
Chris@16 74 }
Chris@16 75 };
Chris@16 76
Chris@16 77 template< class Value = double >
Chris@16 78 struct rk78_coefficients_a4 : boost::array< Value , 4 >
Chris@16 79 {
Chris@16 80 rk78_coefficients_a4( void )
Chris@16 81 {
Chris@16 82 (*this)[0] = static_cast< Value >( 5 )/static_cast< Value >( 12 );
Chris@16 83 (*this)[1] = static_cast< Value >( 0 );
Chris@16 84 (*this)[2] = static_cast< Value >( -25 )/static_cast< Value >( 16 );
Chris@16 85 (*this)[3] = static_cast< Value >( 25 )/static_cast< Value >( 16 );
Chris@16 86 }
Chris@16 87 };
Chris@16 88
Chris@16 89 template< class Value = double >
Chris@16 90 struct rk78_coefficients_a5 : boost::array< Value , 5 >
Chris@16 91 {
Chris@16 92 rk78_coefficients_a5( void )
Chris@16 93 {
Chris@16 94 (*this)[0] = static_cast< Value >( 1 )/static_cast< Value >( 20 );
Chris@16 95 (*this)[1] = static_cast< Value >( 0 );
Chris@16 96 (*this)[2] = static_cast< Value >( 0 );
Chris@16 97 (*this)[3] = static_cast< Value >( 1 )/static_cast< Value >( 4 );
Chris@16 98 (*this)[4] = static_cast< Value >( 1 )/static_cast< Value >( 5 );
Chris@16 99 }
Chris@16 100 };
Chris@16 101
Chris@16 102
Chris@16 103 template< class Value = double >
Chris@16 104 struct rk78_coefficients_a6 : boost::array< Value , 6 >
Chris@16 105 {
Chris@16 106 rk78_coefficients_a6( void )
Chris@16 107 {
Chris@16 108 (*this)[0] = static_cast< Value >( -25 )/static_cast< Value >( 108 );
Chris@16 109 (*this)[1] = static_cast< Value >( 0 );
Chris@16 110 (*this)[2] = static_cast< Value >( 0 );
Chris@16 111 (*this)[3] = static_cast< Value >( 125 )/static_cast< Value >( 108 );
Chris@16 112 (*this)[4] = static_cast< Value >( -65 )/static_cast< Value >( 27 );
Chris@16 113 (*this)[5] = static_cast< Value >( 125 )/static_cast< Value >( 54 );
Chris@16 114 }
Chris@16 115 };
Chris@16 116
Chris@16 117 template< class Value = double >
Chris@16 118 struct rk78_coefficients_a7 : boost::array< Value , 7 >
Chris@16 119 {
Chris@16 120 rk78_coefficients_a7( void )
Chris@16 121 {
Chris@16 122 (*this)[0] = static_cast< Value >( 31 )/static_cast< Value >( 300 );
Chris@16 123 (*this)[1] = static_cast< Value >( 0 );
Chris@16 124 (*this)[2] = static_cast< Value >( 0 );
Chris@16 125 (*this)[3] = static_cast< Value >( 0 );
Chris@16 126 (*this)[4] = static_cast< Value >( 61 )/static_cast< Value >( 225 );
Chris@16 127 (*this)[5] = static_cast< Value >( -2 )/static_cast< Value >( 9 );
Chris@16 128 (*this)[6] = static_cast< Value >( 13 )/static_cast< Value >( 900 );
Chris@16 129 }
Chris@16 130 };
Chris@16 131
Chris@16 132 template< class Value = double >
Chris@16 133 struct rk78_coefficients_a8 : boost::array< Value , 8 >
Chris@16 134 {
Chris@16 135 rk78_coefficients_a8( void )
Chris@16 136 {
Chris@16 137 (*this)[0] = static_cast< Value >( 2 );
Chris@16 138 (*this)[1] = static_cast< Value >( 0 );
Chris@16 139 (*this)[2] = static_cast< Value >( 0 );
Chris@16 140 (*this)[3] = static_cast< Value >( -53 )/static_cast< Value >( 6 );
Chris@16 141 (*this)[4] = static_cast< Value >( 704 )/static_cast< Value >( 45 );
Chris@16 142 (*this)[5] = static_cast< Value >( -107 )/static_cast< Value >( 9 );
Chris@16 143 (*this)[6] = static_cast< Value >( 67 )/static_cast< Value >( 90 );
Chris@16 144 (*this)[7] = static_cast< Value >( 3 );
Chris@16 145 }
Chris@16 146 };
Chris@16 147
Chris@16 148 template< class Value = double >
Chris@16 149 struct rk78_coefficients_a9 : boost::array< Value , 9 >
Chris@16 150 {
Chris@16 151 rk78_coefficients_a9( void )
Chris@16 152 {
Chris@16 153 (*this)[0] = static_cast< Value >( -91 )/static_cast< Value >( 108 );
Chris@16 154 (*this)[1] = static_cast< Value >( 0 );
Chris@16 155 (*this)[2] = static_cast< Value >( 0 );
Chris@16 156 (*this)[3] = static_cast< Value >( 23 )/static_cast< Value >( 108 );
Chris@16 157 (*this)[4] = static_cast< Value >( -976 )/static_cast< Value >( 135 );
Chris@16 158 (*this)[5] = static_cast< Value >( 311 )/static_cast< Value >( 54 );
Chris@16 159 (*this)[6] = static_cast< Value >( -19 )/static_cast< Value >( 60 );
Chris@16 160 (*this)[7] = static_cast< Value >( 17 )/static_cast< Value >( 6 );
Chris@16 161 (*this)[8] = static_cast< Value >( -1 )/static_cast< Value >( 12 );
Chris@16 162 }
Chris@16 163 };
Chris@16 164
Chris@16 165 template< class Value = double >
Chris@16 166 struct rk78_coefficients_a10 : boost::array< Value , 10 >
Chris@16 167 {
Chris@16 168 rk78_coefficients_a10( void )
Chris@16 169 {
Chris@16 170 (*this)[0] = static_cast< Value >( 2383 )/static_cast< Value >( 4100 );
Chris@16 171 (*this)[1] = static_cast< Value >( 0 );
Chris@16 172 (*this)[2] = static_cast< Value >( 0 );
Chris@16 173 (*this)[3] = static_cast< Value >( -341 )/static_cast< Value >( 164 );
Chris@16 174 (*this)[4] = static_cast< Value >( 4496 )/static_cast< Value >( 1025 );
Chris@16 175 (*this)[5] = static_cast< Value >( -301 )/static_cast< Value >( 82 );
Chris@16 176 (*this)[6] = static_cast< Value >( 2133 )/static_cast< Value >( 4100 );
Chris@16 177 (*this)[7] = static_cast< Value >( 45 )/static_cast< Value >( 82 );
Chris@16 178 (*this)[8] = static_cast< Value >( 45 )/static_cast< Value >( 164 );
Chris@16 179 (*this)[9] = static_cast< Value >( 18 )/static_cast< Value >( 41 );
Chris@16 180 }
Chris@16 181 };
Chris@16 182
Chris@16 183 template< class Value = double >
Chris@16 184 struct rk78_coefficients_a11 : boost::array< Value , 11 >
Chris@16 185 {
Chris@16 186 rk78_coefficients_a11( void )
Chris@16 187 {
Chris@16 188 (*this)[0] = static_cast< Value >( 3 )/static_cast< Value >( 205 );
Chris@16 189 (*this)[1] = static_cast< Value >( 0 );
Chris@16 190 (*this)[2] = static_cast< Value >( 0 );
Chris@16 191 (*this)[3] = static_cast< Value >( 0 );
Chris@16 192 (*this)[4] = static_cast< Value >( 0 );
Chris@16 193 (*this)[5] = static_cast< Value >( -6 )/static_cast< Value >( 41 );
Chris@16 194 (*this)[6] = static_cast< Value >( -3 )/static_cast< Value >( 205 );
Chris@16 195 (*this)[7] = static_cast< Value >( -3 )/static_cast< Value >( 41 );
Chris@16 196 (*this)[8] = static_cast< Value >( 3 )/static_cast< Value >( 41 );
Chris@16 197 (*this)[9] = static_cast< Value >( 6 )/static_cast< Value >( 41 );
Chris@16 198 (*this)[10] = static_cast< Value >( 0 );
Chris@16 199 }
Chris@16 200 };
Chris@16 201
Chris@16 202 template< class Value = double >
Chris@16 203 struct rk78_coefficients_a12 : boost::array< Value , 12 >
Chris@16 204 {
Chris@16 205 rk78_coefficients_a12( void )
Chris@16 206 {
Chris@16 207 (*this)[0] = static_cast< Value >( -1777 )/static_cast< Value >( 4100 );
Chris@16 208 (*this)[1] = static_cast< Value >( 0 );
Chris@16 209 (*this)[2] = static_cast< Value >( 0 );
Chris@16 210 (*this)[3] = static_cast< Value >( -341 )/static_cast< Value >( 164 );
Chris@16 211 (*this)[4] = static_cast< Value >( 4496 )/static_cast< Value >( 1025 );
Chris@16 212 (*this)[5] = static_cast< Value >( -289 )/static_cast< Value >( 82 );
Chris@16 213 (*this)[6] = static_cast< Value >( 2193 )/static_cast< Value >( 4100 );
Chris@16 214 (*this)[7] = static_cast< Value >( 51 )/static_cast< Value >( 82 );
Chris@16 215 (*this)[8] = static_cast< Value >( 33 )/static_cast< Value >( 164 );
Chris@16 216 (*this)[9] = static_cast< Value >( 12 )/static_cast< Value >( 41 );
Chris@16 217 (*this)[10] = static_cast< Value >( 0 );
Chris@16 218 (*this)[11] = static_cast< Value >( 1 );
Chris@16 219 }
Chris@16 220 };
Chris@16 221
Chris@16 222 template< class Value = double >
Chris@16 223 struct rk78_coefficients_b : boost::array< Value , 13 >
Chris@16 224 {
Chris@16 225 rk78_coefficients_b( void )
Chris@16 226 {
Chris@16 227 (*this)[0] = static_cast< Value >( 0 );
Chris@16 228 (*this)[1] = static_cast< Value >( 0 );
Chris@16 229 (*this)[2] = static_cast< Value >( 0 );
Chris@16 230 (*this)[3] = static_cast< Value >( 0 );
Chris@16 231 (*this)[4] = static_cast< Value >( 0 );
Chris@16 232 (*this)[5] = static_cast< Value >( 34 )/static_cast<Value>( 105 );
Chris@16 233 (*this)[6] = static_cast< Value >( 9 )/static_cast<Value>( 35 );
Chris@16 234 (*this)[7] = static_cast< Value >( 9 )/static_cast<Value>( 35 );
Chris@16 235 (*this)[8] = static_cast< Value >( 9 )/static_cast<Value>( 280 );
Chris@16 236 (*this)[9] = static_cast< Value >( 9 )/static_cast<Value>( 280 );
Chris@16 237 (*this)[10] = static_cast< Value >( 0 );
Chris@16 238 (*this)[11] = static_cast< Value >( 41 )/static_cast<Value>( 840 );
Chris@16 239 (*this)[12] = static_cast< Value >( 41 )/static_cast<Value>( 840 );
Chris@16 240 }
Chris@16 241 };
Chris@16 242
Chris@16 243 template< class Value = double >
Chris@16 244 struct rk78_coefficients_db : boost::array< Value , 13 >
Chris@16 245 {
Chris@16 246 rk78_coefficients_db( void )
Chris@16 247 {
Chris@16 248 (*this)[0] = static_cast< Value >( 0 ) - static_cast< Value >( 41 )/static_cast<Value>( 840 );
Chris@16 249 (*this)[1] = static_cast< Value >( 0 );
Chris@16 250 (*this)[2] = static_cast< Value >( 0 );
Chris@16 251 (*this)[3] = static_cast< Value >( 0 );
Chris@16 252 (*this)[4] = static_cast< Value >( 0 );
Chris@16 253 (*this)[5] = static_cast< Value >( 0 );
Chris@16 254 (*this)[6] = static_cast< Value >( 0 );
Chris@16 255 (*this)[7] = static_cast< Value >( 0 );
Chris@16 256 (*this)[8] = static_cast< Value >( 0 );
Chris@16 257 (*this)[9] = static_cast< Value >( 0 );
Chris@16 258 (*this)[10] = static_cast< Value >( 0 ) - static_cast< Value >( 41 )/static_cast<Value>( 840 );
Chris@16 259 (*this)[11] = static_cast< Value >( 41 )/static_cast<Value>( 840 );
Chris@16 260 (*this)[12] = static_cast< Value >( 41 )/static_cast<Value>( 840 );
Chris@16 261 }
Chris@16 262 };
Chris@16 263
Chris@16 264
Chris@16 265 template< class Value = double >
Chris@16 266 struct rk78_coefficients_c : boost::array< Value , 13 >
Chris@16 267 {
Chris@16 268 rk78_coefficients_c( void )
Chris@16 269 {
Chris@16 270 (*this)[0] = static_cast< Value >( 0 );
Chris@16 271 (*this)[1] = static_cast< Value >( 2 )/static_cast< Value >( 27 );
Chris@16 272 (*this)[2] = static_cast< Value >( 1 )/static_cast< Value >( 9 );
Chris@16 273 (*this)[3] = static_cast< Value >( 1 )/static_cast<Value>( 6 );
Chris@16 274 (*this)[4] = static_cast< Value >( 5 )/static_cast<Value>( 12 );
Chris@16 275 (*this)[5] = static_cast< Value >( 1 )/static_cast<Value>( 2 );
Chris@16 276 (*this)[6] = static_cast< Value >( 5 )/static_cast<Value>( 6 );
Chris@16 277 (*this)[7] = static_cast< Value >( 1 )/static_cast<Value>( 6 );
Chris@16 278 (*this)[8] = static_cast< Value >( 2 )/static_cast<Value>( 3 );
Chris@16 279 (*this)[9] = static_cast< Value >( 1 )/static_cast<Value>( 3 );
Chris@16 280 (*this)[10] = static_cast< Value >( 1 );
Chris@16 281 (*this)[11] = static_cast< Value >( 0 );
Chris@16 282 (*this)[12] = static_cast< Value >( 1 );
Chris@16 283 }
Chris@16 284 };
Chris@16 285 #endif // DOXYGEN_SKIP
Chris@16 286
Chris@16 287
Chris@16 288
Chris@16 289
Chris@16 290
Chris@16 291 template<
Chris@16 292 class State ,
Chris@16 293 class Value = double ,
Chris@16 294 class Deriv = State ,
Chris@16 295 class Time = Value ,
Chris@101 296 class Algebra = typename algebra_dispatcher< State >::algebra_type ,
Chris@101 297 class Operations = typename operations_dispatcher< State >::operations_type ,
Chris@16 298 class Resizer = initially_resizer
Chris@16 299 >
Chris@16 300 #ifndef DOXYGEN_SKIP
Chris@16 301 class runge_kutta_fehlberg78 : public explicit_error_generic_rk< 13 , 8 , 8 , 7 , State , Value , Deriv , Time ,
Chris@16 302 Algebra , Operations , Resizer >
Chris@16 303 #else
Chris@16 304 class runge_kutta_fehlberg78 : public explicit_error_generic_rk
Chris@16 305 #endif
Chris@16 306 {
Chris@16 307
Chris@16 308 public:
Chris@16 309 #ifndef DOXYGEN_SKIP
Chris@16 310 typedef explicit_error_generic_rk< 13 , 8 , 8 , 7 , State , Value , Deriv , Time ,
Chris@16 311 Algebra , Operations , Resizer > stepper_base_type;
Chris@16 312 #endif
Chris@16 313 typedef typename stepper_base_type::state_type state_type;
Chris@16 314 typedef typename stepper_base_type::value_type value_type;
Chris@16 315 typedef typename stepper_base_type::deriv_type deriv_type;
Chris@16 316 typedef typename stepper_base_type::time_type time_type;
Chris@16 317 typedef typename stepper_base_type::algebra_type algebra_type;
Chris@16 318 typedef typename stepper_base_type::operations_type operations_type;
Chris@16 319 typedef typename stepper_base_type::resizer_type resizer_type;
Chris@16 320
Chris@16 321 #ifndef DOXYGEN_SKIP
Chris@16 322 typedef typename stepper_base_type::stepper_type stepper_type;
Chris@16 323 typedef typename stepper_base_type::wrapped_state_type wrapped_state_type;
Chris@16 324 typedef typename stepper_base_type::wrapped_deriv_type wrapped_deriv_type;
Chris@16 325 #endif // DOXYGEN_SKIP
Chris@16 326
Chris@16 327
Chris@16 328 runge_kutta_fehlberg78( const algebra_type &algebra = algebra_type() ) : stepper_base_type(
Chris@16 329 boost::fusion::make_vector( rk78_coefficients_a1<Value>() , rk78_coefficients_a2<Value>() , rk78_coefficients_a3<Value>() ,
Chris@16 330 rk78_coefficients_a4<Value>() , rk78_coefficients_a5<Value>() , rk78_coefficients_a6<Value>() ,
Chris@16 331 rk78_coefficients_a7<Value>() , rk78_coefficients_a8<Value>() , rk78_coefficients_a9<Value>() ,
Chris@16 332 rk78_coefficients_a10<Value>() , rk78_coefficients_a11<Value>() , rk78_coefficients_a12<Value>() ) ,
Chris@16 333 rk78_coefficients_b<Value>() , rk78_coefficients_db<Value>() , rk78_coefficients_c<Value>() , algebra )
Chris@16 334 { }
Chris@16 335 };
Chris@16 336
Chris@16 337
Chris@16 338
Chris@16 339 /************* DOXYGEN *************/
Chris@16 340
Chris@16 341 /**
Chris@16 342 * \class runge_kutta_fehlberg78
Chris@16 343 * \brief The Runge-Kutta Fehlberg 78 method.
Chris@16 344 *
Chris@16 345 * The Runge-Kutta Fehlberg 78 method is a standard method for high-precision applications.
Chris@16 346 * The method is explicit and fulfills the Error Stepper concept. Step size control
Chris@16 347 * is provided but continuous output is not available for this method.
Chris@16 348 *
Chris@16 349 * This class derives from explicit_error_stepper_base and inherits its interface via CRTP (current recurring template pattern).
Chris@16 350 * Furthermore, it derivs from explicit_error_generic_rk which is a generic Runge-Kutta algorithm with error estimation.
Chris@16 351 * For more details see explicit_error_stepper_base and explicit_error_generic_rk.
Chris@16 352 *
Chris@16 353 * \tparam State The state type.
Chris@16 354 * \tparam Value The value type.
Chris@16 355 * \tparam Deriv The type representing the time derivative of the state.
Chris@16 356 * \tparam Time The time representing the independent variable - the time.
Chris@16 357 * \tparam Algebra The algebra type.
Chris@16 358 * \tparam Operations The operations type.
Chris@16 359 * \tparam Resizer The resizer policy type.
Chris@16 360 */
Chris@16 361
Chris@16 362
Chris@16 363 /**
Chris@16 364 * \fn runge_kutta_fehlberg78::runge_kutta_fehlberg78( const algebra_type &algebra )
Chris@16 365 * \brief Constructs the runge_kutta_cash_fehlberg78 class. This constructor can be used as a default
Chris@16 366 * constructor if the algebra has a default constructor.
Chris@16 367 * \param algebra A copy of algebra is made and stored inside explicit_stepper_base.
Chris@16 368 */
Chris@16 369
Chris@16 370 }
Chris@16 371 }
Chris@16 372 }
Chris@16 373
Chris@16 374 #endif //BOOST_NUMERIC_ODEINT_STEPPER_RUNGE_KUTTA_FEHLBERG87_HPP_INCLUDED