Skip to content

Commit e3e2b9e

Browse files
committed
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.04.1 (tags/RELEASE_600/final)
1 parent a3530bb commit e3e2b9e

14 files changed

Lines changed: 341 additions & 218 deletions

stan/math/prim/fun/ode_store_sensitivities.hpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,10 @@ namespace math {
1111
template <typename F, typename... Args,
1212
typename = require_all_arithmetic_t<scalar_type_t<Args>...>>
1313
Eigen::VectorXd ode_store_sensitivities(const F& f,
14-
const Eigen::VectorXd& coupled_state,
15-
const Eigen::VectorXd& y0,
16-
double t0,
17-
double t,
18-
std::ostream* msgs,
19-
const Args&... args) {
14+
const Eigen::VectorXd& coupled_state,
15+
const Eigen::VectorXd& y0, double t0,
16+
double t, std::ostream* msgs,
17+
const Args&... args) {
2018
return coupled_state.head(y0.size());
2119
}
2220

stan/math/prim/functor/coupled_ode_system.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ struct coupled_ode_system
129129
: public coupled_ode_system_impl<
130130
std::is_arithmetic<return_type_t<T_initial, Args...>>::value, F,
131131
T_initial, Args...> {
132-
coupled_ode_system(const F& f, const Eigen::Matrix<T_initial, Eigen::Dynamic, 1>& y0,
132+
coupled_ode_system(const F& f,
133+
const Eigen::Matrix<T_initial, Eigen::Dynamic, 1>& y0,
133134
std::ostream* msgs, const Args&... args)
134135
: coupled_ode_system_impl<
135136
std::is_arithmetic<return_type_t<T_initial, Args...>>::value, F,

stan/math/prim/functor/integrate_ode_rk45.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ integrate_ode_rk45(const F& f, const std::vector<T1>& y0, const T_t0& t0,
6868
double relative_tolerance = 1e-6,
6969
double absolute_tolerance = 1e-6, int max_num_steps = 1e6) {
7070
internal::integrate_ode_std_vector_interface_adapter<F> f_adapted(f);
71-
auto y = ode_rk45_tol(f_adapted, to_vector(y0), t0, ts,
72-
relative_tolerance, absolute_tolerance,
73-
max_num_steps, msgs, theta, x, x_int);
71+
auto y
72+
= ode_rk45_tol(f_adapted, to_vector(y0), t0, ts, relative_tolerance,
73+
absolute_tolerance, max_num_steps, msgs, theta, x, x_int);
7474

7575
std::vector<std::vector<return_type_t<T1, T_param, T_t0, T_ts>>> y_converted;
76-
for(size_t i = 0; i < y.size(); ++i)
76+
for (size_t i = 0; i < y.size(); ++i)
7777
y_converted.push_back(to_array_1d(y[i]));
7878

7979
return y_converted;

stan/math/prim/functor/integrate_ode_std_vector_interface_adapter.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,18 @@ struct integrate_ode_std_vector_interface_adapter {
1717
// this function might go out of scope in reverse mode
1818
const F f_;
1919

20-
integrate_ode_std_vector_interface_adapter(const F& f) : f_(f) {
21-
}
22-
23-
template<typename T0, typename T1, typename T2>
24-
auto operator()(const T0& t, const Eigen::Matrix<T1, Eigen::Dynamic, 1>& y, std::ostream* msgs,
25-
const std::vector<T2>& theta, const std::vector<double>& x,
26-
const std::vector<int>& x_int) const {
20+
integrate_ode_std_vector_interface_adapter(const F& f) : f_(f) {}
21+
22+
template <typename T0, typename T1, typename T2>
23+
auto operator()(const T0& t, const Eigen::Matrix<T1, Eigen::Dynamic, 1>& y,
24+
std::ostream* msgs, const std::vector<T2>& theta,
25+
const std::vector<double>& x,
26+
const std::vector<int>& x_int) const {
2727
return to_vector(f_(t, to_array_1d(y), msgs, theta, x, x_int));
2828
}
2929
};
3030

31-
}
31+
} // namespace internal
3232

3333
} // namespace math
3434
} // namespace stan

stan/math/prim/functor/ode_rk45.hpp

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ namespace stan {
1313
namespace math {
1414

1515
template <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

2930
template <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;

stan/math/rev/fun/ode_store_sensitivities.hpp

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,12 @@
99
namespace stan {
1010
namespace math {
1111

12-
template <typename F, typename T_initial_or_t0, typename T_t0, typename T_t, typename... Args>
13-
Eigen::Matrix<var, Eigen::Dynamic, 1> ode_store_sensitivities(const F& f,
14-
const Eigen::VectorXd& coupled_state,
15-
const Eigen::Matrix<T_initial_or_t0, Eigen::Dynamic, 1>& y0,
16-
const T_t0& t0,
17-
const T_t& t,
18-
std::ostream* msgs,
19-
const Args&... args) {
12+
template <typename F, typename T_initial_or_t0, typename T_t0, typename T_t,
13+
typename... Args>
14+
Eigen::Matrix<var, Eigen::Dynamic, 1> ode_store_sensitivities(
15+
const F& f, const Eigen::VectorXd& coupled_state,
16+
const Eigen::Matrix<T_initial_or_t0, Eigen::Dynamic, 1>& y0, const T_t0& t0,
17+
const T_t& t, std::ostream* msgs, const Args&... args) {
2018
const size_t N = y0.size();
2119
const size_t y0_vars = count_vars(y0);
2220
const size_t args_vars = count_vars(args...);
@@ -25,7 +23,7 @@ Eigen::Matrix<var, Eigen::Dynamic, 1> ode_store_sensitivities(const F& f,
2523
Eigen::Matrix<var, Eigen::Dynamic, 1> yt(N);
2624

2725
Eigen::VectorXd y = coupled_state.head(N);
28-
26+
2927
Eigen::VectorXd f_y_t;
3028
if (is_var<T_t>::value)
3129
f_y_t = f(value_of(t), y, msgs, value_of(args)...);
@@ -62,25 +60,24 @@ Eigen::Matrix<var, Eigen::Dynamic, 1> ode_store_sensitivities(const F& f,
6260
}
6361

6462
varis_ptr = save_varis(varis_ptr, t0);
65-
if(t0_vars > 0) {
63+
if (t0_vars > 0) {
6664
double dyt_dt0 = 0.0;
6765
for (std::size_t k = 0; k < y0_vars; ++k) {
68-
// dy[j]_dtheta[k]
69-
// theta[k].vi_
70-
dyt_dt0 += -f_y0_t0[k] * coupled_state(N + y0_vars * k + j);
66+
// dy[j]_dtheta[k]
67+
// theta[k].vi_
68+
dyt_dt0 += -f_y0_t0[k] * coupled_state(N + y0_vars * k + j);
7169
}
7270
*partials_ptr = dyt_dt0;
7371
partials_ptr++;
7472
}
7573

7674
varis_ptr = save_varis(varis_ptr, t);
77-
if(t_vars > 0) {
75+
if (t_vars > 0) {
7876
*partials_ptr = f_y_t[j];
7977
partials_ptr++;
8078
}
8179

82-
yt(j) = new precomputed_gradients_vari(y(j), total_vars,
83-
varis, partials);
80+
yt(j) = new precomputed_gradients_vari(y(j), total_vars, varis, partials);
8481
}
8582

8683
return yt;

stan/math/rev/functor/coupled_ode_system.hpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ struct coupled_ode_system_impl<false, F, T_initial, Args...> {
8585
* @param[in] x_int integer data
8686
* @param[in, out] msgs stream for messages
8787
*/
88-
coupled_ode_system_impl(const F& f, const Eigen::Matrix<T_initial, Eigen::Dynamic, 1>& y0,
88+
coupled_ode_system_impl(const F& f,
89+
const Eigen::Matrix<T_initial, Eigen::Dynamic, 1>& y0,
8990
std::ostream* msgs, const Args&... args)
9091
: f_(f),
9192
y0_(y0),
@@ -114,12 +115,12 @@ struct coupled_ode_system_impl<false, F, T_initial, Args...> {
114115
using std::vector;
115116

116117
dz_dt.resize(size());
117-
118+
118119
// Run nested autodiff in this scope
119120
nested_rev_autodiff nested;
120121

121122
Eigen::Matrix<var, Eigen::Dynamic, 1> y_vars(N_);
122-
for(size_t n = 0; n < N_; ++n)
123+
for (size_t n = 0; n < N_; ++n)
123124
y_vars(n) = z(n);
124125

125126
auto local_args_tuple = apply(
@@ -130,8 +131,8 @@ struct coupled_ode_system_impl<false, F, T_initial, Args...> {
130131
args_tuple_);
131132

132133
Eigen::Matrix<var, Eigen::Dynamic, 1> f_y_t_vars
133-
= apply([&](auto&&... args) { return f_(t, y_vars, msgs_, args...); },
134-
local_args_tuple);
134+
= apply([&](auto&&... args) { return f_(t, y_vars, msgs_, args...); },
135+
local_args_tuple);
135136

136137
check_size_match("coupled_ode_system", "dy_dt", f_y_t_vars.size(), "states",
137138
N_);

stan/math/rev/functor/cvodes_integrator.hpp

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ namespace math {
2222
*
2323
* @tparam Lmm ID of ODE solver (1: ADAMS, 2: BDF)
2424
*/
25-
template <int Lmm, typename F, typename T_initial, typename T_t0, typename T_ts, typename... T_Args>
25+
template <int Lmm, typename F, typename T_initial, typename T_t0, typename T_ts,
26+
typename... T_Args>
2627
class cvodes_integrator {
2728
using T_Return = return_type_t<T_initial, T_t0, T_ts, T_Args...>;
2829
using T_initial_or_t0 = return_type_t<T_initial, T_t0>;
@@ -97,8 +98,8 @@ class cvodes_integrator {
9798
const Eigen::VectorXd y_vec = Eigen::Map<const Eigen::VectorXd>(y, N_);
9899

99100
Eigen::VectorXd dy_dt_vec
100-
= apply([&](auto&&... args) { return f_(t, y_vec, msgs_, args...); },
101-
value_of_args_tuple_);
101+
= apply([&](auto&&... args) { return f_(t, y_vec, msgs_, args...); },
102+
value_of_args_tuple_);
102103

103104
check_size_match("cvodes_integrator::rhs", "dy_dt", dy_dt_vec.size(),
104105
"states", N_);
@@ -116,7 +117,7 @@ class cvodes_integrator {
116117

117118
auto f_wrapped = [&](const Eigen::Matrix<var, Eigen::Dynamic, 1>& y) {
118119
return apply([&](auto&&... args) { return f_(t, y, msgs_, args...); },
119-
value_of_args_tuple_);
120+
value_of_args_tuple_);
120121
};
121122

122123
jacobian(f_wrapped, Eigen::Map<const Eigen::VectorXd>(y, N_), fy, Jfy);
@@ -151,13 +152,15 @@ class cvodes_integrator {
151152
}
152153

153154
public:
154-
cvodes_integrator(const F& f, const Eigen::Matrix<T_initial, Eigen::Dynamic, 1>& y0,
155-
const T_t0& t0, const std::vector<T_ts>& ts,
156-
double relative_tolerance, double absolute_tolerance,
157-
long int max_num_steps,
158-
std::ostream* msgs, const T_Args&... args)
155+
cvodes_integrator(const F& f,
156+
const Eigen::Matrix<T_initial, Eigen::Dynamic, 1>& y0,
157+
const T_t0& t0, const std::vector<T_ts>& ts,
158+
double relative_tolerance, double absolute_tolerance,
159+
long int max_num_steps, std::ostream* msgs,
160+
const T_Args&... args)
159161
: f_(f),
160-
y0_(y0.unaryExpr([](const T_initial& val) { return T_initial_or_t0(val); })),
162+
y0_(y0.unaryExpr(
163+
[](const T_initial& val) { return T_initial_or_t0(val); })),
161164
t0_(t0),
162165
ts_(ts),
163166
args_tuple_(args...),
@@ -167,7 +170,7 @@ class cvodes_integrator {
167170
relative_tolerance_(relative_tolerance),
168171
absolute_tolerance_(absolute_tolerance),
169172
max_num_steps_(max_num_steps),
170-
y0_vars_(count_vars(y0_)),
173+
y0_vars_(count_vars(y0_)),
171174
args_vars_(count_vars(args...)),
172175
coupled_ode_(f, y0_, msgs, args...),
173176
coupled_state_(coupled_ode_.initial_state()) {
@@ -257,7 +260,8 @@ class cvodes_integrator {
257260
* @return a vector of states, each state being a vector of the
258261
* same size as the state variable, corresponding to a time in ts.
259262
*/
260-
std::vector<Eigen::Matrix<T_Return, Eigen::Dynamic, 1>> integrate() { // NOLINT(runtime/int)
263+
std::vector<Eigen::Matrix<T_Return, Eigen::Dynamic, 1>>
264+
integrate() { // NOLINT(runtime/int)
261265
std::vector<Eigen::Matrix<T_Return, Eigen::Dynamic, 1>> y;
262266

263267
const double t0_dbl = value_of(t0_);
@@ -320,9 +324,8 @@ class cvodes_integrator {
320324

321325
y.emplace_back(apply(
322326
[&](auto&&... args) {
323-
return ode_store_sensitivities(f_, coupled_state_, y0_,
324-
t0_, ts_[n], msgs_,
325-
args...);
327+
return ode_store_sensitivities(f_, coupled_state_, y0_, t0_,
328+
ts_[n], msgs_, args...);
326329
},
327330
args_tuple_));
328331

stan/math/rev/functor/integrate_ode_bdf.hpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,13 @@ integrate_ode_bdf(const F& f, const std::vector<T_initial>& y0, const T_t0& t0,
2222
double absolute_tolerance = 1e-10,
2323
long int max_num_steps = 1e8) { // NOLINT(runtime/int)
2424
internal::integrate_ode_std_vector_interface_adapter<F> f_adapted(f);
25-
auto y = ode_bdf_tol(f_adapted, to_vector(y0), t0, ts,
26-
relative_tolerance, absolute_tolerance,
27-
max_num_steps, msgs, theta, x, x_int);
25+
auto y
26+
= ode_bdf_tol(f_adapted, to_vector(y0), t0, ts, relative_tolerance,
27+
absolute_tolerance, max_num_steps, msgs, theta, x, x_int);
2828

29-
std::vector<std::vector<return_type_t<T_initial, T_param, T_t0, T_ts>>> y_converted;
30-
for(size_t i = 0; i < y.size(); ++i)
29+
std::vector<std::vector<return_type_t<T_initial, T_param, T_t0, T_ts>>>
30+
y_converted;
31+
for (size_t i = 0; i < y.size(); ++i)
3132
y_converted.push_back(to_array_1d(y[i]));
3233

3334
return y_converted;

0 commit comments

Comments
 (0)