From 15694748c1094fa12f055e29844416f192cbb93f Mon Sep 17 00:00:00 2001 From: Marco Colombo Date: Sun, 22 Dec 2019 21:13:01 +0000 Subject: [PATCH] Remove extra parens around equality checks --- stan/math/prim/mat/prob/lkj_corr_cholesky_lpdf.hpp | 3 +-- stan/math/prim/mat/prob/lkj_corr_lpdf.hpp | 3 +-- stan/math/prim/scal/fun/lub_constrain.hpp | 12 ++++++------ stan/math/prim/scal/fun/trigamma.hpp | 4 ++-- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/stan/math/prim/mat/prob/lkj_corr_cholesky_lpdf.hpp b/stan/math/prim/mat/prob/lkj_corr_cholesky_lpdf.hpp index 4eb87d87538..babc71beb65 100644 --- a/stan/math/prim/mat/prob/lkj_corr_cholesky_lpdf.hpp +++ b/stan/math/prim/mat/prob/lkj_corr_cholesky_lpdf.hpp @@ -39,8 +39,7 @@ return_type_t 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 >::value) { + if (eta == 1.0 && is_constant_all>::value) { lp += sum(values); return (lp); } diff --git a/stan/math/prim/mat/prob/lkj_corr_lpdf.hpp b/stan/math/prim/mat/prob/lkj_corr_lpdf.hpp index 2e17b50ef8b..2d755e3d1ab 100644 --- a/stan/math/prim/mat/prob/lkj_corr_lpdf.hpp +++ b/stan/math/prim/mat/prob/lkj_corr_lpdf.hpp @@ -62,8 +62,7 @@ return_type_t lkj_corr_lpdf( lp += do_lkj_constant(eta, K); } - if ((eta == 1.0) - && stan::is_constant_all >::value) { + if (eta == 1.0 && is_constant_all>::value) { return lp; } diff --git a/stan/math/prim/scal/fun/lub_constrain.hpp b/stan/math/prim/scal/fun/lub_constrain.hpp index b6358a15527..c92552c9982 100644 --- a/stan/math/prim/scal/fun/lub_constrain.hpp +++ b/stan/math/prim/scal/fun/lub_constrain.hpp @@ -56,17 +56,17 @@ inline return_type_t 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); } /** @@ -128,7 +128,7 @@ inline return_type_t 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 { @@ -136,11 +136,11 @@ inline return_type_t lub_constrain(const T& x, const L& lb, 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 diff --git a/stan/math/prim/scal/fun/trigamma.hpp b/stan/math/prim/scal/fun/trigamma.hpp index ea4adaf9cd9..f3cdd90962e 100644 --- a/stan/math/prim/scal/fun/trigamma.hpp +++ b/stan/math/prim/scal/fun/trigamma.hpp @@ -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; }