Skip to content

Commit 7c33da2

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

9 files changed

Lines changed: 110 additions & 81 deletions

File tree

stan/math/mix/functor/laplace_likelihood.hpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,13 @@ inline auto conditional_copy_and_promote(Args&&... args) {
6161
},
6262
std::forward<decltype(arg)>(arg));
6363
} else if constexpr (is_std_vector_v<decltype(arg)>) {
64-
std::vector<decltype(conditional_copy_and_promote<Filter, PromotedType,
65-
CopyType>(arg[0]))> ret;
64+
std::vector<decltype(conditional_copy_and_promote<
65+
Filter, PromotedType, CopyType>(arg[0]))>
66+
ret;
6667
for (std::size_t i = 0; i < arg.size(); ++i) {
67-
ret.push_back(conditional_copy_and_promote<Filter, PromotedType,
68-
CopyType>(arg[i]));
68+
ret.push_back(
69+
conditional_copy_and_promote<Filter, PromotedType, CopyType>(
70+
arg[i]));
6971
}
7072
return ret;
7173
} else {

stan/math/mix/functor/laplace_marginal_density.hpp

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,10 @@ inline void set_zero_adjoint(Output&& output) {
295295
} else if constexpr (is_stan_scalar_v<output_i_t>) {
296296
output_i.adj() = 0;
297297
} else {
298-
static_assert(1, "INTERNAL ERROR:(laplace_marginal_lpdf) set_zero_adjoints was not able to deduce the actiopns needed for the given type.");
298+
static_assert(
299+
1,
300+
"INTERNAL ERROR:(laplace_marginal_lpdf) set_zero_adjoints was "
301+
"not able to deduce the actiopns needed for the given type.");
299302
}
300303
},
301304
std::forward<Output>(output));
@@ -328,7 +331,10 @@ inline void collect_adjoints(Output& output, Input1&& precalc) {
328331
precalc_i.adj() = 0;
329332
}
330333
} else {
331-
static_assert(1, "INTERNAL ERROR:(laplace_marginal_lpdf) collect_adjoints was not able to deduce the actiopns needed for the given type.");
334+
static_assert(
335+
1,
336+
"INTERNAL ERROR:(laplace_marginal_lpdf) collect_adjoints was not "
337+
"able to deduce the actiopns needed for the given type.");
332338
}
333339
},
334340
std::forward<Output>(output), std::forward<Input1>(precalc));
@@ -765,10 +771,12 @@ template <typename Output, typename Input1>
765771
inline void collect_adjoints(Output&& output, const vari* ret,
766772
Input1&& precalc) {
767773
if constexpr (is_tuple_v<Output>) {
768-
static_assert(1,"INTERNAL ERROR:(laplace_marginal_lpdf)"
774+
static_assert(1,
775+
"INTERNAL ERROR:(laplace_marginal_lpdf)"
769776
"Accumulate Adjoints called on a tuple, but tuples cannot be "
770777
"on the reverse mode stack!"
771-
"This is an internal error, please report it to the stan github as an issue.");
778+
"This is an internal error, please report it to the stan "
779+
"github as an issue.");
772780
} else if constexpr (is_std_vector_v<Output>) {
773781
if constexpr (!is_var_v<value_type_t<Output>>) {
774782
const auto output_size = output.size();
@@ -806,7 +814,10 @@ inline void collect_adjoints(Output&& output, Input1&& precalc) {
806814
} else if constexpr (is_stan_scalar_v<output_i_t>) {
807815
output_i += precalc_i;
808816
} else {
809-
static_assert(1, "INTERNAL ERROR:(laplace_marginal_lpdf) collect_adjoints was not able to deduce the actiopns needed for the given type.");
817+
static_assert(
818+
1,
819+
"INTERNAL ERROR:(laplace_marginal_lpdf) collect_adjoints was not "
820+
"able to deduce the actiopns needed for the given type.");
810821
}
811822
},
812823
std::forward<Output>(output), std::forward<Input1>(precalc));
@@ -832,7 +843,10 @@ inline void copy_compute_s2(Output&& output, Input1&& precalc) {
832843
} else if constexpr (is_stan_scalar_v<output_i_t>) {
833844
output_i += (0.5 * precalc_i.adj());
834845
} else {
835-
static_assert(1, "INTERNAL ERROR:(laplace_marginal_lpdf) copy_compute_s2 was not able to deduce the actiopns needed for the given type.");
846+
static_assert(
847+
1,
848+
"INTERNAL ERROR:(laplace_marginal_lpdf) copy_compute_s2 was not "
849+
"able to deduce the actiopns needed for the given type.");
836850
}
837851
},
838852
std::forward<Output>(output), std::forward<Input1>(precalc));
@@ -886,11 +900,12 @@ inline void print_adjoint(Output&& output) {
886900
} else if constexpr (is_stan_scalar_v<Output>) {
887901
std::cout << "adj: " << output.adj() << std::endl;
888902
} else {
889-
static_assert(1, "INTERNAL ERROR:(laplace_marginal_lpdf) print_adjoint was not able to deduce the actiopns needed for the given type.");
903+
static_assert(1,
904+
"INTERNAL ERROR:(laplace_marginal_lpdf) print_adjoint was "
905+
"not able to deduce the actiopns needed for the given type.");
890906
}
891907
}
892908

893-
894909
template <typename Arg, typename Precalc>
895910
inline void laplace_tuple_collect_adjoints(var ret, Arg&& arg,
896911
Precalc&& precalc) {

stan/math/prim/fun/promote_scalar.hpp

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,26 @@
1010
namespace stan {
1111
namespace math {
1212

13-
1413
template <typename PromotionScalars, typename UnPromotedTypes>
1514
inline constexpr auto promote_scalar(UnPromotedTypes&& x) {
16-
if constexpr (std::is_same_v<PromotionScalars, scalar_type_t<UnPromotedTypes>>) {
15+
if constexpr (std::is_same_v<PromotionScalars,
16+
scalar_type_t<UnPromotedTypes>>) {
1717
return std::forward<UnPromotedTypes>(x);
18-
} else if constexpr (is_tuple_v<PromotionScalars> && is_tuple_v<UnPromotedTypes>) {
18+
} else if constexpr (is_tuple_v<
19+
PromotionScalars> && is_tuple_v<UnPromotedTypes>) {
1920
return index_apply<std::tuple_size<std::decay_t<UnPromotedTypes>>::value>(
20-
[&x](auto... Is) {
21-
return std::make_tuple(
22-
promote_scalar<std::decay_t<decltype(std::get<Is>(
23-
std::declval<PromotionScalars>()))>>(std::get<Is>(x))...);
24-
});
21+
[&x](auto... Is) {
22+
return std::make_tuple(
23+
promote_scalar<std::decay_t<decltype(std::get<Is>(
24+
std::declval<PromotionScalars>()))>>(std::get<Is>(x))...);
25+
});
2526
} else if constexpr (is_tuple_v<UnPromotedTypes>) {
26-
return stan::math::apply([](auto&&... args) {
27-
return std::make_tuple(promote_scalar<PromotionScalars>(std::forward<decltype(args)>(args))...);
28-
}, std::forward<UnPromotedTypes>(x));
27+
return stan::math::apply(
28+
[](auto&&... args) {
29+
return std::make_tuple(promote_scalar<PromotionScalars>(
30+
std::forward<decltype(args)>(args))...);
31+
},
32+
std::forward<UnPromotedTypes>(x));
2933
} else if constexpr (is_std_vector_v<UnPromotedTypes>) {
3034
const auto x_size = x.size();
3135
promote_scalar_t<PromotionScalars, UnPromotedTypes> ret(x_size);
@@ -42,7 +46,6 @@ inline constexpr auto promote_scalar(UnPromotedTypes&& x) {
4246
}
4347
}
4448

45-
4649
} // namespace math
4750
} // namespace stan
4851

stan/math/prim/functor/filter_map.hpp

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ namespace internal {
1616
* Filter a tuple and apply a functor to each element that passes the filter.
1717
* @note The `Filter` will only check `T` and if `T` is a tuple, it will
1818
* recursively check each element of the tuple. But it will not inspect into
19-
* `std::vector` elements automatically. If you want to inspect the inner element
20-
* of an `std::vector` your type trait must do that itself.
19+
* `std::vector` elements automatically. If you want to inspect the inner
20+
* element of an `std::vector` your type trait must do that itself.
2121
* @tparam Filter a struct that accepts one template parameter and has a static
2222
* constexpr bool member named value that is true if the type should be
2323
* included in the output tuple.
@@ -33,23 +33,25 @@ namespace internal {
3333
* @return a tuple with the functor applied to each element which passed the
3434
* filter.
3535
*/
36-
template <template <typename...> class Filter, bool InVector = false, bool InTuple = false,
37-
typename F, typename T>
36+
template <template <typename...> class Filter, bool InVector = false,
37+
bool InTuple = false, typename F, typename T>
3838
inline constexpr decltype(auto) filter_map(F&& f, T&& x) {
3939
if constexpr (inspect_tuple_v<Filter, T>) {
4040
if constexpr (is_tuple_v<T>) {
41-
auto ret = stan::math::apply([&f](auto&&... args) {
42-
return stan::math::tuple_concat(
43-
filter_map<Filter, false, true>(f, std::forward<decltype(args)>(args))...
44-
);
45-
}, std::forward<T>(x));
41+
auto ret = stan::math::apply(
42+
[&f](auto&&... args) {
43+
return stan::math::tuple_concat(filter_map<Filter, false, true>(
44+
f, std::forward<decltype(args)>(args))...);
45+
},
46+
std::forward<T>(x));
4647
/* If we are in at this stage, we want tuple_concat to return a tuple here
4748
* So we return a tuple(tuple()) so that tuple_cat concats
4849
* the first layer of tuple.
49-
* For example, if our input is a tuple(double, tuple(double, vec<double>))
50-
* with an identity filter we want tuple_concat to return a
50+
* For example, if our input is a tuple(double, tuple(double,
51+
* vec<double>)) with an identity filter we want tuple_concat to return a
5152
* tuple(double, tuple(double, vec<double>)).
52-
* Without the double tuple we would get back a tuple(double, double, vec<double>).
53+
* Without the double tuple we would get back a tuple(double, double,
54+
* vec<double>).
5355
*/
5456
if constexpr (InTuple) {
5557
return partially_forward_as_tuple(std::move(ret));
@@ -77,27 +79,29 @@ inline constexpr decltype(auto) filter_map(F&& f, T&& x) {
7779
if constexpr (InVector) {
7880
return std::forward<F>(f)(std::forward<T>(x));
7981
} else {
80-
return partially_forward_as_tuple(std::forward<F>(f)(std::forward<T>(x)));
82+
return partially_forward_as_tuple(
83+
std::forward<F>(f)(std::forward<T>(x)));
8184
}
8285
}
8386
} else {
8487
if constexpr (InVector) {
8588
return std::forward<F>(f)(std::forward<T>(x));
8689
} else {
87-
return partially_forward_as_tuple(std::forward<F>(f)(std::forward<T>(x)));
90+
return partially_forward_as_tuple(
91+
std::forward<F>(f)(std::forward<T>(x)));
8892
}
8993
}
9094
} else {
9195
return std::make_tuple();
9296
}
9397
}
94-
}
98+
} // namespace internal
9599
/**
96100
* Filter a tuple and apply a functor to each element that passes the filter.
97101
* @note The `Filter` will only check `T` and if `T` is a tuple, it will
98102
* recursively check each element of the tuple. But it will not inspect into
99-
* `std::vector` elements automatically. If you want to inspect the inner element
100-
* of an `std::vector` your type trait must do that itself.
103+
* `std::vector` elements automatically. If you want to inspect the inner
104+
* element of an `std::vector` your type trait must do that itself.
101105
* @tparam Filter a struct that accepts one template parameter and has a static
102106
* constexpr bool member named value that is true if the type should be
103107
* included in the output tuple.
@@ -108,11 +112,10 @@ inline constexpr decltype(auto) filter_map(F&& f, T&& x) {
108112
* @return a tuple with the functor applied to each element which passed the
109113
* filter.
110114
*/
111-
template <template <typename...> class Filter,
112-
typename F, typename T, require_tuple_t<T>* = nullptr>
115+
template <template <typename...> class Filter, typename F, typename T,
116+
require_tuple_t<T>* = nullptr>
113117
inline constexpr decltype(auto) filter_map(F&& f, T&& x) {
114-
return internal::filter_map<Filter>(
115-
std::forward<F>(f), std::forward<T>(x));
118+
return internal::filter_map<Filter>(std::forward<F>(f), std::forward<T>(x));
116119
}
117120
} // namespace math
118121
} // namespace stan

stan/math/prim/functor/tuple_concat.hpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,7 @@ inline auto constexpr tuple_concat_impl(Tuple1&& x, Tuple2&& y, Tuple3&& z,
4343
* @tparam Tuple Tuple type.
4444
* @param x Tuple.
4545
*/
46-
inline constexpr auto tuple_concat() noexcept {
47-
return std::make_tuple();
48-
}
49-
46+
inline constexpr auto tuple_concat() noexcept { return std::make_tuple(); }
5047

5148
/**
5249
* Base case to pass a tuple forward.

stan/math/prim/meta/contains_tuple.hpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,16 @@ template <typename T, typename... VecArgs>
1414
struct contains_tuple_impl<std::vector<T, VecArgs...>> {
1515
static constexpr bool value = contains_tuple_impl<T>::value;
1616
};
17-
}
17+
} // namespace internal
1818

1919
/**
2020
* Check if the type is a tuple or contains a tuple
2121
* @tparam T type to check
2222
*/
2323
template <typename T>
2424
struct contains_tuple {
25-
static constexpr bool value = internal::contains_tuple_impl<std::decay_t<T>>::value;
25+
static constexpr bool value
26+
= internal::contains_tuple_impl<std::decay_t<T>>::value;
2627
};
2728
template <typename T>
2829
inline constexpr bool contains_tuple_v = contains_tuple<std::decay_t<T>>::value;
@@ -31,7 +32,8 @@ inline constexpr bool contains_tuple_v = contains_tuple<std::decay_t<T>>::value;
3132
* Check if the type is a std::vector containing a tuple
3233
*/
3334
template <typename T>
34-
inline constexpr bool is_std_vector_containing_tuple_v = is_std_vector_v<std::decay_t<T>> && contains_tuple_v<std::decay_t<T>>;
35+
inline constexpr bool is_std_vector_containing_tuple_v
36+
= is_std_vector_v<std::decay_t<T>>&& contains_tuple_v<std::decay_t<T>>;
3537

3638
namespace internal {
3739
template <template <typename...> class Filter, typename T>
@@ -41,10 +43,10 @@ struct inspect_tuple {
4143

4244
template <template <typename...> class Filter, typename... Types>
4345
struct inspect_tuple<Filter, std::tuple<Types...>> {
44-
static constexpr bool value = Filter<std::tuple<Types...>>::value ||
45-
(inspect_tuple<Filter, Types>::value || ...);
46+
static constexpr bool value = Filter<std::tuple<Types...>>::value
47+
|| (inspect_tuple<Filter, Types>::value || ...);
4648
};
47-
}
49+
} // namespace internal
4850

4951
/**
5052
* Check if a tuple or type contains a tuple that passes the filter.
@@ -54,8 +56,8 @@ struct inspect_tuple<Filter, std::tuple<Types...>> {
5456
* @tparam T type to check
5557
*/
5658
template <template <typename...> class Filter, typename T>
57-
inline constexpr bool inspect_tuple_v =
58-
internal::inspect_tuple<Filter, std::decay_t<T>>::value;
59-
}
59+
inline constexpr bool inspect_tuple_v
60+
= internal::inspect_tuple<Filter, std::decay_t<T>>::value;
61+
} // namespace stan
6062

6163
#endif

test/unit/math/laplace/laplace_marginal_lpdf_test.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,9 @@ TEST(laplace, poisson_log_phi_dim_2_array_tuple) {
156156
[&](int solver_num, int hessian_block_size, int max_steps_line_search,
157157
auto&& theta_0) {
158158
auto f_ll = [&](auto&& alpha_rho, auto&& eta1, auto&& eta2) {
159-
std::vector<std::tuple<std::decay_t<decltype(eta1)>, std::decay_t<decltype(eta2)>>> eta_tuple;
159+
std::vector<std::tuple<std::decay_t<decltype(eta1)>,
160+
std::decay_t<decltype(eta2)>>>
161+
eta_tuple;
160162
eta_tuple.push_back(std::make_tuple(eta1, eta2));
161163
using alpha_scalar = stan::scalar_type_t<decltype(alpha_rho)>;
162164
std::vector<std::tuple<alpha_scalar, alpha_scalar>> alpha_tuple;
@@ -165,9 +167,8 @@ TEST(laplace, poisson_log_phi_dim_2_array_tuple) {
165167
poisson_log_likelihood_array_tuple{},
166168
std::forward_as_tuple(sums, eta_tuple), theta_0,
167169
stan::math::test::squared_kernel_functor{},
168-
std::forward_as_tuple(x, alpha_tuple),
169-
tolerance, max_num_steps, hessian_block_size, solver_num,
170-
max_steps_line_search, nullptr);
170+
std::forward_as_tuple(x, alpha_tuple), tolerance, max_num_steps,
171+
hessian_block_size, solver_num, max_steps_line_search, nullptr);
171172
};
172173
auto test1 = 1.0;
173174
auto test2 = 1.0;

test/unit/math/laplace/laplace_utility.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,8 @@ struct squared_kernel_functor {
134134
Eigen::Matrix<return_type_t<T1, T2, T3>, Eigen::Dynamic, Eigen::Dynamic>
135135
operator()(const T1& x, const std::vector<std::tuple<T2, T3>>& arg1,
136136
std::ostream* msgs = nullptr) const {
137-
return stan::math::gp_exp_quad_cov(x, std::get<0>(arg1[0]), std::get<1>(arg1[0]))
137+
return stan::math::gp_exp_quad_cov(x, std::get<0>(arg1[0]),
138+
std::get<1>(arg1[0]))
138139
+ 1e-9 * Eigen::MatrixXd::Identity(x.size(), x.size());
139140
}
140141
};

0 commit comments

Comments
 (0)