Skip to content

Commit 22a2210

Browse files
committed
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
1 parent 82e43da commit 22a2210

26 files changed

+889
-609
lines changed

stan/math/mix/functor/laplace_likelihood.hpp

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace stan {
99
namespace math {
1010

1111
namespace internal {
12-
/**
12+
/**
1313
* Set all adjoints of the output to zero.
1414
*/
1515
template <typename Output>
@@ -43,8 +43,7 @@ inline void set_zero_adjoint(Output&& output) {
4343
}
4444
}
4545

46-
}
47-
46+
} // namespace internal
4847

4948
/**
5049
* functions to compute the log density, first, second,
@@ -160,8 +159,7 @@ inline auto shallow_copy_vargs(Args&&... args) {
160159
*/
161160
template <typename F, typename Theta, typename Stream, typename... Args,
162161
require_eigen_vector_vt<std::is_arithmetic, Theta>* = nullptr>
163-
inline auto theta_grad(F&& f, Theta&& theta,
164-
Stream* msgs, Args&&... args) {
162+
inline auto theta_grad(F&& f, Theta&& theta, Stream* msgs, Args&&... args) {
165163
using Eigen::Dynamic;
166164
using Eigen::Matrix;
167165
nested_rev_autodiff nested;
@@ -186,16 +184,14 @@ inline auto theta_grad(F&& f, Theta&& theta,
186184
*/
187185
template <typename F, typename Theta, typename Stream, typename... Args,
188186
require_eigen_vector_vt<std::is_arithmetic, Theta>* = nullptr>
189-
inline void ll_arg_grad(F&& f, Theta&& theta,
190-
Stream* msgs, Args&&... args) {
187+
inline void ll_arg_grad(F&& f, Theta&& theta, Stream* msgs, Args&&... args) {
191188
using Eigen::Dynamic;
192189
using Eigen::Matrix;
193190
nested_rev_autodiff nested;
194191
var f_var = f(theta, args..., msgs);
195192
grad(f_var.vi_);
196193
}
197194

198-
199195
/**
200196
* Computes negative block diagonal Hessian of `f` wrt`theta` and `args...`
201197
* @note If `Args` contains \ref var types then their adjoints will be
@@ -214,14 +210,15 @@ inline void ll_arg_grad(F&& f, Theta&& theta,
214210
*/
215211
template <typename F, typename Theta, typename Stream, typename... Args,
216212
require_eigen_vector_vt<std::is_arithmetic, Theta>* = nullptr>
217-
inline auto diagonal_hessian(F&& f, Theta&& theta, Stream* msgs, Args&&... args) {
213+
inline auto diagonal_hessian(F&& f, Theta&& theta, Stream* msgs,
214+
Args&&... args) {
218215
using Eigen::Dynamic;
219216
using Eigen::Matrix;
220217
const Eigen::Index theta_size = theta.size();
221218
auto v = Eigen::VectorXd::Ones(theta_size);
222219
Eigen::VectorXd hessian_v = Eigen::VectorXd::Zero(theta_size);
223220
hessian_times_vector(f, hessian_v, std::forward<Theta>(theta), std::move(v),
224-
value_of(args)..., msgs);
221+
value_of(args)..., msgs);
225222
return (-hessian_v).eval();
226223
}
227224

@@ -243,8 +240,9 @@ inline auto diagonal_hessian(F&& f, Theta&& theta, Stream* msgs, Args&&... args)
243240
*/
244241
template <typename F, typename Theta, typename Stream, typename... Args,
245242
require_eigen_vector_vt<std::is_arithmetic, Theta>* = nullptr>
246-
inline auto block_hessian(F&& f, Theta&& theta, const Eigen::Index hessian_block_size,
247-
Stream* msgs, Args&&... args) {
243+
inline auto block_hessian(F&& f, Theta&& theta,
244+
const Eigen::Index hessian_block_size, Stream* msgs,
245+
Args&&... args) {
248246
using Eigen::Dynamic;
249247
using Eigen::Matrix;
250248
const Eigen::Index theta_size = theta.size();
@@ -260,12 +258,12 @@ inline auto block_hessian(F&& f, Theta&& theta, const Eigen::Index hessian_block
260258
}
261259
return (-hessian_theta).eval();
262260
} else {
263-
return (-hessian_block_diag(f, std::forward<Theta>(theta), hessian_block_size,
264-
value_of(args)..., msgs)).eval();
261+
return (-hessian_block_diag(f, std::forward<Theta>(theta),
262+
hessian_block_size, value_of(args)..., msgs))
263+
.eval();
265264
}
266265
}
267266

268-
269267
/**
270268
* Computes theta gradient and negative block diagonal Hessian of `f` wrt
271269
* `theta` and `args...`
@@ -476,28 +474,27 @@ template <typename F, typename Theta, typename TupleArgs, typename Stream,
476474
require_eigen_vector_t<Theta>* = nullptr,
477475
require_tuple_t<TupleArgs>* = nullptr>
478476
inline auto theta_grad(F&& f, Theta&& theta, TupleArgs&& ll_tup,
479-
Stream* msgs = nullptr) {
477+
Stream* msgs = nullptr) {
480478
return apply(
481479
[](auto&& f, auto&& theta, auto&& msgs, auto&&... args) {
482-
return internal::theta_grad(
483-
std::forward<decltype(f)>(f), std::forward<decltype(theta)>(theta),
484-
msgs, std::forward<decltype(args)>(args)...);
480+
return internal::theta_grad(std::forward<decltype(f)>(f),
481+
std::forward<decltype(theta)>(theta), msgs,
482+
std::forward<decltype(args)>(args)...);
485483
},
486484
std::forward<TupleArgs>(ll_tup), std::forward<F>(f),
487485
std::forward<Theta>(theta), msgs);
488486
}
489487

490-
491488
template <typename F, typename Theta, typename TupleArgs, typename Stream,
492489
require_eigen_vector_t<Theta>* = nullptr,
493490
require_tuple_t<TupleArgs>* = nullptr>
494491
inline auto ll_arg_grad(F&& f, Theta&& theta, TupleArgs&& ll_tup,
495-
Stream* msgs = nullptr) {
492+
Stream* msgs = nullptr) {
496493
return apply(
497494
[](auto&& f, auto&& theta, auto&& msgs, auto&&... args) {
498-
return internal::ll_arg_grad(
499-
std::forward<decltype(f)>(f), std::forward<decltype(theta)>(theta),
500-
msgs, std::forward<decltype(args)>(args)...);
495+
return internal::ll_arg_grad(std::forward<decltype(f)>(f),
496+
std::forward<decltype(theta)>(theta), msgs,
497+
std::forward<decltype(args)>(args)...);
501498
},
502499
std::forward<TupleArgs>(ll_tup), std::forward<F>(f),
503500
std::forward<Theta>(theta), msgs);
@@ -506,10 +503,10 @@ inline auto ll_arg_grad(F&& f, Theta&& theta, TupleArgs&& ll_tup,
506503
template <typename F, typename Theta, typename TupleArgs, typename Stream,
507504
require_eigen_vector_t<Theta>* = nullptr,
508505
require_tuple_t<TupleArgs>* = nullptr>
509-
inline auto diagonal_hessian(F&& f, Theta&& theta, TupleArgs&& ll_tuple, Stream* msgs) {
506+
inline auto diagonal_hessian(F&& f, Theta&& theta, TupleArgs&& ll_tuple,
507+
Stream* msgs) {
510508
return apply(
511-
[](auto&& f, auto&& theta, auto* msgs,
512-
auto&&... args) {
509+
[](auto&& f, auto&& theta, auto* msgs, auto&&... args) {
513510
return internal::diagonal_hessian(
514511
std::forward<decltype(f)>(f), std::forward<decltype(theta)>(theta),
515512
msgs, std::forward<decltype(args)>(args)...);
@@ -521,8 +518,9 @@ inline auto diagonal_hessian(F&& f, Theta&& theta, TupleArgs&& ll_tuple, Stream*
521518
template <typename F, typename Theta, typename TupleArgs, typename Stream,
522519
require_eigen_vector_t<Theta>* = nullptr,
523520
require_tuple_t<TupleArgs>* = nullptr>
524-
inline auto block_hessian(F&& f, Theta&& theta, const Eigen::Index hessian_block_size,
525-
TupleArgs&& ll_tuple, Stream* msgs) {
521+
inline auto block_hessian(F&& f, Theta&& theta,
522+
const Eigen::Index hessian_block_size,
523+
TupleArgs&& ll_tuple, Stream* msgs) {
526524
return apply(
527525
[](auto&& f, auto&& theta, auto hessian_block_size, auto* msgs,
528526
auto&&... args) {

stan/math/mix/functor/wolfe_line_search.hpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -590,16 +590,17 @@ struct WolfeInfo {
590590
* 6. **Convergence/guard rails.**
591591
* After each evaluation we check:
592592
* - Gradient tolerance: \f$|\phi'(\alpha)| \le
593-
* \max(\text{opt.abs\_grad\_threshold},\ \text{opt.rel\_grad\_threshold}\,|\phi'(0)|)\f$.
593+
* \max(\text{opt.abs\_grad\_threshold},\
594+
* \text{opt.rel\_grad\_threshold}\,|\phi'(0)|)\f$.
594595
* - Objective change tolerance (for very small steps):
595596
* \f$|\phi(\alpha)-\phi(0)| \le
596-
* \max(\text{opt.abs\_obj\_threshold},\ \text{opt.rel\_obj\_threshold}\,(1+|\phi(0)|))\f$
597-
* and \f$\alpha < \text{opt.min_alpha}\f$.
598-
* If triggered, the routine returns one of `ConvergedGradient`,
599-
* `ConvergedObjective`, or `ConvergedObjectiveAndGradient`.
600-
* If neither test is met but the bracket becomes too small, it returns
601-
* `IntervalTooSmall` (accepting the current point only if it satisfies
602-
* Armijo).
597+
* \max(\text{opt.abs\_obj\_threshold},\
598+
* \text{opt.rel\_obj\_threshold}\,(1+|\phi(0)|))\f$ and \f$\alpha <
599+
* \text{opt.min_alpha}\f$. If triggered, the routine returns one of
600+
* `ConvergedGradient`, `ConvergedObjective`, or
601+
* `ConvergedObjectiveAndGradient`. If neither test is met but the bracket
602+
* becomes too small, it returns `IntervalTooSmall` (accepting the current point
603+
* only if it satisfies Armijo).
603604
*
604605
* If zoom exits without a strong-Wolfe point but an Armijo-OK point was seen,
605606
* the routine **returns** `Armijo` at that best point; otherwise it **returns**

stan/math/mix/prob/laplace_latent_bernoulli_logit_rng.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ inline Eigen::VectorXd laplace_latent_tol_bernoulli_logit_rng(
3939
const double tolerance, const int max_num_steps,
4040
const int hessian_block_size, const int solver,
4141
const int max_steps_line_search, RNG& rng, std::ostream* msgs) {
42-
laplace_options_user_supplied ops{hessian_block_size, solver,
43-
max_steps_line_search, tolerance,
44-
max_num_steps, laplace_line_search_options{},
45-
value_of(theta_0)};
42+
laplace_options_user_supplied ops{
43+
hessian_block_size, solver, max_steps_line_search,
44+
tolerance, max_num_steps, laplace_line_search_options{},
45+
value_of(theta_0)};
4646
return laplace_base_rng(
4747
bernoulli_logit_likelihood{},
4848
std::forward_as_tuple(to_vector(y), n_samples, std::forward<Mean>(mean)),

stan/math/mix/prob/laplace_latent_neg_binomial_2_log_rng.hpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,13 @@ inline Eigen::VectorXd laplace_latent_tol_neg_binomial_2_log_rng(
4444
ThetaVec&& theta_0, const double tolerance, const int max_num_steps,
4545
const int hessian_block_size, const int solver,
4646
const int max_steps_line_search, RNG& rng, std::ostream* msgs) {
47-
laplace_options_user_supplied ops{hessian_block_size, solver,
48-
tolerance,
49-
max_num_steps, laplace_line_search_options{max_steps_line_search},
50-
value_of(theta_0)};
47+
laplace_options_user_supplied ops{
48+
hessian_block_size,
49+
solver,
50+
tolerance,
51+
max_num_steps,
52+
laplace_line_search_options{max_steps_line_search},
53+
value_of(theta_0)};
5154
return laplace_base_rng(
5255
neg_binomial_2_log_likelihood{},
5356
std::forward_as_tuple(std::forward<Eta>(eta), y, y_index,

stan/math/mix/prob/laplace_latent_poisson_log_rng.hpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,13 @@ inline Eigen::VectorXd laplace_latent_tol_poisson_log_rng(
3939
const double tolerance, const int max_num_steps,
4040
const int hessian_block_size, const int solver,
4141
const int max_steps_line_search, RNG& rng, std::ostream* msgs) {
42-
laplace_options_user_supplied ops{hessian_block_size, solver,
43-
tolerance,
44-
max_num_steps, laplace_line_search_options{max_steps_line_search},
45-
value_of(theta_0)};
42+
laplace_options_user_supplied ops{
43+
hessian_block_size,
44+
solver,
45+
tolerance,
46+
max_num_steps,
47+
laplace_line_search_options{max_steps_line_search},
48+
value_of(theta_0)};
4649
return laplace_base_rng(
4750
poisson_log_likelihood{},
4851
std::forward_as_tuple(y, y_index, std::forward<Mean>(mean)),

stan/math/mix/prob/laplace_latent_rng.hpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,12 @@ inline auto laplace_latent_tol_rng(
3737
const int max_num_steps, const int hessian_block_size, const int solver,
3838
const int max_steps_line_search, RNG& rng, std::ostream* msgs) {
3939
const laplace_options_user_supplied ops{
40-
hessian_block_size, solver,
41-
tolerance, max_num_steps,
42-
laplace_line_search_options{max_steps_line_search}, value_of(theta_0)};
40+
hessian_block_size,
41+
solver,
42+
tolerance,
43+
max_num_steps,
44+
laplace_line_search_options{max_steps_line_search},
45+
value_of(theta_0)};
4346
return laplace_base_rng(std::forward<LLFunc>(L_f),
4447
std::forward<LLArgs>(ll_args),
4548
std::forward<CovarFun>(covariance_function),

stan/math/mix/prob/laplace_marginal.hpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,13 @@ inline auto laplace_marginal_tol(
3333
CovarArgs&& covar_args, const ThetaVec& theta_0, double tolerance,
3434
int max_num_steps, const int hessian_block_size, const int solver,
3535
const int max_steps_line_search, std::ostream* msgs) {
36-
laplace_options_user_supplied ops{hessian_block_size, solver,
37-
tolerance,
38-
max_num_steps, laplace_line_search_options{max_steps_line_search},
39-
value_of(theta_0)};
36+
laplace_options_user_supplied ops{
37+
hessian_block_size,
38+
solver,
39+
tolerance,
40+
max_num_steps,
41+
laplace_line_search_options{max_steps_line_search},
42+
value_of(theta_0)};
4043
return laplace_marginal_density(
4144
std::forward<LFun>(L_f), std::forward<LArgs>(l_args),
4245
std::forward<CovarFun>(covariance_function),

stan/math/mix/prob/laplace_marginal_bernoulli_logit_lpmf.hpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,8 @@ struct bernoulli_logit_likelihood {
2727
const std::vector<int>& delta_int, Mean&& mean,
2828
std::ostream* pstream) const {
2929
auto theta_offset = to_ref(add(theta, mean));
30-
return sum(
31-
elt_multiply(theta_offset, y)
32-
- elt_multiply(to_vector(delta_int), log1p_exp(theta_offset)));
30+
return sum(elt_multiply(theta_offset, y)
31+
- elt_multiply(to_vector(delta_int), log1p_exp(theta_offset)));
3332
}
3433
};
3534

@@ -62,10 +61,13 @@ inline auto laplace_marginal_tol_bernoulli_logit_lpmf(
6261
const ThetaVec& theta_0, double tolerance, int max_num_steps,
6362
const int hessian_block_size, const int solver,
6463
const int max_steps_line_search, std::ostream* msgs) {
65-
laplace_options_user_supplied ops{hessian_block_size, solver,
66-
tolerance,
67-
max_num_steps, laplace_line_search_options{max_steps_line_search},
68-
value_of(theta_0)};
64+
laplace_options_user_supplied ops{
65+
hessian_block_size,
66+
solver,
67+
tolerance,
68+
max_num_steps,
69+
laplace_line_search_options{max_steps_line_search},
70+
value_of(theta_0)};
6971
return laplace_marginal_density(
7072
bernoulli_logit_likelihood{},
7173
std::forward_as_tuple(to_vector(y), n_samples, std::forward<Mean>(mean)),

stan/math/mix/prob/laplace_marginal_neg_binomial_2_log_lpmf.hpp

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ struct neg_binomial_2_log_likelihood {
4242
Eigen::Map<const Eigen::VectorXi> y_map(y.data(), y.size());
4343

4444
auto theta_offset = add(theta, mean);
45-
auto log_eta = log(eta);
45+
auto log_eta = log(eta);
4646
auto lse = to_ref(log_sum_exp(theta_offset, log_eta));
4747

4848
return sum(binomial_coefficient_log(subtract(add(y_map, eta), 1.0), y_map))
49-
+ sum(add(
49+
+ sum(add(
5050
// counts_per_group * (theta - log(eta + exp(theta)))
5151
elt_multiply(counts_per_group, subtract(theta_offset, lse)),
5252
// n_per_group * eta * (log(eta) - log(eta + exp(theta)))
@@ -85,10 +85,13 @@ inline auto laplace_marginal_tol_neg_binomial_2_log_lpmf(
8585
const ThetaVec& theta_0, double tolerance, int max_num_steps,
8686
const int hessian_block_size, const int solver,
8787
const int max_steps_line_search, std::ostream* msgs) {
88-
laplace_options_user_supplied ops{hessian_block_size, solver,
89-
tolerance,
90-
max_num_steps, laplace_line_search_options{max_steps_line_search},
91-
value_of(theta_0)};
88+
laplace_options_user_supplied ops{
89+
hessian_block_size,
90+
solver,
91+
tolerance,
92+
max_num_steps,
93+
laplace_line_search_options{max_steps_line_search},
94+
value_of(theta_0)};
9295
return laplace_marginal_density(
9396
neg_binomial_2_log_likelihood{},
9497
std::forward_as_tuple(eta, y, y_index, std::forward<Mean>(mean)),
@@ -142,11 +145,11 @@ struct neg_binomial_2_log_likelihood_summary {
142145
counts_per_group.data(), counts_per_group.size());
143146

144147
auto theta_offset = add(theta, mean);
145-
auto log_eta = log(eta);
148+
auto log_eta = log(eta);
146149
auto lse = to_ref(log_sum_exp(theta_offset, log_eta));
147150

148151
return sum(binomial_coefficient_log(subtract(add(y_map, eta), 1.0), y_map))
149-
+ sum(add(
152+
+ sum(add(
150153
// counts_per_group * (theta - log(eta + exp(theta)))
151154
elt_multiply(counts_per_group_map, subtract(theta_offset, lse)),
152155
// n_per_group * eta * (log(eta) - log(eta + exp(theta)))
@@ -186,10 +189,13 @@ inline auto laplace_marginal_tol_neg_binomial_2_log_summary_lpmf(
186189
const ThetaVec& theta_0, double tolerance, int max_num_steps,
187190
const int hessian_block_size, const int solver,
188191
const int max_steps_line_search, std::ostream* msgs) {
189-
laplace_options_user_supplied ops{hessian_block_size, solver,
190-
tolerance,
191-
max_num_steps, laplace_line_search_options{max_steps_line_search},
192-
value_of(theta_0)};
192+
laplace_options_user_supplied ops{
193+
hessian_block_size,
194+
solver,
195+
tolerance,
196+
max_num_steps,
197+
laplace_line_search_options{max_steps_line_search},
198+
value_of(theta_0)};
193199
return laplace_marginal_density(
194200
neg_binomial_2_log_likelihood_summary{},
195201
std::forward_as_tuple(eta, y, n_per_group, counts_per_group,

stan/math/mix/prob/laplace_marginal_poisson_log_lpmf.hpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,13 @@ inline auto laplace_marginal_tol_poisson_log_lpmf(
7777
const ThetaVec& theta_0, double tolerance, int max_num_steps,
7878
const int hessian_block_size, const int solver,
7979
const int max_steps_line_search, std::ostream* msgs) {
80-
laplace_options_user_supplied ops{hessian_block_size, solver,
81-
tolerance,
82-
max_num_steps, laplace_line_search_options{max_steps_line_search},
83-
value_of(theta_0)};
80+
laplace_options_user_supplied ops{
81+
hessian_block_size,
82+
solver,
83+
tolerance,
84+
max_num_steps,
85+
laplace_line_search_options{max_steps_line_search},
86+
value_of(theta_0)};
8487
return laplace_marginal_density(
8588
poisson_log_likelihood{},
8689
std::forward_as_tuple(y, y_index, std::forward<Mean>(mean)),

0 commit comments

Comments
 (0)