1 #ifndef MEDUSA_BITS_INTEGRATORS_RKEXPLICIT_HPP_
2 #define MEDUSA_BITS_INTEGRATORS_RKEXPLICIT_HPP_
12 namespace integrators {
15 template <
class scalar_t>
17 Eigen::Matrix<scalar_t, 4, 1> alpha;
18 alpha << 0, 0.5, 0.5, 1.0;
19 Eigen::Matrix<scalar_t, 4, 4> beta;
20 beta << 0.0, 0.0, 0.0, 0.0,
24 Eigen::Matrix<scalar_t, 4, 1> gamma;
25 gamma << 1. / 6., 2. / 6., 2. / 6., 1. / 6.;
26 return {alpha, beta, gamma};
29 template <
class scalar_t>
31 Eigen::Matrix<scalar_t, 4, 1> alpha;
32 alpha << 0, 1. / 3., 2. / 3., 1.0;
33 Eigen::Matrix<scalar_t, 4, 4> beta;
34 beta << 0.0, 0.0, 0.0, 0.0,
35 1. / 3., 0.0, 0.0, 0.0,
36 -1. / 3., 1.0, 0.0, 0.0,
38 Eigen::Matrix<scalar_t, 4, 1> gamma;
39 gamma << 1. / 8., 3. / 8., 3. / 8., 1. / 8.;
40 return {alpha, beta, gamma};
43 template <
class scalar_t>
45 Eigen::Matrix<scalar_t, 1, 1> alpha;
47 Eigen::Matrix<scalar_t, 1, 1> beta;
49 Eigen::Matrix<scalar_t, 1, 1> gamma;
51 return {alpha, beta, gamma};
54 template <
class scalar_t>
56 Eigen::Matrix<scalar_t, 2, 1> alpha;
58 Eigen::Matrix<scalar_t, 2, 2> beta;
59 beta << 0.0, 0.0, 0.5, 0.0;
60 Eigen::Matrix<scalar_t, 2, 1> gamma;
62 return {alpha, beta, gamma};
65 template <
class scalar_t>
67 Eigen::Matrix<scalar_t, 3, 1> alpha;
69 Eigen::Matrix<scalar_t, 3, 3> beta;
70 beta << 0.0, 0.0, 0.0,
73 Eigen::Matrix<scalar_t, 3, 1> gamma;
74 gamma << 1. / 6., 2. / 3., 1. / 6.;
75 return {alpha, beta, gamma};
78 template <
class scalar_t>
80 Eigen::Matrix<scalar_t, 6, 1> alpha;
81 alpha << 0, 1. / 4., 3. / 8., 12. / 13., 1., 1. / 2.;
82 Eigen::Matrix<scalar_t, 6, 6> beta;
83 beta << 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
84 1. / 4., 0.0, 0.0, 0.0, 0.0, 0.0,
85 3. / 32., 9. / 32., 0.0, 0.0, 0.0, 0.0,
86 1932. / 2197, -7200. / 2197., 7296. / 2197., 0.0, 0.0, 0.0,
87 439. / 216., -8., 3680. / 513., -845. / 4104., 0.0, 0.0,
88 -8. / 27., 2., -3544. / 2565., 1859. / 4104., -11. / 40., 0.0;
89 Eigen::Matrix<scalar_t, 6, 1> gamma;
90 gamma << 16. / 135., 0.0, 6656. / 12825., 28561. / 56430., -9. / 50., 2. / 55.;
91 return {alpha, beta, gamma};
95 namespace of_order_internal {
97 template <
int order,
class scalar_t>
99 static_assert(order > 0,
"Order must be positive.");
100 static_assert(order < 5,
"Methods of higher orders do not correspond with the number of "
101 "stages, you must call them manually. If you got this error "
102 "calling AB5() method, supply e.g. Fehlberg5 as the first "
103 "parameter and its type as the template parameter.");
108 template <
class scalar_t>
109 struct _of_order_impl<1,
scalar_t> {
114 template <
class scalar_t>
115 struct _of_order_impl<2,
scalar_t> {
120 template <
class scalar_t>
121 struct _of_order_impl<3,
scalar_t> {
122 static RKExplicit<scalar_t, 3>
of_order() {
return RK3(); }
126 template <
class scalar_t>
127 struct _of_order_impl<4,
scalar_t> {
128 static RKExplicit<scalar_t, 4>
of_order() {
return RK4(); }
138 #endif // MEDUSA_BITS_INTEGRATORS_RKEXPLICIT_HPP_