@@ -13,10 +13,11 @@ namespace stan {
1313namespace math {
1414
1515template <typename F, typename T_initial, typename T_t0, typename T_ts,
16- typename ... Args>
17- std::vector<Eigen::Matrix<stan::return_type_t <T_initial, Args...>, Eigen::Dynamic, 1 >>
18- ode_rk45 (const F& f, const Eigen::Matrix<T_initial, Eigen::Dynamic, 1 >& y0, double t0,
19- const std::vector<double >& ts, std::ostream* msgs,
16+ typename ... Args>
17+ std::vector<
18+ Eigen::Matrix<stan::return_type_t <T_initial, Args...>, Eigen::Dynamic, 1 >>
19+ ode_rk45 (const F& f, const Eigen::Matrix<T_initial, Eigen::Dynamic, 1 >& y0,
20+ double t0, const std::vector<double >& ts, std::ostream* msgs,
2021 const Args&... args) {
2122 double relative_tolerance = 1e-6 ;
2223 double absolute_tolerance = 1e-6 ;
@@ -27,10 +28,11 @@ ode_rk45(const F& f, const Eigen::Matrix<T_initial, Eigen::Dynamic, 1>& y0, doub
2728}
2829
2930template <typename F, typename T_initial, typename T_t0, typename T_ts,
30- typename ... Args>
31- std::vector<Eigen::Matrix<stan::return_type_t <T_initial, T_t0, T_ts, Args...>, Eigen::Dynamic, 1 >>
32- ode_rk45_tol (const F& f, const Eigen::Matrix<T_initial, Eigen::Dynamic, 1 >& y0_arg,
33- T_t0 t0,
31+ typename ... Args>
32+ std::vector<Eigen::Matrix<stan::return_type_t <T_initial, T_t0, T_ts, Args...>,
33+ Eigen::Dynamic, 1 >>
34+ ode_rk45_tol (const F& f,
35+ const Eigen::Matrix<T_initial, Eigen::Dynamic, 1 >& y0_arg, T_t0 t0,
3436 const std::vector<T_ts>& ts, double relative_tolerance,
3537 double absolute_tolerance, long int max_num_steps,
3638 std::ostream* msgs, const Args&... args) {
@@ -41,10 +43,9 @@ ode_rk45_tol(const F& f, const Eigen::Matrix<T_initial, Eigen::Dynamic, 1>& y0_a
4143 using boost::numeric::odeint::vector_space_algebra;
4244
4345 using T_initial_or_t0 = return_type_t <T_initial, T_t0>;
44-
45- Eigen::Matrix<T_initial_or_t0, Eigen::Dynamic, 1 > y0 = y0_arg.unaryExpr ([](const T_initial& val) {
46- return T_initial_or_t0 (val);
47- });
46+
47+ Eigen::Matrix<T_initial_or_t0, Eigen::Dynamic, 1 > y0 = y0_arg.unaryExpr (
48+ [](const T_initial& val) { return T_initial_or_t0 (val); });
4849 const std::vector<double > ts_dbl = value_of (ts);
4950
5051 check_finite (" integrate_ode_rk45" , " initial state" , y0);
@@ -77,7 +78,7 @@ ode_rk45_tol(const F& f, const Eigen::Matrix<T_initial, Eigen::Dynamic, 1>& y0_a
7778 using return_t = return_type_t <T_initial, T_t0, T_ts, Args...>;
7879 // creates basic or coupled system by template specializations
7980 coupled_ode_system<F, T_initial_or_t0, Args...> coupled_system (f, y0, msgs,
80- args...);
81+ args...);
8182
8283 // first time in the vector must be time of initial state
8384 std::vector<double > ts_vec (ts.size () + 1 );
@@ -91,14 +92,13 @@ ode_rk45_tol(const F& f, const Eigen::Matrix<T_initial, Eigen::Dynamic, 1>& y0_a
9192 // avoid recording of the initial state which is included by the
9293 // conventions of odeint in the output
9394 auto filtered_observer
94- = [&](const Eigen::VectorXd& coupled_state, double t) -> void {
95+ = [&](const Eigen::VectorXd& coupled_state, double t) -> void {
9596 if (!observer_initial_recorded) {
9697 observer_initial_recorded = true ;
9798 return ;
9899 }
99- y.emplace_back (ode_store_sensitivities (f, coupled_state, y0,
100- t0, ts[time_index],
101- msgs, args...));
100+ y.emplace_back (ode_store_sensitivities (f, coupled_state, y0, t0,
101+ ts[time_index], msgs, args...));
102102 time_index++;
103103 };
104104
@@ -107,12 +107,12 @@ ode_rk45_tol(const F& f, const Eigen::Matrix<T_initial, Eigen::Dynamic, 1>& y0_a
107107
108108 const double step_size = 0.1 ;
109109 integrate_times (
110- make_dense_output (absolute_tolerance, relative_tolerance,
111- runge_kutta_dopri5<Eigen::VectorXd, double ,
112- Eigen::VectorXd, double ,
113- vector_space_algebra>()),
114- std::ref (coupled_system), initial_coupled_state,
115- std::begin (ts_vec), std:: end (ts_vec), step_size, filtered_observer,
110+ make_dense_output (
111+ absolute_tolerance, relative_tolerance ,
112+ runge_kutta_dopri5<Eigen::VectorXd, double , Eigen::VectorXd, double ,
113+ vector_space_algebra>()),
114+ std::ref (coupled_system), initial_coupled_state, std::begin (ts_vec),
115+ std::end (ts_vec), step_size, filtered_observer,
116116 max_step_checker (max_num_steps));
117117
118118 return y;
0 commit comments