Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions stan/math/prim/mat/prob/lkj_corr_cholesky_lpdf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ return_type_t<T_covar, T_shape> lkj_corr_cholesky_lpdf(
for (int k = 0; k < Km1; k++) {
values(k) = (Km1 - k - 1) * log_diagonals(k);
}
if ((eta == 1.0)
&& stan::is_constant_all<typename stan::scalar_type<T_shape> >::value) {
if (eta == 1.0 && is_constant_all<scalar_type<T_shape>>::value) {
lp += sum(values);
return (lp);
}
Expand Down
3 changes: 1 addition & 2 deletions stan/math/prim/mat/prob/lkj_corr_lpdf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ return_type_t<T_y, T_shape> lkj_corr_lpdf(
lp += do_lkj_constant(eta, K);
}

if ((eta == 1.0)
&& stan::is_constant_all<typename stan::scalar_type<T_shape> >::value) {
if (eta == 1.0 && is_constant_all<scalar_type<T_shape>>::value) {
return lp;
}

Expand Down
12 changes: 6 additions & 6 deletions stan/math/prim/scal/fun/lub_constrain.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,17 @@ inline return_type_t<T, L, U> lub_constrain(const T& x, const L& lb,
if (x > 0) {
inv_logit_x = inv_logit(x);
// Prevent x from reaching one unless it really really should.
if ((x < INFTY) && (inv_logit_x == 1)) {
if (x < INFTY && inv_logit_x == 1) {
inv_logit_x = 1 - 1e-15;
}
} else {
inv_logit_x = inv_logit(x);
// Prevent x from reaching zero unless it really really should.
if ((x > NEGATIVE_INFTY) && (inv_logit_x == 0)) {
if (x > NEGATIVE_INFTY && inv_logit_x == 0) {
inv_logit_x = 1e-15;
}
}
return fma((ub - lb), inv_logit_x, lb);
return fma(ub - lb, inv_logit_x, lb);
}

/**
Expand Down Expand Up @@ -128,19 +128,19 @@ inline return_type_t<T, L, U> lub_constrain(const T& x, const L& lb,
inv_logit_x = inv_logit(x);
lp += log(ub - lb) - x - 2 * log1p(exp_minus_x);
// Prevent x from reaching one unless it really really should.
if ((x < INFTY) && (inv_logit_x == 1)) {
if (x < INFTY && inv_logit_x == 1) {
inv_logit_x = 1 - 1e-15;
}
} else {
T exp_x = exp(x);
inv_logit_x = inv_logit(x);
lp += log(ub - lb) + x - 2 * log1p(exp_x);
// Prevent x from reaching zero unless it really really should.
if ((x > NEGATIVE_INFTY) && (inv_logit_x == 0)) {
if (x > NEGATIVE_INFTY && inv_logit_x == 0) {
inv_logit_x = 1e-15;
}
}
return fma((ub - lb), inv_logit_x, lb);
return fma(ub - lb, inv_logit_x, lb);
}

} // namespace math
Expand Down
4 changes: 2 additions & 2 deletions stan/math/prim/scal/fun/trigamma.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ inline T trigamma_impl(const T& x) {

// negative integers and zero return postiive infinity
// see http://mathworld.wolfram.com/PolygammaFunction.html
if ((x <= 0.0) && (floor(x) == x)) {
if (x <= 0.0 && floor(x) == x) {
value = positive_infinity();
return value;
}

// negative non-integers: use the reflection formula
// see http://mathworld.wolfram.com/PolygammaFunction.html
if ((x <= 0) && (floor(x) != x)) {
if (x <= 0 && floor(x) != x) {
value = -trigamma_impl(-x + 1.0) + square(pi() / sin(-pi() * x));
return value;
}
Expand Down