Skip to content

Commit 7f1a995

Browse files
committed
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
1 parent d2de83d commit 7f1a995

16 files changed

Lines changed: 180 additions & 157 deletions

stan/math/mix/functor/laplace_marginal_density_estimator.hpp

Lines changed: 55 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ namespace math {
2929
*/
3030
struct laplace_options_base {
3131
/* Size of the blocks in block diagonal hessian*/
32-
int hessian_block_size{1}; // 0
32+
int hessian_block_size{1}; // 0
3333
/**
3434
* Which linear solver to use inside the Newton step.
3535
*
@@ -45,19 +45,19 @@ struct laplace_options_base {
4545
* `Sigma = K_root * K_root^T` and form `B = I + K_root^T * W * K_root`.
4646
* 3. General LU: form `B = I + Sigma * W` and factorize with LU.
4747
*/
48-
int solver{1}; // 1
48+
int solver{1}; // 1
4949
/**
5050
* Iterations end when the absolute change in the optimization objective
5151
* is less than this tolerance.
5252
*
5353
* Note: the objective used for convergence is the one optimized by the
5454
* Newton/Wolfe loop (not the final Laplace-corrected log marginal density).
5555
*/
56-
double tolerance{1.49012e-08}; // 2
56+
double tolerance{1.49012e-08}; // 2
5757
/* Maximum number of steps*/
58-
int max_num_steps{500}; //3
59-
int allow_fallthrough{true}; // 4
60-
laplace_line_search_options line_search; //5
58+
int max_num_steps{500}; // 3
59+
int allow_fallthrough{true}; // 4
60+
laplace_line_search_options line_search; // 5
6161
laplace_options_base() = default;
6262
laplace_options_base(int hessian_block_size_, int solver_, double tolerance_,
6363
int max_num_steps_, bool allow_fallthrough_,
@@ -79,16 +79,16 @@ struct laplace_options<false> : public laplace_options_base {};
7979
template <>
8080
struct laplace_options<true> : public laplace_options_base {
8181
/* Value for user supplied initial theta */
82-
Eigen::VectorXd theta_0{0}; // 6
82+
Eigen::VectorXd theta_0{0}; // 6
8383

8484
template <typename ThetaVec>
8585
laplace_options(ThetaVec&& theta_0_, int hessian_block_size_, int solver_,
8686
double tolerance_, int max_num_steps_,
8787
bool allow_fallthrough_, int max_steps_line_search_)
8888
: laplace_options_base(hessian_block_size_, solver_, tolerance_,
89-
max_num_steps_, allow_fallthrough_, max_steps_line_search_),
90-
theta_0(std::forward<ThetaVec>(theta_0_)) {
91-
}
89+
max_num_steps_, allow_fallthrough_,
90+
max_steps_line_search_),
91+
theta_0(std::forward<ThetaVec>(theta_0_)) {}
9292
};
9393

9494
using laplace_options_default = laplace_options<false>;
@@ -101,84 +101,80 @@ using laplace_options_user_supplied = laplace_options<true>;
101101
*/
102102
inline auto generate_laplace_options(int theta_0_size) {
103103
auto ops = laplace_options_default{};
104-
return std::make_tuple(Eigen::VectorXd::Zero(theta_0_size).eval(), //0 -> 6
105-
ops.tolerance,
106-
ops.max_num_steps,
107-
ops.hessian_block_size,
108-
ops.solver,
109-
ops.line_search.max_iterations,
110-
static_cast<int>(ops.allow_fallthrough)
111-
);
104+
return std::make_tuple(
105+
Eigen::VectorXd::Zero(theta_0_size).eval(), // 0 -> 6
106+
ops.tolerance, ops.max_num_steps, ops.hessian_block_size, ops.solver,
107+
ops.line_search.max_iterations, static_cast<int>(ops.allow_fallthrough));
112108
}
113109

114-
115110
namespace internal {
116111

117112
template <std::size_t N, typename Tuple, typename CheckType>
118-
inline constexpr bool is_tuple_type_v = std::is_same_v<std::decay_t<CheckType>, std::tuple_element_t<N, std::decay_t<Tuple>>>;
113+
inline constexpr bool is_tuple_type_v
114+
= std::is_same_v<std::decay_t<CheckType>,
115+
std::tuple_element_t<N, std::decay_t<Tuple>>>;
119116

120117
template <typename Ops>
121118
inline constexpr auto tuple_to_laplace_options(Ops&& ops) {
122119
if constexpr (is_tuple_v<Ops>) {
123120
if constexpr (!is_eigen_v<std::tuple_element_t<0, std::decay_t<Ops>>>) {
124121
static_assert(
125-
sizeof(std::decay_t<Ops>*) == 0,
126-
"ERROR:(laplace_marginal_lpdf) The first laplace argument is "
127-
"expected to be an Eigen vector of dynamic size representing the "
128-
"initial theta_0.");
122+
sizeof(std::decay_t<Ops>*) == 0,
123+
"ERROR:(laplace_marginal_lpdf) The first laplace argument is "
124+
"expected to be an Eigen vector of dynamic size representing the "
125+
"initial theta_0.");
129126
}
130127
if constexpr (!is_tuple_type_v<1, Ops, double>) {
131128
static_assert(
132-
sizeof(std::decay_t<Ops>*) == 0,
133-
"ERROR:(laplace_marginal_lpdf) The second laplace argument is "
134-
"expected to be a double representing the tolerance.");
135-
129+
sizeof(std::decay_t<Ops>*) == 0,
130+
"ERROR:(laplace_marginal_lpdf) The second laplace argument is "
131+
"expected to be a double representing the tolerance.");
136132
}
137133
if constexpr (!is_tuple_type_v<2, Ops, int>) {
138134
static_assert(
139-
sizeof(std::decay_t<Ops>*) == 0,
140-
"ERROR:(laplace_marginal_lpdf) The third laplace argument is "
141-
"expected to be an int representing the maximum number of steps.");
135+
sizeof(std::decay_t<Ops>*) == 0,
136+
"ERROR:(laplace_marginal_lpdf) The third laplace argument is "
137+
"expected to be an int representing the maximum number of steps.");
142138
}
143139
if constexpr (!is_tuple_type_v<3, Ops, int>) {
144140
static_assert(
145-
sizeof(std::decay_t<Ops>*) == 0,
146-
"ERROR:(laplace_marginal_lpdf) The fourth laplace argument is "
147-
"expected to be an int representing the solver.");
141+
sizeof(std::decay_t<Ops>*) == 0,
142+
"ERROR:(laplace_marginal_lpdf) The fourth laplace argument is "
143+
"expected to be an int representing the solver.");
148144
}
149145
if constexpr (!is_tuple_type_v<4, Ops, int>) {
150146
static_assert(
151-
sizeof(std::decay_t<Ops>*) == 0,
152-
"ERROR:(laplace_marginal_lpdf) The fifth laplace argument is "
153-
"expected to be an int representing the hessian block size.");
147+
sizeof(std::decay_t<Ops>*) == 0,
148+
"ERROR:(laplace_marginal_lpdf) The fifth laplace argument is "
149+
"expected to be an int representing the hessian block size.");
154150
}
155151
if constexpr (!is_tuple_type_v<5, Ops, int>) {
156152
static_assert(
157-
sizeof(std::decay_t<Ops>*) == 0,
158-
"ERROR:(laplace_marginal_lpdf) The sixth laplace argument is "
159-
"expected to be an int representing the max steps line search.");
153+
sizeof(std::decay_t<Ops>*) == 0,
154+
"ERROR:(laplace_marginal_lpdf) The sixth laplace argument is "
155+
"expected to be an int representing the max steps line search.");
160156
}
161-
if constexpr (!(is_tuple_type_v<6, Ops, int> || is_tuple_type_v<6, Ops, bool>)) {
157+
if constexpr (!(is_tuple_type_v<6, Ops,
158+
int> || is_tuple_type_v<6, Ops, bool>)) {
162159
static_assert(
163-
sizeof(std::decay_t<Ops>*) == 0,
164-
"ERROR:(laplace_marginal_lpdf) The seventh laplace argument is "
165-
"expected to be an int representing allow fallthrough (0/1).");
160+
sizeof(std::decay_t<Ops>*) == 0,
161+
"ERROR:(laplace_marginal_lpdf) The seventh laplace argument is "
162+
"expected to be an int representing allow fallthrough (0/1).");
166163
}
167164
return laplace_options_user_supplied{
168-
value_of(std::get<0>(std::forward<Ops>(ops))),
169-
std::get<3>(ops),
170-
std::get<4>(ops),
171-
std::get<1>(ops),
172-
std::get<2>(ops),
173-
(std::get<6>(ops) > 0) ? true : false,
174-
std::get<5>(ops),
165+
value_of(std::get<0>(std::forward<Ops>(ops))),
166+
std::get<3>(ops),
167+
std::get<4>(ops),
168+
std::get<1>(ops),
169+
std::get<2>(ops),
170+
(std::get<6>(ops) > 0) ? true : false,
171+
std::get<5>(ops),
175172
};
176173
} else {
177174
return std::forward<Ops>(ops);
178175
}
179176
}
180177

181-
182178
template <typename ThetaVec, typename WR, typename L_t, typename A_vec,
183179
typename ThetaGrad, typename LU_t, typename KRoot>
184180
struct laplace_density_estimates {
@@ -1094,12 +1090,12 @@ inline auto run_newton_loop(SolverPolicy& solver, NewtonStateT& state,
10941090
* @param next_solver Name of the solver being attempted next
10951091
* @param e Exception that caused the fallback
10961092
*/
1097-
inline void log_solver_fallback(const bool allow_fallthrough, std::ostream* msgs, std::string_view context,
1093+
inline void log_solver_fallback(const bool allow_fallthrough,
1094+
std::ostream* msgs, std::string_view context,
10981095
Eigen::Index iter,
10991096
std::string_view failed_solver,
11001097
std::string_view next_solver,
11011098
const std::exception& e) {
1102-
11031099
// Build once so we don't interleave with other logs.
11041100
std::ostringstream os;
11051101
os << "[" << context << "] WARNING: solver fallback\n"
@@ -1109,13 +1105,10 @@ inline void log_solver_fallback(const bool allow_fallthrough, std::ostream* msgs
11091105
<< " " << std::left << std::setw(12) << "action:"
11101106
<< "trying " << next_solver << "\n";
11111107
if (!allow_fallthrough) {
1112-
throw std::domain_error(
1113-
std::string("[") + std::string(context)
1114-
+ "]");
1108+
throw std::domain_error(std::string("[") + std::string(context) + "]");
11151109
} else if (msgs) {
11161110
(*msgs) << os.str();
11171111
}
1118-
11191112
}
11201113

11211114
/**
@@ -1297,7 +1290,8 @@ inline auto laplace_marginal_density_est(
12971290
std::string solver_type
12981291
= (options.hessian_block_size == 1) ? "Diagonal" : "Block";
12991292
std::string failed = "solver 1 (" + solver_type + " Hessian-root Cholesky)";
1300-
log_solver_fallback(options.allow_fallthrough, msgs, "laplace_marginal_density", step_iter, failed,
1293+
log_solver_fallback(options.allow_fallthrough, msgs,
1294+
"laplace_marginal_density", step_iter, failed,
13011295
"solver 2 (Covariance-root Cholesky)", e);
13021296
}
13031297
try {
@@ -1308,7 +1302,8 @@ inline auto laplace_marginal_density_est(
13081302
throw_overstep, msgs);
13091303
}
13101304
} catch (const std::exception& e) {
1311-
log_solver_fallback(options.allow_fallthrough, msgs, "laplace_marginal_density", step_iter,
1305+
log_solver_fallback(options.allow_fallthrough, msgs,
1306+
"laplace_marginal_density", step_iter,
13121307
"solver 2 (Covariance-root Cholesky)",
13131308
"solver 3 (General LU solver)", e);
13141309
}

stan/math/mix/prob/laplace_latent_bernoulli_logit_rng.hpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,19 @@ namespace math {
2828
* \rng_arg
2929
* \msg_arg
3030
*/
31-
template <typename Mean, typename CovarFun,
32-
typename CovarArgs, typename OpsTuple, typename RNG>
31+
template <typename Mean, typename CovarFun, typename CovarArgs,
32+
typename OpsTuple, typename RNG>
3333
inline Eigen::VectorXd laplace_latent_tol_bernoulli_logit_rng(
3434
const std::vector<int>& y, const std::vector<int>& n_samples, Mean&& mean,
35-
CovarFun&& covariance_function, CovarArgs&& covar_args, OpsTuple&& ops, RNG& rng, std::ostream* msgs) {
35+
CovarFun&& covariance_function, CovarArgs&& covar_args, OpsTuple&& ops,
36+
RNG& rng, std::ostream* msgs) {
3637
return laplace_base_rng(
3738
bernoulli_logit_likelihood{},
3839
std::forward_as_tuple(to_vector(y), n_samples, std::forward<Mean>(mean)),
3940
std::forward<CovarFun>(covariance_function),
4041
std::forward<CovarArgs>(covar_args),
41-
internal::tuple_to_laplace_options(std::forward<OpsTuple>(ops)),
42-
rng, msgs);
42+
internal::tuple_to_laplace_options(std::forward<OpsTuple>(ops)), rng,
43+
msgs);
4344
}
4445

4546
/**

stan/math/mix/prob/laplace_latent_neg_binomial_2_log_rng.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ namespace math {
3535
* \rng_arg
3636
* \msg_arg
3737
*/
38-
template <typename Eta, typename Mean, typename CovarFun,
39-
typename CovarArgs, typename OpsTuple, typename RNG>
38+
template <typename Eta, typename Mean, typename CovarFun, typename CovarArgs,
39+
typename OpsTuple, typename RNG>
4040
inline Eigen::VectorXd laplace_latent_tol_neg_binomial_2_log_rng(
4141
const std::vector<int>& y, const std::vector<int>& y_index, Eta&& eta,
4242
Mean&& mean, CovarFun&& covariance_function, CovarArgs&& covar_args,
@@ -47,8 +47,8 @@ inline Eigen::VectorXd laplace_latent_tol_neg_binomial_2_log_rng(
4747
std::forward<Mean>(mean)),
4848
std::forward<CovarFun>(covariance_function),
4949
std::forward<CovarArgs>(covar_args),
50-
internal::tuple_to_laplace_options(std::forward<OpsTuple>(ops)),
51-
rng, msgs);
50+
internal::tuple_to_laplace_options(std::forward<OpsTuple>(ops)), rng,
51+
msgs);
5252
}
5353

5454
/**

stan/math/mix/prob/laplace_latent_poisson_log_rng.hpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,19 @@ namespace math {
3030
* \rng_arg
3131
* \msg_arg
3232
*/
33-
template <typename Mean, typename CovarFun,
34-
typename CovarArgs, typename OpsTuple, typename RNG>
33+
template <typename Mean, typename CovarFun, typename CovarArgs,
34+
typename OpsTuple, typename RNG>
3535
inline Eigen::VectorXd laplace_latent_tol_poisson_log_rng(
3636
const std::vector<int>& y, const std::vector<int>& y_index, Mean&& mean,
37-
CovarFun&& covariance_function, CovarArgs&& covar_args,
38-
OpsTuple&& ops,
37+
CovarFun&& covariance_function, CovarArgs&& covar_args, OpsTuple&& ops,
3938
RNG& rng, std::ostream* msgs) {
4039
return laplace_base_rng(
4140
poisson_log_likelihood{},
4241
std::forward_as_tuple(y, y_index, std::forward<Mean>(mean)),
4342
std::forward<CovarFun>(covariance_function),
4443
std::forward<CovarArgs>(covar_args),
45-
internal::tuple_to_laplace_options(std::forward<OpsTuple>(ops)),
46-
rng, msgs);
44+
internal::tuple_to_laplace_options(std::forward<OpsTuple>(ops)), rng,
45+
msgs);
4746
}
4847

4948
/**

stan/math/mix/prob/laplace_latent_rng.hpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,18 @@ namespace math {
2929
* \rng_arg
3030
* \msg_arg
3131
*/
32-
template <typename LLFunc, typename LLArgs,
33-
typename CovarFun, typename CovarArgs, typename OpsTuple, typename RNG>
34-
inline auto laplace_latent_tol_rng(
35-
LLFunc&& L_f, LLArgs&& ll_args, CovarFun&& covariance_function,
36-
CovarArgs&& covar_args, OpsTuple&& ops, RNG& rng, std::ostream* msgs) {
37-
return laplace_base_rng(std::forward<LLFunc>(L_f),
38-
std::forward<LLArgs>(ll_args),
39-
std::forward<CovarFun>(covariance_function),
40-
std::forward<CovarArgs>(covar_args),
41-
internal::tuple_to_laplace_options(std::forward<OpsTuple>(ops)),
42-
rng, msgs);
32+
template <typename LLFunc, typename LLArgs, typename CovarFun,
33+
typename CovarArgs, typename OpsTuple, typename RNG>
34+
inline auto laplace_latent_tol_rng(LLFunc&& L_f, LLArgs&& ll_args,
35+
CovarFun&& covariance_function,
36+
CovarArgs&& covar_args, OpsTuple&& ops,
37+
RNG& rng, std::ostream* msgs) {
38+
return laplace_base_rng(
39+
std::forward<LLFunc>(L_f), std::forward<LLArgs>(ll_args),
40+
std::forward<CovarFun>(covariance_function),
41+
std::forward<CovarArgs>(covar_args),
42+
internal::tuple_to_laplace_options(std::forward<OpsTuple>(ops)), rng,
43+
msgs);
4344
}
4445

4546
/**

stan/math/mix/prob/laplace_marginal.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@ namespace math {
2727
*/
2828
template <bool propto = false, typename LFun, typename LArgs, typename CovarFun,
2929
typename CovarArgs, typename OpsTuple>
30-
inline auto laplace_marginal_tol(
31-
LFun&& L_f, LArgs&& l_args, CovarFun&& covariance_function,
32-
CovarArgs&& covar_args, OpsTuple&& ops,std::ostream* msgs) {
30+
inline auto laplace_marginal_tol(LFun&& L_f, LArgs&& l_args,
31+
CovarFun&& covariance_function,
32+
CovarArgs&& covar_args, OpsTuple&& ops,
33+
std::ostream* msgs) {
3334
return laplace_marginal_density(
3435
std::forward<LFun>(L_f), std::forward<LArgs>(l_args),
3536
std::forward<CovarFun>(covariance_function),

stan/math/mix/prob/laplace_marginal_bernoulli_logit_lpmf.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ struct bernoulli_logit_likelihood {
5252
* \laplace_options
5353
* \msg_arg
5454
*/
55-
template <bool propto = false, typename Mean,
56-
typename CovarFun, typename CovarArgs, typename OpsTuple>
55+
template <bool propto = false, typename Mean, typename CovarFun,
56+
typename CovarArgs, typename OpsTuple>
5757
inline auto laplace_marginal_tol_bernoulli_logit_lpmf(
5858
const std::vector<int>& y, const std::vector<int>& n_samples, Mean&& mean,
59-
CovarFun&& covariance_function, CovarArgs&& covar_args,
60-
OpsTuple&& ops, std::ostream* msgs) {
59+
CovarFun&& covariance_function, CovarArgs&& covar_args, OpsTuple&& ops,
60+
std::ostream* msgs) {
6161
return laplace_marginal_density(
6262
bernoulli_logit_likelihood{},
6363
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: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ struct neg_binomial_2_log_likelihood {
7676
* \laplace_options
7777
* \msg_arg
7878
*/
79-
template <bool propto = false, typename Eta, typename Mean,
80-
typename CovarFun, typename CovarArgs, typename OpsTuple>
79+
template <bool propto = false, typename Eta, typename Mean, typename CovarFun,
80+
typename CovarArgs, typename OpsTuple>
8181
inline auto laplace_marginal_tol_neg_binomial_2_log_lpmf(
8282
const std::vector<int>& y, const std::vector<int>& y_index, const Eta& eta,
8383
Mean&& mean, CovarFun&& covariance_function, CovarArgs&& covar_args,
@@ -170,13 +170,13 @@ struct neg_binomial_2_log_likelihood_summary {
170170
* \laplace_options
171171
* \msg_arg
172172
*/
173-
template <bool propto = false, typename Eta, typename Mean,
174-
typename CovarFun, typename CovarArgs, typename OpsTuple>
173+
template <bool propto = false, typename Eta, typename Mean, typename CovarFun,
174+
typename CovarArgs, typename OpsTuple>
175175
inline auto laplace_marginal_tol_neg_binomial_2_log_summary_lpmf(
176176
const std::vector<int>& y, const std::vector<int>& n_per_group,
177177
const std::vector<int>& counts_per_group, const Eta& eta, Mean&& mean,
178-
CovarFun&& covariance_function, CovarArgs&& covar_args,
179-
OpsTuple&& ops, std::ostream* msgs) {
178+
CovarFun&& covariance_function, CovarArgs&& covar_args, OpsTuple&& ops,
179+
std::ostream* msgs) {
180180
return laplace_marginal_density(
181181
neg_binomial_2_log_likelihood_summary{},
182182
std::forward_as_tuple(eta, y, n_per_group, counts_per_group,

0 commit comments

Comments
 (0)