diff --git a/stan/math/fwd/fun/mdivide_left.hpp b/stan/math/fwd/fun/mdivide_left.hpp index e68a24f4584..7fd7c6a1e5e 100644 --- a/stan/math/fwd/fun/mdivide_left.hpp +++ b/stan/math/fwd/fun/mdivide_left.hpp @@ -60,9 +60,6 @@ template , T1::RowsAtCompileTime, T2::ColsAtCompileTime> mdivide_left(const T1& A, const T2& b) { - constexpr int S1 = T1::RowsAtCompileTime; - constexpr int C2 = T2::ColsAtCompileTime; - check_square("mdivide_left", "A", A); check_multiplicable("mdivide_left", "A", A, "b", b); if (A.size() == 0) { diff --git a/stan/math/fwd/fun/mdivide_left_tri_low.hpp b/stan/math/fwd/fun/mdivide_left_tri_low.hpp index 1b7f16a18be..67be26be5d1 100644 --- a/stan/math/fwd/fun/mdivide_left_tri_low.hpp +++ b/stan/math/fwd/fun/mdivide_left_tri_low.hpp @@ -56,7 +56,6 @@ inline Eigen::Matrix, T1::RowsAtCompileTime, T2::ColsAtCompileTime> mdivide_left_tri_low(const T1& A, const T2& b) { constexpr int S1 = T1::RowsAtCompileTime; - constexpr int C2 = T2::ColsAtCompileTime; check_square("mdivide_left_tri_low", "A", A); check_multiplicable("mdivide_left_tri_low", "A", A, "b", b); diff --git a/stan/math/fwd/fun/mdivide_right.hpp b/stan/math/fwd/fun/mdivide_right.hpp index 4bfa509609c..b87cbcb102e 100644 --- a/stan/math/fwd/fun/mdivide_right.hpp +++ b/stan/math/fwd/fun/mdivide_right.hpp @@ -97,7 +97,6 @@ inline Eigen::Matrix, EigMat1::RowsAtCompileTime, mdivide_right(const EigMat1& A, const EigMat2& b) { using T = typename value_type_t::Scalar; constexpr int R1 = EigMat1::RowsAtCompileTime; - constexpr int C1 = EigMat1::ColsAtCompileTime; constexpr int R2 = EigMat2::RowsAtCompileTime; constexpr int C2 = EigMat2::ColsAtCompileTime; diff --git a/stan/math/fwd/fun/mdivide_right_tri_low.hpp b/stan/math/fwd/fun/mdivide_right_tri_low.hpp index 13c0403ccbf..a5fe504a146 100644 --- a/stan/math/fwd/fun/mdivide_right_tri_low.hpp +++ b/stan/math/fwd/fun/mdivide_right_tri_low.hpp @@ -98,7 +98,6 @@ inline Eigen::Matrix, EigMat1::RowsAtCompileTime, mdivide_right_tri_low(const EigMat1& A, const EigMat2& b) { using T = typename value_type_t::Scalar; constexpr int R1 = EigMat1::RowsAtCompileTime; - constexpr int C1 = EigMat1::ColsAtCompileTime; constexpr int R2 = EigMat2::RowsAtCompileTime; constexpr int C2 = EigMat2::ColsAtCompileTime; check_square("mdivide_right_tri_low", "b", b); diff --git a/stan/math/opencl/kernel_generator/broadcast.hpp b/stan/math/opencl/kernel_generator/broadcast.hpp index 9fb82198725..84062e9ed17 100644 --- a/stan/math/opencl/kernel_generator/broadcast.hpp +++ b/stan/math/opencl/kernel_generator/broadcast.hpp @@ -98,7 +98,6 @@ class broadcast_ * @return pair of indices - bottom and top diagonal */ inline std::pair extreme_diagonals() const { - int bottom, top; std::pair arg_diags = this->template get_arg<0>().extreme_diagonals(); return {Colwise ? std::numeric_limits::min() : arg_diags.first, diff --git a/stan/math/opencl/mrrr.hpp b/stan/math/opencl/mrrr.hpp index d2b1eca5f49..79d5c6a1956 100644 --- a/stan/math/opencl/mrrr.hpp +++ b/stan/math/opencl/mrrr.hpp @@ -373,7 +373,6 @@ inline void mrrr_cl(const Eigen::Ref diagonal, cluster_end--; // now this is the index of the last element of the // cluster if (cluster_end > i) { // cluster - double_d a = high[cluster_end - 1], b = low[cluster_end]; double_d max_shift = (high[cluster_end - 1] - low[cluster_end]) / min_rel_sep; double_d next_shift; @@ -396,7 +395,6 @@ inline void mrrr_cl(const Eigen::Ref diagonal, i = cluster_end; } else { // isolated eigenvalue - int twist_idx; const double_d low_gap = i == block.start ? double_d(std::numeric_limits::infinity()) diff --git a/stan/math/opencl/prim/bernoulli_cdf.hpp b/stan/math/opencl/prim/bernoulli_cdf.hpp index 5f521574f9a..9a3435162aa 100644 --- a/stan/math/opencl/prim/bernoulli_cdf.hpp +++ b/stan/math/opencl/prim/bernoulli_cdf.hpp @@ -33,7 +33,6 @@ return_type_t bernoulli_cdf(const T_n_cl& n, using T_partials_return = partials_return_t; using std::isnan; constexpr bool is_n_vector = !is_stan_scalar::value; - constexpr bool is_theta_vector = !is_stan_scalar::value; check_consistent_sizes(function, "Random variable", n, "Probability parameter", theta); diff --git a/stan/math/opencl/prim/bernoulli_lccdf.hpp b/stan/math/opencl/prim/bernoulli_lccdf.hpp index e2b45cbda0f..975d6657c2c 100644 --- a/stan/math/opencl/prim/bernoulli_lccdf.hpp +++ b/stan/math/opencl/prim/bernoulli_lccdf.hpp @@ -34,7 +34,6 @@ return_type_t bernoulli_lccdf(const T_n_cl& n, using T_partials_return = partials_return_t; using std::isnan; constexpr bool is_n_vector = !is_stan_scalar::value; - constexpr bool is_theta_vector = !is_stan_scalar::value; check_consistent_sizes(function, "Random variable", n, "Probability parameter", theta); diff --git a/stan/math/opencl/prim/bernoulli_lcdf.hpp b/stan/math/opencl/prim/bernoulli_lcdf.hpp index e93d9269fb5..0e34cada8c5 100644 --- a/stan/math/opencl/prim/bernoulli_lcdf.hpp +++ b/stan/math/opencl/prim/bernoulli_lcdf.hpp @@ -34,7 +34,6 @@ return_type_t bernoulli_lcdf(const T_n_cl& n, using T_partials_return = partials_return_t; using std::isnan; constexpr bool is_n_vector = !is_stan_scalar::value; - constexpr bool is_theta_vector = !is_stan_scalar::value; check_consistent_sizes(function, "Random variable", n, "Probability parameter", theta); diff --git a/stan/math/opencl/prim/bernoulli_logit_lpmf.hpp b/stan/math/opencl/prim/bernoulli_logit_lpmf.hpp index f9aa2e28c1d..f848bfd7b11 100644 --- a/stan/math/opencl/prim/bernoulli_logit_lpmf.hpp +++ b/stan/math/opencl/prim/bernoulli_logit_lpmf.hpp @@ -32,7 +32,6 @@ return_type_t bernoulli_logit_lpmf(const T_n_cl& n, using T_partials_return = partials_return_t; using std::isnan; constexpr bool is_n_vector = !is_stan_scalar::value; - constexpr bool is_theta_vector = !is_stan_scalar::value; check_consistent_sizes(function, "Random variable", n, "Probability parameter", theta); diff --git a/stan/math/opencl/prim/dot_self.hpp b/stan/math/opencl/prim/dot_self.hpp index 544c6fc241d..9d2c0232e57 100644 --- a/stan/math/opencl/prim/dot_self.hpp +++ b/stan/math/opencl/prim/dot_self.hpp @@ -19,7 +19,6 @@ namespace math { template * = nullptr> inline auto dot_self(const T& a) { - const char* function = "dot_self(OpenCL)"; return sum(elt_multiply(a, a)); } diff --git a/stan/math/opencl/prim/poisson_log_lpmf.hpp b/stan/math/opencl/prim/poisson_log_lpmf.hpp index 309f5abe5f7..a75b7379d3c 100644 --- a/stan/math/opencl/prim/poisson_log_lpmf.hpp +++ b/stan/math/opencl/prim/poisson_log_lpmf.hpp @@ -35,7 +35,6 @@ return_type_t poisson_log_lpmf(const T_n_cl& n, using std::isinf; using std::isnan; constexpr bool is_n_vector = !is_stan_scalar::value; - constexpr bool is_alpha_vector = !is_stan_scalar::value; check_consistent_sizes(function, "Random variable", n, "Log rate parameter", alpha); diff --git a/stan/math/opencl/prim/poisson_lpmf.hpp b/stan/math/opencl/prim/poisson_lpmf.hpp index efec66951a1..4d3d8bdbfc4 100644 --- a/stan/math/opencl/prim/poisson_lpmf.hpp +++ b/stan/math/opencl/prim/poisson_lpmf.hpp @@ -34,7 +34,6 @@ return_type_t poisson_lpmf(const T_n_cl& n, using T_partials_return = partials_return_t; using std::isinf; constexpr bool is_n_vector = !is_stan_scalar::value; - constexpr bool is_lambda_vector = !is_stan_scalar::value; check_consistent_sizes(function, "Random variable", n, "Rate parameter", lambda); diff --git a/stan/math/opencl/rev/matrix_power.hpp b/stan/math/opencl/rev/matrix_power.hpp index 4dec6ce82b2..401e484530a 100644 --- a/stan/math/opencl/rev/matrix_power.hpp +++ b/stan/math/opencl/rev/matrix_power.hpp @@ -34,16 +34,17 @@ inline var_value> matrix_power(const var_value& M, if (M.size() == 0) return M; - size_t N = M.rows(); + auto N = M.rows(); + if (n == 0) { - return diag_matrix(constant(1.0, M.rows(), 1)); + return diag_matrix(constant(1.0, N, 1)); } if (n == 1) { return M; } arena_t>> arena_powers(n + 1); - arena_powers[0] = diag_matrix(constant(1.0, M.rows(), 1)); + arena_powers[0] = diag_matrix(constant(1.0, N, 1)); arena_powers[1] = M.val(); for (size_t i = 2; i <= n; ++i) { arena_powers[i] = arena_powers[1] * arena_powers[i - 1]; diff --git a/stan/math/opencl/rev/softmax.hpp b/stan/math/opencl/rev/softmax.hpp index f61ba86963d..5cc0384730e 100644 --- a/stan/math/opencl/rev/softmax.hpp +++ b/stan/math/opencl/rev/softmax.hpp @@ -2,7 +2,8 @@ #define STAN_MATH_OPENCL_REV_SOFTMAX_HPP #ifdef STAN_OPENCL -#include +#include +#include #include #include #include diff --git a/stan/math/prim/fun/cholesky_factor_constrain.hpp b/stan/math/prim/fun/cholesky_factor_constrain.hpp index 701c29fe06e..ef8addb9ae1 100644 --- a/stan/math/prim/fun/cholesky_factor_constrain.hpp +++ b/stan/math/prim/fun/cholesky_factor_constrain.hpp @@ -37,7 +37,6 @@ cholesky_factor_constrain(const T& x, int M, int N) { "((N * (N + 1)) / 2 + (M - N) * N)", ((N * (N + 1)) / 2 + (M - N) * N)); Eigen::Matrix y(M, N); - T_scalar zero(0); int pos = 0; const auto& x_ref = to_ref(x); diff --git a/stan/math/prim/fun/gp_exponential_cov.hpp b/stan/math/prim/fun/gp_exponential_cov.hpp index 96bd41b4f37..138e2d1165e 100644 --- a/stan/math/prim/fun/gp_exponential_cov.hpp +++ b/stan/math/prim/fun/gp_exponential_cov.hpp @@ -282,7 +282,6 @@ gp_exponential_cov(const std::vector> &x1, } T_s sigma_sq = square(sigma); - T_l temp; std::vector, -1, 1>> x1_new = divide_columns(x1, length_scale); diff --git a/stan/math/prim/fun/grad_2F1.hpp b/stan/math/prim/fun/grad_2F1.hpp index f48fcdd8efd..eb736e813b6 100644 --- a/stan/math/prim/fun/grad_2F1.hpp +++ b/stan/math/prim/fun/grad_2F1.hpp @@ -65,7 +65,6 @@ TupleT grad_2F1_impl_ab(const T1& a1, const T2& a2, const T3& b1, const T_z& z, int sign_z = sign(z); auto log_z = log(abs(z)); - double log_precision = log(precision); int log_t_new_sign = 1.0; int log_t_old_sign = 1.0; @@ -190,7 +189,6 @@ TupleT grad_2F1_impl(const T1& a1, const T2& a2, const T3& b1, const T_z& z, if (calc_z) { auto hyper1 = hypergeometric_2F1(a1_euler, a2_euler, b1, z_euler); auto hyper2 = hypergeometric_2F1(1 + a2, 1 - a1 + b1, 1 + b1, z_euler); - auto pre_mult = a2 * pow(1 - z, -1 - a2); std::get<3>(grad_tuple_rtn) = a2 * pow(1 - z, -1 - a2) * hyper1 + (a2 * (b1 - a1) * pow(1 - z, -a2) diff --git a/stan/math/prim/fun/lb_free.hpp b/stan/math/prim/fun/lb_free.hpp index dc28998461c..9e1ee605ebf 100644 --- a/stan/math/prim/fun/lb_free.hpp +++ b/stan/math/prim/fun/lb_free.hpp @@ -83,9 +83,9 @@ inline auto lb_free(T&& y, L&& lb) { template * = nullptr> inline auto lb_free(const std::vector y, const L& lb) { auto&& lb_ref = to_ref(lb); - std::vector ret(y.size()); + std::vector ret(y.size()); std::transform(y.begin(), y.end(), ret.begin(), - [&lb](auto&& yy) { return lb_free(yy, lb); }); + [&lb_ref](auto&& yy) { return lb_free(yy, lb_ref); }); return ret; } diff --git a/stan/math/prim/fun/stan_print.hpp b/stan/math/prim/fun/stan_print.hpp index b8d363b622f..14deeec3779 100644 --- a/stan/math/prim/fun/stan_print.hpp +++ b/stan/math/prim/fun/stan_print.hpp @@ -71,7 +71,6 @@ void stan_print(std::ostream* o, const T& x) { template *> void stan_print(std::ostream* o, const T& x) { *o << '('; - constexpr auto tuple_size = std::tuple_size>::value; size_t i = 0; stan::math::for_each( [&i, o](auto&& elt) { diff --git a/stan/math/prim/functor/hcubature.hpp b/stan/math/prim/functor/hcubature.hpp index 1cbf995ddc5..b342dc42e56 100644 --- a/stan/math/prim/functor/hcubature.hpp +++ b/stan/math/prim/functor/hcubature.hpp @@ -465,7 +465,6 @@ double hcubature(const F& integrand, const T_pars& pars, const int& dim, int numevals = (dim == 1) ? 15 : 1 + 4 * dim + 2 * dim * (dim - 1) + std::pow(2, dim); int evals_per_box = numevals; - int kdiv = kdivide; double error = err; double val = result; @@ -491,7 +490,9 @@ double hcubature(const F& integrand, const T_pars& pars, const int& dim, std::vector mb(box.b); mb[box.kdiv] -= w; - double result_1, result_2, err_1, err_2, kdivide_1, kdivide_2; + double result_1, result_2, err_1, err_2; + double kdivide_1 = math::NOT_A_NUMBER; + double kdivide_2 = math::NOT_A_NUMBER; if (dim == 1) { std::tie(result_1, err_1) diff --git a/stan/math/prim/functor/operands_and_partials.hpp b/stan/math/prim/functor/operands_and_partials.hpp index 318374f9e12..4fd97837916 100644 --- a/stan/math/prim/functor/operands_and_partials.hpp +++ b/stan/math/prim/functor/operands_and_partials.hpp @@ -54,7 +54,8 @@ class ops_partials_edge; * for this specialization must be a `Arithmetic` */ template -struct ops_partials_edge> { +class ops_partials_edge> { + public: using inner_op = std::conditional_t>::value, value_type_t, Op>; using partials_t = empty_broadcast_array; diff --git a/stan/math/prim/functor/partials_propagator.hpp b/stan/math/prim/functor/partials_propagator.hpp index eeba3d6f82a..1d8d10f7e01 100644 --- a/stan/math/prim/functor/partials_propagator.hpp +++ b/stan/math/prim/functor/partials_propagator.hpp @@ -16,7 +16,7 @@ namespace math { namespace internal { template -struct partials_propagator; +class partials_propagator; /** \ingroup type_trait * \callergraph diff --git a/stan/math/prim/prob/gaussian_dlm_obs_rng.hpp b/stan/math/prim/prob/gaussian_dlm_obs_rng.hpp index 39e1af623dd..f4aa29c7068 100644 --- a/stan/math/prim/prob/gaussian_dlm_obs_rng.hpp +++ b/stan/math/prim/prob/gaussian_dlm_obs_rng.hpp @@ -97,22 +97,22 @@ inline Eigen::MatrixXd gaussian_dlm_obs_rng(const Eigen::MatrixXd &F, int r = F.cols(); // number of variables int n = G.rows(); // number of states - check_size_match(function, "rows of F", F.rows(), "rows of G", G.rows()); + check_size_match(function, "rows of F", F.rows(), "rows of G", n); check_finite(function, "F", F); check_square(function, "G", G); check_finite(function, "G", G); - check_size_match(function, "rows of V", V.rows(), "cols of F", F.cols()); + check_size_match(function, "rows of V", V.rows(), "cols of F", r); check_finite(function, "V", V); check_positive(function, "V rows", V.rows()); check_symmetric(function, "V", V); - check_size_match(function, "rows of W", W.rows(), "rows of G", G.rows()); + check_size_match(function, "rows of W", W.rows(), "rows of G", n); check_finite(function, "W", W); check_positive(function, "W rows", W.rows()); check_symmetric(function, "W", W); - check_size_match(function, "rows of W", W.rows(), "rows of G", G.rows()); - check_size_match(function, "size of m0", m0.size(), "rows of G", G.rows()); + check_size_match(function, "rows of W", W.rows(), "rows of G", n); + check_size_match(function, "size of m0", m0.size(), "rows of G", n); check_finite(function, "m0", m0); - check_size_match(function, "rows of C0", C0.rows(), "rows of G", G.rows()); + check_size_match(function, "rows of C0", C0.rows(), "rows of G", n); check_finite(function, "C0", C0); check_positive(function, "C0 rows", C0.rows()); check_symmetric(function, "C0", C0); diff --git a/stan/math/prim/prob/multi_student_t_lpdf.hpp b/stan/math/prim/prob/multi_student_t_lpdf.hpp index ea0257a8619..a5eaef677bc 100644 --- a/stan/math/prim/prob/multi_student_t_lpdf.hpp +++ b/stan/math/prim/prob/multi_student_t_lpdf.hpp @@ -53,8 +53,6 @@ return_type_t multi_student_t_lpdf( check_positive(function, "Degrees of freedom parameter", nu); check_finite(function, "Degrees of freedom parameter", nu); - size_t num_y = size_mvt(y); - size_t num_mu = size_mvt(mu); check_consistent_sizes_mvt(function, "y", y, "mu", mu); vector_seq_view y_vec(y); diff --git a/stan/math/prim/prob/skew_double_exponential_lccdf.hpp b/stan/math/prim/prob/skew_double_exponential_lccdf.hpp index ceb7c554ae8..a70a20a59a8 100644 --- a/stan/math/prim/prob/skew_double_exponential_lccdf.hpp +++ b/stan/math/prim/prob/skew_double_exponential_lccdf.hpp @@ -71,7 +71,6 @@ return_type_t skew_double_exponential_lccdf( scalar_seq_view> sigma_vec(sigma_val); scalar_seq_view> tau_vec(tau_val); - const int size_sigma = stan::math::size(sigma); const auto N = max_size(y, mu, sigma, tau); auto inv_sigma_val = to_ref(inv(sigma_val)); scalar_seq_view inv_sigma(inv_sigma_val); diff --git a/stan/math/rev/core/grad.hpp b/stan/math/rev/core/grad.hpp index 570b86d18d6..edcb3a11d1d 100644 --- a/stan/math/rev/core/grad.hpp +++ b/stan/math/rev/core/grad.hpp @@ -23,7 +23,7 @@ namespace math { *

This function does not recover any memory from the computation. * */ -static void grad() { +static inline void grad() { size_t end = ChainableStack::instance_->var_stack_.size(); size_t beginning = empty_nested() ? 0 : end - nested_size(); for (size_t i = end; i-- > beginning;) { diff --git a/stan/math/rev/core/operator_subtraction.hpp b/stan/math/rev/core/operator_subtraction.hpp index 935a8372472..e800590d519 100644 --- a/stan/math/rev/core/operator_subtraction.hpp +++ b/stan/math/rev/core/operator_subtraction.hpp @@ -101,7 +101,7 @@ template * = nullptr> inline var operator-(Arith a, const var& b) { return make_callback_vari( a - b.vi_->val_, - [bvi = b.vi_, a](const auto& vi) mutable { bvi->adj_ -= vi.adj_; }); + [bvi = b.vi_](const auto& vi) mutable { bvi->adj_ -= vi.adj_; }); } /** diff --git a/stan/math/rev/core/precomputed_gradients.hpp b/stan/math/rev/core/precomputed_gradients.hpp index 05cd3a3f4a6..4960985702f 100644 --- a/stan/math/rev/core/precomputed_gradients.hpp +++ b/stan/math/rev/core/precomputed_gradients.hpp @@ -80,10 +80,10 @@ class precomputed_gradients_vari_template : public vari { size_(size), varis_(varis), gradients_(gradients), - container_operands_(index_apply([&, this](auto... Is) { + container_operands_(index_apply([&](auto... Is) { return std::make_tuple(to_arena(std::get(container_operands))...); })), - container_gradients_(index_apply([&, this](auto... Is) { + container_gradients_(index_apply([&](auto... Is) { return std::make_tuple( to_arena(std::get(container_gradients))...); })) { @@ -123,10 +123,10 @@ class precomputed_gradients_vari_template : public vari { vars.size())), gradients_(ChainableStack::instance_->memalloc_.alloc_array( vars.size())), - container_operands_(index_apply([&, this](auto... Is) { + container_operands_(index_apply([&](auto... Is) { return std::make_tuple(to_arena(std::get(container_operands))...); })), - container_gradients_(index_apply([&, this](auto... Is) { + container_gradients_(index_apply([&](auto... Is) { return std::make_tuple( to_arena(std::get(container_gradients))...); })) { diff --git a/stan/math/rev/core/set_zero_all_adjoints_nested.hpp b/stan/math/rev/core/set_zero_all_adjoints_nested.hpp index eaf9ba8bd9f..282a199ebf4 100644 --- a/stan/math/rev/core/set_zero_all_adjoints_nested.hpp +++ b/stan/math/rev/core/set_zero_all_adjoints_nested.hpp @@ -17,7 +17,7 @@ namespace math { * It is preferred to use the nested_rev_autodiff class for * nested autodiff class as it handles recovery of memory automatically. */ -static void set_zero_all_adjoints_nested() { +static inline void set_zero_all_adjoints_nested() { if (empty_nested()) { throw std::logic_error( "empty_nested() must be false before calling" diff --git a/stan/math/rev/core/vari.hpp b/stan/math/rev/core/vari.hpp index 9722a191d1a..f61d2917dfc 100644 --- a/stan/math/rev/core/vari.hpp +++ b/stan/math/rev/core/vari.hpp @@ -848,7 +848,7 @@ class vari_value> : public vari_base, */ template * = nullptr> explicit vari_value(S&& x) - : adj_(x), val_(std::forward(x)), chainable_alloc() { + : chainable_alloc(), adj_(x), val_(std::forward(x)) { this->set_zero_adjoint(); ChainableStack::instance_->var_stack_.push_back(this); } @@ -871,7 +871,7 @@ class vari_value> : public vari_base, */ template * = nullptr> vari_value(S&& x, bool stacked) - : adj_(x), val_(std::forward(x)), chainable_alloc() { + : chainable_alloc(), adj_(x), val_(std::forward(x)) { this->set_zero_adjoint(); if (stacked) { ChainableStack::instance_->var_stack_.push_back(this); diff --git a/stan/math/rev/fun/beta.hpp b/stan/math/rev/fun/beta.hpp index 25a5cd85701..01e0de95029 100644 --- a/stan/math/rev/fun/beta.hpp +++ b/stan/math/rev/fun/beta.hpp @@ -66,10 +66,9 @@ inline var beta(const var& a, const var& b) { */ inline var beta(const var& a, double b) { auto digamma_ab = digamma(a.val()) - digamma(a.val() + b); - return make_callback_var(beta(a.val(), b), - [a, b, digamma_ab](auto& vi) mutable { - a.adj() += vi.adj() * digamma_ab * vi.val(); - }); + return make_callback_var(beta(a.val(), b), [a, digamma_ab](auto& vi) mutable { + a.adj() += vi.adj() * digamma_ab * vi.val(); + }); } /** @@ -180,10 +179,9 @@ inline auto beta(const Scalar& a, const VarMat& b) { auto digamma_ab = to_arena((digamma(arena_b.val()).array() - digamma(arena_a + arena_b.val().array())) * beta_val.array()); - return make_callback_var( - beta_val, [arena_a, arena_b, digamma_ab](auto& vi) mutable { - arena_b.adj().array() += vi.adj().array() * digamma_ab.array(); - }); + return make_callback_var(beta_val, [arena_b, digamma_ab](auto& vi) mutable { + arena_b.adj().array() += vi.adj().array() * digamma_ab.array(); + }); } } @@ -210,12 +208,11 @@ inline auto beta(const VarMat& a, const Scalar& b) { double arena_b = value_of(b); auto digamma_ab = to_arena(digamma(arena_a.val()).array() - digamma(arena_a.val().array() + arena_b)); - return make_callback_var(beta(arena_a.val(), arena_b), - [arena_a, arena_b, digamma_ab](auto& vi) mutable { - arena_a.adj().array() += vi.adj().array() - * digamma_ab - * vi.val().array(); - }); + return make_callback_var( + beta(arena_a.val(), arena_b), [arena_a, digamma_ab](auto& vi) mutable { + arena_a.adj().array() + += vi.adj().array() * digamma_ab * vi.val().array(); + }); } else if (!is_constant::value) { arena_t> arena_a = value_of(a); var arena_b = b; diff --git a/stan/math/rev/fun/inv_inc_beta.hpp b/stan/math/rev/fun/inv_inc_beta.hpp index 23f1484bf37..097c0383adf 100644 --- a/stan/math/rev/fun/inv_inc_beta.hpp +++ b/stan/math/rev/fun/inv_inc_beta.hpp @@ -59,7 +59,7 @@ inline var inv_inc_beta(const T1& a, const T2& b, const T3& p) { double b_val = value_of(b); double p_val = value_of(p); double w = inv_inc_beta(a_val, b_val, p_val); - return make_callback_var(w, [a, b, p, a_val, b_val, p_val, w](auto& vi) { + return make_callback_var(w, [a, b, p, a_val, b_val, w](auto& vi) { double log_w = log(w); double log1m_w = log1m(w); double one_m_a = 1 - a_val; diff --git a/stan/math/rev/fun/lb_constrain.hpp b/stan/math/rev/fun/lb_constrain.hpp index e132d434190..0bdad75a716 100644 --- a/stan/math/rev/fun/lb_constrain.hpp +++ b/stan/math/rev/fun/lb_constrain.hpp @@ -111,7 +111,7 @@ inline auto lb_constrain(const T& x, const L& lb, var& lp) { }); } else { return make_callback_var(std::exp(value_of(x)) + lb_val, - [lp, arena_lb = var(lb)](auto& vi) mutable { + [arena_lb = var(lb)](auto& vi) mutable { arena_lb.adj() += vi.adj(); }); } @@ -211,7 +211,7 @@ inline auto lb_constrain(const T& x, const L& lb, return_type_t& lp) { const auto& x_ref = to_ref(x); lp += sum(x_ref); arena_t ret = value_of(x_ref).array().exp() + lb_val; - reverse_pass_callback([ret, lp, arena_lb = var(lb)]() mutable { + reverse_pass_callback([ret, arena_lb = var(lb)]() mutable { arena_lb.adj() += ret.adj().sum(); }); return ret_type(ret); @@ -333,7 +333,6 @@ inline auto lb_constrain(const T& x, const L& lb, return_type_t& lp) { auto exp_x = to_arena(arena_x.val().array().exp()); arena_t ret = (is_not_inf_lb).select(exp_x + lb_val, arena_x.val().array()); - auto lp_old = lp; lp += (is_not_inf_lb).select(arena_x.val(), 0).sum(); reverse_pass_callback([arena_x, ret, exp_x, lp, is_not_inf_lb]() mutable { const auto lp_adj = lp.adj(); diff --git a/stan/math/rev/fun/lub_constrain.hpp b/stan/math/rev/fun/lub_constrain.hpp index 4910bb1aa05..ac54a675b8b 100644 --- a/stan/math/rev/fun/lub_constrain.hpp +++ b/stan/math/rev/fun/lub_constrain.hpp @@ -313,28 +313,28 @@ inline auto lub_constrain(const T& x, const L& lb, const U& ub, } else { arena_t arena_x = x; arena_t arena_lb = lb; - const auto x_val = value_of(arena_x).array(); + const auto arena_x_val = to_arena(value_of(arena_x).array()); const auto lb_val = value_of(arena_lb).array().eval(); check_less("lub_constrain", "lb", lb_val, ub_val); auto is_lb_inf = to_arena((lb_val == NEGATIVE_INFTY)); auto diff = to_arena(ub_val - lb_val); - auto neg_abs_x = to_arena(-(value_of(arena_x).array()).abs()); - auto inv_logit_x = to_arena(inv_logit(value_of(arena_x).array())); - arena_t ret = (is_lb_inf).select( - ub_val - value_of(arena_x).array().exp(), diff * inv_logit_x + lb_val); + auto neg_abs_x = to_arena(-arena_x_val.abs()); + auto inv_logit_x = to_arena(inv_logit(arena_x_val)); + arena_t ret = (is_lb_inf).select(ub_val - arena_x_val.exp(), + diff * inv_logit_x + lb_val); lp += (is_lb_inf) - .select(value_of(arena_x).array(), + .select(arena_x_val, log(diff) + (neg_abs_x - (2.0 * log1p_exp(neg_abs_x)))) .sum(); - reverse_pass_callback([arena_x, ub, arena_lb, ret, lp, diff, inv_logit_x, - is_lb_inf]() mutable { + reverse_pass_callback([arena_x, arena_x_val, ub, arena_lb, ret, lp, diff, + inv_logit_x, is_lb_inf]() mutable { using T_var = arena_t>; using L_var = arena_t>; const auto lp_adj = lp.adj(); if (!is_constant::value) { - const auto x_sign = value_of(arena_x).array().sign().eval(); + const auto x_sign = arena_x_val.sign().eval(); forward_as(arena_x).adj().array() += (is_lb_inf).select( - ret.adj().array() * -value_of(arena_x).array().exp() + lp_adj, + ret.adj().array() * -arena_x_val.exp() + lp_adj, ret.adj().array() * diff * inv_logit_x * (1.0 - inv_logit_x) + lp.adj() * (1.0 - 2.0 * inv_logit_x)); } diff --git a/stan/math/rev/fun/read_cov_L.hpp b/stan/math/rev/fun/read_cov_L.hpp index 0c294742932..d4e7b4da8ce 100644 --- a/stan/math/rev/fun/read_cov_L.hpp +++ b/stan/math/rev/fun/read_cov_L.hpp @@ -39,7 +39,7 @@ inline auto read_cov_L(const T_CPCs& CPCs, const T_sds& sds, var_value res = sds.val().matrix().asDiagonal() * corr_L.val(); - reverse_pass_callback([CPCs, sds, corr_L, log_prob, res]() mutable { + reverse_pass_callback([sds, corr_L, log_prob, res]() mutable { size_t K = sds.size(); corr_L.adj() += sds.val().matrix().asDiagonal() * res.adj(); diff --git a/stan/math/rev/fun/svd.hpp b/stan/math/rev/fun/svd.hpp index f0c3e4656b2..33ef934cbc9 100644 --- a/stan/math/rev/fun/svd.hpp +++ b/stan/math/rev/fun/svd.hpp @@ -61,7 +61,7 @@ inline auto svd(const EigMat& m) { arena_t arena_V = svd.matrixV(); reverse_pass_callback([arena_m, arena_U, singular_values, arena_V, arena_Fp, - arena_Fm, M]() mutable { + arena_Fm]() mutable { // SVD-U reverse mode Eigen::MatrixXd UUadjT = arena_U.val_op().transpose() * arena_U.adj_op(); auto u_adj diff --git a/stan/math/rev/fun/svd_U.hpp b/stan/math/rev/fun/svd_U.hpp index bc7d1481b2c..6a208e3c6e3 100644 --- a/stan/math/rev/fun/svd_U.hpp +++ b/stan/math/rev/fun/svd_U.hpp @@ -52,8 +52,8 @@ inline auto svd_U(const EigMat& m) { arena_t arena_U = svd.matrixU(); auto arena_V = to_arena(svd.matrixV()); - reverse_pass_callback([arena_m, arena_U, arena_D, arena_V, arena_Fp, - M]() mutable { + reverse_pass_callback([arena_m, arena_U, arena_D, arena_V, + arena_Fp]() mutable { Eigen::MatrixXd UUadjT = arena_U.val_op().transpose() * arena_U.adj_op(); arena_m.adj() += .5 * arena_U.val_op() diff --git a/stan/math/rev/fun/svd_V.hpp b/stan/math/rev/fun/svd_V.hpp index aaa4b2806d8..963c3c71572 100644 --- a/stan/math/rev/fun/svd_V.hpp +++ b/stan/math/rev/fun/svd_V.hpp @@ -52,8 +52,8 @@ inline auto svd_V(const EigMat& m) { auto arena_U = to_arena(svd.matrixU()); arena_t arena_V = svd.matrixV(); - reverse_pass_callback([arena_m, arena_U, arena_D, arena_V, arena_Fm, - M]() mutable { + reverse_pass_callback([arena_m, arena_U, arena_D, arena_V, + arena_Fm]() mutable { Eigen::MatrixXd VTVadj = arena_V.val_op().transpose() * arena_V.adj_op(); arena_m.adj() += 0.5 * arena_U diff --git a/stan/math/rev/fun/ub_constrain.hpp b/stan/math/rev/fun/ub_constrain.hpp index aa43b65b0e7..9057330c691 100644 --- a/stan/math/rev/fun/ub_constrain.hpp +++ b/stan/math/rev/fun/ub_constrain.hpp @@ -214,7 +214,7 @@ inline auto ub_constrain(const T& x, const U& ub, return_type_t& lp) { auto x_ref = to_ref(value_of(x)); arena_t ret = ub_val - x_ref.array().exp(); lp += x_ref.sum(); - reverse_pass_callback([ret, lp, arena_ub = var(ub)]() mutable { + reverse_pass_callback([ret, arena_ub = var(ub)]() mutable { arena_ub.adj() += ret.adj().sum(); }); return ret_type(ret); diff --git a/stan/math/rev/functor/cvodes_integrator_adjoint.hpp b/stan/math/rev/functor/cvodes_integrator_adjoint.hpp index 0c23f0758bf..a1769f4bdee 100644 --- a/stan/math/rev/functor/cvodes_integrator_adjoint.hpp +++ b/stan/math/rev/functor/cvodes_integrator_adjoint.hpp @@ -93,8 +93,8 @@ class cvodes_integrator_adjoint_vari : public vari_base { N_Vector nv_absolute_tolerance_forward_; N_Vector nv_absolute_tolerance_backward_; SUNMatrix A_forward_; - SUNLinearSolver LS_forward_; SUNMatrix A_backward_; + SUNLinearSolver LS_forward_; SUNLinearSolver LS_backward_; void* cvodes_mem_; std::tuple local_args_tuple_; diff --git a/stan/math/rev/functor/dae_system.hpp b/stan/math/rev/functor/dae_system.hpp index 544f0affd85..02b0096988d 100644 --- a/stan/math/rev/functor/dae_system.hpp +++ b/stan/math/rev/functor/dae_system.hpp @@ -81,17 +81,17 @@ class dae_system { dae_system(const F& f, const Tyy& yy0, const Typ& yp0, std::ostream* msgs, const T_par&... args) : f_(f), + local_args_tuple_(deep_copy_vars(args)...), + dbl_args_tuple_(value_of(args)...), + args_tuple_(std::forward_as_tuple(args...)), + msgs_(msgs), yy(yy0), yp(yp0), dbl_yy(stan::math::value_of(yy0)), dbl_yp(stan::math::value_of(yp0)), - local_args_tuple_(deep_copy_vars(args)...), - dbl_args_tuple_(value_of(args)...), - args_tuple_(std::forward_as_tuple(args...)), N(yy0.size()), M(count_vars(args...)), ns((is_var_yy0 ? N : 0) + (is_var_yp0 ? N : 0) + M), - msgs_(msgs), varis(ChainableStack::instance_->memalloc_.alloc_array(ns)), all_vars(ns), dbl_rr(N) { diff --git a/test/unit/math/mix/core/operator_division_test.cpp b/test/unit/math/mix/core/operator_division_test.cpp index e64c0f7621d..f279595907b 100644 --- a/test/unit/math/mix/core/operator_division_test.cpp +++ b/test/unit/math/mix/core/operator_division_test.cpp @@ -55,8 +55,6 @@ struct operator_divide_tester { } // namespace stan TEST(mathMixCore, operatorDivisionVarMat) { - auto f = [](const auto& x1, const auto& x2) { return x1 / x2; }; - Eigen::MatrixXd mat1(2, 2); mat1 << -2, -1, 0.5, 2.8; Eigen::MatrixXd mat2 = mat1.reverse(); diff --git a/test/unit/math/mix/core/operator_minus_minus_test.cpp b/test/unit/math/mix/core/operator_minus_minus_test.cpp index e47046a748a..b9815ac9f9c 100644 --- a/test/unit/math/mix/core/operator_minus_minus_test.cpp +++ b/test/unit/math/mix/core/operator_minus_minus_test.cpp @@ -5,6 +5,8 @@ TEST(mathMixCore, operatorMinusMinusPre1) { auto f = [](const auto& x1) { auto y = x1; auto z = --y; + // Suppress unused variable warning + z = z + 0; return y; }; stan::test::expect_common_unary(f); @@ -24,6 +26,8 @@ TEST(mathMixCore, operatorMinusMinusPost1) { auto f = [](const auto& x1) { auto y = x1; auto z = y--; + // Suppress unused variable warning + z = z + 0; return y; }; stan::test::expect_common_unary(f); diff --git a/test/unit/math/mix/core/operator_plus_plus_test.cpp b/test/unit/math/mix/core/operator_plus_plus_test.cpp index 5306ff7c109..5c2b6ed285a 100644 --- a/test/unit/math/mix/core/operator_plus_plus_test.cpp +++ b/test/unit/math/mix/core/operator_plus_plus_test.cpp @@ -5,6 +5,8 @@ TEST(mathMixCore, operatorPlusPlusPre1) { auto f = [](const auto& x1) { auto y = x1; auto z = ++y; + // Suppress unused variable warning + z = z + 0; return y; }; stan::test::expect_common_unary(f); @@ -24,6 +26,8 @@ TEST(mathMixCore, operatorPlusPlusPost1) { auto f = [](const auto& x1) { auto y = x1; auto z = y++; + // Suppress unused variable warning + z = z + 0; return y; }; stan::test::expect_common_unary(f); diff --git a/test/unit/math/mix/fun/abs_test.cpp b/test/unit/math/mix/fun/abs_test.cpp index 20e8bcb3488..d62982c3ba5 100644 --- a/test/unit/math/mix/fun/abs_test.cpp +++ b/test/unit/math/mix/fun/abs_test.cpp @@ -17,6 +17,11 @@ TEST(mixFun, absBasics) { // test int -> int vectorization std::vector u{1, 2, 3, 4}; std::vector v = abs(u); + + EXPECT_FLOAT_EQ(a, 1); + EXPECT_FLOAT_EQ(b, 2.3); + EXPECT_MATRIX_EQ(x, y); + EXPECT_STD_VECTOR_EQ(u, v); } template @@ -231,9 +236,11 @@ TEST(mixFun, absReturnType) { // validate return types not overpromoted to complex by assignability std::complex a = 3; stan::math::var b = abs(a); + EXPECT_FLOAT_EQ(b.val(), 3); std::complex> c = 3; stan::math::fvar d = abs(c); + EXPECT_FLOAT_EQ(d.val(), 3); SUCCEED(); } diff --git a/test/unit/math/mix/fun/eigendecompose_identity_complex_test.cpp b/test/unit/math/mix/fun/eigendecompose_identity_complex_test.cpp index 098d133ebf2..65be4d32153 100644 --- a/test/unit/math/mix/fun/eigendecompose_identity_complex_test.cpp +++ b/test/unit/math/mix/fun/eigendecompose_identity_complex_test.cpp @@ -40,6 +40,7 @@ TEST(mathMixFun, eigenvectorsIdComplex) { using fv_t = stan::math::fvar; using ffv_t = stan::math::fvar; + expectComplexEigenvectorsId(); expectComplexEigenvectorsId(); expectComplexEigenvectorsId(); expectComplexEigenvectorsId(); diff --git a/test/unit/math/mix/fun/eigendecompose_identity_test.cpp b/test/unit/math/mix/fun/eigendecompose_identity_test.cpp index abf0735f0ef..8a2f99ddc3f 100644 --- a/test/unit/math/mix/fun/eigendecompose_identity_test.cpp +++ b/test/unit/math/mix/fun/eigendecompose_identity_test.cpp @@ -14,12 +14,12 @@ template void expectEigenvectorsId() { for (const auto& m_d : stan::test::square_test_matrices(1, 2)) { Eigen::Matrix m(m_d); - auto vecs = eigenvectors(m).eval(); - auto vals = eigenvalues(m).eval(); + auto vecs = stan::math::eigenvectors(m).eval(); + auto vals = stan::math::eigenvalues(m).eval(); auto I = (vecs.inverse() * m * vecs * vals.asDiagonal().inverse()).real(); expect_identity_matrix(I); - std::tie(vecs, vals) = eigendecompose(m); + std::tie(vecs, vals) = stan::math::eigendecompose(m); auto I2 = (vecs.inverse() * m * vecs * vals.asDiagonal().inverse()).real(); expect_identity_matrix(I2); } @@ -33,6 +33,7 @@ TEST(mathMixFun, eigenvectorsId) { using fv_t = stan::math::fvar; using ffv_t = stan::math::fvar; + expectEigenvectorsId(); expectEigenvectorsId(); expectEigenvectorsId(); expectEigenvectorsId(); diff --git a/test/unit/math/mix/fun/generalized_inverse_test.cpp b/test/unit/math/mix/fun/generalized_inverse_test.cpp index 723ed902984..98610f02010 100644 --- a/test/unit/math/mix/fun/generalized_inverse_test.cpp +++ b/test/unit/math/mix/fun/generalized_inverse_test.cpp @@ -79,11 +79,6 @@ TEST(mathMixMatFun, gen_inv_test_6) { } TEST(mathMixMatFun, gen_inv_test_8) { - using stan::test::expect_ad; - using stan::test::expect_ad_matvar; - - auto f = [](const auto& G) { return stan::math::generalized_inverse(G); }; - Eigen::MatrixXd z(2, 2); z << 1, 2, 5, std::numeric_limits::quiet_NaN(); EXPECT_NO_THROW(stan::math::generalized_inverse(z)); diff --git a/test/unit/math/mix/fun/pow_part2_test.cpp b/test/unit/math/mix/fun/pow_part2_test.cpp index 440c4aa0e39..6fb46d08e2d 100644 --- a/test/unit/math/mix/fun/pow_part2_test.cpp +++ b/test/unit/math/mix/fun/pow_part2_test.cpp @@ -89,7 +89,9 @@ TEST(mathMixFun, powIntAmbiguityTest) { auto d5 = pow(cv, cv); auto e = a1 + a2 + a3 + a4 + a5 + b1 + b2 + b3 + b4 + b5 + c1 + c2 + c3 + c4 - + c5 + d1 + d2 + d3 + d4 + d5; + + c5 + d1 + d2 + d3 + d4 + d5 + e1 + e2 + e3 + e4 + e5; + // Suppress unused variable warning + e = e + 0; } TEST(mathMixFun, powIntAmbiguityTestFvar) { @@ -128,4 +130,6 @@ TEST(mathMixFun, powIntAmbiguityTestFvar) { auto e = a1 + a2 + a3 + a4 + a5 + b1 + b2 + b3 + b4 + b5 + c1 + c2 + c3 + c4 + c5 + d1 + d2 + d3 + d4 + d5; + // Suppress unused variable warning + e = e + 0; } diff --git a/test/unit/math/mix/fun/scalbn_test.cpp b/test/unit/math/mix/fun/scalbn_test.cpp index d68618fc38e..e02da4c82a4 100644 --- a/test/unit/math/mix/fun/scalbn_test.cpp +++ b/test/unit/math/mix/fun/scalbn_test.cpp @@ -26,7 +26,7 @@ void expect_all_scalbn(double x) { TEST(mathMixMatFun, scalbn) { double inf = std::numeric_limits::infinity(); double nan = std::numeric_limits::quiet_NaN(); - for (double x : std::vector{2.3}) { + for (double x : std::vector{2.3, inf, nan}) { expect_all_scalbn(x); } } diff --git a/test/unit/math/mix/fun/to_complex_test.cpp b/test/unit/math/mix/fun/to_complex_test.cpp index 5a35775393a..acec1e94bd8 100644 --- a/test/unit/math/mix/fun/to_complex_test.cpp +++ b/test/unit/math/mix/fun/to_complex_test.cpp @@ -8,7 +8,7 @@ TEST(mathMixMatFun, to_complex) { return stan::math::to_complex(x, y); }; - EXPECT_EQ(std::complex(), stan::math::to_complex()); + EXPECT_EQ(std::complex(), f0()); stan::test::expect_common_unary(f1); stan::test::expect_common_binary(f2); } diff --git a/test/unit/math/mix/fun/trace_gen_inv_quad_form_ldlt_test.cpp b/test/unit/math/mix/fun/trace_gen_inv_quad_form_ldlt_test.cpp index e07e730d0eb..b337526634d 100644 --- a/test/unit/math/mix/fun/trace_gen_inv_quad_form_ldlt_test.cpp +++ b/test/unit/math/mix/fun/trace_gen_inv_quad_form_ldlt_test.cpp @@ -81,10 +81,6 @@ TEST(mathMixMatFun, traceGenInvQuadForm_vec) { return stan::math::trace_gen_inv_quad_form_ldlt(c, ldlt_a, b); }; - auto f1 = [&](const auto& c) { - return [&](const auto& a, const auto& b) { return f(c, a, b); }; - }; - Eigen::MatrixXd a00(0, 0); Eigen::MatrixXd b00(0, 0); Eigen::VectorXd c0(0); diff --git a/test/unit/math/opencl/rev/add_test.cpp b/test/unit/math/opencl/rev/add_test.cpp index a0a47be5276..15c4d501b2f 100644 --- a/test/unit/math/opencl/rev/add_test.cpp +++ b/test/unit/math/opencl/rev/add_test.cpp @@ -50,7 +50,6 @@ TEST(OpenCLPrim, add_m_small_zero) { stan::math::test::compare_cpu_opencl_prim_rev(add_functor, d0, d0); double d3 = 3.0; - auto a = stan::math::add(d1, d3); stan::math::test::compare_cpu_opencl_prim_rev(add_functor, d1, d3); stan::math::test::compare_cpu_opencl_prim_rev(add_functor, d3, d1); stan::math::test::compare_cpu_opencl_prim_rev(add_functor, d3, d0); diff --git a/test/unit/math/opencl/rev/cauchy_cdf_test.cpp b/test/unit/math/opencl/rev/cauchy_cdf_test.cpp index 87a04257b93..022f3ce1334 100644 --- a/test/unit/math/opencl/rev/cauchy_cdf_test.cpp +++ b/test/unit/math/opencl/rev/cauchy_cdf_test.cpp @@ -62,7 +62,6 @@ auto cauchy_cdf_functor = [](const auto& y, const auto& mu, const auto& sigma) { TEST(ProbDistributionsCauchyCdf, opencl_matches_cpu_small) { int N = 3; - int M = 2; Eigen::VectorXd y(N); y << 0.3, 0.8, 1.0; @@ -80,7 +79,6 @@ TEST(ProbDistributionsCauchyCdf, opencl_matches_cpu_small) { TEST(ProbDistributionsCauchyCdf, opencl_matches_cpu_small_y_neg_inf) { int N = 3; - int M = 2; Eigen::VectorXd y(N); y << 0.3, -INFINITY, 1.0; diff --git a/test/unit/math/opencl/rev/dirichlet_lpdf_test.cpp b/test/unit/math/opencl/rev/dirichlet_lpdf_test.cpp index 46456104097..a1790aab93d 100644 --- a/test/unit/math/opencl/rev/dirichlet_lpdf_test.cpp +++ b/test/unit/math/opencl/rev/dirichlet_lpdf_test.cpp @@ -76,7 +76,6 @@ auto dirichlet_lpdf_functor_propto = [](const auto& theta, const auto& alpha) { TEST(ProbDistributionsDirichlet, opencl_matches_cpu_small) { int N = 3; - int M = 2; Eigen::VectorXd theta1(N); theta1 << 0.5, 0.4, 0.1; diff --git a/test/unit/math/opencl/rev/exp_mod_normal_lcdf_test.cpp b/test/unit/math/opencl/rev/exp_mod_normal_lcdf_test.cpp index db7084537a0..8aa201f3a4f 100644 --- a/test/unit/math/opencl/rev/exp_mod_normal_lcdf_test.cpp +++ b/test/unit/math/opencl/rev/exp_mod_normal_lcdf_test.cpp @@ -88,7 +88,6 @@ auto exp_mod_normal_lcdf_functor TEST(ProbDistributionsDoubleExpModNormalLcdf, opencl_matches_cpu_small) { int N = 3; - int M = 2; Eigen::VectorXd y(N); y << -0.3, 1.8, 1.4; @@ -109,7 +108,6 @@ TEST(ProbDistributionsDoubleExpModNormalLcdf, opencl_matches_cpu_small) { TEST(ProbDistributionsDoubleExpModNormalLcdf, opencl_matches_cpu_small_y_pos_inf) { int N = 3; - int M = 2; Eigen::VectorXd y(N); y << -0.3, 1.8, INFINITY; @@ -130,7 +128,6 @@ TEST(ProbDistributionsDoubleExpModNormalLcdf, TEST(ProbDistributionsDoubleExpModNormalLcdf, opencl_matches_cpu_small_y_neg_inf) { int N = 3; - int M = 2; Eigen::VectorXd y(N); y << -0.3, 1.8, -INFINITY; diff --git a/test/unit/math/opencl/rev/normal_lpdf_test.cpp b/test/unit/math/opencl/rev/normal_lpdf_test.cpp index 0a4d2e98f05..0a8df483c48 100644 --- a/test/unit/math/opencl/rev/normal_lpdf_test.cpp +++ b/test/unit/math/opencl/rev/normal_lpdf_test.cpp @@ -67,7 +67,6 @@ auto normal_lpdf_functor_propto TEST(ProbDistributionsNormal, opencl_matches_cpu_small) { int N = 3; - int M = 2; Eigen::VectorXd y(N); y << 0.3, 0.8, 1.0; diff --git a/test/unit/math/opencl/rev/scaled_inv_chi_square_lpdf_test.cpp b/test/unit/math/opencl/rev/scaled_inv_chi_square_lpdf_test.cpp index cf698c694a5..90bafb1a806 100644 --- a/test/unit/math/opencl/rev/scaled_inv_chi_square_lpdf_test.cpp +++ b/test/unit/math/opencl/rev/scaled_inv_chi_square_lpdf_test.cpp @@ -77,7 +77,6 @@ auto scaled_inv_chi_square_lpdf_functor_propto TEST(ProbDistributionsScaledInvChiSquare, opencl_matches_cpu_small) { int N = 3; - int M = 2; Eigen::VectorXd y(N); y << 0.3, 0.8, 1.0; @@ -100,7 +99,6 @@ TEST(ProbDistributionsScaledInvChiSquare, opencl_matches_cpu_small) { TEST(ProbDistributionsScaledInvChiSquare, opencl_matches_cpu_small_y_negative) { int N = 3; - int M = 2; Eigen::VectorXd y(N); y << 0.3, -0.8, 1.0; diff --git a/test/unit/math/opencl/rev/student_t_lpdf_test.cpp b/test/unit/math/opencl/rev/student_t_lpdf_test.cpp index b6b56727a50..886f9687735 100644 --- a/test/unit/math/opencl/rev/student_t_lpdf_test.cpp +++ b/test/unit/math/opencl/rev/student_t_lpdf_test.cpp @@ -91,7 +91,6 @@ auto student_t_lpdf_functor_propto TEST(ProbDistributionsStudentT, opencl_matches_cpu_small) { int N = 3; - int M = 2; Eigen::VectorXd y(N); y << 0.3, -0.8, 1.0; diff --git a/test/unit/math/prim/err/check_consistent_sizes_mvt_test.cpp b/test/unit/math/prim/err/check_consistent_sizes_mvt_test.cpp index 934f893ba15..38ffd05b6a4 100644 --- a/test/unit/math/prim/err/check_consistent_sizes_mvt_test.cpp +++ b/test/unit/math/prim/err/check_consistent_sizes_mvt_test.cpp @@ -6,8 +6,6 @@ TEST(checkConsistentSizesMvt, checkConsistentSizesMvt) { using stan::math::check_consistent_sizes_mvt; - size_t expected_size = 3; - std::vector good(3); Eigen::VectorXd good_single(4); good_single << 1.0, 2.0, 3.0, 4.0; diff --git a/test/unit/math/prim/err/check_greater_or_equal_test.cpp b/test/unit/math/prim/err/check_greater_or_equal_test.cpp index 90a6c2a5ad2..b07bc3985ca 100644 --- a/test/unit/math/prim/err/check_greater_or_equal_test.cpp +++ b/test/unit/math/prim/err/check_greater_or_equal_test.cpp @@ -6,8 +6,8 @@ TEST(ErrorHandlingMat, CheckGreaterOrEqualMatrix) { using stan::math::check_greater_or_equal; const char* function = "check_greater_or_equal"; - double x; - double low; + double x = 0; + double low = 0; Eigen::Matrix x_mat; Eigen::Matrix low_mat; x_mat.resize(3, 3); @@ -161,8 +161,8 @@ TEST(ErrorHandlingMat, CheckGreaterOrEqualMatrix) { TEST(ErrorHandlingMat, CheckGreaterOrEqual_Matrix_one_indexed_message) { using stan::math::check_greater_or_equal; static const char* function = "check_greater_or_equal"; - double x; - double low; + double x = 0; + double low = 0; Eigen::Matrix x_mat; Eigen::Matrix low_mat; x_mat.resize(3, 3); @@ -234,8 +234,8 @@ TEST(ErrorHandlingMat, CheckGreaterOrEqual_nan) { const char* function = "check_greater_or_equal"; double nan = std::numeric_limits::quiet_NaN(); - double x; - double low; + double x = 0; + double low = 0; Eigen::Matrix x_mat(3, 3); x_mat << -1, 0, 1, -1, 0, 1, -1, 0, 1; Eigen::Matrix low_mat(3, 3); diff --git a/test/unit/math/prim/err/check_greater_test.cpp b/test/unit/math/prim/err/check_greater_test.cpp index 6cca864d182..86d861b9893 100644 --- a/test/unit/math/prim/err/check_greater_test.cpp +++ b/test/unit/math/prim/err/check_greater_test.cpp @@ -6,8 +6,8 @@ TEST(ErrorHandlingMat, CheckGreater_Matrix) { using stan::math::check_greater; const char* function = "check_greater"; - double x; - double low; + double x = 0; + double low = 0; Eigen::Matrix x_mat; Eigen::Matrix low_mat; x_mat.resize(3, 3); @@ -155,8 +155,8 @@ TEST(ErrorHandlingMat, CheckGreater_Matrix) { TEST(ErrorHandlingMat, CheckGreater_Matrix_one_indexed_message) { using stan::math::check_greater; static const char* function = "check_greater"; - double x; - double low; + double x = 0; + double low = 0; Eigen::Matrix x_mat; Eigen::Matrix low_mat; x_mat.resize(3, 3); diff --git a/test/unit/math/prim/err/check_less_or_equal_test.cpp b/test/unit/math/prim/err/check_less_or_equal_test.cpp index e695b8859fd..c38022f0954 100644 --- a/test/unit/math/prim/err/check_less_or_equal_test.cpp +++ b/test/unit/math/prim/err/check_less_or_equal_test.cpp @@ -6,8 +6,8 @@ TEST(ErrorHandlingMat, CheckLessOrEqual_Matrix) { using stan::math::check_less_or_equal; const char* function = "check_less_or_equal"; - double x; - double high; + double x = 0; + double high = 0; Eigen::Matrix x_mat; Eigen::Matrix high_mat; x_mat.resize(3, 3); @@ -120,8 +120,8 @@ TEST(ErrorHandlingMat, CheckLessOrEqual_Matrix) { TEST(ErrorHandlingMat, CheckLessOrEqual_Matrix_one_indexed_message) { using stan::math::check_less_or_equal; const char* function = "check_less"; - double x; - double high; + double x = 0; + double high = 0; Eigen::Matrix x_mat; Eigen::Matrix high_mat; x_mat.resize(3, 3); diff --git a/test/unit/math/prim/err/check_less_test.cpp b/test/unit/math/prim/err/check_less_test.cpp index 87a80b2658f..a1184b55c16 100644 --- a/test/unit/math/prim/err/check_less_test.cpp +++ b/test/unit/math/prim/err/check_less_test.cpp @@ -6,8 +6,8 @@ TEST(ErrorHandlingMat, CheckLess_Matrix) { using stan::math::check_less; const char* function = "check_less"; - double x; - double high; + double x = 0; + double high = 0; Eigen::Matrix x_mat; Eigen::Matrix high_mat; x_mat.resize(3, 3); @@ -124,8 +124,8 @@ TEST(ErrorHandlingMat, CheckLess_Matrix) { TEST(ErrorHandlingMat, CheckLess_Matrix_one_indexed_message) { using stan::math::check_less; const char* function = "check_less"; - double x; - double high; + double x = 0; + double high = 0; Eigen::Matrix x_mat; Eigen::Matrix high_mat; x_mat.resize(3, 3); diff --git a/test/unit/math/prim/err/check_matching_dims_test.cpp b/test/unit/math/prim/err/check_matching_dims_test.cpp index 78e4f0b46da..4643355b52f 100644 --- a/test/unit/math/prim/err/check_matching_dims_test.cpp +++ b/test/unit/math/prim/err/check_matching_dims_test.cpp @@ -153,7 +153,7 @@ TEST(ErrorHandlingMatrix, checkMatchingDims_compile_time_sizes) { TEST(ErrorHandlingMatrix, checkMatchingDimsScalar) { Eigen::Matrix y1; - double x; + double x = 0; y1.resize(3, 3); EXPECT_THROW( diff --git a/test/unit/math/prim/fun/dims_test.cpp b/test/unit/math/prim/fun/dims_test.cpp index e619799f94c..67a988a8598 100644 --- a/test/unit/math/prim/fun/dims_test.cpp +++ b/test/unit/math/prim/fun/dims_test.cpp @@ -8,11 +8,11 @@ TEST(MathMatrixPrimMat, dims) { using stan::math::dims; using std::vector; - double x1; + double x1 = 0; vector dims1 = dims(x1); EXPECT_EQ(0U, dims1.size()); - int x2; + int x2 = 0; vector dims2 = dims(x2); EXPECT_EQ(0U, dims2.size()); diff --git a/test/unit/math/prim/fun/gp_exponential_cov_test.cpp b/test/unit/math/prim/fun/gp_exponential_cov_test.cpp index 67971fabc77..cad2e7af4c7 100644 --- a/test/unit/math/prim/fun/gp_exponential_cov_test.cpp +++ b/test/unit/math/prim/fun/gp_exponential_cov_test.cpp @@ -109,7 +109,6 @@ TEST(MathPrimMat, vec_eigen_vec_eigen_gp_exponential_cov1) { TEST(MathPrimMat, vec_eigen_vec_eigen_ard_gp_exponential_cov1) { double sigma = 0.3; - double temp; std::vector l = {1, 2, 3}; diff --git a/test/unit/math/prim/fun/grad_2F1_test.cpp b/test/unit/math/prim/fun/grad_2F1_test.cpp index 7561c26831f..f2236c04167 100644 --- a/test/unit/math/prim/fun/grad_2F1_test.cpp +++ b/test/unit/math/prim/fun/grad_2F1_test.cpp @@ -68,8 +68,7 @@ TEST(MathPrimScalFun, grad2F1_4) { double b1 = 10; double z = 1; - EXPECT_THROW(auto grad_tuple = stan::math::grad_2F1(a1, a2, b1, z), - std::domain_error); + EXPECT_THROW(stan::math::grad_2F1(a1, a2, b1, z), std::domain_error); } TEST(MathPrimScalFun, grad2F1_5) { @@ -78,8 +77,7 @@ TEST(MathPrimScalFun, grad2F1_5) { double b1 = 20; double z = 1.2; - EXPECT_THROW(auto grad_tuple = stan::math::grad_2F1(a1, a2, b1, z), - std::domain_error); + EXPECT_THROW(stan::math::grad_2F1(a1, a2, b1, z), std::domain_error); } TEST(MathPrimScalFun, grad2F1_6) { diff --git a/test/unit/math/prim/fun/offset_multiplier_matrix_transform_test.cpp b/test/unit/math/prim/fun/offset_multiplier_matrix_transform_test.cpp index ae3be863301..22b181dae61 100644 --- a/test/unit/math/prim/fun/offset_multiplier_matrix_transform_test.cpp +++ b/test/unit/math/prim/fun/offset_multiplier_matrix_transform_test.cpp @@ -18,8 +18,6 @@ TEST(prob_transform, offset_multiplier_matrix_j) { EXPECT_MATRIX_EQ(mu.array() + sigma.array() * x.array(), offset_multiplier_constrain(x, mu, sigma, lp)); EXPECT_FLOAT_EQ(-17.0 + sum(log(sigma)), lp); - - double lp1 = -12.9; } TEST(ProbTransform, offset_multiplier_matrix_Exception) { diff --git a/test/unit/math/prim/fun/select_test.cpp b/test/unit/math/prim/fun/select_test.cpp index cc572be9924..1086b27e9fc 100644 --- a/test/unit/math/prim/fun/select_test.cpp +++ b/test/unit/math/prim/fun/select_test.cpp @@ -11,8 +11,6 @@ TEST(MathFunctions, select_scalar_scalar) { EXPECT_FLOAT_EQ(5.5, select(false, 2.0, 5.5)); double dbl_a = -5.5; - int int_a = -5; - double dbl_b = 6.3251; int int_b = 6; int int_res = select(false, dbl_a, int_b); diff --git a/test/unit/math/prim/fun/size_mvt_test.cpp b/test/unit/math/prim/fun/size_mvt_test.cpp index 0d514e59605..bacfb2844b1 100644 --- a/test/unit/math/prim/fun/size_mvt_test.cpp +++ b/test/unit/math/prim/fun/size_mvt_test.cpp @@ -5,10 +5,10 @@ TEST(MathPrimFun, size_mvt_scalar) { using stan::math::size_mvt; - double x1; + double x1 = 0; EXPECT_THROW(size_mvt(x1), std::invalid_argument); - int x2; + int x2 = 0; EXPECT_THROW(size_mvt(x2), std::invalid_argument); } diff --git a/test/unit/math/prim/fun/size_zero_test.cpp b/test/unit/math/prim/fun/size_zero_test.cpp index 18aa5d4147b..41082d4ad38 100644 --- a/test/unit/math/prim/fun/size_zero_test.cpp +++ b/test/unit/math/prim/fun/size_zero_test.cpp @@ -6,7 +6,7 @@ TEST(MathMatrixPrimScal, size_zero) { std::vector x(3), y(0); stan::math::matrix_d m(3, 4); stan::math::matrix_d n(3, 0); - int f, g; + int f = 0, g = 0; EXPECT_EQ(0, stan::math::size_zero(x)); EXPECT_EQ(0, stan::math::size_zero(m)); diff --git a/test/unit/math/prim/functor/integrate_1d_impl_test.cpp b/test/unit/math/prim/functor/integrate_1d_impl_test.cpp index dc456fd353b..9d6c665800e 100644 --- a/test/unit/math/prim/functor/integrate_1d_impl_test.cpp +++ b/test/unit/math/prim/functor/integrate_1d_impl_test.cpp @@ -337,19 +337,15 @@ TEST(StanMath_integrate_1d_impl_prim, TestThrows) { } TEST(StanMath_integrate_1d_impl_prim, test_integer_arguments) { - double v; - EXPECT_NO_THROW( - v = stan::math::integrate_1d_impl(integrate_1d_impl_test::f2{}, 0, 1, - std::sqrt(stan::math::EPSILON), - integrate_1d_impl_test::msgs)); - EXPECT_NO_THROW( - v = stan::math::integrate_1d_impl(integrate_1d_impl_test::f2{}, 0.0, 1, - std::sqrt(stan::math::EPSILON), - integrate_1d_impl_test::msgs)); - EXPECT_NO_THROW( - v = stan::math::integrate_1d_impl(integrate_1d_impl_test::f2{}, 0, 1.0, - std::sqrt(stan::math::EPSILON), - integrate_1d_impl_test::msgs)); + EXPECT_NO_THROW(stan::math::integrate_1d_impl( + integrate_1d_impl_test::f2{}, 0, 1, std::sqrt(stan::math::EPSILON), + integrate_1d_impl_test::msgs)); + EXPECT_NO_THROW(stan::math::integrate_1d_impl( + integrate_1d_impl_test::f2{}, 0.0, 1, std::sqrt(stan::math::EPSILON), + integrate_1d_impl_test::msgs)); + EXPECT_NO_THROW(stan::math::integrate_1d_impl( + integrate_1d_impl_test::f2{}, 0, 1.0, std::sqrt(stan::math::EPSILON), + integrate_1d_impl_test::msgs)); } TEST(StanMath_integrate_1d_impl_prim, test1) { @@ -421,7 +417,6 @@ TEST(StanMath_integrate_1d_impl_prim, TestTolerance) { std::ostringstream *msgs = nullptr; double t = 0.5; - double b = 1.0; double A = 0.5; double v1 = 1.0; double v2 = 1.0; diff --git a/test/unit/math/prim/functor/integrate_1d_test.cpp b/test/unit/math/prim/functor/integrate_1d_test.cpp index 139a7b858cf..fca9c52e0de 100644 --- a/test/unit/math/prim/functor/integrate_1d_test.cpp +++ b/test/unit/math/prim/functor/integrate_1d_test.cpp @@ -402,16 +402,15 @@ TEST(StanMath_integrate_1d_prim, TestThrows) { } TEST(StanMath_integrate_1d_prim, test_integer_arguments) { - double v; - EXPECT_NO_THROW(v = stan::math::integrate_1d(integrate_1d_test::f2{}, 0, 1, - std::vector(), {}, {}, - integrate_1d_test::msgs, 1e-6)); - EXPECT_NO_THROW(v = stan::math::integrate_1d(integrate_1d_test::f2{}, 0.0, 1, - std::vector(), {}, {}, - integrate_1d_test::msgs, 1e-6)); - EXPECT_NO_THROW(v = stan::math::integrate_1d(integrate_1d_test::f2{}, 0, 1.0, - std::vector(), {}, {}, - integrate_1d_test::msgs, 1e-6)); + EXPECT_NO_THROW(stan::math::integrate_1d(integrate_1d_test::f2{}, 0, 1, + std::vector(), {}, {}, + integrate_1d_test::msgs, 1e-6)); + EXPECT_NO_THROW(stan::math::integrate_1d(integrate_1d_test::f2{}, 0.0, 1, + std::vector(), {}, {}, + integrate_1d_test::msgs, 1e-6)); + EXPECT_NO_THROW(stan::math::integrate_1d(integrate_1d_test::f2{}, 0, 1.0, + std::vector(), {}, {}, + integrate_1d_test::msgs, 1e-6)); } TEST(StanMath_integrate_1d_prim, test1) { @@ -489,7 +488,6 @@ TEST(StanMath_integrate_1d_prim, TestTolerance) { std::ostringstream *msgs = nullptr; double t = 0.5; - double b = 1.0; double A = 0.5; double v1 = 1.0; double v2 = 1.0; diff --git a/test/unit/math/prim/functor/reduce_sum_test.cpp b/test/unit/math/prim/functor/reduce_sum_test.cpp index b56161475f5..e87bedc14ca 100644 --- a/test/unit/math/prim/functor/reduce_sum_test.cpp +++ b/test/unit/math/prim/functor/reduce_sum_test.cpp @@ -10,7 +10,6 @@ TEST(StanMathPrim_reduce_sum, value) { using stan::math::test::get_new_msg; double lambda_d = 10.0; const std::size_t elems = 10000; - const std::size_t num_iter = 1000; std::vector data(elems); for (std::size_t i = 0; i != elems; ++i) diff --git a/test/unit/math/prim/prob/hmm_latent_rng_test.cpp b/test/unit/math/prim/prob/hmm_latent_rng_test.cpp index d308941ea48..0a5606e9abd 100644 --- a/test/unit/math/prim/prob/hmm_latent_rng_test.cpp +++ b/test/unit/math/prim/prob/hmm_latent_rng_test.cpp @@ -83,7 +83,7 @@ TEST(hmm_rng_test, chiSquareGoodnessFitTest_symmetric) { std::vector counts_1(2); // int product = 0; std::vector states; - int a = 0, b = 0, c = 0, d = 0; + int a = 0, c = 0; for (int i = 0; i < N; ++i) { states = hmm_latent_rng(log_omegas, Gamma, rho, rng); ++counts_0[states[0] - stan::error_index::value]; @@ -91,12 +91,8 @@ TEST(hmm_rng_test, chiSquareGoodnessFitTest_symmetric) { // product += states[0] * states[1]; a += (states[0] == stan::error_index::value && states[1] == stan::error_index::value); - b += (states[0] == stan::error_index::value - && states[1] == 1 + stan::error_index::value); c += (states[0] == 1 + stan::error_index::value && states[1] == stan::error_index::value); - d += (states[0] == 1 + stan::error_index::value - && states[1] == 1 + stan::error_index::value); } // Test the marginal probabilities of each variable diff --git a/test/unit/math/prim/prob/poisson_binomial_ccdf_log_test.cpp b/test/unit/math/prim/prob/poisson_binomial_ccdf_log_test.cpp index 41a02542645..a6ca3e9afcc 100644 --- a/test/unit/math/prim/prob/poisson_binomial_ccdf_log_test.cpp +++ b/test/unit/math/prim/prob/poisson_binomial_ccdf_log_test.cpp @@ -91,8 +91,6 @@ TEST(ProbDistributionsPoissonBinomial, } TEST(ProbDistributionsPoissonBinomial, lccdf_check_error_scalar_y_oob) { - static double inff = std::numeric_limits::infinity(); - Eigen::Matrix theta(3); theta << 0.5, 0.2, 0.7; @@ -115,8 +113,6 @@ TEST(ProbDistributionsPoissonBinomial, lccdf_check_error_theta_is_not_prob) { } TEST(ProbDistributionsPoissonBinomial, lccdf_check_error_vectorial_y_oob) { - static double inff = std::numeric_limits::infinity(); - Eigen::Matrix theta(3); theta << 0.5, 0.2, 0.1; std::vector ys1{-1, 2}; @@ -160,7 +156,6 @@ TEST(ProbDistributionsPoissonBinomial, TEST(ProbDistributionsPoissonBinomial, lccdf_check_error_vectorial_y_oob_with_vectorial_theta) { - using mat = Eigen::Matrix; using vec = Eigen::Matrix; vec theta1(3); @@ -177,7 +172,6 @@ TEST(ProbDistributionsPoissonBinomial, TEST(ProbDistributionsPoissonBinomial, lccdf_check_error_vectorial_y_and_theta_inconsistent_sizes) { - using mat = Eigen::Matrix; using vec = Eigen::Matrix; vec theta(3); diff --git a/test/unit/math/prim/prob/poisson_binomial_cdf_log_test.cpp b/test/unit/math/prim/prob/poisson_binomial_cdf_log_test.cpp index 31097803302..0d15079aa06 100644 --- a/test/unit/math/prim/prob/poisson_binomial_cdf_log_test.cpp +++ b/test/unit/math/prim/prob/poisson_binomial_cdf_log_test.cpp @@ -87,8 +87,6 @@ TEST(ProbDistributionsPoissonBinomial, } TEST(ProbDistributionsPoissonBinomial, lcdf_check_error_scalar_y_oob) { - static double inff = std::numeric_limits::infinity(); - Eigen::Matrix theta(3); theta << 0.5, 0.2, 0.7; @@ -109,8 +107,6 @@ TEST(ProbDistributionsPoissonBinomial, lcdf_check_error_theta_is_not_prob) { } TEST(ProbDistributionsPoissonBinomial, lcdf_check_error_vectorial_y_oob) { - static double inff = std::numeric_limits::infinity(); - Eigen::Matrix theta(3); theta << 0.5, 0.2, 0.1; std::vector ys1{-1, 2}; @@ -154,7 +150,6 @@ TEST(ProbDistributionsPoissonBinomial, TEST(ProbDistributionsPoissonBinomial, lcdf_check_error_vectorial_y_oob_with_vectorial_theta) { - using mat = Eigen::Matrix; using vec = Eigen::Matrix; vec theta1(3); @@ -171,7 +166,6 @@ TEST(ProbDistributionsPoissonBinomial, TEST(ProbDistributionsPoissonBinomial, lcdf_check_error_vectorial_y_and_theta_inconsistent_sizes) { - using mat = Eigen::Matrix; using vec = Eigen::Matrix; vec theta(3); diff --git a/test/unit/math/prim/prob/poisson_binomial_test.cpp b/test/unit/math/prim/prob/poisson_binomial_test.cpp index 9f88e57c314..d2533f9eaa6 100644 --- a/test/unit/math/prim/prob/poisson_binomial_test.cpp +++ b/test/unit/math/prim/prob/poisson_binomial_test.cpp @@ -89,8 +89,6 @@ TEST(ProbDistributionsPoissonBinomial, } TEST(ProbDistributionsPoissonBinomial, lpmf_check_error_scalar_y_oob) { - static double inff = std::numeric_limits::infinity(); - Eigen::Matrix theta(3); theta << 0.5, 0.2, 0.7; @@ -111,8 +109,6 @@ TEST(ProbDistributionsPoissonBinomial, lpmf_check_error_theta_is_not_prob) { } TEST(ProbDistributionsPoissonBinomial, lpmf_check_error_vectorial_y_oob) { - static double inff = std::numeric_limits::infinity(); - Eigen::Matrix theta(3); theta << 0.5, 0.2, 0.1; std::vector ys1{-1, 2}; @@ -156,7 +152,6 @@ TEST(ProbDistributionsPoissonBinomial, TEST(ProbDistributionsPoissonBinomial, lpmf_check_error_vectorial_y_oob_with_vectorial_theta) { - using mat = Eigen::Matrix; using vec = Eigen::Matrix; vec theta1(3); @@ -173,7 +168,6 @@ TEST(ProbDistributionsPoissonBinomial, TEST(ProbDistributionsPoissonBinomial, lpmf_check_error_vectorial_y_and_theta_inconsistent_sizes) { - using mat = Eigen::Matrix; using vec = Eigen::Matrix; vec theta(3); @@ -192,7 +186,6 @@ TEST(ProbDistributionsPoissonBinomial, * success probabilities to the same value */ TEST(ProbDistributionsPoissonBinomial, chiSquareGoodnessFitTest) { - using mat = Eigen::Matrix; using vec = Eigen::Matrix; boost::random::mt19937 rng; diff --git a/test/unit/math/prim/prob/von_mises_cdf_test.cpp b/test/unit/math/prim/prob/von_mises_cdf_test.cpp index bd5480319fc..1b4c1a50ea2 100644 --- a/test/unit/math/prim/prob/von_mises_cdf_test.cpp +++ b/test/unit/math/prim/prob/von_mises_cdf_test.cpp @@ -62,7 +62,6 @@ TEST(ProbVonMises, pdf_cdf_agree_test) { TEST(ProbVonMises, pointwise_cdf_test) { using stan::math::von_mises_cdf; - double pi = stan::math::pi(); // check that our von_mises_cdf coincides with scipy's for mu = -pi, 0, pi double ABS_TOL = 1e-12; ASSERT_NEAR(0.0000157567385742, von_mises_cdf(-3.141492653589793, 0, 0.01), diff --git a/test/unit/math/rev/core/callback_vari_test.cpp b/test/unit/math/rev/core/callback_vari_test.cpp index ee822326b09..3bfcad264e0 100644 --- a/test/unit/math/rev/core/callback_vari_test.cpp +++ b/test/unit/math/rev/core/callback_vari_test.cpp @@ -27,6 +27,7 @@ TEST(AgradRevCBack, callback_vari_const_scalar_compile_test) { stan::math::var b = stan::math::make_callback_vari( a_val, [a](const auto& vi) mutable { a.adj() += vi.adj(); }); + EXPECT_FLOAT_EQ(a.val(), b.val()); } TEST(AgradRevCBack, callback_vari_eigen_test) { diff --git a/test/unit/math/rev/core/chainable_object_test.cpp b/test/unit/math/rev/core/chainable_object_test.cpp index 9b1b09f42ba..d668b330310 100644 --- a/test/unit/math/rev/core/chainable_object_test.cpp +++ b/test/unit/math/rev/core/chainable_object_test.cpp @@ -13,8 +13,8 @@ int ChainableObjectTest::counter = 0; TEST(AgradRevChain, chainable_object_test) { { - auto ptr = new stan::math::chainable_object( - ChainableObjectTest()); + EXPECT_NO_THROW(new stan::math::chainable_object( + ChainableObjectTest())); ChainableObjectTest::counter = 0; } @@ -27,8 +27,8 @@ TEST(AgradRevChain, chainable_object_nested_test) { stan::math::start_nested(); { - auto ptr = new stan::math::chainable_object( - ChainableObjectTest()); + EXPECT_NO_THROW(new stan::math::chainable_object( + ChainableObjectTest())); ChainableObjectTest::counter = 0; } @@ -41,8 +41,7 @@ TEST(AgradRevChain, chainable_object_nested_test) { TEST(AgradRevChain, make_chainable_ptr_test) { { - ChainableObjectTest* ptr - = stan::math::make_chainable_ptr(ChainableObjectTest()); + EXPECT_NO_THROW(stan::math::make_chainable_ptr(ChainableObjectTest())); ChainableObjectTest::counter = 0; } @@ -55,8 +54,7 @@ TEST(AgradRevChain, make_chainable_ptr_nested_test) { stan::math::start_nested(); { - ChainableObjectTest* ptr - = stan::math::make_chainable_ptr(ChainableObjectTest()); + EXPECT_NO_THROW(stan::math::make_chainable_ptr(ChainableObjectTest())); ChainableObjectTest::counter = 0; } @@ -78,9 +76,9 @@ int UnsafeChainableObjectTest::counter = 0; TEST(AgradRevChain, unsafe_chainable_object_test) { { - auto ptr - = new stan::math::unsafe_chainable_object( - UnsafeChainableObjectTest()); + EXPECT_NO_THROW( + new stan::math::unsafe_chainable_object( + UnsafeChainableObjectTest())); UnsafeChainableObjectTest::counter = 0; } @@ -93,9 +91,8 @@ TEST(AgradRevChain, unsafe_chainable_object_nested_test) { stan::math::start_nested(); { - auto ptr - = new stan::math::unsafe_chainable_object( - UnsafeChainableObjectTest()); + EXPECT_NO_THROW( + stan::math::make_unsafe_chainable_ptr(UnsafeChainableObjectTest())); UnsafeChainableObjectTest::counter = 0; } @@ -108,8 +105,8 @@ TEST(AgradRevChain, unsafe_chainable_object_nested_test) { TEST(AgradRevChain, make_unsafe_chainable_ptr_test) { { - UnsafeChainableObjectTest* ptr - = stan::math::make_unsafe_chainable_ptr(UnsafeChainableObjectTest()); + EXPECT_NO_THROW( + stan::math::make_unsafe_chainable_ptr(UnsafeChainableObjectTest())); UnsafeChainableObjectTest::counter = 0; } @@ -122,8 +119,8 @@ TEST(AgradRevChain, make_unsafe_chainable_ptr_nested_test) { stan::math::start_nested(); { - UnsafeChainableObjectTest* ptr - = stan::math::make_unsafe_chainable_ptr(UnsafeChainableObjectTest()); + EXPECT_NO_THROW( + stan::math::make_unsafe_chainable_ptr(UnsafeChainableObjectTest())); UnsafeChainableObjectTest::counter = 0; } diff --git a/test/unit/math/rev/core/grad_test.cpp b/test/unit/math/rev/core/grad_test.cpp index 47493088637..b3fdaa1bcc8 100644 --- a/test/unit/math/rev/core/grad_test.cpp +++ b/test/unit/math/rev/core/grad_test.cpp @@ -10,7 +10,7 @@ TEST(AgradRev, multiple_grads) { stan::math::var b = 3.0 * a; stan::math::var c = sin(a) * b; // fixes warning regarding unused variable - c = c; + EXPECT_FLOAT_EQ(c.val(), sin(2) * 6); stan::math::var nothing; } diff --git a/test/unit/math/rev/core/profiling_test.cpp b/test/unit/math/rev/core/profiling_test.cpp index 00ca1fd0ac2..b8f6c1e2f3d 100644 --- a/test/unit/math/rev/core/profiling_test.cpp +++ b/test/unit/math/rev/core/profiling_test.cpp @@ -100,6 +100,7 @@ TEST(Profiling, var_loop) { var a = i; var b = 2.0; c = c + a; + b = b + 0; std::chrono::milliseconds timespan(10); std::this_thread::sleep_for(timespan); } diff --git a/test/unit/math/rev/core/thread_stack_instance_test.cpp b/test/unit/math/rev/core/thread_stack_instance_test.cpp index 06b1a520258..389c8129cb8 100644 --- a/test/unit/math/rev/core/thread_stack_instance_test.cpp +++ b/test/unit/math/rev/core/thread_stack_instance_test.cpp @@ -86,6 +86,7 @@ TEST(thread_stack_instance, child_instances) { // set) stan::math::var a = 1; stan::math::var b = a * a; + EXPECT_FLOAT_EQ(b.val(), 1); ChainableStack::AutodiffStackStorage* main_ad_stack = ChainableStack::instance_; diff --git a/test/unit/math/rev/core/var_test.cpp b/test/unit/math/rev/core/var_test.cpp index be133e754c2..3e6576e033c 100644 --- a/test/unit/math/rev/core/var_test.cpp +++ b/test/unit/math/rev/core/var_test.cpp @@ -561,8 +561,6 @@ TEST_F(AgradRev, var_matrix_view_assignment) { var_value A_v_colwise_reverse = A_v.colwise_reverse(); var_value A_v_rowwise_colwise_reverse = A_v.rowwise_reverse().colwise_reverse(); - var A_v_coeff1 = A_v.coeff(5); - var A_v_coeff2 = A_v.coeff(1, 2); A_v.block(0, 0, 3, 3) = A_v.block(1, 1, 3, 3); // Checks adjoints from all assigned slices are propogated upwards var b_v = stan::math::sum(A_v_block) + stan::math::sum(A_v_transpose) @@ -594,8 +592,6 @@ TEST_F(AgradRev, var_matrix_view_assignment_const) { var_value A_v_colwise_reverse = A_v.colwise_reverse(); var_value A_v_rowwise_colwise_reverse = A_v.rowwise_reverse().colwise_reverse(); - var A_v_coeff1 = A_v.coeff(5); - var A_v_coeff2 = A_v.coeff(1, 2); A_v.block(0, 0, 3, 3) = A_v.block(1, 1, 3, 3); // Checks adjoints from all assigned slices are propogated upwards var b_v = stan::math::sum(A_v_block) + stan::math::sum(A_v_transpose) @@ -627,8 +623,6 @@ TEST_F(AgradRev, var_matrix_view_eval) { auto A_v_rowwise_colwise_reverse = A_v.rowwise_reverse().colwise_reverse().eval(); // NOTE: Coefficient references make a new var. - auto A_v_coeff1 = A_v.coeff(5); - auto A_v_coeff2 = A_v.coeff(1, 2); A_v.block(0, 0, 3, 3) = A_v.block(1, 1, 3, 3); // Checks adjoints from all assigned slices are propogated upwards var b_v = stan::math::sum(A_v_block) + stan::math::sum(A_v_transpose) diff --git a/test/unit/math/rev/err/check_pos_semidefinite_test.cpp b/test/unit/math/rev/err/check_pos_semidefinite_test.cpp index 514a158ee2c..d8e634e7031 100644 --- a/test/unit/math/rev/err/check_pos_semidefinite_test.cpp +++ b/test/unit/math/rev/err/check_pos_semidefinite_test.cpp @@ -41,7 +41,6 @@ TEST(AgradRevErrorHandlingMatrix, checkPosSemiDefiniteMatrixVarCheck) { using stan::math::var; Matrix y; - double nan = std::numeric_limits::quiet_NaN(); using stan::math::check_pos_semidefinite; y.resize(3, 3); diff --git a/test/unit/math/rev/functor/algebra_solver_fp_test.cpp b/test/unit/math/rev/functor/algebra_solver_fp_test.cpp index 129c6aef5be..88a73e338fa 100644 --- a/test/unit/math/rev/functor/algebra_solver_fp_test.cpp +++ b/test/unit/math/rev/functor/algebra_solver_fp_test.cpp @@ -66,7 +66,7 @@ struct FP_exp_func_test : public ::testing::Test { f_scale{1.0} {} auto fd_functor(int i) { - auto f_fd = [this, i](const Eigen::VectorXd& y_) { + auto f_fd = [this](const Eigen::VectorXd& y_) { KinsolFixedPointEnv env(f, x, y_, x_r, x_i, msgs, u_scale, f_scale); FixedPointSolver, FixedPointADJac> fp; diff --git a/test/unit/math/rev/functor/coupled_ode_system_test.cpp b/test/unit/math/rev/functor/coupled_ode_system_test.cpp index e513a20a3c3..5eb63a1037c 100644 --- a/test/unit/math/rev/functor/coupled_ode_system_test.cpp +++ b/test/unit/math/rev/functor/coupled_ode_system_test.cpp @@ -65,7 +65,6 @@ TEST_F(StanAgradRevOde, initial_state_dv) { const size_t N = 3; const size_t M = 4; - const size_t z_size = N + N * M; Eigen::VectorXd y0_d = Eigen::VectorXd::Zero(N); std::vector theta_v(M, 0.0); diff --git a/test/unit/math/rev/functor/reduce_sum_test.cpp b/test/unit/math/rev/functor/reduce_sum_test.cpp index fbd6ad1fa21..7f3a971b488 100644 --- a/test/unit/math/rev/functor/reduce_sum_test.cpp +++ b/test/unit/math/rev/functor/reduce_sum_test.cpp @@ -202,7 +202,6 @@ TEST(StanMathRev_reduce_sum, grouped_gradient) { using stan::math::test::get_new_msg; using stan::math::test::grouped_count_lpdf; - double lambda_d = 10.0; const std::size_t groups = 10; const std::size_t elems_per_group = 1000; const std::size_t elems = groups * elems_per_group; @@ -263,7 +262,6 @@ TEST(StanMathRev_reduce_sum, grouped_gradient_eigen) { using stan::math::test::get_new_msg; using stan::math::test::grouped_count_lpdf; - double lambda_d = 10.0; const std::size_t groups = 10; const std::size_t elems_per_group = 1000; const std::size_t elems = groups * elems_per_group; @@ -326,7 +324,6 @@ TEST(StanMathRev_reduce_sum, slice_group_gradient) { using stan::math::test::get_new_msg; using stan::math::test::slice_group_count_lpdf; - double lambda_d = 10.0; const std::size_t groups = 10; const std::size_t elems_per_group = 1000; const std::size_t elems = groups * elems_per_group; diff --git a/test/unit/math/rev/functor/solve_newton_test.cpp b/test/unit/math/rev/functor/solve_newton_test.cpp index 86e4c54b4ba..ae6e6474894 100644 --- a/test/unit/math/rev/functor/solve_newton_test.cpp +++ b/test/unit/math/rev/functor/solve_newton_test.cpp @@ -237,7 +237,6 @@ TEST_F(degenerate_eq_test, newton_guess2) { TEST_F(variadic_test, newton) { using stan::math::var; bool is_newton = true; - bool is_impl = false; bool use_tol = false; for (int k = 0; k < n_x; k++) { var y_1 = y_1_dbl; diff --git a/test/unit/math/rev/functor/test_fixture_ode.hpp b/test/unit/math/rev/functor/test_fixture_ode.hpp index d6992e99485..1082e6ea66c 100644 --- a/test/unit/math/rev/functor/test_fixture_ode.hpp +++ b/test/unit/math/rev/functor/test_fixture_ode.hpp @@ -145,7 +145,6 @@ struct ODETestFixture : public ::testing::Test { void test_analytical(F_ode const& ode_sol, F_sol const& analy_sol, double tol, Eigen::VectorXd const& x, double t, const T_args&... args) { - ode_problem_type& ode = static_cast(*this); auto sol = ode_sol(x); int n = sol.size(); auto sol_0 = analy_sol(t, args...); @@ -185,8 +184,6 @@ struct ODETestFixture : public ::testing::Test { F_grad_sol const& analy_grad_sol, double tol, Eigen::VectorXd const& x, double t, const T_args&... args) { - ode_problem_type& ode = static_cast(*this); - stan::math::nested_rev_autodiff nested; auto sol_0 = analy_sol(t, args...); diff --git a/test/unit/math/rev/functor/util_algebra_solver.hpp b/test/unit/math/rev/functor/util_algebra_solver.hpp index 40e18048991..34468a49cfe 100644 --- a/test/unit/math/rev/functor/util_algebra_solver.hpp +++ b/test/unit/math/rev/functor/util_algebra_solver.hpp @@ -529,7 +529,6 @@ Eigen::Matrix variadic_eq_impl_test( using stan::math::solve_powell_tol; using stan::math::var; - int n_x = 2; Eigen::VectorXd x(2); x << 1, 1; // initial guess diff --git a/test/unit/math/rev/meta/promote_var_matrix_test.cpp b/test/unit/math/rev/meta/promote_var_matrix_test.cpp index c9a43b52b39..2c94fbc3267 100644 --- a/test/unit/math/rev/meta/promote_var_matrix_test.cpp +++ b/test/unit/math/rev/meta/promote_var_matrix_test.cpp @@ -8,7 +8,6 @@ TEST(MathFunctions, PromoteVarMatrix) { using std::is_same; using var_matrix = var_value; using var_vector = var_value; - using var_row_vector = var_value; using matrix_var = Eigen::Matrix; using vector_var = Eigen::Matrix; using row_vector_var = Eigen::Matrix; diff --git a/test/unit/math/rev/meta/return_var_matrix_test.cpp b/test/unit/math/rev/meta/return_var_matrix_test.cpp index 7acae6cf81d..a532c503302 100644 --- a/test/unit/math/rev/meta/return_var_matrix_test.cpp +++ b/test/unit/math/rev/meta/return_var_matrix_test.cpp @@ -9,7 +9,6 @@ TEST(MathFunctions, ReturnVarMatrix) { using std::is_same; using var_matrix = var_value; using var_vector = var_value; - using var_row_vector = var_value; using matrix_var = Eigen::Matrix; using vector_var = Eigen::Matrix; using row_vector_var = Eigen::Matrix; diff --git a/test/unit/math/rev/prob/bernoulli_logit_glm_lpmf_test.cpp b/test/unit/math/rev/prob/bernoulli_logit_glm_lpmf_test.cpp index c4227743f2c..288d4bae864 100644 --- a/test/unit/math/rev/prob/bernoulli_logit_glm_lpmf_test.cpp +++ b/test/unit/math/rev/prob/bernoulli_logit_glm_lpmf_test.cpp @@ -104,7 +104,6 @@ TYPED_TEST(ProbDistributionsBernoulliLogitGLM, using matrix_v = typename TypeParam::matrix_v; using vector_v = typename TypeParam::vector_v; - using row_vector_v = typename TypeParam::row_vector_v; vector y2{1, 0, 1}; Matrix x2_val(3, 2); x2_val << -1234, 46, -42, 24, 25, 27; @@ -168,7 +167,6 @@ TYPED_TEST(ProbDistributionsBernoulliLogitGLM, broadcast_y) { using std::vector; using matrix_v = typename TypeParam::matrix_v; using vector_v = typename TypeParam::vector_v; - using row_vector_v = typename TypeParam::row_vector_v; int y = 1; Matrix y_vec = Matrix::Constant(3, 1, y); Matrix x(3, 2); @@ -206,7 +204,6 @@ TYPED_TEST(ProbDistributionsBernoulliLogitGLM, using std::vector; using matrix_v = typename TypeParam::matrix_v; using vector_v = typename TypeParam::vector_v; - using row_vector_v = typename TypeParam::row_vector_v; vector y{}; Matrix x(0, 2); Matrix beta(2, 1); @@ -252,7 +249,6 @@ TYPED_TEST(ProbDistributionsBernoulliLogitGLM, using std::vector; using matrix_v = typename TypeParam::matrix_v; using vector_v = typename TypeParam::vector_v; - using row_vector_v = typename TypeParam::row_vector_v; vector y{1, 0, 1}; Matrix x(3, 0); @@ -294,7 +290,6 @@ TYPED_TEST(ProbDistributionsBernoulliLogitGLM, using std::vector; using matrix_v = typename TypeParam::matrix_v; using vector_v = typename TypeParam::vector_v; - using row_vector_v = typename TypeParam::row_vector_v; for (size_t ii = 0; ii < 42; ii++) { vector y(3); for (size_t i = 0; i < 3; i++) { @@ -357,8 +352,6 @@ TYPED_TEST(ProbDistributionsBernoulliLogitGLM, using stan::math::var; using std::vector; using matrix_v = typename TypeParam::matrix_v; - using vector_v = typename TypeParam::vector_v; - using row_vector_v = typename TypeParam::row_vector_v; for (size_t ii = 0; ii < 42; ii++) { vector y(3); @@ -412,7 +405,6 @@ TYPED_TEST(ProbDistributionsBernoulliLogitGLM, using std::vector; using matrix_v = typename TypeParam::matrix_v; using vector_v = typename TypeParam::vector_v; - using row_vector_v = typename TypeParam::row_vector_v; for (size_t ii = 0; ii < 42; ii++) { vector y(3); diff --git a/test/unit/math/rev/prob/categorical_logit_glm_lpmf_test.cpp b/test/unit/math/rev/prob/categorical_logit_glm_lpmf_test.cpp index 666c468dcc4..4a2cf6c9930 100644 --- a/test/unit/math/rev/prob/categorical_logit_glm_lpmf_test.cpp +++ b/test/unit/math/rev/prob/categorical_logit_glm_lpmf_test.cpp @@ -9,7 +9,6 @@ template stan::return_type_t categorical_logit_glm_simple_lpmf( const std::vector& y, const T_x& x, const T_alpha& alpha, const T_beta& beta) { - using T_x_beta = stan::return_type_t; using T_return = stan::return_type_t; const size_t N_instances = x.rows(); @@ -78,7 +77,6 @@ TYPED_TEST(ProbDistributionsCategoricalLogitGLM, using std::vector; using matrix_v = typename TypeParam::matrix_v; using vector_v = typename TypeParam::vector_v; - using row_vector_v = typename TypeParam::row_vector_v; double eps = 1e-13; const size_t N_instances = 5; const size_t N_attributes = 2; @@ -143,7 +141,6 @@ TYPED_TEST(ProbDistributionsCategoricalLogitGLM, single_instance) { using std::vector; using matrix_v = typename TypeParam::matrix_v; using vector_v = typename TypeParam::vector_v; - using row_vector_v = typename TypeParam::row_vector_v; double eps = 1e-13; const size_t N_instances = 1; @@ -208,7 +205,6 @@ TYPED_TEST(ProbDistributionsCategoricalLogitGLM, zero_instances) { using std::vector; using matrix_v = typename TypeParam::matrix_v; using vector_v = typename TypeParam::vector_v; - using row_vector_v = typename TypeParam::row_vector_v; double eps = 1e-13; const size_t N_instances = 0; const size_t N_attributes = 2; @@ -265,7 +261,6 @@ TYPED_TEST(ProbDistributionsCategoricalLogitGLM, single_class) { using std::vector; using matrix_v = typename TypeParam::matrix_v; using vector_v = typename TypeParam::vector_v; - using row_vector_v = typename TypeParam::row_vector_v; double eps = 1e-13; const size_t N_instances = 5; const size_t N_attributes = 2; @@ -330,7 +325,6 @@ TYPED_TEST(ProbDistributionsCategoricalLogitGLM, zero_attributes) { using std::vector; using matrix_v = typename TypeParam::matrix_v; using vector_v = typename TypeParam::vector_v; - using row_vector_v = typename TypeParam::row_vector_v; double eps = 1e-13; const size_t N_instances = 5; const size_t N_attributes = 0; @@ -445,7 +439,6 @@ TYPED_TEST(ProbDistributionsCategoricalLogitGLM, y_broadcasting) { using std::vector; using matrix_v = typename TypeParam::matrix_v; using vector_v = typename TypeParam::vector_v; - using row_vector_v = typename TypeParam::row_vector_v; double eps = 1e-13; const size_t N_instances = 5; const size_t N_attributes = 2; @@ -510,7 +503,6 @@ TYPED_TEST(ProbDistributionsCategoricalLogitGLM, using std::vector; using matrix_v = typename TypeParam::matrix_v; using vector_v = typename TypeParam::vector_v; - using row_vector_v = typename TypeParam::row_vector_v; double eps = 1e-11; const size_t N_instances = 89; const size_t N_attributes = 23; diff --git a/test/unit/math/rev/prob/neg_binomial_2_log_glm_lpmf_test.cpp b/test/unit/math/rev/prob/neg_binomial_2_log_glm_lpmf_test.cpp index 6333faad127..84263d44519 100644 --- a/test/unit/math/rev/prob/neg_binomial_2_log_glm_lpmf_test.cpp +++ b/test/unit/math/rev/prob/neg_binomial_2_log_glm_lpmf_test.cpp @@ -79,7 +79,6 @@ TYPED_TEST(ProbDistributionsNegBinomial2LogGLM, using std::vector; using matrix_v = typename TypeParam::matrix_v; using vector_v = typename TypeParam::vector_v; - using row_vector_v = typename TypeParam::row_vector_v; vector y{1, 0, 1}; Matrix x_val(3, 2); @@ -177,7 +176,6 @@ TYPED_TEST(ProbDistributionsNegBinomial2LogGLM, broadcast_y) { using std::vector; using matrix_v = typename TypeParam::matrix_v; using vector_v = typename TypeParam::vector_v; - using row_vector_v = typename TypeParam::row_vector_v; int y = 13; Matrix y_vec = Matrix::Constant(3, 1, y); @@ -220,7 +218,6 @@ TYPED_TEST(ProbDistributionsNegBinomial2LogGLM, using std::vector; using matrix_v = typename TypeParam::matrix_v; using vector_v = typename TypeParam::vector_v; - using row_vector_v = typename TypeParam::row_vector_v; vector y{}; Matrix x(0, 2); @@ -267,7 +264,6 @@ TYPED_TEST(ProbDistributionsNegBinomial2LogGLM, using std::vector; using matrix_v = typename TypeParam::matrix_v; using vector_v = typename TypeParam::vector_v; - using row_vector_v = typename TypeParam::row_vector_v; vector y{1, 0, 1}; Matrix x(3, 0); @@ -309,7 +305,6 @@ TYPED_TEST(ProbDistributionsNegBinomial2LogGLM, using std::vector; using matrix_v = typename TypeParam::matrix_v; using vector_v = typename TypeParam::vector_v; - using row_vector_v = typename TypeParam::row_vector_v; for (size_t ii = 0; ii < 200; ii++) { vector y(3); @@ -375,8 +370,6 @@ TYPED_TEST(ProbDistributionsNegBinomial2LogGLM, using stan::math::var; using std::vector; using matrix_v = typename TypeParam::matrix_v; - using vector_v = typename TypeParam::vector_v; - using row_vector_v = typename TypeParam::row_vector_v; for (size_t ii = 0; ii < 42; ii++) { vector y(3); @@ -436,7 +429,6 @@ TYPED_TEST(ProbDistributionsNegBinomial2LogGLM, using std::vector; using matrix_v = typename TypeParam::matrix_v; using vector_v = typename TypeParam::vector_v; - using row_vector_v = typename TypeParam::row_vector_v; for (size_t ii = 0; ii < 200; ii++) { vector y(3); diff --git a/test/unit/math/rev/prob/normal_id_glm_lpdf_test.cpp b/test/unit/math/rev/prob/normal_id_glm_lpdf_test.cpp index 451d4823d88..9a38096b55e 100644 --- a/test/unit/math/rev/prob/normal_id_glm_lpdf_test.cpp +++ b/test/unit/math/rev/prob/normal_id_glm_lpdf_test.cpp @@ -74,7 +74,6 @@ TYPED_TEST(ProbDistributionsNormalIdGLM, glm_matches_normal_id_vars) { using stan::math::var; using matrix_v = typename TypeParam::matrix_v; using vector_v = typename TypeParam::vector_v; - using row_vector_v = typename TypeParam::row_vector_v; Matrix y(3, 1); y << 14, 32, 21; Matrix x(3, 2); @@ -136,9 +135,7 @@ TYPED_TEST(ProbDistributionsNormalIdGLM, glm_matches_normal_id_simple) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::var; - using matrix_v = typename TypeParam::matrix_v; using vector_v = typename TypeParam::vector_v; - using row_vector_v = typename TypeParam::row_vector_v; double eps = 1e-9; Matrix y(3, 1); @@ -217,7 +214,6 @@ TYPED_TEST(ProbDistributionsNormalIdGLM, broadcast_y) { using stan::math::var; using matrix_v = typename TypeParam::matrix_v; using vector_v = typename TypeParam::vector_v; - using row_vector_v = typename TypeParam::row_vector_v; double y = 13; var y1 = y; @@ -261,12 +257,10 @@ TYPED_TEST(ProbDistributionsNormalIdGLM, using stan::math::var; using matrix_v = typename TypeParam::matrix_v; using vector_v = typename TypeParam::vector_v; - using row_vector_v = typename TypeParam::row_vector_v; Matrix y_val(0, 1); vector_v y = y_val; Matrix x_val(0, 2); - matrix_v x = x_val; Matrix beta_val(2, 1); beta_val << 0.3, 2; vector_v beta = beta_val; @@ -313,7 +307,6 @@ TYPED_TEST(ProbDistributionsNormalIdGLM, using stan::math::var; using matrix_v = typename TypeParam::matrix_v; using vector_v = typename TypeParam::vector_v; - using row_vector_v = typename TypeParam::row_vector_v; Matrix y_val(3, 1); y_val << 14, 32, 21; @@ -366,7 +359,6 @@ TYPED_TEST(ProbDistributionsNormalIdGLM, glm_matches_normal_id_vars_rand) { using stan::math::var; using matrix_v = typename TypeParam::matrix_v; using vector_v = typename TypeParam::vector_v; - using row_vector_v = typename TypeParam::row_vector_v; for (size_t ii = 0; ii < 42; ii++) { Matrix yreal = Matrix::Random(3, 1); @@ -436,7 +428,6 @@ TYPED_TEST(ProbDistributionsNormalIdGLM, using stan::math::var; using matrix_v = typename TypeParam::matrix_v; using vector_v = typename TypeParam::vector_v; - using row_vector_v = typename TypeParam::row_vector_v; for (size_t ii = 0; ii < 42; ii++) { Matrix yreal = Matrix::Random(3, 1); @@ -497,7 +488,6 @@ TYPED_TEST(ProbDistributionsNormalIdGLM, using stan::math::var; using matrix_v = typename TypeParam::matrix_v; using vector_v = typename TypeParam::vector_v; - using row_vector_v = typename TypeParam::row_vector_v; for (size_t ii = 0; ii < 42; ii++) { Matrix yreal = Matrix::Random(3, 1); @@ -568,7 +558,6 @@ TYPED_TEST(ProbDistributionsNormalIdGLM, using stan::math::var; using matrix_v = typename TypeParam::matrix_v; using vector_v = typename TypeParam::vector_v; - using row_vector_v = typename TypeParam::row_vector_v; for (size_t ii = 0; ii < 42; ii++) { Matrix yreal = Matrix::Random(3, 1); diff --git a/test/unit/math/rev/prob/ordered_logistic_glm_lpmf_test.cpp b/test/unit/math/rev/prob/ordered_logistic_glm_lpmf_test.cpp index 7aa0928afcf..3436f57a2f8 100644 --- a/test/unit/math/rev/prob/ordered_logistic_glm_lpmf_test.cpp +++ b/test/unit/math/rev/prob/ordered_logistic_glm_lpmf_test.cpp @@ -18,7 +18,6 @@ TEST(ProbDistributionsOrderedLogisticGLM, using Eigen::MatrixXd; using Eigen::VectorXd; using std::vector; - double eps = 1e-13; int N = 5; int M = 2; int C = 4; @@ -38,7 +37,6 @@ TEST(ProbDistributionsOrderedLogisticGLM, using Eigen::MatrixXd; using Eigen::VectorXd; using std::vector; - double eps = 1e-13; int N = 5; int M = 2; int C = 4; @@ -74,7 +72,6 @@ TYPED_TEST(ProbDistributionsOrderedLogisticGLM, using std::vector; using matrix_v = typename TypeParam::matrix_v; using vector_v = typename TypeParam::vector_v; - using row_vector_v = typename TypeParam::row_vector_v; double eps = 1e-13; int N = 5; @@ -125,7 +122,6 @@ TYPED_TEST(ProbDistributionsOrderedLogisticGLM, using std::vector; using matrix_v = typename TypeParam::matrix_v; using vector_v = typename TypeParam::vector_v; - using row_vector_v = typename TypeParam::row_vector_v; double eps = 1e-13; int N = 5; @@ -235,7 +231,6 @@ TYPED_TEST(ProbDistributionsOrderedLogisticGLM, using std::vector; using matrix_v = typename TypeParam::matrix_v; using vector_v = typename TypeParam::vector_v; - using row_vector_v = typename TypeParam::row_vector_v; double eps = 1e-13; int N = 1; @@ -284,7 +279,6 @@ TYPED_TEST(ProbDistributionsOrderedLogisticGLM, using std::vector; using matrix_v = typename TypeParam::matrix_v; using vector_v = typename TypeParam::vector_v; - using row_vector_v = typename TypeParam::row_vector_v; double eps = 1e-13; int N = 0; @@ -328,7 +322,6 @@ TYPED_TEST(ProbDistributionsOrderedLogisticGLM, using std::vector; using matrix_v = typename TypeParam::matrix_v; using vector_v = typename TypeParam::vector_v; - using row_vector_v = typename TypeParam::row_vector_v; double eps = 1e-13; int N = 5; @@ -367,7 +360,6 @@ TYPED_TEST(ProbDistributionsOrderedLogisticGLM, using std::vector; using matrix_v = typename TypeParam::matrix_v; using vector_v = typename TypeParam::vector_v; - using row_vector_v = typename TypeParam::row_vector_v; double eps = 1e-13; int N = 5; @@ -416,7 +408,6 @@ TYPED_TEST(ProbDistributionsOrderedLogisticGLM, using std::vector; using matrix_v = typename TypeParam::matrix_v; using vector_v = typename TypeParam::vector_v; - using row_vector_v = typename TypeParam::row_vector_v; double eps = 1e-7; int N = 155; diff --git a/test/unit/math/rev/prob/poisson_log_glm_lpmf_test.cpp b/test/unit/math/rev/prob/poisson_log_glm_lpmf_test.cpp index 5a42e83f8b5..aa44a99133a 100644 --- a/test/unit/math/rev/prob/poisson_log_glm_lpmf_test.cpp +++ b/test/unit/math/rev/prob/poisson_log_glm_lpmf_test.cpp @@ -70,7 +70,6 @@ TYPED_TEST(ProbDistributionsPoissonLogGLM, glm_matches_poisson_log_vars) { using std::vector; using matrix_v = typename TypeParam::matrix_v; using vector_v = typename TypeParam::vector_v; - using row_vector_v = typename TypeParam::row_vector_v; vector y{14, 2, 5}; Matrix x_val(3, 2); @@ -157,7 +156,6 @@ TYPED_TEST(ProbDistributionsPoissonLogGLM, broadcast_y) { using std::vector; using matrix_v = typename TypeParam::matrix_v; using vector_v = typename TypeParam::vector_v; - using row_vector_v = typename TypeParam::row_vector_v; int y = 13; Matrix y_vec = Matrix::Constant(3, 1, y); Matrix x(3, 2); @@ -195,7 +193,6 @@ TYPED_TEST(ProbDistributionsPoissonLogGLM, using std::vector; using matrix_v = typename TypeParam::matrix_v; using vector_v = typename TypeParam::vector_v; - using row_vector_v = typename TypeParam::row_vector_v; vector y{}; Matrix x(0, 2); Matrix beta(2, 1); @@ -235,7 +232,6 @@ TYPED_TEST(ProbDistributionsPoissonLogGLM, using std::vector; using matrix_v = typename TypeParam::matrix_v; using vector_v = typename TypeParam::vector_v; - using row_vector_v = typename TypeParam::row_vector_v; vector y{14, 2, 5}; Matrix x(3, 0); Matrix beta(0, 1); @@ -270,7 +266,6 @@ TYPED_TEST(ProbDistributionsPoissonLogGLM, glm_matches_poisson_log_vars_rand) { using std::vector; using matrix_v = typename TypeParam::matrix_v; using vector_v = typename TypeParam::vector_v; - using row_vector_v = typename TypeParam::row_vector_v; for (size_t ii = 0; ii < 200; ii++) { vector y(3); for (size_t i = 0; i < 3; i++) { @@ -328,8 +323,6 @@ TYPED_TEST(ProbDistributionsPoissonLogGLM, using stan::math::var; using std::vector; using matrix_v = typename TypeParam::matrix_v; - using vector_v = typename TypeParam::vector_v; - using row_vector_v = typename TypeParam::row_vector_v; for (size_t ii = 0; ii < 42; ii++) { vector y(3); @@ -383,7 +376,6 @@ TYPED_TEST(ProbDistributionsPoissonLogGLM, using std::vector; using matrix_v = typename TypeParam::matrix_v; using vector_v = typename TypeParam::vector_v; - using row_vector_v = typename TypeParam::row_vector_v; for (size_t ii = 0; ii < 42; ii++) { vector y(3); diff --git a/test/unit/math/rev/prob/weibull_test.cpp b/test/unit/math/rev/prob/weibull_test.cpp index bc8997a5420..c8cb6ff5247 100644 --- a/test/unit/math/rev/prob/weibull_test.cpp +++ b/test/unit/math/rev/prob/weibull_test.cpp @@ -434,11 +434,12 @@ TEST(ProbDistributionsWeibull, derivativesPrecomputed) { } }; - std::ostringstream message_stream; - message_stream << "y = " << t.y << ", alpha = " << t.alpha - << ", sigma = " << t.sigma; + std::string message_stream; + message_stream = "y = " + std::to_string(t.y) + + ", alpha = " + std::to_string(t.alpha) + + ", sigma = " + std::to_string(t.sigma); - const char* message = message_stream.str().c_str(); + const char* message = message_stream.c_str(); my_expect_near(value_of(val), t.value, "value", message); my_expect_near(gradients[0], t.grad_y, "grad_y", message); diff --git a/test/unit/math/test_ad_matvar.hpp b/test/unit/math/test_ad_matvar.hpp index 098061d1906..713f6f5a539 100644 --- a/test/unit/math/test_ad_matvar.hpp +++ b/test/unit/math/test_ad_matvar.hpp @@ -968,9 +968,9 @@ void expect_ad_vectorized_matvar(const ad_tolerances& tols, const F& f, std::vector y_stdvec_vec{y_vec, y_vec}; std::vector> x_stdvec_stdvec{x_stdvec, x_stdvec}; std::vector> y_stdvec_stdvec{y_stdvec, y_stdvec}; - expect_ad_matvar(tols, f, x[0], y); // scal, mat - expect_ad_matvar(tols, f, x[0], y_vec); // scal, mat - expect_ad_matvar(tols, f, x[0], y_stdvec); // scal, nest + expect_ad_matvar(tols, f, x_scal, y); // scal, mat + expect_ad_matvar(tols, f, x_scal, y_vec); // scal, mat + expect_ad_matvar(tols, f, x_scal, y_stdvec); // scal, nest expect_ad_matvar(tols, f, x, y_vec); // stdvec, vec expect_ad_matvar(tols, f, x_stdvec, y_stdvec_vec); // nest, nest expect_ad_matvar(tols, f, x_stdvec, y); // nest, mat