Skip to content

Commit 35db9d9

Browse files
committed
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
1 parent d0226e5 commit 35db9d9

3 files changed

Lines changed: 84 additions & 40 deletions

File tree

stan/math/prim/constraint/lub_constrain.hpp

Lines changed: 40 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,12 @@ template <typename T, typename L, typename U, require_eigen_t<T>* = nullptr,
121121
require_all_stan_scalar_t<L, U>* = nullptr,
122122
require_not_var_t<return_type_t<T, L, U>>* = nullptr>
123123
inline auto lub_constrain(T&& x, const L& lb, const U& ub) {
124-
return make_holder([lb, ub](auto&& x_) {
125-
return std::forward<decltype(x_)>(x_).unaryExpr([lb, ub](auto&& xx) { return lub_constrain(xx, lb, ub); });
126-
}, std::forward<T>(x));
124+
return make_holder(
125+
[lb, ub](auto&& x_) {
126+
return std::forward<decltype(x_)>(x_).unaryExpr(
127+
[lb, ub](auto&& xx) { return lub_constrain(xx, lb, ub); });
128+
},
129+
std::forward<T>(x));
127130
}
128131

129132
/**
@@ -135,10 +138,12 @@ template <typename T, typename L, typename U, typename Lp,
135138
require_not_var_t<return_type_t<T, L, U>>* = nullptr,
136139
require_convertible_t<return_type_t<T, L, U>, Lp>* = nullptr>
137140
inline auto lub_constrain(T&& x, const L& lb, const U& ub, Lp& lp) {
138-
return eval(make_holder([lb, ub, &lp](auto&& x_) {
139-
return std::forward<decltype(x_)>(x_).unaryExpr(
140-
[lb, ub, &lp](auto&& xx) { return lub_constrain(xx, lb, ub, lp); });
141-
}, std::forward<T>(x)));
141+
return eval(make_holder(
142+
[lb, ub, &lp](auto&& x_) {
143+
return std::forward<decltype(x_)>(x_).unaryExpr(
144+
[lb, ub, &lp](auto&& xx) { return lub_constrain(xx, lb, ub, lp); });
145+
},
146+
std::forward<T>(x)));
142147
}
143148

144149
/**
@@ -151,11 +156,13 @@ template <typename T, typename L, typename U,
151156
require_not_var_t<return_type_t<T, L, U>>* = nullptr>
152157
inline auto lub_constrain(T&& x, L&& lb, const U& ub) {
153158
check_matching_dims("lub_constrain", "x", x, "lb", lb);
154-
return make_holder([ub](auto&& x_, auto&& lb_) {
155-
return std::forward<decltype(x_)>(x_).binaryExpr(lb_, [ub](auto&& xx, auto&& llb) {
156-
return lub_constrain(xx, llb, ub);
157-
});
158-
}, std::forward<T>(x), std::forward<L>(lb));
159+
return make_holder(
160+
[ub](auto&& x_, auto&& lb_) {
161+
return std::forward<decltype(x_)>(x_).binaryExpr(
162+
lb_,
163+
[ub](auto&& xx, auto&& llb) { return lub_constrain(xx, llb, ub); });
164+
},
165+
std::forward<T>(x), std::forward<L>(lb));
159166
}
160167

161168
/**
@@ -169,11 +176,13 @@ template <typename T, typename L, typename U, typename Lp,
169176
require_convertible_t<return_type_t<T, L, U>, Lp>* = nullptr>
170177
inline auto lub_constrain(T&& x, L&& lb, const U& ub, Lp& lp) {
171178
check_matching_dims("lub_constrain", "x", x, "lb", lb);
172-
return eval(make_holder([ub, &lp](auto&& x_, auto&& lb_) {
173-
return to_ref(x_).binaryExpr(lb_, [ub, &lp](auto&& xx, auto&& llb) {
174-
return lub_constrain(xx, llb, ub, lp);
175-
});
176-
}, std::forward<T>(x), std::forward<L>(lb)));
179+
return eval(make_holder(
180+
[ub, &lp](auto&& x_, auto&& lb_) {
181+
return to_ref(x_).binaryExpr(lb_, [ub, &lp](auto&& xx, auto&& llb) {
182+
return lub_constrain(xx, llb, ub, lp);
183+
});
184+
},
185+
std::forward<T>(x), std::forward<L>(lb)));
177186
}
178187

179188
/**
@@ -186,11 +195,13 @@ template <typename T, typename L, typename U,
186195
require_not_var_t<return_type_t<T, L, U>>* = nullptr>
187196
inline auto lub_constrain(T&& x, const L& lb, U&& ub) {
188197
check_matching_dims("lub_constrain", "x", x, "ub", ub);
189-
return make_holder([lb](auto&& x_, auto&& ub_){
190-
return x_.binaryExpr(ub_, [lb](auto&& xx, auto&& uub) {
191-
return lub_constrain(xx, lb, uub);
192-
});
193-
}, std::forward<T>(x), std::forward<U>(ub));
198+
return make_holder(
199+
[lb](auto&& x_, auto&& ub_) {
200+
return x_.binaryExpr(ub_, [lb](auto&& xx, auto&& uub) {
201+
return lub_constrain(xx, lb, uub);
202+
});
203+
},
204+
std::forward<T>(x), std::forward<U>(ub));
194205
}
195206

196207
/**
@@ -204,11 +215,13 @@ template <typename T, typename L, typename U, typename Lp,
204215
require_convertible_t<return_type_t<T, L, U>, Lp>* = nullptr>
205216
inline auto lub_constrain(T&& x, const L& lb, U&& ub, Lp& lp) {
206217
check_matching_dims("lub_constrain", "x", x, "ub", ub);
207-
return eval(make_holder([lb, &lp](auto&& x_, auto&& ub_){
208-
return x_.binaryExpr(ub_, [lb, &lp](auto&& xx, auto&& uub) {
209-
return lub_constrain(xx, lb, uub, lp);
210-
});
211-
}, std::forward<T>(x), std::forward<U>(ub)));
218+
return eval(make_holder(
219+
[lb, &lp](auto&& x_, auto&& ub_) {
220+
return x_.binaryExpr(ub_, [lb, &lp](auto&& xx, auto&& uub) {
221+
return lub_constrain(xx, lb, uub, lp);
222+
});
223+
},
224+
std::forward<T>(x), std::forward<U>(ub)));
212225
}
213226

214227
/**

test/unit/math/mix/constraint/lub_constrain_helpers.hpp

Lines changed: 44 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,45 @@ template <typename T1, typename T2, typename T3>
66
inline void expect(const T1& x, const T2& lb, const T3& ub) {
77
auto f1 = [](auto&& x, auto&& lb, auto&& ub) {
88
stan::return_type_t<decltype(x), decltype(lb), decltype(ub)> lp = 0;
9-
return stan::math::lub_constrain<false>(std::forward<decltype(x)>(x), std::forward<decltype(lb)>(lb), std::forward<decltype(ub)>(ub), lp);
9+
return stan::math::lub_constrain<false>(std::forward<decltype(x)>(x),
10+
std::forward<decltype(lb)>(lb),
11+
std::forward<decltype(ub)>(ub), lp);
1012
};
1113
auto f2 = [](auto&& x, auto&& lb, auto&& ub) {
1214
stan::return_type_t<decltype(x), decltype(lb), decltype(ub)> lp = 0;
13-
return stan::math::lub_constrain<true>(std::forward<decltype(x)>(x), std::forward<decltype(lb)>(lb), std::forward<decltype(ub)>(ub), lp);
15+
return stan::math::lub_constrain<true>(std::forward<decltype(x)>(x),
16+
std::forward<decltype(lb)>(lb),
17+
std::forward<decltype(ub)>(ub), lp);
1418
};
1519
auto f3 = [](auto&& x, auto&& lb, auto&& ub) {
1620
stan::return_type_t<decltype(x), decltype(lb), decltype(ub)> lp = 0;
17-
stan::math::lub_constrain<true>(std::forward<decltype(x)>(x), std::forward<decltype(lb)>(lb), std::forward<decltype(ub)>(ub), lp);
21+
stan::math::lub_constrain<true>(std::forward<decltype(x)>(x),
22+
std::forward<decltype(lb)>(lb),
23+
std::forward<decltype(ub)>(ub), lp);
1824
return lp;
1925
};
2026
auto f4 = [](auto&& x, auto&& lb, auto&& ub) {
2127
stan::return_type_t<decltype(x), decltype(lb), decltype(ub)> lp = 0;
22-
auto xx = stan::math::lub_constrain<true>(std::forward<decltype(x)>(x), std::forward<decltype(lb)>(lb), std::forward<decltype(ub)>(ub), lp);
28+
auto xx = stan::math::lub_constrain<true>(
29+
std::forward<decltype(x)>(x), std::forward<decltype(lb)>(lb),
30+
std::forward<decltype(ub)>(ub), lp);
2331
return stan::math::add(lp, stan::math::sum(std::move(xx)));
2432
};
2533
auto f5 = [](auto&& x, auto&& lb, auto&& ub) {
2634
stan::return_type_t<decltype(x), decltype(lb), decltype(ub)> lp = 0;
27-
return stan::math::lub_constrain<false>(std::forward<decltype(x)>(x), std::forward_as_tuple(std::forward<decltype(lb)>(lb), std::forward<decltype(ub)>(ub)), lp);
35+
return stan::math::lub_constrain<false>(
36+
std::forward<decltype(x)>(x),
37+
std::forward_as_tuple(std::forward<decltype(lb)>(lb),
38+
std::forward<decltype(ub)>(ub)),
39+
lp);
2840
};
2941
auto f6 = [](auto&& x, auto&& lb, auto&& ub) {
3042
stan::return_type_t<decltype(x), decltype(lb), decltype(ub)> lp = 0;
31-
return stan::math::lub_constrain<true>(std::forward<decltype(x)>(x), std::forward_as_tuple(std::forward<decltype(lb)>(lb), std::forward<decltype(ub)>(ub)), lp);
43+
return stan::math::lub_constrain<true>(
44+
std::forward<decltype(x)>(x),
45+
std::forward_as_tuple(std::forward<decltype(lb)>(lb),
46+
std::forward<decltype(ub)>(ub)),
47+
lp);
3248
};
3349

3450
stan::test::expect_ad(f1, x, lb, ub);
@@ -42,20 +58,28 @@ template <typename T1, typename T2, typename T3>
4258
inline void expect_vec(const T1& x, const T2& lb, const T3& ub) {
4359
auto f1 = [](auto&& x, auto&& lb, auto&& ub) {
4460
stan::return_type_t<decltype(x), decltype(lb), decltype(ub)> lp = 0;
45-
return stan::math::lub_constrain<false>(std::forward<decltype(x)>(x), std::forward<decltype(lb)>(lb), std::forward<decltype(ub)>(ub), lp);
61+
return stan::math::lub_constrain<false>(std::forward<decltype(x)>(x),
62+
std::forward<decltype(lb)>(lb),
63+
std::forward<decltype(ub)>(ub), lp);
4664
};
4765
auto f2 = [](auto&& x, auto&& lb, auto&& ub) {
4866
stan::return_type_t<decltype(x), decltype(lb), decltype(ub)> lp = 0;
49-
return stan::math::lub_constrain<true>(std::forward<decltype(x)>(x), std::forward<decltype(lb)>(lb), std::forward<decltype(ub)>(ub), lp);
67+
return stan::math::lub_constrain<true>(std::forward<decltype(x)>(x),
68+
std::forward<decltype(lb)>(lb),
69+
std::forward<decltype(ub)>(ub), lp);
5070
};
5171
auto f3 = [](auto&& x, auto&& lb, auto&& ub) {
5272
stan::return_type_t<decltype(x), decltype(lb), decltype(ub)> lp = 0;
53-
stan::math::lub_constrain<true>(std::forward<decltype(x)>(x), std::forward<decltype(lb)>(lb), std::forward<decltype(ub)>(ub), lp);
73+
stan::math::lub_constrain<true>(std::forward<decltype(x)>(x),
74+
std::forward<decltype(lb)>(lb),
75+
std::forward<decltype(ub)>(ub), lp);
5476
return lp;
5577
};
5678
auto f4 = [](auto&& x, auto&& lb, auto&& ub) {
5779
stan::return_type_t<decltype(x), decltype(lb), decltype(ub)> lp = 0;
58-
auto xx = stan::math::eval(stan::math::lub_constrain<true>(std::forward<decltype(x)>(x), std::forward<decltype(lb)>(lb), std::forward<decltype(ub)>(ub), lp));
80+
auto xx = stan::math::eval(stan::math::lub_constrain<true>(
81+
std::forward<decltype(x)>(x), std::forward<decltype(lb)>(lb),
82+
std::forward<decltype(ub)>(ub), lp));
5983
stan::return_type_t<decltype(x), decltype(lb), decltype(ub)> xx_acc = 0;
6084
for (size_t i = 0; i < xx.size(); ++i) {
6185
xx_acc += stan::math::sum(xx[i]);
@@ -64,11 +88,19 @@ inline void expect_vec(const T1& x, const T2& lb, const T3& ub) {
6488
};
6589
auto f5 = [](auto&& x, auto&& lb, auto&& ub) {
6690
stan::return_type_t<decltype(x), decltype(lb), decltype(ub)> lp = 0;
67-
return stan::math::lub_constrain<false>(std::forward<decltype(x)>(x), std::make_tuple(std::forward<decltype(lb)>(lb), std::forward<decltype(ub)>(ub)), lp);
91+
return stan::math::lub_constrain<false>(
92+
std::forward<decltype(x)>(x),
93+
std::make_tuple(std::forward<decltype(lb)>(lb),
94+
std::forward<decltype(ub)>(ub)),
95+
lp);
6896
};
6997
auto f6 = [](auto&& x, auto&& lb, auto&& ub) {
7098
stan::return_type_t<decltype(x), decltype(lb), decltype(ub)> lp = 0;
71-
return stan::math::lub_constrain<true>(std::forward<decltype(x)>(x), std::make_tuple(std::forward<decltype(lb)>(lb), std::forward<decltype(ub)>(ub)), lp);
99+
return stan::math::lub_constrain<true>(
100+
std::forward<decltype(x)>(x),
101+
std::make_tuple(std::forward<decltype(lb)>(lb),
102+
std::forward<decltype(ub)>(ub)),
103+
lp);
72104
};
73105

74106
stan::test::expect_ad(f1, x, lb, ub);

test/unit/math/test_ad.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1031,7 +1031,6 @@ inline std::vector<double> common_args(F&& comparison) {
10311031
return common_args_filtered;
10321032
}
10331033

1034-
10351034
inline std::vector<int> common_nonzero_int_args() {
10361035
static const std::vector<int> args{-1, 1};
10371036
return args;

0 commit comments

Comments
 (0)