Skip to content

Commit e4240a7

Browse files
committed
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
1 parent 32df045 commit e4240a7

2 files changed

Lines changed: 17 additions & 10 deletions

File tree

stan/math/prim/fun/log_gamma_q_dgamma.hpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ inline return_type_t<T_a, T_z> log_q_gamma_cf(const T_a& a, const T_z& z,
4242
const T_return log_prefactor = a * log(z) - z - lgamma(a);
4343

4444
T_return b_init = z + 1.0 - a;
45-
T_return C = (fabs(value_of(b_init)) >= EPSILON) ? b_init : std::decay_t<decltype(b_init)>(EPSILON);
45+
T_return C = (fabs(value_of(b_init)) >= EPSILON)
46+
? b_init
47+
: std::decay_t<decltype(b_init)>(EPSILON);
4648
T_return D = 0.0;
4749
T_return f = C;
4850
for (int i = 1; i <= max_steps; ++i) {
@@ -83,14 +85,16 @@ inline return_type_t<T_a, T_z> log_q_gamma_cf(const T_a& a, const T_z& z,
8385
* @return structure containing log(Q(a,z)) and d/da log(Q(a,z))
8486
*/
8587
template <typename T_a, typename T_z>
86-
inline std::pair<return_type_t<T_a, T_z>, return_type_t<T_a, T_z>> log_gamma_q_dgamma(
87-
const T_a& a, const T_z& z, double precision = 1.49012e-08, int max_steps = 250) {
88+
inline std::pair<return_type_t<T_a, T_z>, return_type_t<T_a, T_z>>
89+
log_gamma_q_dgamma(const T_a& a, const T_z& z, double precision = 1.49012e-08,
90+
int max_steps = 250) {
8891
using T_return = return_type_t<T_a, T_z>;
8992
const double a_val = value_of(a);
9093
const double z_val = value_of(z);
9194
// For z > a + 1, use continued fraction for better numerical stability
9295
if (z_val > a_val + 1.0) {
93-
std::pair<T_return, T_return> result{internal::log_q_gamma_cf(a_val, z_val, precision, max_steps), 0.0};
96+
std::pair<T_return, T_return> result{
97+
internal::log_q_gamma_cf(a_val, z_val, precision, max_steps), 0.0};
9498
// For gradient, use: d/da log(Q) = (1/Q) * dQ/da
9599
// grad_reg_inc_gamma computes dQ/da
96100
const T_return Q_val = exp(result.first);

stan/math/prim/prob/gamma_lccdf.hpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ namespace internal {
3131
/**
3232
* Computes log q and d(log q) / d(alpha) using continued fraction.
3333
*/
34-
template <bool any_fvar, bool partials_fvar, typename T_shape, typename T1, typename T2>
34+
template <bool any_fvar, bool partials_fvar, typename T_shape, typename T1,
35+
typename T2>
3536
inline std::optional<std::pair<return_type_t<T1, T2>, return_type_t<T1, T2>>>
3637
eval_q_cf(const T1& alpha, const T2& beta_y) {
3738
using scalar_t = return_type_t<T1, T2>;
@@ -88,8 +89,7 @@ eval_q_log1m(const T1& alpha, const T2& beta_y) {
8889
auto log_Q_fvar = log1m(gamma_p(alpha_unit, beta_unit));
8990
out.second = log_Q_fvar.d_;
9091
} else {
91-
out.second
92-
= -grad_reg_lower_inc_gamma(alpha, beta_y) / exp(out.first);
92+
out.second = -grad_reg_lower_inc_gamma(alpha, beta_y) / exp(out.first);
9393
}
9494
}
9595
return std::optional{out};
@@ -152,12 +152,15 @@ inline return_type_t<T_y, T_shape, T_inv_scale> gamma_lccdf(
152152
}
153153
std::optional<std::pair<T_partials_return, T_partials_return>> result;
154154
if (beta_y > alpha_val + 1.0) {
155-
result = internal::eval_q_cf<any_fvar, partials_fvar, T_shape>(alpha_val, beta_y);
155+
result = internal::eval_q_cf<any_fvar, partials_fvar, T_shape>(alpha_val,
156+
beta_y);
156157
} else {
157-
result = internal::eval_q_log1m<partials_fvar, T_shape>(alpha_val, beta_y);
158+
result
159+
= internal::eval_q_log1m<partials_fvar, T_shape>(alpha_val, beta_y);
158160
if (!result && beta_y > 0.0) {
159161
// Fallback to continued fraction if log1m fails
160-
result = internal::eval_q_cf<any_fvar, partials_fvar, T_shape>(alpha_val, beta_y);
162+
result = internal::eval_q_cf<any_fvar, partials_fvar, T_shape>(
163+
alpha_val, beta_y);
161164
}
162165
}
163166
if (unlikely(!result)) {

0 commit comments

Comments
 (0)