annotate DEPENDENCIES/generic/include/boost/numeric/odeint/stepper/runge_kutta_fehlberg78.hpp @ 16:2665513ce2d3

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