Skip to content

Commit 31116c0

Browse files
committed
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
1 parent 62432fb commit 31116c0

File tree

5 files changed

+62
-82
lines changed

5 files changed

+62
-82
lines changed

stan/math/prim/fun/size.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ inline int64_t size(const T& m) {
3434
return m.size();
3535
}
3636

37-
3837
template <typename T, require_tuple_t<T>* = nullptr>
3938
inline int64_t size(const T& /*t*/) {
4039
return std::tuple_size<std::remove_reference_t<T>>{};

stan/math/prim/fun/vector_seq_view.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ using is_matrix_or_std_vector_or_tuple
1313

1414
template <typename T>
1515
using is_scalar_container = math::disjunction<
16-
is_matrix<T>,
17-
math::is_tuple<T>,
16+
is_matrix<T>, math::is_tuple<T>,
1817
math::conjunction<is_std_vector<T>, is_stan_scalar<value_type_t<T>>>>;
1918
} // namespace internal
2019

stan/math/prim/prob/gaussian_copula_cholesky_lpdf.hpp

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,25 @@ namespace math {
1717
namespace internal {
1818

1919
template <typename Ty_elem, typename Ttuple, std::size_t... I>
20-
auto apply_lcdfs_elem_impl(
21-
Ty_elem&& y_elem, Ttuple&& lcdf_tuple, std::index_sequence<I...>) {
20+
auto apply_lcdfs_elem_impl(Ty_elem&& y_elem, Ttuple&& lcdf_tuple,
21+
std::index_sequence<I...>) {
2222
auto&& lcdf_func = std::get<0>(lcdf_tuple);
23-
return lcdf_func(
24-
std::forward<Ty_elem>(y_elem),
25-
std::get<I + 1>(std::forward<Ttuple>(lcdf_tuple))...
26-
);
23+
return lcdf_func(std::forward<Ty_elem>(y_elem),
24+
std::get<I + 1>(std::forward<Ttuple>(lcdf_tuple))...);
2725
}
2826

2927
template <typename Ty, typename Ttuple>
3028
auto apply_lcdfs(Ty&& y, Ttuple&& lcdf_tuple) {
3129
return index_apply<std::tuple_size<std::remove_reference_t<Ttuple>>{}>(
32-
[&y, &lcdf_tuple](auto... Is) {
33-
return std::make_tuple(
34-
apply_lcdfs_elem_impl(
35-
y[Is], std::get<Is>(lcdf_tuple), std::make_index_sequence<
36-
std::tuple_size<std::remove_reference_t<decltype(std::get<Is>(lcdf_tuple))>>{} - 1>{}
37-
)...
38-
);
39-
});
40-
}
30+
[&y, &lcdf_tuple](auto... Is) {
31+
return std::make_tuple(apply_lcdfs_elem_impl(
32+
y[Is], std::get<Is>(lcdf_tuple),
33+
std::make_index_sequence<std::tuple_size<std::remove_reference_t<
34+
decltype(std::get<Is>(lcdf_tuple))>>{}
35+
- 1>{})...);
36+
});
4137
}
42-
38+
} // namespace internal
4339

4440
/** \ingroup multivar_dists
4541
* The log of the Gaussian copula density for the given y and
@@ -67,15 +63,17 @@ auto apply_lcdfs(Ty&& y, Ttuple&& lcdf_tuple) {
6763
* @tparam T_chol Type of cholesky factor.
6864
*/
6965
template <bool propto, typename T_y, typename T_lcdf_fun_tuple, typename T_chol>
70-
auto gaussian_copula_cholesky_lpdf(
71-
const T_y& y, const T_lcdf_fun_tuple& lcdf_fun_tuple, const T_chol chol) {
66+
auto gaussian_copula_cholesky_lpdf(const T_y& y,
67+
const T_lcdf_fun_tuple& lcdf_fun_tuple,
68+
const T_chol chol) {
7269
static constexpr const char* function = "gaussian_copula_cholesky_lpdf";
7370

7471
using T_y_ref = ref_type_t<T_y>;
7572
using T_chol_ref = ref_type_t<T_chol>;
7673
using T_lcdf_ref = ref_type_t<T_lcdf_fun_tuple>;
7774

78-
check_consistent_sizes_mvt(function, "y", y, "lcdf_fun_tuple", lcdf_fun_tuple);
75+
check_consistent_sizes_mvt(function, "y", y, "lcdf_fun_tuple",
76+
lcdf_fun_tuple);
7977
const size_t size_mvt_y = size_mvt(y);
8078
const size_t size_mvt_lcdf_tuple = size_mvt(lcdf_fun_tuple);
8179
T_y_ref y_ref = y;
@@ -84,7 +82,9 @@ auto gaussian_copula_cholesky_lpdf(
8482

8583
vector_seq_view<T_y_ref> y_vec(y_ref);
8684
vector_seq_view<T_lcdf_ref> lcdf_tuple_vec(lcdf_tuple_ref);
87-
using T_return = return_type_t<T_y, decltype(internal::apply_lcdfs(y_vec[0], lcdf_tuple_vec[0])), T_chol>;
85+
using T_return = return_type_t<
86+
T_y, decltype(internal::apply_lcdfs(y_vec[0], lcdf_tuple_vec[0])),
87+
T_chol>;
8888

8989
if (size_mvt_y == 0) {
9090
return T_return(0);
@@ -135,14 +135,14 @@ auto gaussian_copula_cholesky_lpdf(
135135
const auto& func_i = lcdf_tuple_vec[i];
136136

137137
const auto& res = internal::apply_lcdfs(y_i, func_i);
138-
const auto& u = index_apply<std::tuple_size<std::remove_reference_t<decltype(res)>>{}>(
139-
[&res, size_y](auto... Is) {
140-
Eigen::Matrix<T_return, Eigen::Dynamic, 1> u_inner(size_y);
141-
static_cast<void>(std::initializer_list<int>{
142-
(u_inner[Is] = std::get<Is>(res), 0)...
138+
const auto& u = index_apply<
139+
std::tuple_size<std::remove_reference_t<decltype(res)>>{}>(
140+
[&res, size_y](auto... Is) {
141+
Eigen::Matrix<T_return, Eigen::Dynamic, 1> u_inner(size_y);
142+
static_cast<void>(std::initializer_list<int>{
143+
(u_inner[Is] = std::get<Is>(res), 0)...});
144+
return u_inner;
143145
});
144-
return u_inner;
145-
});
146146
check_bounded(function, "LCDF-transformed inputs", u, NEGATIVE_INFTY, 0);
147147
q[i] = std_normal_log_qf(u);
148148
lp -= std_normal_lpdf<propto>(q[i]);
@@ -153,8 +153,9 @@ auto gaussian_copula_cholesky_lpdf(
153153
}
154154

155155
template <typename T_y, typename T_lcdf_fun_tuple, typename T_chol>
156-
auto gaussian_copula_cholesky_lpdf(
157-
const T_y& y, const T_lcdf_fun_tuple& lcdf_fun_tuple, const T_chol chol) {
156+
auto gaussian_copula_cholesky_lpdf(const T_y& y,
157+
const T_lcdf_fun_tuple& lcdf_fun_tuple,
158+
const T_chol chol) {
158159
return gaussian_copula_cholesky_lpdf<false>(y, lcdf_fun_tuple, chol);
159160
}
160161
} // namespace math

test/unit/math/mix/prob/gaussian_copula_cholesky_test.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@ TEST_F(AgradRev, ProbDistributionsGaussCopulaCholesky) {
44
// Bind functors for compatibility with AD framework
55
auto f = [](const auto func1, const auto func2) {
66
return [=](const auto& y, const auto& args, const auto& sigma) {
7-
auto lcdf_functors = std::make_tuple(
8-
std::make_tuple(func1, args[0]),
9-
std::make_tuple(func2, args[1])
10-
);
7+
auto lcdf_functors = std::make_tuple(std::make_tuple(func1, args[0]),
8+
std::make_tuple(func2, args[1]));
119
auto sigma_sym = stan::math::multiply(0.5, sigma + sigma.transpose());
1210
auto L = stan::math::cholesky_decompose(sigma_sym);
1311
return stan::math::gaussian_copula_cholesky_lpdf(y, lcdf_functors, L);
@@ -24,9 +22,7 @@ TEST_F(AgradRev, ProbDistributionsGaussCopulaCholesky) {
2422
auto func1 = [](const auto& y, const auto& mu) {
2523
return stan::math::normal_lcdf(y, mu, 1.0);
2624
};
27-
auto func2 = [](const auto& y) {
28-
return stan::math::std_normal_lcdf(y);
29-
};
25+
auto func2 = [](const auto& y) { return stan::math::std_normal_lcdf(y); };
3026

3127
Eigen::MatrixXd Sigma22(2, 2);
3228
Sigma22 << 2.0, 0.5, 0.5, 1.1;

test/unit/math/prim/prob/gaussian_copula_cholesky_lpdf_test.cpp

Lines changed: 28 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
#include <gtest/gtest.h>
33

44
TEST(ProbDistributionsGaussianCopulaCholesky, EqualsMultiNormalCholesky) {
5+
using stan::math::diag_pre_multiply;
56
using stan::math::gaussian_copula_cholesky_lpdf;
67
using stan::math::multi_normal_cholesky_lpdf;
7-
using stan::math::diag_pre_multiply;
88

99
Eigen::VectorXd y(2);
1010
y << 1, 3;
@@ -22,25 +22,19 @@ TEST(ProbDistributionsGaussianCopulaCholesky, EqualsMultiNormalCholesky) {
2222
return stan::math::normal_lcdf(y, mu, sigma);
2323
};
2424

25-
auto std_norm_lcdf = [](auto&& y) {
26-
return stan::math::std_normal_lcdf(y);
27-
};
25+
auto std_norm_lcdf = [](auto&& y) { return stan::math::std_normal_lcdf(y); };
2826

2927
// y[0] ~ normal(0.1, 2)
3028
// y[1] ~ normal(0, 1)
31-
auto lcdf_functors = std::make_tuple(
32-
std::make_tuple(norm_lcdf, mu[0], sd[0]),
33-
std::make_tuple(std_norm_lcdf)
34-
);
35-
36-
double log_prob =
37-
stan::math::normal_lpdf(y[0], 0.1, 2) +
38-
stan::math::std_normal_lpdf(y[1]) +
39-
gaussian_copula_cholesky_lpdf(y, lcdf_functors, chol);
29+
auto lcdf_functors = std::make_tuple(std::make_tuple(norm_lcdf, mu[0], sd[0]),
30+
std::make_tuple(std_norm_lcdf));
4031

32+
double log_prob = stan::math::normal_lpdf(y[0], 0.1, 2)
33+
+ stan::math::std_normal_lpdf(y[1])
34+
+ gaussian_copula_cholesky_lpdf(y, lcdf_functors, chol);
4135

42-
double expected_log_prob = multi_normal_cholesky_lpdf(
43-
y, mu, diag_pre_multiply(sd, chol));
36+
double expected_log_prob
37+
= multi_normal_cholesky_lpdf(y, mu, diag_pre_multiply(sd, chol));
4438

4539
EXPECT_FLOAT_EQ(log_prob, expected_log_prob);
4640
}
@@ -62,15 +56,13 @@ TEST(ProbDistributionsGaussianCopulaCholesky, NonNormalMarginals) {
6256

6357
// y[0] ~ gamma(2, 1)
6458
// y[1] ~ exponential(2)
65-
auto lcdf_functors = std::make_tuple(
66-
std::make_tuple(gamma_lcdf, 2.0, 1.0),
67-
std::make_tuple(exp_lcdf, 2.0)
68-
);
59+
auto lcdf_functors = std::make_tuple(std::make_tuple(gamma_lcdf, 2.0, 1.0),
60+
std::make_tuple(exp_lcdf, 2.0));
6961

70-
double log_prob =
71-
stan::math::gamma_lpdf(y[0], 2.0, 1.0) +
72-
stan::math::exponential_lpdf(y[1], 2.0) +
73-
stan::math::gaussian_copula_cholesky_lpdf(y, lcdf_functors, chol);
62+
double log_prob
63+
= stan::math::gamma_lpdf(y[0], 2.0, 1.0)
64+
+ stan::math::exponential_lpdf(y[1], 2.0)
65+
+ stan::math::gaussian_copula_cholesky_lpdf(y, lcdf_functors, chol);
7466

7567
EXPECT_FLOAT_EQ(log_prob, -16.61005941);
7668
}
@@ -92,32 +84,25 @@ TEST(ProbDistributionsGaussianCopulaCholesky, Errors) {
9284
return stan::math::exponential_lcdf(y, scale);
9385
};
9486

95-
auto lcdf_functors = std::make_tuple(
96-
std::make_tuple(gamma_lcdf, 2.0, 1.0),
97-
std::make_tuple(exp_lcdf, 2.0)
98-
);
87+
auto lcdf_functors = std::make_tuple(std::make_tuple(gamma_lcdf, 2.0, 1.0),
88+
std::make_tuple(exp_lcdf, 2.0));
9989

100-
auto small_lcdf_functors = std::make_tuple(
101-
std::make_tuple(gamma_lcdf, 2.0, 1.0)
102-
);
90+
auto small_lcdf_functors
91+
= std::make_tuple(std::make_tuple(gamma_lcdf, 2.0, 1.0));
10392

104-
auto invalid_lcdf_functors = std::make_tuple(
105-
std::make_tuple(gamma_lcdf, 2.0, 1.0),
106-
std::make_tuple([](auto&& y){ return y * 10; })
107-
);
93+
auto invalid_lcdf_functors
94+
= std::make_tuple(std::make_tuple(gamma_lcdf, 2.0, 1.0),
95+
std::make_tuple([](auto&& y) { return y * 10; }));
10896

10997
EXPECT_THROW(
110-
stan::math::gaussian_copula_cholesky_lpdf(y, small_lcdf_functors, chol),
111-
std::invalid_argument
112-
);
98+
stan::math::gaussian_copula_cholesky_lpdf(y, small_lcdf_functors, chol),
99+
std::invalid_argument);
113100

114101
EXPECT_THROW(
115-
stan::math::gaussian_copula_cholesky_lpdf(small_y, lcdf_functors, chol),
116-
std::invalid_argument
117-
);
102+
stan::math::gaussian_copula_cholesky_lpdf(small_y, lcdf_functors, chol),
103+
std::invalid_argument);
118104

119105
EXPECT_THROW(
120-
stan::math::gaussian_copula_cholesky_lpdf(y, invalid_lcdf_functors, chol),
121-
std::domain_error
122-
);
106+
stan::math::gaussian_copula_cholesky_lpdf(y, invalid_lcdf_functors, chol),
107+
std::domain_error);
123108
}

0 commit comments

Comments
 (0)