diff --git a/stan/math/fwd/fun/hypergeometric_1F0.hpp b/stan/math/fwd/fun/hypergeometric_1F0.hpp index df2b8a1ac63..21ae6764487 100644 --- a/stan/math/fwd/fun/hypergeometric_1F0.hpp +++ b/stan/math/fwd/fun/hypergeometric_1F0.hpp @@ -31,15 +31,15 @@ namespace math { template , require_all_stan_scalar_t* = nullptr, require_any_fvar_t* = nullptr> -inline FvarT hypergeometric_1F0(const Ta& a, const Tz& z) { +FvarT hypergeometric_1F0(const Ta& a, const Tz& z) { partials_type_t a_val = value_of(a); partials_type_t z_val = value_of(z); FvarT rtn = FvarT(hypergeometric_1F0(a_val, z_val), 0.0); if constexpr (is_autodiff_v) { - rtn.d_ += a.d() * -rtn.val() * log1m(z_val); + rtn.d_ += forward_as(a).d() * -rtn.val() * log1m(z_val); } if constexpr (is_autodiff_v) { - rtn.d_ += z.d() * rtn.val() * a_val * inv(1 - z_val); + rtn.d_ += forward_as(z).d() * rtn.val() * a_val * inv(1 - z_val); } return rtn; } diff --git a/stan/math/fwd/fun/hypergeometric_2F1.hpp b/stan/math/fwd/fun/hypergeometric_2F1.hpp index 1b316e58988..1699aea4e55 100644 --- a/stan/math/fwd/fun/hypergeometric_2F1.hpp +++ b/stan/math/fwd/fun/hypergeometric_2F1.hpp @@ -46,16 +46,16 @@ inline return_type_t hypergeometric_2F1(const Ta1& a1, typename fvar_t::Scalar grad = 0; if constexpr (is_autodiff_v) { - grad += a1.d() * std::get<0>(grad_tuple); + grad += forward_as(a1).d() * std::get<0>(grad_tuple); } if constexpr (is_autodiff_v) { - grad += a2.d() * std::get<1>(grad_tuple); + grad += forward_as(a2).d() * std::get<1>(grad_tuple); } if constexpr (is_autodiff_v) { - grad += b.d() * std::get<2>(grad_tuple); + grad += forward_as(b).d() * std::get<2>(grad_tuple); } if constexpr (is_autodiff_v) { - grad += z.d() * std::get<3>(grad_tuple); + grad += forward_as(z).d() * std::get<3>(grad_tuple); } return fvar_t(hypergeometric_2F1(a1_val, a2_val, b_val, z_val), grad); diff --git a/stan/math/fwd/fun/inv_inc_beta.hpp b/stan/math/fwd/fun/inv_inc_beta.hpp index 6dd75154fdf..f22a39ada79 100644 --- a/stan/math/fwd/fun/inv_inc_beta.hpp +++ b/stan/math/fwd/fun/inv_inc_beta.hpp @@ -63,7 +63,7 @@ inline fvar> inv_inc_beta(const T1& a, + log(hypergeometric_3F2(da_a, da_b, w)) - 2 * lgamma(ap1)); auto da3 = inc_beta(a_val, b_val, w) * exp(lbeta_ab) * (log_w - digamma(a_val) + digamma_apb); - inv_d_ += a.d_ * da1 * (da2 - da3); + inv_d_ += forward_as>(a).d_ * da1 * (da2 - da3); } if constexpr (is_fvar::value) { @@ -76,11 +76,12 @@ inline fvar> inv_inc_beta(const T1& a, auto db3 = inc_beta(b_val, a_val, one_m_w) * exp(lbeta_ab) * (log1m_w - digamma(b_val) + digamma_apb); - inv_d_ += b.d_ * db1 * (exp(db2) - db3); + inv_d_ += forward_as>(b).d_ * db1 * (exp(db2) - db3); } if constexpr (is_fvar::value) { - inv_d_ += p.d_ * exp(one_m_b * log1m_w + one_m_a * log_w + lbeta_ab); + inv_d_ += forward_as>(p).d_ + * exp(one_m_b * log1m_w + one_m_a * log_w + lbeta_ab); } return fvar(w, inv_d_); diff --git a/stan/math/fwd/fun/polar.hpp b/stan/math/fwd/fun/polar.hpp index 118479d0730..2728e6ded8d 100644 --- a/stan/math/fwd/fun/polar.hpp +++ b/stan/math/fwd/fun/polar.hpp @@ -44,7 +44,7 @@ inline std::complex> polar(const fvar& r, U theta) { * Returns complex number with specified magnitude and phase angle. * * @tparam T autodiff value type for phase angle - * * @tparam U arithmetic type for magnitude ++* * @tparam U arithmetic type for magnitude * @param[in] r magnitude * @param[in] theta phase angle * @return complex number with magnitude and phase angle diff --git a/stan/math/fwd/functor/gradient.hpp b/stan/math/fwd/functor/gradient.hpp index 7ac311ca0f8..e31e542e874 100644 --- a/stan/math/fwd/functor/gradient.hpp +++ b/stan/math/fwd/functor/gradient.hpp @@ -37,8 +37,8 @@ namespace math { * @param[out] grad_fx Gradient of function at argument */ template -inline void gradient(const F& f, const Eigen::Matrix& x, - T& fx, Eigen::Matrix& grad_fx) { +void gradient(const F& f, const Eigen::Matrix& x, T& fx, + Eigen::Matrix& grad_fx) { Eigen::Matrix, Eigen::Dynamic, 1> x_fvar(x.size()); grad_fx.resize(x.size()); for (int i = 0; i < x.size(); ++i) { diff --git a/stan/math/fwd/functor/hessian.hpp b/stan/math/fwd/functor/hessian.hpp index ab686b52dbf..ba75e8007f2 100644 --- a/stan/math/fwd/functor/hessian.hpp +++ b/stan/math/fwd/functor/hessian.hpp @@ -38,9 +38,9 @@ namespace math { * @param[out] H Hessian of function at argument */ template -inline void hessian(const F& f, const Eigen::Matrix& x, - T& fx, Eigen::Matrix& grad, - Eigen::Matrix& H) { +void hessian(const F& f, const Eigen::Matrix& x, T& fx, + Eigen::Matrix& grad, + Eigen::Matrix& H) { H.resize(x.size(), x.size()); grad.resize(x.size()); // size 0 separate because nothing to loop over in main body diff --git a/stan/math/fwd/functor/integrate_1d.hpp b/stan/math/fwd/functor/integrate_1d.hpp index 501993bcdbf..a38b154c753 100644 --- a/stan/math/fwd/functor/integrate_1d.hpp +++ b/stan/math/fwd/functor/integrate_1d.hpp @@ -48,7 +48,7 @@ inline return_type_t integrate_1d_impl( if constexpr (is_fvar::value || is_fvar::value) { auto val_args = std::make_tuple(value_of(args)...); if constexpr (is_fvar::value) { - ret.d_ += a.d_ + ret.d_ += math::forward_as(a).d_ * math::apply( [&](auto &&... tuple_args) { return -f(a_val, 0.0, msgs, tuple_args...); @@ -56,7 +56,7 @@ inline return_type_t integrate_1d_impl( val_args); } if constexpr (is_fvar::value) { - ret.d_ += b.d_ + ret.d_ += math::forward_as(b).d_ * math::apply( [&](auto &&... tuple_args) { return f(b_val, 0.0, msgs, tuple_args...); diff --git a/stan/math/fwd/functor/jacobian.hpp b/stan/math/fwd/functor/jacobian.hpp index 030e16c1749..283a2f71e5c 100644 --- a/stan/math/fwd/functor/jacobian.hpp +++ b/stan/math/fwd/functor/jacobian.hpp @@ -8,9 +8,9 @@ namespace stan { namespace math { template -inline void jacobian(const F& f, const Eigen::Matrix& x, - Eigen::Matrix& fx, - Eigen::Matrix& J) { +void jacobian(const F& f, const Eigen::Matrix& x, + Eigen::Matrix& fx, + Eigen::Matrix& J) { using Eigen::Dynamic; using Eigen::Matrix; Matrix, Dynamic, 1> x_fvar(x.size()); diff --git a/stan/math/memory/stack_alloc.hpp b/stan/math/memory/stack_alloc.hpp index 3d73c7d6b52..8a8ef2cc7c1 100644 --- a/stan/math/memory/stack_alloc.hpp +++ b/stan/math/memory/stack_alloc.hpp @@ -26,7 +26,7 @@ namespace math { * @tparam Type of object to which pointer points. */ template -inline bool is_aligned(T* ptr, unsigned int bytes_aligned) { +bool is_aligned(T* ptr, unsigned int bytes_aligned) { return (reinterpret_cast(ptr) % bytes_aligned) == 0U; } diff --git a/stan/math/mix/functor/hessian_times_vector.hpp b/stan/math/mix/functor/hessian_times_vector.hpp index 405ee2a9856..dbd1c62c347 100644 --- a/stan/math/mix/functor/hessian_times_vector.hpp +++ b/stan/math/mix/functor/hessian_times_vector.hpp @@ -38,10 +38,10 @@ inline void hessian_times_vector( template * = nullptr, require_stan_scalar_t* = nullptr> -inline void hessian_times_vector(const F& f, - const Eigen::Matrix& x, - const EigVec& v, T& fx, - Eigen::Matrix& Hv) { +void hessian_times_vector(const F& f, + const Eigen::Matrix& x, + const EigVec& v, T& fx, + Eigen::Matrix& Hv) { using Eigen::Matrix; Matrix grad; Matrix H; diff --git a/stan/math/mix/functor/partial_derivative.hpp b/stan/math/mix/functor/partial_derivative.hpp index 34245741c7e..dfa428c2185 100644 --- a/stan/math/mix/functor/partial_derivative.hpp +++ b/stan/math/mix/functor/partial_derivative.hpp @@ -22,9 +22,9 @@ namespace math { * @param[out] dfx_dxn Value of partial derivative */ template -inline void partial_derivative(const F& f, - const Eigen::Matrix& x, - int n, T& fx, T& dfx_dxn) { +void partial_derivative(const F& f, + const Eigen::Matrix& x, int n, + T& fx, T& dfx_dxn) { Eigen::Matrix, Eigen::Dynamic, 1> x_fvar(x.size()); for (int i = 0; i < x.size(); ++i) { x_fvar(i) = fvar(x(i), i == n); diff --git a/stan/math/opencl/copy.hpp b/stan/math/opencl/copy.hpp index 9a06ea7cc26..e3599e5c933 100644 --- a/stan/math/opencl/copy.hpp +++ b/stan/math/opencl/copy.hpp @@ -232,7 +232,7 @@ inline T_dst from_matrix_cl(const matrix_cl& src) { * @return Eigen matrix with a copy of the data in the source matrix */ template * = nullptr> -inline auto from_matrix_cl(const T& src) { +auto from_matrix_cl(const T& src) { return from_matrix_cl< Eigen::Matrix, Eigen::Dynamic, Eigen::Dynamic>>(src); } diff --git a/stan/math/opencl/indexing_rev.hpp b/stan/math/opencl/indexing_rev.hpp index c3cff5ecb76..94be70c2c68 100644 --- a/stan/math/opencl/indexing_rev.hpp +++ b/stan/math/opencl/indexing_rev.hpp @@ -19,8 +19,8 @@ namespace math { * @param idx indices * @param res adjoint of the result of the indexing operation */ -inline void indexing_rev(matrix_cl& adj, const matrix_cl& idx, - const matrix_cl& res) { +void indexing_rev(matrix_cl& adj, const matrix_cl& idx, + const matrix_cl& res) { int local_mem_size = opencl_context.device()[0].getInfo(); int preferred_work_groups diff --git a/stan/math/opencl/kernel_generator/evaluate_into.hpp b/stan/math/opencl/kernel_generator/evaluate_into.hpp index aaed90b8afb..c171f62e1e4 100644 --- a/stan/math/opencl/kernel_generator/evaluate_into.hpp +++ b/stan/math/opencl/kernel_generator/evaluate_into.hpp @@ -18,8 +18,7 @@ namespace math { */ template template -inline void operation_cl::evaluate_into( - T_lhs& lhs) const { +void operation_cl::evaluate_into(T_lhs& lhs) const { static_assert( is_kernel_expression::value, "operation_cl::evaluate_into: left hand side is not a valid expression!"); diff --git a/stan/math/opencl/kernel_generator/holder_cl.hpp b/stan/math/opencl/kernel_generator/holder_cl.hpp index 8257554f7f4..175ef1689d6 100644 --- a/stan/math/opencl/kernel_generator/holder_cl.hpp +++ b/stan/math/opencl/kernel_generator/holder_cl.hpp @@ -64,7 +64,7 @@ class holder_cl_ */ template * = nullptr> -inline auto holder_cl(T&& a, Ptrs*... ptrs) { +auto holder_cl(T&& a, Ptrs*... ptrs) { return holder_cl_, Ptrs...>( as_operation_cl(std::forward(a)), ptrs...); } @@ -81,8 +81,8 @@ namespace internal { * @return `holder_cl` referencing given expression */ template -inline auto make_holder_cl_impl_step2(T&& expr, std::index_sequence, - const std::tuple& ptrs) { +auto make_holder_cl_impl_step2(T&& expr, std::index_sequence, + const std::tuple& ptrs) { return holder_cl(std::forward(expr), std::get(ptrs)...); } @@ -96,8 +96,8 @@ inline auto make_holder_cl_impl_step2(T&& expr, std::index_sequence, * @return `holder_cl` referencing given expression */ template -inline auto make_holder_cl_impl_step1(const T& func, std::index_sequence, - Args&&... args) { +auto make_holder_cl_impl_step1(const T& func, std::index_sequence, + Args&&... args) { std::tuple*...> res; auto ptrs = std::tuple_cat( holder_handle_element(std::forward(args), std::get(res))...); @@ -122,7 +122,7 @@ template ()(std::declval()...)), Args...>* = nullptr> -inline auto make_holder_cl(const T& func, Args&&... args) { +auto make_holder_cl(const T& func, Args&&... args) { return internal::make_holder_cl_impl_step1( func, std::make_index_sequence(), std::forward(args)...); diff --git a/stan/math/opencl/kernel_generator/multi_result_kernel.hpp b/stan/math/opencl/kernel_generator/multi_result_kernel.hpp index 0b0cbadec57..2cf0bcb2676 100644 --- a/stan/math/opencl/kernel_generator/multi_result_kernel.hpp +++ b/stan/math/opencl/kernel_generator/multi_result_kernel.hpp @@ -665,7 +665,7 @@ class results_cl { * @param results results that will be calculated in same kernel. */ template -inline results_cl results(T_results&&... results) { +results_cl results(T_results&&... results) { return results_cl(std::forward(results)...); } diff --git a/stan/math/opencl/prim/bernoulli_cdf.hpp b/stan/math/opencl/prim/bernoulli_cdf.hpp index c23a097a0c5..32bd3479d59 100644 --- a/stan/math/opencl/prim/bernoulli_cdf.hpp +++ b/stan/math/opencl/prim/bernoulli_cdf.hpp @@ -27,8 +27,8 @@ template < typename T_n_cl, typename T_prob_cl, require_all_prim_or_rev_kernel_expression_t* = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t bernoulli_cdf(const T_n_cl& n, - const T_prob_cl& theta) { +return_type_t bernoulli_cdf(const T_n_cl& n, + const T_prob_cl& theta) { static constexpr const char* function = "bernoulli_cdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isnan; diff --git a/stan/math/opencl/prim/bernoulli_lccdf.hpp b/stan/math/opencl/prim/bernoulli_lccdf.hpp index 42a9f7cac6d..7de8edb66e6 100644 --- a/stan/math/opencl/prim/bernoulli_lccdf.hpp +++ b/stan/math/opencl/prim/bernoulli_lccdf.hpp @@ -28,8 +28,8 @@ template < typename T_n_cl, typename T_prob_cl, require_all_prim_or_rev_kernel_expression_t* = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t bernoulli_lccdf(const T_n_cl& n, - const T_prob_cl& theta) { +return_type_t bernoulli_lccdf(const T_n_cl& n, + const T_prob_cl& theta) { static constexpr const char* function = "bernoulli_lccdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isnan; diff --git a/stan/math/opencl/prim/bernoulli_lcdf.hpp b/stan/math/opencl/prim/bernoulli_lcdf.hpp index 82259f44e61..aad36c9651e 100644 --- a/stan/math/opencl/prim/bernoulli_lcdf.hpp +++ b/stan/math/opencl/prim/bernoulli_lcdf.hpp @@ -28,8 +28,8 @@ template < typename T_n_cl, typename T_prob_cl, require_all_prim_or_rev_kernel_expression_t* = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t bernoulli_lcdf(const T_n_cl& n, - const T_prob_cl& theta) { +return_type_t bernoulli_lcdf(const T_n_cl& n, + const T_prob_cl& theta) { static constexpr const char* function = "bernoulli_lcdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isnan; diff --git a/stan/math/opencl/prim/bernoulli_logit_glm_lpmf.hpp b/stan/math/opencl/prim/bernoulli_logit_glm_lpmf.hpp index 2bcafae51ff..ba535db8aee 100644 --- a/stan/math/opencl/prim/bernoulli_logit_glm_lpmf.hpp +++ b/stan/math/opencl/prim/bernoulli_logit_glm_lpmf.hpp @@ -53,7 +53,7 @@ template * = nullptr> -inline return_type_t bernoulli_logit_glm_lpmf( +return_type_t bernoulli_logit_glm_lpmf( const T_y_cl& y, const T_x_cl& x, const T_alpha_cl& alpha, const T_beta_cl& beta) { static constexpr const char* function = "bernoulli_logit_glm_lpmf(OpenCL)"; @@ -144,7 +144,8 @@ inline return_type_t bernoulli_logit_glm_lpmf( if constexpr (is_alpha_vector) { partials<1>(ops_partials) = theta_derivative_cl; } else { - partials<1>(ops_partials)[0] + forward_as>( + partials<1>(ops_partials))[0] = sum(from_matrix_cl(theta_derivative_sum_cl)); } } diff --git a/stan/math/opencl/prim/bernoulli_logit_lpmf.hpp b/stan/math/opencl/prim/bernoulli_logit_lpmf.hpp index 282dbd08164..af6635b3441 100644 --- a/stan/math/opencl/prim/bernoulli_logit_lpmf.hpp +++ b/stan/math/opencl/prim/bernoulli_logit_lpmf.hpp @@ -26,8 +26,8 @@ template < bool propto, typename T_n_cl, typename T_prob_cl, require_all_prim_or_rev_kernel_expression_t* = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t bernoulli_logit_lpmf(const T_n_cl& n, - const T_prob_cl& theta) { +return_type_t bernoulli_logit_lpmf(const T_n_cl& n, + const T_prob_cl& theta) { static constexpr const char* function = "bernoulli_logit_lpmf(OpenCL)"; using T_partials_return = partials_return_t; using std::isnan; diff --git a/stan/math/opencl/prim/bernoulli_lpmf.hpp b/stan/math/opencl/prim/bernoulli_lpmf.hpp index 1a73f212243..344bdf5e084 100644 --- a/stan/math/opencl/prim/bernoulli_lpmf.hpp +++ b/stan/math/opencl/prim/bernoulli_lpmf.hpp @@ -29,8 +29,8 @@ template < bool propto, typename T_n_cl, typename T_prob_cl, require_all_prim_or_rev_kernel_expression_t* = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t bernoulli_lpmf(const T_n_cl& n, - const T_prob_cl& theta) { +return_type_t bernoulli_lpmf(const T_n_cl& n, + const T_prob_cl& theta) { static constexpr const char* function = "bernoulli_lpmf(OpenCL)"; using T_partials_return = partials_return_t; constexpr bool is_n_vector = !is_stan_scalar::value; @@ -77,7 +77,7 @@ inline return_type_t bernoulli_lpmf(const T_n_cl& n, partials<0>(ops_partials) = deriv_cl; } } else { - auto n_sum_expr = rowwise_sum(n); + auto n_sum_expr = rowwise_sum(forward_as>(n)); matrix_cl n_sum_cl; @@ -85,7 +85,7 @@ inline return_type_t bernoulli_lpmf(const T_n_cl& n, = expressions(n_sum_expr, n_bounded_expr); size_t n_sum = sum(from_matrix_cl(n_sum_cl)); - double theta_val_scal = theta_val; + double theta_val_scal = forward_as(theta_val); if (n_sum == N) { logp = N * log(theta_val_scal); } else if (n_sum == 0) { @@ -94,7 +94,8 @@ inline return_type_t bernoulli_lpmf(const T_n_cl& n, logp = n_sum * log(theta_val_scal) + (N - n_sum) * log1m(theta_val_scal); } if constexpr (is_autodiff_v) { - double& edge1_partial = partials<0>(ops_partials)[0]; + double& edge1_partial = forward_as>( + partials<0>(ops_partials))[0]; if (n_sum == N) { edge1_partial += N / theta_val_scal; } else if (n_sum == 0) { diff --git a/stan/math/opencl/prim/beta_binomial_lpmf.hpp b/stan/math/opencl/prim/beta_binomial_lpmf.hpp index 39406d1b38e..a0c23dc8840 100644 --- a/stan/math/opencl/prim/beta_binomial_lpmf.hpp +++ b/stan/math/opencl/prim/beta_binomial_lpmf.hpp @@ -40,7 +40,7 @@ template < require_all_prim_or_rev_kernel_expression_t* = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t beta_binomial_lpmf( +return_type_t beta_binomial_lpmf( const T_n_cl& n, const T_N_cl N, const T_size1_cl& alpha, const T_size2_cl& beta) { using std::isfinite; diff --git a/stan/math/opencl/prim/beta_lpdf.hpp b/stan/math/opencl/prim/beta_lpdf.hpp index 59de46f585c..1756c768a6a 100644 --- a/stan/math/opencl/prim/beta_lpdf.hpp +++ b/stan/math/opencl/prim/beta_lpdf.hpp @@ -40,7 +40,7 @@ template * = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t beta_lpdf( +return_type_t beta_lpdf( const T_y_cl& y, const T_scale_succ_cl& alpha, const T_scale_fail_cl& beta) { using std::isfinite; diff --git a/stan/math/opencl/prim/beta_proportion_lpdf.hpp b/stan/math/opencl/prim/beta_proportion_lpdf.hpp index 0c0cbacc632..47efd47861a 100644 --- a/stan/math/opencl/prim/beta_proportion_lpdf.hpp +++ b/stan/math/opencl/prim/beta_proportion_lpdf.hpp @@ -39,7 +39,7 @@ template * = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t beta_proportion_lpdf( +return_type_t beta_proportion_lpdf( const T_y_cl& y, const T_loc_cl& mu, const T_prec_cl& kappa) { static constexpr const char* function = "beta_proportion_lpdf(OpenCL)"; using T_partials_return = partials_return_t; diff --git a/stan/math/opencl/prim/binomial_logit_glm_lpmf.hpp b/stan/math/opencl/prim/binomial_logit_glm_lpmf.hpp index a569498f5e1..ac726b2e153 100644 --- a/stan/math/opencl/prim/binomial_logit_glm_lpmf.hpp +++ b/stan/math/opencl/prim/binomial_logit_glm_lpmf.hpp @@ -29,7 +29,7 @@ template * = nullptr> -inline return_type_t binomial_logit_glm_lpmf( +return_type_t binomial_logit_glm_lpmf( const T_n_cl& n, const T_N_cl& N, const T_x_cl& x, const T_alpha_cl& alpha, const T_beta_cl& beta) { static const char* function = "binomial_logit_glm_lpmf(OpenCL)"; @@ -111,7 +111,9 @@ inline return_type_t binomial_logit_glm_lpmf( if constexpr (is_alpha_vector) { partials<1>(ops_partials) = theta_deriv_cl; } else { - partials<1>(ops_partials)[0] = sum(from_matrix_cl(theta_deriv_sum_cl)); + forward_as>( + partials<1>(ops_partials))[0] + = sum(from_matrix_cl(theta_deriv_sum_cl)); } } if constexpr (is_autodiff_v) { diff --git a/stan/math/opencl/prim/binomial_logit_lpmf.hpp b/stan/math/opencl/prim/binomial_logit_lpmf.hpp index 8b02d157c37..286addfc82a 100644 --- a/stan/math/opencl/prim/binomial_logit_lpmf.hpp +++ b/stan/math/opencl/prim/binomial_logit_lpmf.hpp @@ -31,9 +31,8 @@ template * = nullptr, require_any_nonscalar_prim_or_rev_kernel_expression_t< T_n_cl, T_N_cl, T_prob_cl>* = nullptr> -inline return_type_t binomial_logit_lpmf(const T_n_cl& n, - const T_N_cl N, - const T_prob_cl& alpha) { +return_type_t binomial_logit_lpmf(const T_n_cl& n, const T_N_cl N, + const T_prob_cl& alpha) { static constexpr const char* function = "binomial_logit_lpmf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; diff --git a/stan/math/opencl/prim/binomial_lpmf.hpp b/stan/math/opencl/prim/binomial_lpmf.hpp index e963807f64f..8bed274f468 100644 --- a/stan/math/opencl/prim/binomial_lpmf.hpp +++ b/stan/math/opencl/prim/binomial_lpmf.hpp @@ -33,8 +33,8 @@ template * = nullptr, require_any_nonscalar_prim_or_rev_kernel_expression_t< T_n_cl, T_N_cl, T_prob_cl>* = nullptr> -inline return_type_t binomial_lpmf(const T_n_cl& n, const T_N_cl N, - const T_prob_cl& theta) { +return_type_t binomial_lpmf(const T_n_cl& n, const T_N_cl N, + const T_prob_cl& theta) { static constexpr const char* function = "binomial_lpmf(OpenCL)"; using T_partials_return = partials_return_t; using std::isnan; @@ -113,8 +113,9 @@ inline return_type_t binomial_lpmf(const T_n_cl& n, const T_N_cl N, if constexpr (need_sums) { int sum_n = sum(from_matrix_cl(sum_n_cl)); int sum_N = sum(from_matrix_cl(sum_N_cl)); - double theta_dbl = theta_val; - double& partial = partials<0>(ops_partials)[0]; + double theta_dbl = forward_as(theta_val); + double& partial = forward_as>( + partials<0>(ops_partials))[0]; if (sum_N != 0) { if (sum_n == 0) { partial = -sum_N / (1.0 - theta_dbl); diff --git a/stan/math/opencl/prim/categorical_logit_glm_lpmf.hpp b/stan/math/opencl/prim/categorical_logit_glm_lpmf.hpp index 2396cd9e659..aaae3438f1f 100644 --- a/stan/math/opencl/prim/categorical_logit_glm_lpmf.hpp +++ b/stan/math/opencl/prim/categorical_logit_glm_lpmf.hpp @@ -46,7 +46,7 @@ template * = nullptr> -inline return_type_t categorical_logit_glm_lpmf( +return_type_t categorical_logit_glm_lpmf( const T_y& y, const T_x& x, const T_alpha& alpha, const T_beta& beta) { using T_partials_return = partials_return_t; constexpr bool is_y_vector = !is_stan_scalar::value; @@ -88,8 +88,8 @@ inline return_type_t categorical_logit_glm_lpmf( = opencl_kernels::categorical_logit_glm.get_option("LOCAL_SIZE_"); const int wgs = (N_instances + local_size - 1) / local_size; - constexpr bool need_alpha_derivative = is_autodiff_v; - constexpr bool need_beta_derivative = is_autodiff_v; + bool need_alpha_derivative = is_autodiff_v; + bool need_beta_derivative = is_autodiff_v; matrix_cl logp_cl(wgs, 1); matrix_cl exp_lin_cl(N_instances, N_classes); @@ -127,12 +127,13 @@ inline return_type_t categorical_logit_glm_lpmf( if constexpr (is_y_vector) { partials<0>(ops_partials) = indexing(beta_val, col_index(x.rows(), x.cols()), - rowwise_broadcast(y_val - 1)) + rowwise_broadcast(forward_as>(y_val) - 1)) - elt_multiply(exp_lin_cl * transpose(beta_val), rowwise_broadcast(inv_sum_exp_lin_cl)); } else { partials<0>(ops_partials) - = indexing(beta_val, col_index(x.rows(), x.cols()), y_val - 1) + = indexing(beta_val, col_index(x.rows(), x.cols()), + forward_as(y_val) - 1) - elt_multiply(exp_lin_cl * transpose(beta_val), rowwise_broadcast(inv_sum_exp_lin_cl)); } @@ -151,8 +152,9 @@ inline return_type_t categorical_logit_glm_lpmf( try { opencl_kernels::categorical_logit_glm_beta_derivative( cl::NDRange(local_size * N_attributes), cl::NDRange(local_size), - partials<2>(ops_partials), temp, y_val_cl, x_val, N_instances, - N_attributes, N_classes, is_y_vector); + forward_as>(partials<2>(ops_partials)), + temp, y_val_cl, x_val, N_instances, N_attributes, N_classes, + is_y_vector); } catch (const cl::Error& e) { check_opencl_error(function, e); } diff --git a/stan/math/opencl/prim/cauchy_cdf.hpp b/stan/math/opencl/prim/cauchy_cdf.hpp index 795eb6b2beb..84d1e19a1c5 100644 --- a/stan/math/opencl/prim/cauchy_cdf.hpp +++ b/stan/math/opencl/prim/cauchy_cdf.hpp @@ -31,7 +31,7 @@ template < require_all_prim_or_rev_kernel_expression_t* = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t cauchy_cdf( +return_type_t cauchy_cdf( const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& sigma) { static constexpr const char* function = "cauchy_cdf(OpenCL)"; using T_partials_return = partials_return_t; diff --git a/stan/math/opencl/prim/cauchy_lccdf.hpp b/stan/math/opencl/prim/cauchy_lccdf.hpp index cb20f5349b5..6d9cb8d79be 100644 --- a/stan/math/opencl/prim/cauchy_lccdf.hpp +++ b/stan/math/opencl/prim/cauchy_lccdf.hpp @@ -31,7 +31,7 @@ template < require_all_prim_or_rev_kernel_expression_t* = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t cauchy_lccdf( +return_type_t cauchy_lccdf( const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& sigma) { static constexpr const char* function = "cauchy_lccdf(OpenCL)"; using T_partials_return = partials_return_t; diff --git a/stan/math/opencl/prim/cauchy_lcdf.hpp b/stan/math/opencl/prim/cauchy_lcdf.hpp index 0fc66720f3d..c19665e5773 100644 --- a/stan/math/opencl/prim/cauchy_lcdf.hpp +++ b/stan/math/opencl/prim/cauchy_lcdf.hpp @@ -31,7 +31,7 @@ template < require_all_prim_or_rev_kernel_expression_t* = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t cauchy_lcdf( +return_type_t cauchy_lcdf( const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& sigma) { static constexpr const char* function = "cauchy_lcdf(OpenCL)"; using T_partials_return = partials_return_t; diff --git a/stan/math/opencl/prim/cauchy_lpdf.hpp b/stan/math/opencl/prim/cauchy_lpdf.hpp index faaa477c9a2..9ec186bd224 100644 --- a/stan/math/opencl/prim/cauchy_lpdf.hpp +++ b/stan/math/opencl/prim/cauchy_lpdf.hpp @@ -35,7 +35,7 @@ template < require_all_prim_or_rev_kernel_expression_t* = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t cauchy_lpdf( +return_type_t cauchy_lpdf( const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& sigma) { static constexpr const char* function = "cauchy_lpdf(OpenCL)"; using T_partials_return = partials_return_t; diff --git a/stan/math/opencl/prim/chi_square_lpdf.hpp b/stan/math/opencl/prim/chi_square_lpdf.hpp index 4c875021a30..553ad80a0b0 100644 --- a/stan/math/opencl/prim/chi_square_lpdf.hpp +++ b/stan/math/opencl/prim/chi_square_lpdf.hpp @@ -35,8 +35,8 @@ template < bool propto, typename T_y_cl, typename T_dof_cl, require_all_prim_or_rev_kernel_expression_t* = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t chi_square_lpdf(const T_y_cl& y, - const T_dof_cl& nu) { +return_type_t chi_square_lpdf(const T_y_cl& y, + const T_dof_cl& nu) { static constexpr const char* function = "chi_square_lpdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; diff --git a/stan/math/opencl/prim/double_exponential_cdf.hpp b/stan/math/opencl/prim/double_exponential_cdf.hpp index 7428963c418..8b09791c96a 100644 --- a/stan/math/opencl/prim/double_exponential_cdf.hpp +++ b/stan/math/opencl/prim/double_exponential_cdf.hpp @@ -30,7 +30,7 @@ template < require_all_prim_or_rev_kernel_expression_t* = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t double_exponential_cdf( +return_type_t double_exponential_cdf( const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& sigma) { static constexpr const char* function = "double_exponential_cdf(OpenCL)"; using T_partials_return = partials_return_t; diff --git a/stan/math/opencl/prim/double_exponential_lccdf.hpp b/stan/math/opencl/prim/double_exponential_lccdf.hpp index d1ace573441..5baafc72bfa 100644 --- a/stan/math/opencl/prim/double_exponential_lccdf.hpp +++ b/stan/math/opencl/prim/double_exponential_lccdf.hpp @@ -31,7 +31,7 @@ template < require_all_prim_or_rev_kernel_expression_t* = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t double_exponential_lccdf( +return_type_t double_exponential_lccdf( const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& sigma) { static constexpr const char* function = "double_exponential_lccdf(OpenCL)"; using T_partials_return = partials_return_t; diff --git a/stan/math/opencl/prim/double_exponential_lcdf.hpp b/stan/math/opencl/prim/double_exponential_lcdf.hpp index 6b898e35d94..31592578699 100644 --- a/stan/math/opencl/prim/double_exponential_lcdf.hpp +++ b/stan/math/opencl/prim/double_exponential_lcdf.hpp @@ -30,7 +30,7 @@ template < require_all_prim_or_rev_kernel_expression_t* = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t double_exponential_lcdf( +return_type_t double_exponential_lcdf( const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& sigma) { static constexpr const char* function = "double_exponential_lcdf(OpenCL)"; using T_partials_return = partials_return_t; diff --git a/stan/math/opencl/prim/double_exponential_lpdf.hpp b/stan/math/opencl/prim/double_exponential_lpdf.hpp index 6046467b7b2..cdc68587faa 100644 --- a/stan/math/opencl/prim/double_exponential_lpdf.hpp +++ b/stan/math/opencl/prim/double_exponential_lpdf.hpp @@ -33,7 +33,7 @@ template < require_all_prim_or_rev_kernel_expression_t* = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t double_exponential_lpdf( +return_type_t double_exponential_lpdf( const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& sigma) { static constexpr const char* function = "double_exponential_lpdf(OpenCL)"; using T_partials_return = partials_return_t; diff --git a/stan/math/opencl/prim/exp_mod_normal_cdf.hpp b/stan/math/opencl/prim/exp_mod_normal_cdf.hpp index 9510340e2fa..d45519fe9cd 100644 --- a/stan/math/opencl/prim/exp_mod_normal_cdf.hpp +++ b/stan/math/opencl/prim/exp_mod_normal_cdf.hpp @@ -33,9 +33,9 @@ template * = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t -exp_mod_normal_cdf(const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& sigma, - const T_inv_scale_cl& lambda) { +return_type_t exp_mod_normal_cdf( + const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& sigma, + const T_inv_scale_cl& lambda) { static constexpr const char* function = "exp_mod_normal_cdf(OpenCL)"; using T_partials_return = partials_return_t; diff --git a/stan/math/opencl/prim/exp_mod_normal_lccdf.hpp b/stan/math/opencl/prim/exp_mod_normal_lccdf.hpp index 8f250a0d40f..a3aa1514459 100644 --- a/stan/math/opencl/prim/exp_mod_normal_lccdf.hpp +++ b/stan/math/opencl/prim/exp_mod_normal_lccdf.hpp @@ -34,7 +34,7 @@ template * = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t +return_type_t exp_mod_normal_lccdf(const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& sigma, const T_inv_scale_cl& lambda) { static constexpr const char* function = "exp_mod_normal_lccdf(OpenCL)"; diff --git a/stan/math/opencl/prim/exp_mod_normal_lcdf.hpp b/stan/math/opencl/prim/exp_mod_normal_lcdf.hpp index b1e34e4de3a..57508e3f221 100644 --- a/stan/math/opencl/prim/exp_mod_normal_lcdf.hpp +++ b/stan/math/opencl/prim/exp_mod_normal_lcdf.hpp @@ -34,9 +34,9 @@ template * = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t -exp_mod_normal_lcdf(const T_y_cl& y, const T_loc_cl& mu, - const T_scale_cl& sigma, const T_inv_scale_cl& lambda) { +return_type_t exp_mod_normal_lcdf( + const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& sigma, + const T_inv_scale_cl& lambda) { static constexpr const char* function = "exp_mod_normal_lcdf(OpenCL)"; using T_partials_return = partials_return_t; diff --git a/stan/math/opencl/prim/exp_mod_normal_lpdf.hpp b/stan/math/opencl/prim/exp_mod_normal_lpdf.hpp index e00858c4518..091ba28a0ae 100644 --- a/stan/math/opencl/prim/exp_mod_normal_lpdf.hpp +++ b/stan/math/opencl/prim/exp_mod_normal_lpdf.hpp @@ -36,9 +36,9 @@ template * = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t -exp_mod_normal_lpdf(const T_y_cl& y, const T_loc_cl& mu, - const T_scale_cl& sigma, const T_inv_scale_cl& lambda) { +return_type_t exp_mod_normal_lpdf( + const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& sigma, + const T_inv_scale_cl& lambda) { static constexpr const char* function = "exp_mod_normal_lpdf(OpenCL)"; using T_partials_return = partials_return_t; diff --git a/stan/math/opencl/prim/exponential_cdf.hpp b/stan/math/opencl/prim/exponential_cdf.hpp index aa150618fde..0cc9510ce79 100644 --- a/stan/math/opencl/prim/exponential_cdf.hpp +++ b/stan/math/opencl/prim/exponential_cdf.hpp @@ -30,7 +30,7 @@ template * = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t exponential_cdf( +return_type_t exponential_cdf( const T_y_cl& y, const T_inv_scale_cl& beta) { static constexpr const char* function = "exponential_cdf(OpenCL)"; using T_partials_return = partials_return_t; diff --git a/stan/math/opencl/prim/exponential_lccdf.hpp b/stan/math/opencl/prim/exponential_lccdf.hpp index fe612a2792d..b43f08ed35e 100644 --- a/stan/math/opencl/prim/exponential_lccdf.hpp +++ b/stan/math/opencl/prim/exponential_lccdf.hpp @@ -30,7 +30,7 @@ template * = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t exponential_lccdf( +return_type_t exponential_lccdf( const T_y_cl& y, const T_inv_scale_cl& beta) { static constexpr const char* function = "exponential_lccdf(OpenCL)"; using T_partials_return = partials_return_t; diff --git a/stan/math/opencl/prim/exponential_lcdf.hpp b/stan/math/opencl/prim/exponential_lcdf.hpp index b598b78276e..641ce3354c1 100644 --- a/stan/math/opencl/prim/exponential_lcdf.hpp +++ b/stan/math/opencl/prim/exponential_lcdf.hpp @@ -30,7 +30,7 @@ template * = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t exponential_lcdf( +return_type_t exponential_lcdf( const T_y_cl& y, const T_inv_scale_cl& beta) { static constexpr const char* function = "exponential_lcdf(OpenCL)"; using T_partials_return = partials_return_t; diff --git a/stan/math/opencl/prim/exponential_lpdf.hpp b/stan/math/opencl/prim/exponential_lpdf.hpp index f20517ee955..bfe07601bc0 100644 --- a/stan/math/opencl/prim/exponential_lpdf.hpp +++ b/stan/math/opencl/prim/exponential_lpdf.hpp @@ -44,7 +44,7 @@ template * = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t exponential_lpdf( +return_type_t exponential_lpdf( const T_y_cl& y, const T_inv_scale_cl& beta) { using std::isfinite; static constexpr const char* function = "exponential_lpdf(OpenCL)"; diff --git a/stan/math/opencl/prim/frechet_cdf.hpp b/stan/math/opencl/prim/frechet_cdf.hpp index 8c422aebb3e..b06c716c92d 100644 --- a/stan/math/opencl/prim/frechet_cdf.hpp +++ b/stan/math/opencl/prim/frechet_cdf.hpp @@ -31,7 +31,7 @@ template < require_all_prim_or_rev_kernel_expression_t* = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t frechet_cdf( +return_type_t frechet_cdf( const T_y_cl& y, const T_shape_cl& alpha, const T_scale_cl& sigma) { static constexpr const char* function = "frechet_cdf(OpenCL)"; using T_partials_return = partials_return_t; diff --git a/stan/math/opencl/prim/frechet_lccdf.hpp b/stan/math/opencl/prim/frechet_lccdf.hpp index 7942d421675..8dec08db992 100644 --- a/stan/math/opencl/prim/frechet_lccdf.hpp +++ b/stan/math/opencl/prim/frechet_lccdf.hpp @@ -31,7 +31,7 @@ template < require_all_prim_or_rev_kernel_expression_t* = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t frechet_lccdf( +return_type_t frechet_lccdf( const T_y_cl& y, const T_shape_cl& alpha, const T_scale_cl& sigma) { static constexpr const char* function = "frechet_lccdf(OpenCL)"; using T_partials_return = partials_return_t; diff --git a/stan/math/opencl/prim/frechet_lcdf.hpp b/stan/math/opencl/prim/frechet_lcdf.hpp index b162e27f864..ec248254f91 100644 --- a/stan/math/opencl/prim/frechet_lcdf.hpp +++ b/stan/math/opencl/prim/frechet_lcdf.hpp @@ -31,7 +31,7 @@ template < require_all_prim_or_rev_kernel_expression_t* = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t frechet_lcdf( +return_type_t frechet_lcdf( const T_y_cl& y, const T_shape_cl& alpha, const T_scale_cl& sigma) { static constexpr const char* function = "frechet_lcdf(OpenCL)"; using T_partials_return = partials_return_t; diff --git a/stan/math/opencl/prim/frechet_lpdf.hpp b/stan/math/opencl/prim/frechet_lpdf.hpp index 608882cbd60..b2c9d678a34 100644 --- a/stan/math/opencl/prim/frechet_lpdf.hpp +++ b/stan/math/opencl/prim/frechet_lpdf.hpp @@ -36,7 +36,7 @@ template < require_all_prim_or_rev_kernel_expression_t* = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t frechet_lpdf( +return_type_t frechet_lpdf( const T_y_cl& y, const T_shape_cl& alpha, const T_scale_cl& sigma) { using std::isfinite; static constexpr const char* function = "frechet_lpdf(OpenCL)"; diff --git a/stan/math/opencl/prim/gamma_lpdf.hpp b/stan/math/opencl/prim/gamma_lpdf.hpp index 35af358c658..46e4c00b478 100644 --- a/stan/math/opencl/prim/gamma_lpdf.hpp +++ b/stan/math/opencl/prim/gamma_lpdf.hpp @@ -44,7 +44,7 @@ template * = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t gamma_lpdf( +return_type_t gamma_lpdf( const T_y_cl& y, const T_shape_cl& alpha, const T_inv_scale_cl& beta) { using std::isfinite; using std::isnan; diff --git a/stan/math/opencl/prim/gumbel_cdf.hpp b/stan/math/opencl/prim/gumbel_cdf.hpp index ebea01725f1..289ccabc376 100644 --- a/stan/math/opencl/prim/gumbel_cdf.hpp +++ b/stan/math/opencl/prim/gumbel_cdf.hpp @@ -31,8 +31,9 @@ template < require_all_prim_or_rev_kernel_expression_t* = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t gumbel_cdf( - const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& beta) { +return_type_t gumbel_cdf(const T_y_cl& y, + const T_loc_cl& mu, + const T_scale_cl& beta) { static constexpr const char* function = "gumbel_cdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; diff --git a/stan/math/opencl/prim/gumbel_lccdf.hpp b/stan/math/opencl/prim/gumbel_lccdf.hpp index 002805c6037..87c6aa7cdaf 100644 --- a/stan/math/opencl/prim/gumbel_lccdf.hpp +++ b/stan/math/opencl/prim/gumbel_lccdf.hpp @@ -31,7 +31,7 @@ template < require_all_prim_or_rev_kernel_expression_t* = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t gumbel_lccdf( +return_type_t gumbel_lccdf( const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& beta) { static constexpr const char* function = "gumbel_lccdf(OpenCL)"; using T_partials_return = partials_return_t; diff --git a/stan/math/opencl/prim/gumbel_lcdf.hpp b/stan/math/opencl/prim/gumbel_lcdf.hpp index 0d7418f252f..116a3f25119 100644 --- a/stan/math/opencl/prim/gumbel_lcdf.hpp +++ b/stan/math/opencl/prim/gumbel_lcdf.hpp @@ -31,7 +31,7 @@ template < require_all_prim_or_rev_kernel_expression_t* = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t gumbel_lcdf( +return_type_t gumbel_lcdf( const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& beta) { static constexpr const char* function = "gumbel_lcdf(OpenCL)"; using T_partials_return = partials_return_t; diff --git a/stan/math/opencl/prim/gumbel_lpdf.hpp b/stan/math/opencl/prim/gumbel_lpdf.hpp index abf6e5cf87b..d0d90a7c1bf 100644 --- a/stan/math/opencl/prim/gumbel_lpdf.hpp +++ b/stan/math/opencl/prim/gumbel_lpdf.hpp @@ -33,7 +33,7 @@ template < require_all_prim_or_rev_kernel_expression_t* = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t gumbel_lpdf( +return_type_t gumbel_lpdf( const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& beta) { using std::isfinite; using std::isnan; diff --git a/stan/math/opencl/prim/inv_chi_square_lpdf.hpp b/stan/math/opencl/prim/inv_chi_square_lpdf.hpp index f58d52891c6..a6ad295c9c2 100644 --- a/stan/math/opencl/prim/inv_chi_square_lpdf.hpp +++ b/stan/math/opencl/prim/inv_chi_square_lpdf.hpp @@ -41,8 +41,8 @@ template < bool propto, typename T_y_cl, typename T_dof_cl, require_all_prim_or_rev_kernel_expression_t* = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t inv_chi_square_lpdf(const T_y_cl& y, - const T_dof_cl& nu) { +return_type_t inv_chi_square_lpdf(const T_y_cl& y, + const T_dof_cl& nu) { using std::isfinite; using std::isnan; static constexpr const char* function = "inv_chi_square_lpdf(OpenCL)"; diff --git a/stan/math/opencl/prim/inv_gamma_lpdf.hpp b/stan/math/opencl/prim/inv_gamma_lpdf.hpp index d678c8dba58..940199ceea8 100644 --- a/stan/math/opencl/prim/inv_gamma_lpdf.hpp +++ b/stan/math/opencl/prim/inv_gamma_lpdf.hpp @@ -36,7 +36,7 @@ template < require_all_prim_or_rev_kernel_expression_t* = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t inv_gamma_lpdf( +return_type_t inv_gamma_lpdf( const T_y_cl& y, const T_shape_cl& alpha, const T_scale_cl& beta) { using std::isfinite; using std::isnan; diff --git a/stan/math/opencl/prim/logistic_cdf.hpp b/stan/math/opencl/prim/logistic_cdf.hpp index 7d02536baa3..3546c79e591 100644 --- a/stan/math/opencl/prim/logistic_cdf.hpp +++ b/stan/math/opencl/prim/logistic_cdf.hpp @@ -31,7 +31,7 @@ template < require_all_prim_or_rev_kernel_expression_t* = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t logistic_cdf( +return_type_t logistic_cdf( const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& sigma) { static constexpr const char* function = "logistic_cdf(OpenCL)"; using T_partials_return = partials_return_t; diff --git a/stan/math/opencl/prim/logistic_lccdf.hpp b/stan/math/opencl/prim/logistic_lccdf.hpp index 2c9155969cf..a6b7be3197f 100644 --- a/stan/math/opencl/prim/logistic_lccdf.hpp +++ b/stan/math/opencl/prim/logistic_lccdf.hpp @@ -31,7 +31,7 @@ template < require_all_prim_or_rev_kernel_expression_t* = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t logistic_lccdf( +return_type_t logistic_lccdf( const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& sigma) { static constexpr const char* function = "logistic_lccdf(OpenCL)"; using T_partials_return = partials_return_t; diff --git a/stan/math/opencl/prim/logistic_lcdf.hpp b/stan/math/opencl/prim/logistic_lcdf.hpp index f16c9518bd1..133de304534 100644 --- a/stan/math/opencl/prim/logistic_lcdf.hpp +++ b/stan/math/opencl/prim/logistic_lcdf.hpp @@ -31,7 +31,7 @@ template < require_all_prim_or_rev_kernel_expression_t* = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t logistic_lcdf( +return_type_t logistic_lcdf( const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& sigma) { static constexpr const char* function = "logistic_lcdf(OpenCL)"; using T_partials_return = partials_return_t; diff --git a/stan/math/opencl/prim/logistic_lpdf.hpp b/stan/math/opencl/prim/logistic_lpdf.hpp index cfcfb2b5ba7..82de4eb5efb 100644 --- a/stan/math/opencl/prim/logistic_lpdf.hpp +++ b/stan/math/opencl/prim/logistic_lpdf.hpp @@ -37,7 +37,7 @@ template < require_all_prim_or_rev_kernel_expression_t* = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t logistic_lpdf( +return_type_t logistic_lpdf( const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& sigma) { using std::isfinite; static constexpr const char* function = "logistic_lpdf(OpenCL)"; diff --git a/stan/math/opencl/prim/lognormal_cdf.hpp b/stan/math/opencl/prim/lognormal_cdf.hpp index 19781c96639..c7341cd52db 100644 --- a/stan/math/opencl/prim/lognormal_cdf.hpp +++ b/stan/math/opencl/prim/lognormal_cdf.hpp @@ -31,7 +31,7 @@ template < require_all_prim_or_rev_kernel_expression_t* = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t lognormal_cdf( +return_type_t lognormal_cdf( const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& sigma) { static constexpr const char* function = "lognormal_cdf(OpenCL)"; using T_partials_return = partials_return_t; diff --git a/stan/math/opencl/prim/lognormal_lccdf.hpp b/stan/math/opencl/prim/lognormal_lccdf.hpp index af407a42967..e9eb8f688f8 100644 --- a/stan/math/opencl/prim/lognormal_lccdf.hpp +++ b/stan/math/opencl/prim/lognormal_lccdf.hpp @@ -31,7 +31,7 @@ template < require_all_prim_or_rev_kernel_expression_t* = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t lognormal_lccdf( +return_type_t lognormal_lccdf( const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& sigma) { static constexpr const char* function = "lognormal_lccdf(OpenCL)"; using T_partials_return = partials_return_t; diff --git a/stan/math/opencl/prim/lognormal_lcdf.hpp b/stan/math/opencl/prim/lognormal_lcdf.hpp index 3f977a24e0a..f7542866189 100644 --- a/stan/math/opencl/prim/lognormal_lcdf.hpp +++ b/stan/math/opencl/prim/lognormal_lcdf.hpp @@ -31,7 +31,7 @@ template < require_all_prim_or_rev_kernel_expression_t* = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t lognormal_lcdf( +return_type_t lognormal_lcdf( const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& sigma) { static constexpr const char* function = "lognormal_lcdf(OpenCL)"; using T_partials_return = partials_return_t; diff --git a/stan/math/opencl/prim/lognormal_lpdf.hpp b/stan/math/opencl/prim/lognormal_lpdf.hpp index 4b06ed80871..d96b60eb34f 100644 --- a/stan/math/opencl/prim/lognormal_lpdf.hpp +++ b/stan/math/opencl/prim/lognormal_lpdf.hpp @@ -37,7 +37,7 @@ template < require_all_prim_or_rev_kernel_expression_t* = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t lognormal_lpdf( +return_type_t lognormal_lpdf( const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& sigma) { using std::isfinite; static constexpr const char* function = "lognormal_lpdf(OpenCL)"; diff --git a/stan/math/opencl/prim/neg_binomial_2_log_glm_lpmf.hpp b/stan/math/opencl/prim/neg_binomial_2_log_glm_lpmf.hpp index 0fef410adea..61743dc3fab 100644 --- a/stan/math/opencl/prim/neg_binomial_2_log_glm_lpmf.hpp +++ b/stan/math/opencl/prim/neg_binomial_2_log_glm_lpmf.hpp @@ -65,7 +65,7 @@ template * = nullptr> -inline return_type_t +return_type_t neg_binomial_2_log_glm_lpmf(const T_y_cl& y, const T_x_cl& x, const T_alpha_cl& alpha, const T_beta_cl& beta, const T_phi_cl& phi) { @@ -168,11 +168,14 @@ neg_binomial_2_log_glm_lpmf(const T_y_cl& y, const T_x_cl& x, } if constexpr (include_summand::value && !is_phi_vector) { - logp += N * (multiply_log(phi_val, phi_val) - lgamma(phi_val)); + logp += N + * (multiply_log(forward_as(phi_val), + forward_as(phi_val)) + - lgamma(forward_as(phi_val))); } if constexpr (include_summand::value && !is_y_vector && !is_phi_vector) { - logp += lgamma(y_val + phi_val) * N; + logp += forward_as(lgamma(y_val + phi_val)) * N; } auto ops_partials = make_partials_propagator(x, alpha, beta, phi); @@ -200,7 +203,8 @@ neg_binomial_2_log_glm_lpmf(const T_y_cl& y, const T_x_cl& x, if constexpr (is_alpha_vector) { partials<1>(ops_partials) = std::move(theta_derivative_cl); } else { - partials<1>(ops_partials)[0] + forward_as>( + partials<1>(ops_partials))[0] = sum(from_matrix_cl(theta_derivative_sum_cl)); } } @@ -208,7 +212,9 @@ neg_binomial_2_log_glm_lpmf(const T_y_cl& y, const T_x_cl& x, if constexpr (is_phi_vector) { partials<3>(ops_partials) = std::move(phi_derivative_cl); } else { - partials<3>(ops_partials)[0] = sum(from_matrix_cl(phi_derivative_cl)); + forward_as>( + partials<3>(ops_partials))[0] + = sum(from_matrix_cl(phi_derivative_cl)); } } return ops_partials.build(logp); diff --git a/stan/math/opencl/prim/normal_cdf.hpp b/stan/math/opencl/prim/normal_cdf.hpp index 2e764e8eb81..3cda89b0a39 100644 --- a/stan/math/opencl/prim/normal_cdf.hpp +++ b/stan/math/opencl/prim/normal_cdf.hpp @@ -31,7 +31,7 @@ template < require_all_prim_or_rev_kernel_expression_t* = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t normal_cdf( +return_type_t normal_cdf( const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& sigma) { static constexpr const char* function = "normal_cdf(OpenCL)"; using T_partials_return = partials_return_t; diff --git a/stan/math/opencl/prim/normal_id_glm_lpdf.hpp b/stan/math/opencl/prim/normal_id_glm_lpdf.hpp index 385d5acab8b..cf05ff2457b 100644 --- a/stan/math/opencl/prim/normal_id_glm_lpdf.hpp +++ b/stan/math/opencl/prim/normal_id_glm_lpdf.hpp @@ -59,7 +59,7 @@ template * = nullptr> -inline return_type_t +return_type_t normal_id_glm_lpdf(const T_y_cl& y, const T_x_cl& x, const T_alpha_cl& alpha, const T_beta_cl& beta, const T_sigma_cl& sigma) { using T_partials_return @@ -149,7 +149,9 @@ normal_id_glm_lpdf(const T_y_cl& y, const T_x_cl& x, const T_alpha_cl& alpha, if constexpr (is_y_vector) { partials<0>(ops_partials) = -mu_derivative_cl; } else { - partials<0>(ops_partials)[0] = -mu_derivative_sum; + forward_as>( + partials<0>(ops_partials))[0] + = -mu_derivative_sum; } } if constexpr (is_autodiff_v) { @@ -160,7 +162,9 @@ normal_id_glm_lpdf(const T_y_cl& y, const T_x_cl& x, const T_alpha_cl& alpha, if constexpr (is_alpha_vector) { partials<2>(ops_partials) = mu_derivative_cl; } else { - partials<2>(ops_partials)[0] = mu_derivative_sum; + forward_as>( + partials<2>(ops_partials))[0] + = mu_derivative_sum; } } if constexpr (is_autodiff_v) { @@ -203,7 +207,7 @@ normal_id_glm_lpdf(const T_y_cl& y, const T_x_cl& x, const T_alpha_cl& alpha, if constexpr (is_sigma_vector) { logp -= sum(from_matrix_cl(log_sigma_sum_cl)); } else { - logp -= N * log(sigma_val); + logp -= N * log(forward_as(sigma_val)); } } logp -= 0.5 * y_scaled_sq_sum; diff --git a/stan/math/opencl/prim/normal_lccdf.hpp b/stan/math/opencl/prim/normal_lccdf.hpp index 775b9a9238b..a5d6473e71a 100644 --- a/stan/math/opencl/prim/normal_lccdf.hpp +++ b/stan/math/opencl/prim/normal_lccdf.hpp @@ -31,7 +31,7 @@ template < require_all_prim_or_rev_kernel_expression_t* = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t normal_lccdf( +return_type_t normal_lccdf( const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& sigma) { static constexpr const char* function = "normal_lccdf(OpenCL)"; using T_partials_return = partials_return_t; diff --git a/stan/math/opencl/prim/normal_lcdf.hpp b/stan/math/opencl/prim/normal_lcdf.hpp index 40459eaf384..adca8c171f4 100644 --- a/stan/math/opencl/prim/normal_lcdf.hpp +++ b/stan/math/opencl/prim/normal_lcdf.hpp @@ -177,7 +177,7 @@ template < require_all_prim_or_rev_kernel_expression_t* = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t normal_lcdf( +return_type_t normal_lcdf( const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& sigma) { static constexpr const char* function = "normal_lcdf(OpenCL)"; using std::isfinite; diff --git a/stan/math/opencl/prim/ordered_logistic_glm_lpmf.hpp b/stan/math/opencl/prim/ordered_logistic_glm_lpmf.hpp index e53124a4e1b..26d980b4b88 100644 --- a/stan/math/opencl/prim/ordered_logistic_glm_lpmf.hpp +++ b/stan/math/opencl/prim/ordered_logistic_glm_lpmf.hpp @@ -49,7 +49,7 @@ template * = nullptr> -inline return_type_t ordered_logistic_glm_lpmf( +return_type_t ordered_logistic_glm_lpmf( const T_y& y, const T_x& x, const T_beta& beta, const T_cuts& cuts) { using Eigen::Array; using Eigen::Dynamic; diff --git a/stan/math/opencl/prim/pareto_cdf.hpp b/stan/math/opencl/prim/pareto_cdf.hpp index d047ce2847a..ad996da8a9b 100644 --- a/stan/math/opencl/prim/pareto_cdf.hpp +++ b/stan/math/opencl/prim/pareto_cdf.hpp @@ -30,7 +30,7 @@ template < require_all_prim_or_rev_kernel_expression_t* = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t pareto_cdf( +return_type_t pareto_cdf( const T_y_cl& y, const T_scale_cl& y_min, const T_shape_cl& alpha) { static constexpr const char* function = "pareto_cdf(OpenCL)"; using T_partials_return = partials_return_t; diff --git a/stan/math/opencl/prim/pareto_lccdf.hpp b/stan/math/opencl/prim/pareto_lccdf.hpp index 72815b94f9d..2cb018ce0a3 100644 --- a/stan/math/opencl/prim/pareto_lccdf.hpp +++ b/stan/math/opencl/prim/pareto_lccdf.hpp @@ -30,7 +30,7 @@ template < require_all_prim_or_rev_kernel_expression_t* = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t pareto_lccdf( +return_type_t pareto_lccdf( const T_y_cl& y, const T_scale_cl& y_min, const T_shape_cl& alpha) { static constexpr const char* function = "pareto_lccdf(OpenCL)"; using T_partials_return = partials_return_t; diff --git a/stan/math/opencl/prim/pareto_lcdf.hpp b/stan/math/opencl/prim/pareto_lcdf.hpp index 118d6d9a51b..dd4042ef845 100644 --- a/stan/math/opencl/prim/pareto_lcdf.hpp +++ b/stan/math/opencl/prim/pareto_lcdf.hpp @@ -30,7 +30,7 @@ template < require_all_prim_or_rev_kernel_expression_t* = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t pareto_lcdf( +return_type_t pareto_lcdf( const T_y_cl& y, const T_scale_cl& y_min, const T_shape_cl& alpha) { static constexpr const char* function = "pareto_lcdf(OpenCL)"; using T_partials_return = partials_return_t; diff --git a/stan/math/opencl/prim/pareto_lpdf.hpp b/stan/math/opencl/prim/pareto_lpdf.hpp index fccd07c67e1..24248901ab5 100644 --- a/stan/math/opencl/prim/pareto_lpdf.hpp +++ b/stan/math/opencl/prim/pareto_lpdf.hpp @@ -35,7 +35,7 @@ template < require_all_prim_or_rev_kernel_expression_t* = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t pareto_lpdf( +return_type_t pareto_lpdf( const T_y_cl& y, const T_scale_cl& y_min, const T_shape_cl& alpha) { static constexpr const char* function = "pareto_lpdf(OpenCL)"; using T_partials_return = partials_return_t; diff --git a/stan/math/opencl/prim/pareto_type_2_cdf.hpp b/stan/math/opencl/prim/pareto_type_2_cdf.hpp index f04b8254eaa..f61bc4fec49 100644 --- a/stan/math/opencl/prim/pareto_type_2_cdf.hpp +++ b/stan/math/opencl/prim/pareto_type_2_cdf.hpp @@ -33,9 +33,9 @@ template * = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t -pareto_type_2_cdf(const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& lambda, - const T_shape_cl& alpha) { +return_type_t pareto_type_2_cdf( + const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& lambda, + const T_shape_cl& alpha) { static constexpr const char* function = "pareto_type_2_cdf(OpenCL)"; using T_partials_return = partials_return_t; diff --git a/stan/math/opencl/prim/pareto_type_2_lccdf.hpp b/stan/math/opencl/prim/pareto_type_2_lccdf.hpp index a2cd0de0d69..5ec0e2f89ce 100644 --- a/stan/math/opencl/prim/pareto_type_2_lccdf.hpp +++ b/stan/math/opencl/prim/pareto_type_2_lccdf.hpp @@ -33,9 +33,9 @@ template * = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t -pareto_type_2_lccdf(const T_y_cl& y, const T_loc_cl& mu, - const T_scale_cl& lambda, const T_shape_cl& alpha) { +return_type_t pareto_type_2_lccdf( + const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& lambda, + const T_shape_cl& alpha) { static constexpr const char* function = "pareto_type_2_lccdf(OpenCL)"; using T_partials_return = partials_return_t; diff --git a/stan/math/opencl/prim/pareto_type_2_lcdf.hpp b/stan/math/opencl/prim/pareto_type_2_lcdf.hpp index e19bfdf214f..a5ad8e7cf3a 100644 --- a/stan/math/opencl/prim/pareto_type_2_lcdf.hpp +++ b/stan/math/opencl/prim/pareto_type_2_lcdf.hpp @@ -33,9 +33,9 @@ template * = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t -pareto_type_2_lcdf(const T_y_cl& y, const T_loc_cl& mu, - const T_scale_cl& lambda, const T_shape_cl& alpha) { +return_type_t pareto_type_2_lcdf( + const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& lambda, + const T_shape_cl& alpha) { static constexpr const char* function = "pareto_type_2_lcdf(OpenCL)"; using T_partials_return = partials_return_t; diff --git a/stan/math/opencl/prim/pareto_type_2_lpdf.hpp b/stan/math/opencl/prim/pareto_type_2_lpdf.hpp index ea887504b24..61d63d41333 100644 --- a/stan/math/opencl/prim/pareto_type_2_lpdf.hpp +++ b/stan/math/opencl/prim/pareto_type_2_lpdf.hpp @@ -36,9 +36,9 @@ template * = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t -pareto_type_2_lpdf(const T_y_cl& y, const T_loc_cl& mu, - const T_scale_cl& lambda, const T_shape_cl& alpha) { +return_type_t pareto_type_2_lpdf( + const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& lambda, + const T_shape_cl& alpha) { static constexpr const char* function = "pareto_type_2_lpdf(OpenCL)"; using T_partials_return = partials_return_t; diff --git a/stan/math/opencl/prim/poisson_log_glm_lpmf.hpp b/stan/math/opencl/prim/poisson_log_glm_lpmf.hpp index 896cb14dca9..2011deeaf7a 100644 --- a/stan/math/opencl/prim/poisson_log_glm_lpmf.hpp +++ b/stan/math/opencl/prim/poisson_log_glm_lpmf.hpp @@ -51,7 +51,7 @@ template * = nullptr> -inline return_type_t poisson_log_glm_lpmf( +return_type_t poisson_log_glm_lpmf( const T_y_cl& y, const T_x_cl& x, const T_alpha_cl& alpha, const T_beta_cl& beta) { static constexpr const char* function = "poisson_log_glm_lpmf(OpenCL)"; @@ -133,7 +133,9 @@ inline return_type_t poisson_log_glm_lpmf( if constexpr (is_alpha_vector) { partials<1>(ops_partials) = theta_derivative_cl; } else { - partials<1>(ops_partials)[0] = theta_derivative_sum; + forward_as>( + partials<1>(ops_partials))[0] + = theta_derivative_sum; } } if constexpr (is_autodiff_v) { diff --git a/stan/math/opencl/prim/poisson_log_lpmf.hpp b/stan/math/opencl/prim/poisson_log_lpmf.hpp index d8315283b15..9fe2e19a8ef 100644 --- a/stan/math/opencl/prim/poisson_log_lpmf.hpp +++ b/stan/math/opencl/prim/poisson_log_lpmf.hpp @@ -28,8 +28,8 @@ template * = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t poisson_log_lpmf( - const T_n_cl& n, const T_log_rate_cl& alpha) { +return_type_t poisson_log_lpmf(const T_n_cl& n, + const T_log_rate_cl& alpha) { static constexpr const char* function = "poisson_log_lpmf(OpenCL)"; using T_partials_return = partials_return_t; using std::isinf; diff --git a/stan/math/opencl/prim/poisson_lpmf.hpp b/stan/math/opencl/prim/poisson_lpmf.hpp index 4d1644f1204..69a5ababdce 100644 --- a/stan/math/opencl/prim/poisson_lpmf.hpp +++ b/stan/math/opencl/prim/poisson_lpmf.hpp @@ -28,8 +28,8 @@ template < bool propto, typename T_n_cl, typename T_rate_cl, require_all_prim_or_rev_kernel_expression_t* = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t poisson_lpmf(const T_n_cl& n, - const T_rate_cl& lambda) { +return_type_t poisson_lpmf(const T_n_cl& n, + const T_rate_cl& lambda) { static constexpr const char* function = "poisson_lpmf(OpenCL)"; using T_partials_return = partials_return_t; using std::isinf; diff --git a/stan/math/opencl/prim/prod.hpp b/stan/math/opencl/prim/prod.hpp index 8ca63878155..dc8b22d5d6e 100644 --- a/stan/math/opencl/prim/prod.hpp +++ b/stan/math/opencl/prim/prod.hpp @@ -18,7 +18,7 @@ namespace math { */ template * = nullptr> -inline value_type_t prod(const T& m) { +value_type_t prod(const T& m) { if constexpr (is_matrix_cl::value) { if (m.size() < 1000) { // for small matrices running another kernel is not worth it diff --git a/stan/math/opencl/prim/rayleigh_cdf.hpp b/stan/math/opencl/prim/rayleigh_cdf.hpp index 7a91b7000e5..e8abefe60fa 100644 --- a/stan/math/opencl/prim/rayleigh_cdf.hpp +++ b/stan/math/opencl/prim/rayleigh_cdf.hpp @@ -28,8 +28,8 @@ template < typename T_y_cl, typename T_scale_cl, require_all_prim_or_rev_kernel_expression_t* = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t rayleigh_cdf(const T_y_cl& y, - const T_scale_cl& sigma) { +return_type_t rayleigh_cdf(const T_y_cl& y, + const T_scale_cl& sigma) { static constexpr const char* function = "rayleigh_cdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; diff --git a/stan/math/opencl/prim/rayleigh_lccdf.hpp b/stan/math/opencl/prim/rayleigh_lccdf.hpp index ace88bd71d5..ab6fb33877c 100644 --- a/stan/math/opencl/prim/rayleigh_lccdf.hpp +++ b/stan/math/opencl/prim/rayleigh_lccdf.hpp @@ -28,8 +28,8 @@ template < typename T_y_cl, typename T_scale_cl, require_all_prim_or_rev_kernel_expression_t* = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t rayleigh_lccdf( - const T_y_cl& y, const T_scale_cl& sigma) { +return_type_t rayleigh_lccdf(const T_y_cl& y, + const T_scale_cl& sigma) { static constexpr const char* function = "rayleigh_lccdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; diff --git a/stan/math/opencl/prim/rayleigh_lcdf.hpp b/stan/math/opencl/prim/rayleigh_lcdf.hpp index 0d8f881fdcf..5a8187063ee 100644 --- a/stan/math/opencl/prim/rayleigh_lcdf.hpp +++ b/stan/math/opencl/prim/rayleigh_lcdf.hpp @@ -28,8 +28,8 @@ template < typename T_y_cl, typename T_scale_cl, require_all_prim_or_rev_kernel_expression_t* = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t rayleigh_lcdf( - const T_y_cl& y, const T_scale_cl& sigma) { +return_type_t rayleigh_lcdf(const T_y_cl& y, + const T_scale_cl& sigma) { static constexpr const char* function = "rayleigh_lcdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; diff --git a/stan/math/opencl/prim/rayleigh_lpdf.hpp b/stan/math/opencl/prim/rayleigh_lpdf.hpp index cea9523ff4c..478c92b7daf 100644 --- a/stan/math/opencl/prim/rayleigh_lpdf.hpp +++ b/stan/math/opencl/prim/rayleigh_lpdf.hpp @@ -28,8 +28,8 @@ template < bool propto, typename T_y_cl, typename T_scale_cl, require_all_prim_or_rev_kernel_expression_t* = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t rayleigh_lpdf( - const T_y_cl& y, const T_scale_cl& sigma) { +return_type_t rayleigh_lpdf(const T_y_cl& y, + const T_scale_cl& sigma) { static constexpr const char* function = "rayleigh_lpdf(OpenCL)"; using T_partials_return = partials_return_t; diff --git a/stan/math/opencl/prim/rep_array.hpp b/stan/math/opencl/prim/rep_array.hpp index a7b9db7fc90..f170d6f5739 100644 --- a/stan/math/opencl/prim/rep_array.hpp +++ b/stan/math/opencl/prim/rep_array.hpp @@ -29,7 +29,7 @@ template < require_any_t< is_matrix_cl, math::conjunction, is_matrix_cl>>>* = nullptr> -inline auto rep_array(const scalar_type_t& x, int n) { +auto rep_array(const scalar_type_t& x, int n) { return rep_matrix(x, n, 1); } diff --git a/stan/math/opencl/prim/rep_row_vector.hpp b/stan/math/opencl/prim/rep_row_vector.hpp index 118eebf7371..c210ef3a642 100644 --- a/stan/math/opencl/prim/rep_row_vector.hpp +++ b/stan/math/opencl/prim/rep_row_vector.hpp @@ -28,7 +28,7 @@ template < require_any_t< is_matrix_cl, math::conjunction, is_matrix_cl>>>* = nullptr> -inline auto rep_row_vector(const scalar_type_t& x, int n) { +auto rep_row_vector(const scalar_type_t& x, int n) { return rep_matrix(x, 1, n); } diff --git a/stan/math/opencl/prim/rep_vector.hpp b/stan/math/opencl/prim/rep_vector.hpp index bd62290e6ee..efafc90db44 100644 --- a/stan/math/opencl/prim/rep_vector.hpp +++ b/stan/math/opencl/prim/rep_vector.hpp @@ -28,7 +28,7 @@ template < require_any_t< is_matrix_cl, math::conjunction, is_matrix_cl>>>* = nullptr> -inline auto rep_vector(const scalar_type_t& x, int n) { +auto rep_vector(const scalar_type_t& x, int n) { return rep_matrix(x, n, 1); } diff --git a/stan/math/opencl/prim/sign.hpp b/stan/math/opencl/prim/sign.hpp index 53c1bab9419..39bf4398071 100644 --- a/stan/math/opencl/prim/sign.hpp +++ b/stan/math/opencl/prim/sign.hpp @@ -15,7 +15,7 @@ namespace math { */ template * = nullptr> -inline auto sign(const T& x) { +auto sign(const T& x) { return select(x == 0, 0, select(x < 0, -1, 1)); } diff --git a/stan/math/opencl/prim/skew_double_exponential_cdf.hpp b/stan/math/opencl/prim/skew_double_exponential_cdf.hpp index f7dc0489b80..54ca316d072 100644 --- a/stan/math/opencl/prim/skew_double_exponential_cdf.hpp +++ b/stan/math/opencl/prim/skew_double_exponential_cdf.hpp @@ -33,7 +33,7 @@ template * = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t +return_type_t skew_double_exponential_cdf(const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& sigma, const T_skewness_cl& tau) { static constexpr const char* function = "skew_double_exponential_cdf(OpenCL)"; diff --git a/stan/math/opencl/prim/skew_double_exponential_lccdf.hpp b/stan/math/opencl/prim/skew_double_exponential_lccdf.hpp index e4c7452a2cf..bc25f1fbc58 100644 --- a/stan/math/opencl/prim/skew_double_exponential_lccdf.hpp +++ b/stan/math/opencl/prim/skew_double_exponential_lccdf.hpp @@ -33,7 +33,7 @@ template * = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t +return_type_t skew_double_exponential_lccdf(const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& sigma, const T_skewness_cl& tau) { diff --git a/stan/math/opencl/prim/skew_double_exponential_lcdf.hpp b/stan/math/opencl/prim/skew_double_exponential_lcdf.hpp index 54b316657a6..74210cd4ecb 100644 --- a/stan/math/opencl/prim/skew_double_exponential_lcdf.hpp +++ b/stan/math/opencl/prim/skew_double_exponential_lcdf.hpp @@ -33,7 +33,7 @@ template * = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t +return_type_t skew_double_exponential_lcdf(const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& sigma, const T_skewness_cl& tau) { diff --git a/stan/math/opencl/prim/skew_double_exponential_lpdf.hpp b/stan/math/opencl/prim/skew_double_exponential_lpdf.hpp index e6c46abc558..8ac28ce67ee 100644 --- a/stan/math/opencl/prim/skew_double_exponential_lpdf.hpp +++ b/stan/math/opencl/prim/skew_double_exponential_lpdf.hpp @@ -36,7 +36,7 @@ template * = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t +return_type_t skew_double_exponential_lpdf(const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& sigma, const T_skewness_cl& tau) { diff --git a/stan/math/opencl/prim/std_normal_cdf.hpp b/stan/math/opencl/prim/std_normal_cdf.hpp index 5a0cd0c1316..2161094d25f 100644 --- a/stan/math/opencl/prim/std_normal_cdf.hpp +++ b/stan/math/opencl/prim/std_normal_cdf.hpp @@ -23,7 +23,7 @@ namespace math { template * = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t std_normal_cdf(const T_y_cl& y) { +return_type_t std_normal_cdf(const T_y_cl& y) { static constexpr const char* function = "std_normal_cdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; diff --git a/stan/math/opencl/prim/std_normal_lccdf.hpp b/stan/math/opencl/prim/std_normal_lccdf.hpp index 7a3c90c7089..59f42b33f9b 100644 --- a/stan/math/opencl/prim/std_normal_lccdf.hpp +++ b/stan/math/opencl/prim/std_normal_lccdf.hpp @@ -24,7 +24,7 @@ namespace math { template * = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t std_normal_lccdf(const T_y_cl& y) { +return_type_t std_normal_lccdf(const T_y_cl& y) { static constexpr const char* function = "std_normal_lccdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; diff --git a/stan/math/opencl/prim/std_normal_lcdf.hpp b/stan/math/opencl/prim/std_normal_lcdf.hpp index 1f9f50d08c0..2a6c0efbfdb 100644 --- a/stan/math/opencl/prim/std_normal_lcdf.hpp +++ b/stan/math/opencl/prim/std_normal_lcdf.hpp @@ -178,7 +178,7 @@ const char opencl_std_normal_lcdf_dnlcdf[] = STRINGIFY( template * = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t std_normal_lcdf(const T_y_cl& y) { +return_type_t std_normal_lcdf(const T_y_cl& y) { static constexpr const char* function = "std_normal_lcdf(OpenCL)"; using std::isfinite; using std::isnan; diff --git a/stan/math/opencl/prim/sum.hpp b/stan/math/opencl/prim/sum.hpp index d9175d45516..8d65436c8d1 100644 --- a/stan/math/opencl/prim/sum.hpp +++ b/stan/math/opencl/prim/sum.hpp @@ -18,7 +18,7 @@ namespace math { */ template * = nullptr> -inline value_type_t sum(const T& m) { +value_type_t sum(const T& m) { if constexpr (is_matrix_cl::value) { if (m.size() < 1000) { // for small matrices running another kernel is not worth it diff --git a/stan/math/opencl/prim/trace.hpp b/stan/math/opencl/prim/trace.hpp index fede30166f3..0693b2c3a9a 100644 --- a/stan/math/opencl/prim/trace.hpp +++ b/stan/math/opencl/prim/trace.hpp @@ -19,7 +19,7 @@ namespace math { */ template * = nullptr> -inline value_type_t trace(const T& m) { +value_type_t trace(const T& m) { return sum(diagonal(m)); } diff --git a/stan/math/opencl/prim/uniform_cdf.hpp b/stan/math/opencl/prim/uniform_cdf.hpp index a5c99c28820..3f940ae62c2 100644 --- a/stan/math/opencl/prim/uniform_cdf.hpp +++ b/stan/math/opencl/prim/uniform_cdf.hpp @@ -30,8 +30,9 @@ template * = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t uniform_cdf( - const T_y_cl& y, const T_low_cl& alpha, const T_high_cl& beta) { +return_type_t uniform_cdf(const T_y_cl& y, + const T_low_cl& alpha, + const T_high_cl& beta) { static constexpr const char* function = "uniform_cdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; diff --git a/stan/math/opencl/prim/uniform_lccdf.hpp b/stan/math/opencl/prim/uniform_lccdf.hpp index 19a62e4e90e..99c0e886437 100644 --- a/stan/math/opencl/prim/uniform_lccdf.hpp +++ b/stan/math/opencl/prim/uniform_lccdf.hpp @@ -30,7 +30,7 @@ template * = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t uniform_lccdf( +return_type_t uniform_lccdf( const T_y_cl& y, const T_low_cl& alpha, const T_high_cl& beta) { static constexpr const char* function = "uniform_lccdf(OpenCL)"; using T_partials_return = partials_return_t; diff --git a/stan/math/opencl/prim/uniform_lcdf.hpp b/stan/math/opencl/prim/uniform_lcdf.hpp index 7dfc44ae79f..305d575b6c7 100644 --- a/stan/math/opencl/prim/uniform_lcdf.hpp +++ b/stan/math/opencl/prim/uniform_lcdf.hpp @@ -30,8 +30,9 @@ template * = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t uniform_lcdf( - const T_y_cl& y, const T_low_cl& alpha, const T_high_cl& beta) { +return_type_t uniform_lcdf(const T_y_cl& y, + const T_low_cl& alpha, + const T_high_cl& beta) { static constexpr const char* function = "uniform_lcdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; diff --git a/stan/math/opencl/prim/weibull_cdf.hpp b/stan/math/opencl/prim/weibull_cdf.hpp index 2788ed8842e..69c96b624f6 100644 --- a/stan/math/opencl/prim/weibull_cdf.hpp +++ b/stan/math/opencl/prim/weibull_cdf.hpp @@ -31,7 +31,7 @@ template < require_all_prim_or_rev_kernel_expression_t* = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t weibull_cdf( +return_type_t weibull_cdf( const T_y_cl& y, const T_shape_cl& alpha, const T_scale_cl& sigma) { static constexpr const char* function = "weibull_cdf(OpenCL)"; using T_partials_return = partials_return_t; diff --git a/stan/math/opencl/prim/weibull_lccdf.hpp b/stan/math/opencl/prim/weibull_lccdf.hpp index 8a0563490f7..7cc45b759e1 100644 --- a/stan/math/opencl/prim/weibull_lccdf.hpp +++ b/stan/math/opencl/prim/weibull_lccdf.hpp @@ -31,7 +31,7 @@ template < require_all_prim_or_rev_kernel_expression_t* = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t weibull_lccdf( +return_type_t weibull_lccdf( const T_y_cl& y, const T_shape_cl& alpha, const T_scale_cl& sigma) { static constexpr const char* function = "weibull_lccdf(OpenCL)"; using T_partials_return = partials_return_t; diff --git a/stan/math/opencl/prim/weibull_lcdf.hpp b/stan/math/opencl/prim/weibull_lcdf.hpp index f805f7579ed..5b0dfb0425a 100644 --- a/stan/math/opencl/prim/weibull_lcdf.hpp +++ b/stan/math/opencl/prim/weibull_lcdf.hpp @@ -31,7 +31,7 @@ template < require_all_prim_or_rev_kernel_expression_t* = nullptr, require_any_not_stan_scalar_t* = nullptr> -inline return_type_t weibull_lcdf( +return_type_t weibull_lcdf( const T_y_cl& y, const T_shape_cl& alpha, const T_scale_cl& sigma) { static constexpr const char* function = "weibull_lcdf(OpenCL)"; using T_partials_return = partials_return_t; diff --git a/stan/math/opencl/qr_decomposition.hpp b/stan/math/opencl/qr_decomposition.hpp index fd68adb2e9f..6392b43a342 100644 --- a/stan/math/opencl/qr_decomposition.hpp +++ b/stan/math/opencl/qr_decomposition.hpp @@ -31,9 +31,8 @@ namespace math { * @param r Block size. Optimal value depends on the hardware. */ template -inline void qr_decomposition_cl(const matrix_cl& A, - matrix_cl& Q, matrix_cl& R, - int r = 100) { +void qr_decomposition_cl(const matrix_cl& A, matrix_cl& Q, + matrix_cl& R, int r = 100) { using std::copysign; using std::sqrt; int rows = A.rows(); diff --git a/stan/math/opencl/rev/add_diag.hpp b/stan/math/opencl/rev/add_diag.hpp index 231e4d3f0db..48e234b4d66 100644 --- a/stan/math/opencl/rev/add_diag.hpp +++ b/stan/math/opencl/rev/add_diag.hpp @@ -40,10 +40,11 @@ inline auto add_diag(const T_m& mat, const T_a& to_add) { } if constexpr (is_autodiff_v) { if constexpr (!is_stan_scalar::value) { - auto& to_add_adj = to_add_arena.adj(); + auto& to_add_adj + = forward_as>>(to_add_arena).adj(); to_add_adj += diagonal(res.adj()); } else { - auto& to_add_adj = to_add_arena.adj(); + auto& to_add_adj = forward_as>(to_add_arena).adj(); to_add_adj += to_add_adj + sum(diagonal(res.adj())); } } diff --git a/stan/math/opencl/rev/adjoint_results.hpp b/stan/math/opencl/rev/adjoint_results.hpp index bc42d21aac0..4a2dede57d0 100644 --- a/stan/math/opencl/rev/adjoint_results.hpp +++ b/stan/math/opencl/rev/adjoint_results.hpp @@ -148,8 +148,7 @@ class adjoint_results_cl : protected results_cl { * @param results results that will be calculated. */ template -inline adjoint_results_cl adjoint_results( - T_results&&... results) { +adjoint_results_cl adjoint_results(T_results&&... results) { return adjoint_results_cl(std::forward(results)...); } diff --git a/stan/math/opencl/rev/arena_matrix_cl.hpp b/stan/math/opencl/rev/arena_matrix_cl.hpp index 37ab828c880..6b5026822ba 100644 --- a/stan/math/opencl/rev/arena_matrix_cl.hpp +++ b/stan/math/opencl/rev/arena_matrix_cl.hpp @@ -145,7 +145,7 @@ class arena_matrix_cl : public matrix_cl_base { #undef ARENA_MATRIX_CL_CONST_FUNCTION_WRAPPER }; template -inline matrix_cl::matrix_cl(const arena_matrix_cl& A) +matrix_cl::matrix_cl(const arena_matrix_cl& A) // works like a move constructor, except it does not modify `a` : buffer_cl_(A.impl_->buffer_cl_), rows_(A.impl_->rows_), diff --git a/stan/math/opencl/rev/copy.hpp b/stan/math/opencl/rev/copy.hpp index 50201e3e565..dbd2994c262 100644 --- a/stan/math/opencl/rev/copy.hpp +++ b/stan/math/opencl/rev/copy.hpp @@ -206,7 +206,7 @@ inline T_dst from_matrix_cl(const var_value& a) { * @return var with a copy of the data on the host */ template * = nullptr> -inline auto from_matrix_cl(const var_value& src) { +auto from_matrix_cl(const var_value& src) { return from_matrix_cl>(src); } diff --git a/stan/math/opencl/rev/to_arena.hpp b/stan/math/opencl/rev/to_arena.hpp index 6fc0c9bc475..ce4fdbdca9f 100644 --- a/stan/math/opencl/rev/to_arena.hpp +++ b/stan/math/opencl/rev/to_arena.hpp @@ -22,7 +22,7 @@ namespace math { * @return argument */ template * = nullptr> -inline arena_t to_arena(const T& a) { +arena_t to_arena(const T& a) { arena_t res(a.buffer(), a.rows(), a.cols(), a.view()); for (cl::Event e : a.read_events()) { res.add_read_event(e); diff --git a/stan/math/opencl/symmetric_eigensolver.hpp b/stan/math/opencl/symmetric_eigensolver.hpp index ea4d907412a..d1878fe43c8 100644 --- a/stan/math/opencl/symmetric_eigensolver.hpp +++ b/stan/math/opencl/symmetric_eigensolver.hpp @@ -10,9 +10,9 @@ namespace stan { namespace math { template -inline void symmetric_eigensolver(const matrix_cl& A, - matrix_cl& eigenvalues, - matrix_cl& eigenvectors) { +void symmetric_eigensolver(const matrix_cl& A, + matrix_cl& eigenvalues, + matrix_cl& eigenvectors) { matrix_cl packed; if (A.rows() <= 2) { packed = A; diff --git a/stan/math/prim/constraint/cholesky_factor_free.hpp b/stan/math/prim/constraint/cholesky_factor_free.hpp index 1ef81d0bfff..7bd879033f6 100644 --- a/stan/math/prim/constraint/cholesky_factor_free.hpp +++ b/stan/math/prim/constraint/cholesky_factor_free.hpp @@ -23,7 +23,7 @@ namespace math { * @throw std::domain_error If the matrix is not a Cholesky factor. */ template * = nullptr> -inline Eigen::Matrix, Eigen::Dynamic, 1> cholesky_factor_free( +Eigen::Matrix, Eigen::Dynamic, 1> cholesky_factor_free( const T& y) { using std::log; diff --git a/stan/math/prim/constraint/corr_matrix_free.hpp b/stan/math/prim/constraint/corr_matrix_free.hpp index 6a44b3177bd..87479eb9e34 100644 --- a/stan/math/prim/constraint/corr_matrix_free.hpp +++ b/stan/math/prim/constraint/corr_matrix_free.hpp @@ -31,8 +31,7 @@ namespace math { * factor_cov_matrix() on log scale are unconstrained. */ template * = nullptr> -inline Eigen::Matrix, Eigen::Dynamic, 1> corr_matrix_free( - const T& y) { +Eigen::Matrix, Eigen::Dynamic, 1> corr_matrix_free(const T& y) { using Eigen::Array; using Eigen::Dynamic; diff --git a/stan/math/prim/constraint/cov_matrix_free.hpp b/stan/math/prim/constraint/cov_matrix_free.hpp index 4d71f179665..6324d2c61e9 100644 --- a/stan/math/prim/constraint/cov_matrix_free.hpp +++ b/stan/math/prim/constraint/cov_matrix_free.hpp @@ -35,8 +35,7 @@ namespace math { * has zero dimensionality, or has a non-positive diagonal element. */ template * = nullptr> -inline Eigen::Matrix, Eigen::Dynamic, 1> cov_matrix_free( - const T& y) { +Eigen::Matrix, Eigen::Dynamic, 1> cov_matrix_free(const T& y) { const auto& y_ref = to_ref(y); check_square("cov_matrix_free", "y", y_ref); check_nonzero_size("cov_matrix_free", "y", y_ref); diff --git a/stan/math/prim/constraint/cov_matrix_free_lkj.hpp b/stan/math/prim/constraint/cov_matrix_free_lkj.hpp index ba2486fd3bf..a2fa9764a19 100644 --- a/stan/math/prim/constraint/cov_matrix_free_lkj.hpp +++ b/stan/math/prim/constraint/cov_matrix_free_lkj.hpp @@ -28,7 +28,7 @@ namespace math { * factorized by factor_cov_matrix() */ template * = nullptr> -inline Eigen::Matrix, Eigen::Dynamic, 1> cov_matrix_free_lkj( +Eigen::Matrix, Eigen::Dynamic, 1> cov_matrix_free_lkj( const T& y) { using Eigen::Array; using Eigen::Dynamic; @@ -57,7 +57,7 @@ inline Eigen::Matrix, Eigen::Dynamic, 1> cov_matrix_free_lkj( * @param x The standard vector to untransform. */ template * = nullptr> -inline auto cov_matrix_free_lkj(T&& x) { +auto cov_matrix_free_lkj(T&& x) { return apply_vector_unary::apply(std::forward(x), [](auto&& v) { return cov_matrix_free_lkj(std::forward(v)); }); diff --git a/stan/math/prim/constraint/ordered_free.hpp b/stan/math/prim/constraint/ordered_free.hpp index dabf83aed84..03058fb57cf 100644 --- a/stan/math/prim/constraint/ordered_free.hpp +++ b/stan/math/prim/constraint/ordered_free.hpp @@ -25,7 +25,7 @@ namespace math { * ordered scalars. */ template * = nullptr> -inline plain_type_t ordered_free(const EigVec& y) { +plain_type_t ordered_free(const EigVec& y) { const auto& y_ref = to_ref(y); check_ordered("stan::math::ordered_free", "Ordered variable", y_ref); using std::log; diff --git a/stan/math/prim/err/check_cholesky_factor.hpp b/stan/math/prim/err/check_cholesky_factor.hpp index 099d2bc3986..8213b4304ca 100644 --- a/stan/math/prim/err/check_cholesky_factor.hpp +++ b/stan/math/prim/err/check_cholesky_factor.hpp @@ -58,8 +58,8 @@ inline void check_cholesky_factor(const char* function, const char* name, * element in matrix is `NaN` */ template * = nullptr> -inline void check_cholesky_factor(const char* function, const char* name, - const StdVec& y) { +void check_cholesky_factor(const char* function, const char* name, + const StdVec& y) { for (size_t i = 0; i < y.size(); ++i) { check_cholesky_factor(function, internal::make_iter_name(name, i).c_str(), y[i]); diff --git a/stan/math/prim/err/check_cholesky_factor_corr.hpp b/stan/math/prim/err/check_cholesky_factor_corr.hpp index 4542b2ece42..1c7ff949485 100644 --- a/stan/math/prim/err/check_cholesky_factor_corr.hpp +++ b/stan/math/prim/err/check_cholesky_factor_corr.hpp @@ -34,8 +34,8 @@ namespace math { * element in matrix is NaN */ template * = nullptr> -inline void check_cholesky_factor_corr(const char* function, const char* name, - const Mat& y) { +void check_cholesky_factor_corr(const char* function, const char* name, + const Mat& y) { const auto& y_ref = to_ref(value_of_rec(y)); check_square(function, name, y_ref); check_lower_triangular(function, name, y_ref); @@ -66,8 +66,8 @@ inline void check_cholesky_factor_corr(const char* function, const char* name, * element in matrix is NaN */ template * = nullptr> -inline void check_cholesky_factor_corr(const char* function, const char* name, - const StdVec& y) { +void check_cholesky_factor_corr(const char* function, const char* name, + const StdVec& y) { for (size_t i = 0; i < y.size(); ++i) { check_cholesky_factor_corr(function, internal::make_iter_name(name, i).c_str(), y[i]); diff --git a/stan/math/prim/err/check_corr_matrix.hpp b/stan/math/prim/err/check_corr_matrix.hpp index 36a9d81e40b..08e026ff944 100644 --- a/stan/math/prim/err/check_corr_matrix.hpp +++ b/stan/math/prim/err/check_corr_matrix.hpp @@ -73,8 +73,8 @@ inline void check_corr_matrix(const char* function, const char* name, * 1, not positive definite, or any of the elements are `NaN` */ template * = nullptr> -inline void check_corr_matrix(const char* function, const char* name, - const StdVec& y) { +void check_corr_matrix(const char* function, const char* name, + const StdVec& y) { for (auto&& y_i : y) { check_corr_matrix(function, name, y_i); } diff --git a/stan/math/prim/err/check_cov_matrix.hpp b/stan/math/prim/err/check_cov_matrix.hpp index ab1ab633f19..4e4c402cb2c 100644 --- a/stan/math/prim/err/check_cov_matrix.hpp +++ b/stan/math/prim/err/check_cov_matrix.hpp @@ -49,8 +49,7 @@ inline void check_cov_matrix(const char* function, const char* name, * not positive definite, or if any element of the matrix is `NaN` */ template * = nullptr> -inline void check_cov_matrix(const char* function, const char* name, - const StdVec& y) { +void check_cov_matrix(const char* function, const char* name, const StdVec& y) { for (auto&& y_i : y) { check_cov_matrix(function, name, y_i); } diff --git a/stan/math/prim/err/check_ordered.hpp b/stan/math/prim/err/check_ordered.hpp index 4b8f34c5b2c..88d5baa5316 100644 --- a/stan/math/prim/err/check_ordered.hpp +++ b/stan/math/prim/err/check_ordered.hpp @@ -27,8 +27,7 @@ namespace math { */ template * = nullptr, require_not_std_vector_t* = nullptr> -inline void check_ordered(const char* function, const char* name, - const T_y& y) { +void check_ordered(const char* function, const char* name, const T_y& y) { const auto& y_ref = to_ref(value_of_rec(y)); for (Eigen::Index n = 1; n < y_ref.size(); n++) { if (!(y_ref[n] > y_ref[n - 1])) { @@ -59,8 +58,7 @@ inline void check_ordered(const char* function, const char* name, * are duplicated values, or if any element is `NaN` */ template * = nullptr> -inline void check_ordered(const char* function, const char* name, - const T_y& y) { +void check_ordered(const char* function, const char* name, const T_y& y) { for (size_t n = 1; n < y.size(); n++) { if (!(y[n] > y[n - 1])) { [&]() STAN_COLD_PATH { @@ -91,8 +89,7 @@ inline void check_ordered(const char* function, const char* name, */ template * = nullptr, require_not_vt_stan_scalar* = nullptr> -inline void check_ordered(const char* function, const char* name, - const T_y& y) { +void check_ordered(const char* function, const char* name, const T_y& y) { for (size_t i = 0; i < y.size(); ++i) { check_ordered(function, internal::make_iter_name(name, i).c_str(), y[i]); } diff --git a/stan/math/prim/err/check_positive_ordered.hpp b/stan/math/prim/err/check_positive_ordered.hpp index d38b513843e..cc36790af5f 100644 --- a/stan/math/prim/err/check_positive_ordered.hpp +++ b/stan/math/prim/err/check_positive_ordered.hpp @@ -28,8 +28,8 @@ namespace math { */ template * = nullptr, require_not_std_vector_t* = nullptr> -inline void check_positive_ordered(const char* function, const char* name, - const Vec& y) { +void check_positive_ordered(const char* function, const char* name, + const Vec& y) { if (y.size() == 0) { return; } @@ -60,8 +60,8 @@ inline void check_positive_ordered(const char* function, const char* name, * `NaN` */ template * = nullptr> -inline void check_positive_ordered(const char* function, const char* name, - const StdVec& y) { +void check_positive_ordered(const char* function, const char* name, + const StdVec& y) { for (size_t i = 0; i < y.size(); ++i) { check_positive_ordered(function, internal::make_iter_name(name, i).c_str(), y[i]); diff --git a/stan/math/prim/err/check_simplex.hpp b/stan/math/prim/err/check_simplex.hpp index 562687de7ee..67b6bb831c1 100644 --- a/stan/math/prim/err/check_simplex.hpp +++ b/stan/math/prim/err/check_simplex.hpp @@ -31,8 +31,7 @@ namespace math { * is `NaN` */ template * = nullptr> -inline void check_simplex(const char* function, const char* name, - const T& theta) { +void check_simplex(const char* function, const char* name, const T& theta) { using std::fabs; check_nonzero_size(function, name, theta); auto&& theta_ref = to_ref(value_of_rec(theta)); @@ -79,8 +78,7 @@ inline void check_simplex(const char* function, const char* name, * is `NaN` */ template * = nullptr> -inline void check_simplex(const char* function, const char* name, - const T& theta) { +void check_simplex(const char* function, const char* name, const T& theta) { for (size_t i = 0; i < theta.size(); ++i) { check_simplex(function, internal::make_iter_name(name, i).c_str(), theta[i]); diff --git a/stan/math/prim/err/check_sorted.hpp b/stan/math/prim/err/check_sorted.hpp index 8ef1f6a5dd2..9a345fb2fec 100644 --- a/stan/math/prim/err/check_sorted.hpp +++ b/stan/math/prim/err/check_sorted.hpp @@ -23,8 +23,7 @@ namespace math { * not sorted, or if any element is NaN. */ template * = nullptr> -inline void check_sorted(const char* function, const char* name, - const EigVec& y) { +void check_sorted(const char* function, const char* name, const EigVec& y) { const auto& y_ref = to_ref(y); for (Eigen::Index n = 1; n < y_ref.size(); n++) { if (!(y_ref[n] >= y_ref[n - 1])) { @@ -54,8 +53,8 @@ inline void check_sorted(const char* function, const char* name, * is NaN. */ template -inline void check_sorted(const char* function, const char* name, - const std::vector& y) { +void check_sorted(const char* function, const char* name, + const std::vector& y) { for (size_t n = 1; n < y.size(); n++) { if (!(y[n] >= y[n - 1])) { std::ostringstream msg1; diff --git a/stan/math/prim/err/check_stochastic_column.hpp b/stan/math/prim/err/check_stochastic_column.hpp index 33f2e040059..c410fef398a 100644 --- a/stan/math/prim/err/check_stochastic_column.hpp +++ b/stan/math/prim/err/check_stochastic_column.hpp @@ -32,8 +32,8 @@ namespace math { * if any element is `NaN` */ template * = nullptr> -inline void check_stochastic_column(const char* function, const char* name, - const T& theta) { +void check_stochastic_column(const char* function, const char* name, + const T& theta) { using std::fabs; check_nonzero_size(function, name, theta); auto&& theta_ref = to_ref(value_of_rec(theta)); @@ -86,8 +86,8 @@ inline void check_stochastic_column(const char* function, const char* name, * matrices or if any element is `NaN` */ template * = nullptr> -inline void check_stochastic_column(const char* function, const char* name, - const T& theta) { +void check_stochastic_column(const char* function, const char* name, + const T& theta) { for (size_t i = 0; i < theta.size(); ++i) { check_stochastic_column(function, internal::make_iter_name(name, i).c_str(), theta[i]); diff --git a/stan/math/prim/err/check_stochastic_row.hpp b/stan/math/prim/err/check_stochastic_row.hpp index 55001bfb2ba..fa917ae2a63 100644 --- a/stan/math/prim/err/check_stochastic_row.hpp +++ b/stan/math/prim/err/check_stochastic_row.hpp @@ -32,8 +32,8 @@ namespace math { * any element is `NaN` */ template * = nullptr> -inline void check_stochastic_row(const char* function, const char* name, - const T& theta) { +void check_stochastic_row(const char* function, const char* name, + const T& theta) { using std::fabs; check_nonzero_size(function, name, theta); auto&& theta_ref = to_ref(value_of_rec(theta)); @@ -86,8 +86,8 @@ inline void check_stochastic_row(const char* function, const char* name, * stochastic matrix or if any element is `NaN` */ template * = nullptr> -inline void check_stochastic_row(const char* function, const char* name, - const T& theta) { +void check_stochastic_row(const char* function, const char* name, + const T& theta) { for (size_t i = 0; i < theta.size(); ++i) { check_stochastic_row(function, internal::make_iter_name(name, i).c_str(), theta[i]); diff --git a/stan/math/prim/err/check_sum_to_zero.hpp b/stan/math/prim/err/check_sum_to_zero.hpp index 3a5342235b8..b384f5cc778 100644 --- a/stan/math/prim/err/check_sum_to_zero.hpp +++ b/stan/math/prim/err/check_sum_to_zero.hpp @@ -28,8 +28,7 @@ namespace math { * @throw `std::domain_error` if the vector does not sum to zero */ template * = nullptr> -inline void check_sum_to_zero(const char* function, const char* name, - const T& theta) { +void check_sum_to_zero(const char* function, const char* name, const T& theta) { using std::fabs; // the size-zero case is technically a valid sum-to-zero vector, // but it cannot be unconstrained to anything @@ -61,8 +60,7 @@ inline void check_sum_to_zero(const char* function, const char* name, * @throw `std::domain_error` if the vector does not sum to zero */ template * = nullptr> -inline void check_sum_to_zero(const char* function, const char* name, - const T& theta) { +void check_sum_to_zero(const char* function, const char* name, const T& theta) { for (size_t i = 0; i < theta.size(); ++i) { check_sum_to_zero(function, internal::make_iter_name(name, i).c_str(), theta[i]); diff --git a/stan/math/prim/err/check_unit_vector.hpp b/stan/math/prim/err/check_unit_vector.hpp index 46b786bbaec..fd165bf3dbe 100644 --- a/stan/math/prim/err/check_unit_vector.hpp +++ b/stan/math/prim/err/check_unit_vector.hpp @@ -34,8 +34,8 @@ namespace math { */ template * = nullptr, require_not_std_vector_t* = nullptr> -inline void check_unit_vector(const char* function, const char* name, - const Vec& theta) { +void check_unit_vector(const char* function, const char* name, + const Vec& theta) { check_nonzero_size(function, name, theta); using std::fabs; scalar_type_t ssq = value_of_rec(theta).squaredNorm(); @@ -64,8 +64,8 @@ inline void check_unit_vector(const char* function, const char* name, * element is `NaN` */ template * = nullptr> -inline void check_unit_vector(const char* function, const char* name, - const StdVec& theta) { +void check_unit_vector(const char* function, const char* name, + const StdVec& theta) { for (size_t i = 0; i < theta.size(); ++i) { check_unit_vector(function, internal::make_iter_name(name, i).c_str(), theta[i]); diff --git a/stan/math/prim/err/elementwise_check.hpp b/stan/math/prim/err/elementwise_check.hpp index c88364f64d5..bd9f4a7aa74 100644 --- a/stan/math/prim/err/elementwise_check.hpp +++ b/stan/math/prim/err/elementwise_check.hpp @@ -85,7 +85,7 @@ inline void pipe_in(std::stringstream& ss, Arg0 arg0, const Args... args) { * @param args arguments */ template -inline void elementwise_throw_domain_error(const Args... args) { +void elementwise_throw_domain_error(const Args... args) { std::stringstream ss; pipe_in(ss, args...); throw std::domain_error(ss.str()); diff --git a/stan/math/prim/fun/autocorrelation.hpp b/stan/math/prim/fun/autocorrelation.hpp index 560509cea8a..e9b7c4a4e67 100644 --- a/stan/math/prim/fun/autocorrelation.hpp +++ b/stan/math/prim/fun/autocorrelation.hpp @@ -59,8 +59,8 @@ inline size_t fft_next_good_size(size_t N) { * @param fft FFT engine instance. */ template -inline void autocorrelation(const std::vector& y, std::vector& ac, - Eigen::FFT& fft) { +void autocorrelation(const std::vector& y, std::vector& ac, + Eigen::FFT& fft) { using std::complex; using std::vector; @@ -116,9 +116,8 @@ inline void autocorrelation(const std::vector& y, std::vector& ac, * @param fft FFT engine instance. */ template -inline void autocorrelation(const Eigen::MatrixBase& y, - Eigen::MatrixBase& ac, - Eigen::FFT& fft) { +void autocorrelation(const Eigen::MatrixBase& y, + Eigen::MatrixBase& ac, Eigen::FFT& fft) { size_t N = y.size(); size_t M = internal::fft_next_good_size(N); size_t Mt2 = 2 * M; @@ -162,7 +161,7 @@ inline void autocorrelation(const Eigen::MatrixBase& y, * @param ac Autocorrelations. */ template -inline void autocorrelation(const std::vector& y, std::vector& ac) { +void autocorrelation(const std::vector& y, std::vector& ac) { Eigen::FFT fft; size_t N = y.size(); ac.resize(N); @@ -189,8 +188,8 @@ inline void autocorrelation(const std::vector& y, std::vector& ac) { * @param ac Autocorrelations. */ template -inline void autocorrelation(const Eigen::MatrixBase& y, - Eigen::MatrixBase& ac) { +void autocorrelation(const Eigen::MatrixBase& y, + Eigen::MatrixBase& ac) { Eigen::FFT fft; autocorrelation(y, ac, fft); } diff --git a/stan/math/prim/fun/autocovariance.hpp b/stan/math/prim/fun/autocovariance.hpp index b0da20754a5..e9c9b564e42 100644 --- a/stan/math/prim/fun/autocovariance.hpp +++ b/stan/math/prim/fun/autocovariance.hpp @@ -30,8 +30,8 @@ namespace math { * @param fft FFT engine instance. */ template -inline void autocovariance(const std::vector& y, std::vector& acov, - Eigen::FFT& fft) { +void autocovariance(const std::vector& y, std::vector& acov, + Eigen::FFT& fft) { autocorrelation(y, acov, fft); T var = variance(y) * (y.size() - 1) / y.size(); @@ -63,9 +63,8 @@ inline void autocovariance(const std::vector& y, std::vector& acov, * @param fft FFT engine instance. */ template -inline void autocovariance(const Eigen::MatrixBase& y, - Eigen::MatrixBase& acov, - Eigen::FFT& fft) { +void autocovariance(const Eigen::MatrixBase& y, + Eigen::MatrixBase& acov, Eigen::FFT& fft) { autocorrelation(y, acov, fft); acov = acov.array() * (y.array() - y.mean()).square().sum() / y.size(); } @@ -87,7 +86,7 @@ inline void autocovariance(const Eigen::MatrixBase& y, * @param acov Autocovariances. */ template -inline void autocovariance(const std::vector& y, std::vector& acov) { +void autocovariance(const std::vector& y, std::vector& acov) { Eigen::FFT fft; size_t N = y.size(); acov.resize(N); @@ -116,8 +115,8 @@ inline void autocovariance(const std::vector& y, std::vector& acov) { * @param acov Autocovariances. */ template -inline void autocovariance(const Eigen::MatrixBase& y, - Eigen::MatrixBase& acov) { +void autocovariance(const Eigen::MatrixBase& y, + Eigen::MatrixBase& acov) { Eigen::FFT fft; autocovariance(y, acov, fft); } diff --git a/stan/math/prim/fun/chol2inv.hpp b/stan/math/prim/fun/chol2inv.hpp index 26bdece0f33..8f2f3c3d866 100644 --- a/stan/math/prim/fun/chol2inv.hpp +++ b/stan/math/prim/fun/chol2inv.hpp @@ -20,7 +20,7 @@ namespace math { * lower triangular */ template * = nullptr> -inline plain_type_t chol2inv(const T& L) { +plain_type_t chol2inv(const T& L) { const Eigen::Ref>& L_ref = L; check_square("chol2inv", "L", L_ref); check_lower_triangular("chol2inv", "L", L_ref); diff --git a/stan/math/prim/fun/diag_post_multiply.hpp b/stan/math/prim/fun/diag_post_multiply.hpp index 35a3946a8f6..5564618660d 100644 --- a/stan/math/prim/fun/diag_post_multiply.hpp +++ b/stan/math/prim/fun/diag_post_multiply.hpp @@ -22,7 +22,7 @@ namespace math { template * = nullptr, require_eigen_vector_t* = nullptr, require_all_not_st_var* = nullptr> -inline auto diag_post_multiply(const T1& m1, const T2& m2) { +auto diag_post_multiply(const T1& m1, const T2& m2) { check_size_match("diag_post_multiply", "m2.size()", m2.size(), "m1.cols()", m1.cols()); return m1 * m2.asDiagonal(); diff --git a/stan/math/prim/fun/diag_pre_multiply.hpp b/stan/math/prim/fun/diag_pre_multiply.hpp index d4de767cb00..a3ed197b6e2 100644 --- a/stan/math/prim/fun/diag_pre_multiply.hpp +++ b/stan/math/prim/fun/diag_pre_multiply.hpp @@ -22,7 +22,7 @@ namespace math { template * = nullptr, require_eigen_t* = nullptr, require_all_not_st_var* = nullptr> -inline auto diag_pre_multiply(const T1& m1, const T2& m2) { +auto diag_pre_multiply(const T1& m1, const T2& m2) { check_size_match("diag_pre_multiply", "m1.size()", m1.size(), "m2.rows()", m2.rows()); diff --git a/stan/math/prim/fun/eigenvalues_sym.hpp b/stan/math/prim/fun/eigenvalues_sym.hpp index 766288832db..bc6df83f8ac 100644 --- a/stan/math/prim/fun/eigenvalues_sym.hpp +++ b/stan/math/prim/fun/eigenvalues_sym.hpp @@ -20,8 +20,7 @@ namespace math { */ template * = nullptr, require_not_st_var* = nullptr> -inline Eigen::Matrix, -1, 1> eigenvalues_sym( - const EigMat& m) { +Eigen::Matrix, -1, 1> eigenvalues_sym(const EigMat& m) { if (unlikely(m.size() == 0)) { return Eigen::Matrix, -1, 1>(0, 1); } diff --git a/stan/math/prim/fun/eigenvectors_sym.hpp b/stan/math/prim/fun/eigenvectors_sym.hpp index e763f20044b..88da84d3983 100644 --- a/stan/math/prim/fun/eigenvectors_sym.hpp +++ b/stan/math/prim/fun/eigenvectors_sym.hpp @@ -10,7 +10,7 @@ namespace math { template * = nullptr, require_not_st_var* = nullptr> -inline Eigen::Matrix, Eigen::Dynamic, Eigen::Dynamic> +Eigen::Matrix, Eigen::Dynamic, Eigen::Dynamic> eigenvectors_sym(const EigMat& m) { if (unlikely(m.size() == 0)) { return Eigen::Matrix, -1, -1>(0, 0); diff --git a/stan/math/prim/fun/elt_divide.hpp b/stan/math/prim/fun/elt_divide.hpp index 4bc628c31be..d0fedb64bdc 100644 --- a/stan/math/prim/fun/elt_divide.hpp +++ b/stan/math/prim/fun/elt_divide.hpp @@ -22,7 +22,7 @@ namespace math { template * = nullptr, require_all_not_st_var* = nullptr> -inline auto elt_divide(const Mat1& m1, const Mat2& m2) { +auto elt_divide(const Mat1& m1, const Mat2& m2) { check_matching_dims("elt_divide", "m1", m1, "m2", m2); return (m1.array() / m2.array()).matrix(); } @@ -40,7 +40,7 @@ inline auto elt_divide(const Mat1& m1, const Mat2& m2) { */ template * = nullptr, require_stan_scalar_t* = nullptr> -inline auto elt_divide(const Mat& m, Scal s) { +auto elt_divide(const Mat& m, Scal s) { return divide(m, s); } @@ -57,13 +57,13 @@ inline auto elt_divide(const Mat& m, Scal s) { */ template * = nullptr, require_eigen_t* = nullptr> -inline auto elt_divide(Scal s, const Mat& m) { +auto elt_divide(Scal s, const Mat& m) { return (s / m.array()).matrix(); } template * = nullptr> -inline auto elt_divide(Scal1 s1, Scal2 s2) { +auto elt_divide(Scal1 s1, Scal2 s2) { return s1 / s2; } diff --git a/stan/math/prim/fun/elt_multiply.hpp b/stan/math/prim/fun/elt_multiply.hpp index 3ddbe9e0427..bad90c7a26d 100644 --- a/stan/math/prim/fun/elt_multiply.hpp +++ b/stan/math/prim/fun/elt_multiply.hpp @@ -23,7 +23,7 @@ namespace math { template * = nullptr, require_all_not_st_var* = nullptr> -inline auto elt_multiply(const Mat1& m1, const Mat2& m2) { +auto elt_multiply(const Mat1& m1, const Mat2& m2) { check_matching_dims("elt_multiply", "m1", m1, "m2", m2); return m1.cwiseProduct(m2); } @@ -41,7 +41,7 @@ inline auto elt_multiply(const Mat1& m1, const Mat2& m2) { */ template * = nullptr> -inline auto elt_multiply(const Scalar1& a, const Scalar2& b) { +auto elt_multiply(const Scalar1& a, const Scalar2& b) { return a * b; } diff --git a/stan/math/prim/fun/factor_U.hpp b/stan/math/prim/fun/factor_U.hpp index 9dc03b97887..6e9c600f4e0 100644 --- a/stan/math/prim/fun/factor_U.hpp +++ b/stan/math/prim/fun/factor_U.hpp @@ -22,7 +22,7 @@ namespace math { template * = nullptr, require_eigen_vector_t* = nullptr, require_vt_same* = nullptr> -inline void factor_U(const T_U& U, T_CPCs&& CPCs) { +void factor_U(const T_U& U, T_CPCs&& CPCs) { size_t K = U.rows(); size_t position = 0; size_t pull = K - 1; diff --git a/stan/math/prim/fun/factor_cov_matrix.hpp b/stan/math/prim/fun/factor_cov_matrix.hpp index e02a650d9ce..c123a08aecc 100644 --- a/stan/math/prim/fun/factor_cov_matrix.hpp +++ b/stan/math/prim/fun/factor_cov_matrix.hpp @@ -25,8 +25,7 @@ template * = nullptr, require_all_eigen_vector_t* = nullptr, require_all_vt_same* = nullptr> -inline bool factor_cov_matrix(const T_Sigma& Sigma, T_CPCs&& CPCs, - T_sds&& sds) { +bool factor_cov_matrix(const T_Sigma& Sigma, T_CPCs&& CPCs, T_sds&& sds) { using T_scalar = value_type_t; size_t K = sds.rows(); const Eigen::Ref>& Sigma_ref = Sigma; diff --git a/stan/math/prim/fun/gp_dot_prod_cov.hpp b/stan/math/prim/fun/gp_dot_prod_cov.hpp index 14d0745634b..caa1d5291e0 100644 --- a/stan/math/prim/fun/gp_dot_prod_cov.hpp +++ b/stan/math/prim/fun/gp_dot_prod_cov.hpp @@ -34,8 +34,7 @@ namespace math { * x is nan or infinite */ template -inline Eigen::Matrix, Eigen::Dynamic, - Eigen::Dynamic> +Eigen::Matrix, Eigen::Dynamic, Eigen::Dynamic> gp_dot_prod_cov(const std::vector> &x, const T_sigma &sigma) { check_not_nan("gp_dot_prod_cov", "sigma", sigma); @@ -97,8 +96,7 @@ gp_dot_prod_cov(const std::vector> &x, * x is nan or infinite */ template -inline Eigen::Matrix, Eigen::Dynamic, - Eigen::Dynamic> +Eigen::Matrix, Eigen::Dynamic, Eigen::Dynamic> gp_dot_prod_cov(const std::vector &x, const T_sigma &sigma) { check_nonnegative("gp_dot_prod_cov", "sigma", sigma); check_finite("gp_dot_prod_cov", "sigma", sigma); @@ -154,8 +152,8 @@ gp_dot_prod_cov(const std::vector &x, const T_sigma &sigma) { * or if x1 or x2 are nan or inf */ template -inline Eigen::Matrix, Eigen::Dynamic, - Eigen::Dynamic> +Eigen::Matrix, Eigen::Dynamic, + Eigen::Dynamic> gp_dot_prod_cov(const std::vector> &x1, const std::vector> &x2, const T_sigma &sigma) { @@ -218,8 +216,8 @@ gp_dot_prod_cov(const std::vector> &x1, * or if x1 or x2 are nan or inf */ template -inline Eigen::Matrix, Eigen::Dynamic, - Eigen::Dynamic> +Eigen::Matrix, Eigen::Dynamic, + Eigen::Dynamic> gp_dot_prod_cov(const std::vector &x1, const std::vector &x2, const T_sigma &sigma) { check_nonnegative("gp_dot_prod_cov", "sigma", sigma); diff --git a/stan/math/prim/fun/grad_2F1.hpp b/stan/math/prim/fun/grad_2F1.hpp index 42d5d2a50dd..6399dec7c5f 100644 --- a/stan/math/prim/fun/grad_2F1.hpp +++ b/stan/math/prim/fun/grad_2F1.hpp @@ -49,9 +49,8 @@ template , typename TupleT = std::tuple> -inline TupleT grad_2F1_impl_ab(const T1& a1, const T2& a2, const T3& b1, - const T_z& z, double precision = 1e-14, - int max_steps = 1e6) { +TupleT grad_2F1_impl_ab(const T1& a1, const T2& a2, const T3& b1, const T_z& z, + double precision = 1e-14, int max_steps = 1e6) { TupleT grad_tuple = TupleT(0, 0, 0); if (z == 0) { @@ -168,9 +167,8 @@ template , typename TupleT = std::tuple> -inline TupleT grad_2F1_impl(const T1& a1, const T2& a2, const T3& b1, - const T_z& z, double precision = 1e-14, - int max_steps = 1e6) { +TupleT grad_2F1_impl(const T1& a1, const T2& a2, const T3& b1, const T_z& z, + double precision = 1e-14, int max_steps = 1e6) { bool euler_transform = false; try { check_2F1_converges("hypergeometric_2F1", a1, a2, b1, z); @@ -270,8 +268,8 @@ inline TupleT grad_2F1_impl(const T1& a1, const T2& a2, const T3& b1, */ template >* = nullptr> -inline auto grad_2F1(const T1& a1, const T2& a2, const T3& b1, const T_z& z, - double precision = 1e-14, int max_steps = 1e6) { +auto grad_2F1(const T1& a1, const T2& a2, const T3& b1, const T_z& z, + double precision = 1e-14, int max_steps = 1e6) { return internal::grad_2F1_impl, is_autodiff_v, is_autodiff_v, is_autodiff_v>( value_of(a1), value_of(a2), value_of(b1), value_of(z), precision, @@ -303,8 +301,8 @@ inline auto grad_2F1(const T1& a1, const T2& a2, const T3& b1, const T_z& z, */ template >* = nullptr> -inline auto grad_2F1(const T1& a1, const T2& a2, const T3& b1, const T_z& z, - double precision = 1e-14, int max_steps = 1e6) { +auto grad_2F1(const T1& a1, const T2& a2, const T3& b1, const T_z& z, + double precision = 1e-14, int max_steps = 1e6) { return internal::grad_2F1_impl(a1, a2, b1, z, precision, max_steps); } @@ -328,8 +326,8 @@ inline auto grad_2F1(const T1& a1, const T2& a2, const T3& b1, const T_z& z, * @param[in] max_steps number of steps to take */ template -inline auto grad_2F1(const T1& a1, const T2& a2, const T3& b1, const T_z& z, - double precision = 1e-14, int max_steps = 1e6) { +auto grad_2F1(const T1& a1, const T2& a2, const T3& b1, const T_z& z, + double precision = 1e-14, int max_steps = 1e6) { return grad_2F1(a1, a2, b1, z, precision, max_steps); } diff --git a/stan/math/prim/fun/grad_F32.hpp b/stan/math/prim/fun/grad_F32.hpp index c8f2d56d5f7..a9ab44f3d09 100644 --- a/stan/math/prim/fun/grad_F32.hpp +++ b/stan/math/prim/fun/grad_F32.hpp @@ -52,9 +52,9 @@ template -inline void grad_F32(T1* g, const T2& a1, const T3& a2, const T4& a3, - const T5& b1, const T6& b2, const T7& z, - const T8& precision = 1e-6, int max_steps = 1e5) { +void grad_F32(T1* g, const T2& a1, const T3& a2, const T4& a3, const T5& b1, + const T6& b2, const T7& z, const T8& precision = 1e-6, + int max_steps = 1e5) { check_3F2_converges("grad_F32", a1, a2, a3, b1, b2, z); for (int i = 0; i < 6; ++i) { diff --git a/stan/math/prim/fun/grad_reg_inc_beta.hpp b/stan/math/prim/fun/grad_reg_inc_beta.hpp index f4fa1b58178..07159b9f9ce 100644 --- a/stan/math/prim/fun/grad_reg_inc_beta.hpp +++ b/stan/math/prim/fun/grad_reg_inc_beta.hpp @@ -32,9 +32,9 @@ namespace math { * @param[in] betaAB the value of beta(a, b) */ template -inline void grad_reg_inc_beta(T& g1, T& g2, const T& a, const T& b, const T& z, - const T& digammaA, const T& digammaB, - const T& digammaSum, const T& betaAB) { +void grad_reg_inc_beta(T& g1, T& g2, const T& a, const T& b, const T& z, + const T& digammaA, const T& digammaB, + const T& digammaSum, const T& betaAB) { using std::exp; T c1 = log(z); diff --git a/stan/math/prim/fun/grad_reg_inc_gamma.hpp b/stan/math/prim/fun/grad_reg_inc_gamma.hpp index 79f47def83e..34f9122adbe 100644 --- a/stan/math/prim/fun/grad_reg_inc_gamma.hpp +++ b/stan/math/prim/fun/grad_reg_inc_gamma.hpp @@ -49,9 +49,9 @@ namespace math { (a-1)_k\right) \frac{1}{z^k} \end{array} \f] */ template -inline return_type_t grad_reg_inc_gamma(T1 a, T2 z, T1 g, T1 dig, - double precision = 1e-6, - int max_steps = 1e5) { +return_type_t grad_reg_inc_gamma(T1 a, T2 z, T1 g, T1 dig, + double precision = 1e-6, + int max_steps = 1e5) { using std::exp; using std::fabs; using std::log; diff --git a/stan/math/prim/fun/grad_reg_lower_inc_gamma.hpp b/stan/math/prim/fun/grad_reg_lower_inc_gamma.hpp index 9e70b33c0a0..b93e37f9637 100644 --- a/stan/math/prim/fun/grad_reg_lower_inc_gamma.hpp +++ b/stan/math/prim/fun/grad_reg_lower_inc_gamma.hpp @@ -107,9 +107,9 @@ namespace math { * */ template -inline return_type_t grad_reg_lower_inc_gamma(const T1& a, const T2& z, - double precision = 1e-10, - int max_steps = 1e5) { +return_type_t grad_reg_lower_inc_gamma(const T1& a, const T2& z, + double precision = 1e-10, + int max_steps = 1e5) { using std::exp; using std::log; using std::pow; diff --git a/stan/math/prim/fun/hypergeometric_1F0.hpp b/stan/math/prim/fun/hypergeometric_1F0.hpp index dfe9905f74d..2833e503887 100644 --- a/stan/math/prim/fun/hypergeometric_1F0.hpp +++ b/stan/math/prim/fun/hypergeometric_1F0.hpp @@ -28,7 +28,7 @@ namespace math { * @return Hypergeometric 1F0 function */ template * = nullptr> -inline return_type_t hypergeometric_1F0(const Ta& a, const Tz& z) { +return_type_t hypergeometric_1F0(const Ta& a, const Tz& z) { check_less("hypergeometric_1F0", "abs(z)", std::fabs(z), 1.0); return boost::math::hypergeometric_1F0(a, z, boost_policy_t<>()); diff --git a/stan/math/prim/fun/hypergeometric_2F2.hpp b/stan/math/prim/fun/hypergeometric_2F2.hpp index 7a25c777d0a..1c4afd06afd 100644 --- a/stan/math/prim/fun/hypergeometric_2F2.hpp +++ b/stan/math/prim/fun/hypergeometric_2F2.hpp @@ -22,8 +22,8 @@ namespace math { template * = nullptr, require_stan_scalar_t* = nullptr> -inline return_type_t hypergeometric_2F2(const Ta& a, const Tb& b, - const Tz& z) { +return_type_t hypergeometric_2F2(const Ta& a, const Tb& b, + const Tz& z) { if (a.size() != 2 || b.size() != 2) { std::stringstream msg; msg << "Inputs to hypergeometric 2F2 do not contain two values" diff --git a/stan/math/prim/fun/hypergeometric_pFq.hpp b/stan/math/prim/fun/hypergeometric_pFq.hpp index 1ea870d170c..c2b30610314 100644 --- a/stan/math/prim/fun/hypergeometric_pFq.hpp +++ b/stan/math/prim/fun/hypergeometric_pFq.hpp @@ -25,8 +25,8 @@ namespace math { template * = nullptr, require_arithmetic_t* = nullptr> -inline return_type_t hypergeometric_pFq(const Ta& a, const Tb& b, - const Tz& z) { +return_type_t hypergeometric_pFq(const Ta& a, const Tb& b, + const Tz& z) { plain_type_t a_ref = a; plain_type_t b_ref = b; check_finite("hypergeometric_pFq", "a", a_ref); diff --git a/stan/math/prim/fun/imag.hpp b/stan/math/prim/fun/imag.hpp index af9d45ecc82..49ecbf5499c 100644 --- a/stan/math/prim/fun/imag.hpp +++ b/stan/math/prim/fun/imag.hpp @@ -15,7 +15,7 @@ namespace math { * @return imaginary component of argument */ template > -inline T imag(const std::complex& z) { +T imag(const std::complex& z) { return z.imag(); } diff --git a/stan/math/prim/fun/inc_beta_dda.hpp b/stan/math/prim/fun/inc_beta_dda.hpp index 4ed2c0e4758..b913f0c5801 100644 --- a/stan/math/prim/fun/inc_beta_dda.hpp +++ b/stan/math/prim/fun/inc_beta_dda.hpp @@ -36,7 +36,7 @@ namespace math { * @pre 0 <= z <= 1 */ template -inline T inc_beta_dda(T a, T b, T z, T digamma_a, T digamma_ab) { +T inc_beta_dda(T a, T b, T z, T digamma_a, T digamma_ab) { using std::fabs; using std::log; using std::pow; diff --git a/stan/math/prim/fun/inc_beta_ddb.hpp b/stan/math/prim/fun/inc_beta_ddb.hpp index 5514743f3e9..4d980824b80 100644 --- a/stan/math/prim/fun/inc_beta_ddb.hpp +++ b/stan/math/prim/fun/inc_beta_ddb.hpp @@ -14,7 +14,7 @@ namespace stan { namespace math { template -inline T inc_beta_dda(T a, T b, T z, T digamma_a, T digamma_ab); +T inc_beta_dda(T a, T b, T z, T digamma_a, T digamma_ab); /** * Returns the partial derivative of the regularized @@ -39,7 +39,7 @@ inline T inc_beta_dda(T a, T b, T z, T digamma_a, T digamma_ab); * @pre 0 <= z <= 1 */ template -inline T inc_beta_ddb(T a, T b, T z, T digamma_b, T digamma_ab) { +T inc_beta_ddb(T a, T b, T z, T digamma_b, T digamma_ab) { using std::fabs; using std::log; using std::pow; diff --git a/stan/math/prim/fun/inc_beta_ddz.hpp b/stan/math/prim/fun/inc_beta_ddz.hpp index 4543df47880..455c80b82d5 100644 --- a/stan/math/prim/fun/inc_beta_ddz.hpp +++ b/stan/math/prim/fun/inc_beta_ddz.hpp @@ -27,7 +27,7 @@ namespace math { * @pre 0 < z <= 1 */ template -inline T inc_beta_ddz(T a, T b, T z) { +T inc_beta_ddz(T a, T b, T z) { using std::exp; using std::log; return exp((b - 1) * log1m(z) + (a - 1) * log(z) + lgamma(a + b) - lgamma(a) diff --git a/stan/math/prim/fun/inverse_softmax.hpp b/stan/math/prim/fun/inverse_softmax.hpp index 7b07b65a6b8..9e276f9ec2e 100644 --- a/stan/math/prim/fun/inverse_softmax.hpp +++ b/stan/math/prim/fun/inverse_softmax.hpp @@ -34,7 +34,7 @@ namespace math { * output vectors differ. */ template * = nullptr> -inline void inverse_softmax(const Vector& simplex, Vector& y) { +void inverse_softmax(const Vector& simplex, Vector& y) { check_matching_sizes("inverse_softmax", "simplex", simplex, "y", y); y = log(simplex); } diff --git a/stan/math/prim/fun/lbeta.hpp b/stan/math/prim/fun/lbeta.hpp index 5dfb7687677..5716c290b8c 100644 --- a/stan/math/prim/fun/lbeta.hpp +++ b/stan/math/prim/fun/lbeta.hpp @@ -62,7 +62,7 @@ namespace math { * @return Log of the beta function applied to the two values. */ template * = nullptr> -inline return_type_t lbeta(const T1 a, const T2 b) { +return_type_t lbeta(const T1 a, const T2 b) { using T_ret = return_type_t; if (is_any_nan(a, b)) { diff --git a/stan/math/prim/fun/lgamma_stirling.hpp b/stan/math/prim/fun/lgamma_stirling.hpp index 99505c3ff50..e96c2fcdae3 100644 --- a/stan/math/prim/fun/lgamma_stirling.hpp +++ b/stan/math/prim/fun/lgamma_stirling.hpp @@ -23,7 +23,7 @@ namespace math { * @return Stirling's approximation to lgamma(x). */ template -inline return_type_t lgamma_stirling(const T x) { +return_type_t lgamma_stirling(const T x) { return HALF_LOG_TWO_PI + (x - 0.5) * log(x) - x; } diff --git a/stan/math/prim/fun/lgamma_stirling_diff.hpp b/stan/math/prim/fun/lgamma_stirling_diff.hpp index 4d248f22a83..26bd33b58de 100644 --- a/stan/math/prim/fun/lgamma_stirling_diff.hpp +++ b/stan/math/prim/fun/lgamma_stirling_diff.hpp @@ -40,7 +40,7 @@ constexpr double lgamma_stirling_diff_useful = 10; * @return Difference between lgamma(x) and its Stirling approximation. */ template -inline return_type_t lgamma_stirling_diff(const T x) { +return_type_t lgamma_stirling_diff(const T x) { using T_ret = return_type_t; if (is_nan(value_of_rec(x))) { diff --git a/stan/math/prim/fun/log_mix.hpp b/stan/math/prim/fun/log_mix.hpp index 558dad2aa32..0cb1038fc3b 100644 --- a/stan/math/prim/fun/log_mix.hpp +++ b/stan/math/prim/fun/log_mix.hpp @@ -74,8 +74,8 @@ inline double log_mix(T_theta theta, T_lambda1 lambda1, T_lambda2 lambda2) { */ template * = nullptr> -inline return_type_t log_mix(const T_theta& theta, - const T_lam& lambda) { +return_type_t log_mix(const T_theta& theta, + const T_lam& lambda) { static constexpr const char* function = "log_mix"; using T_partials_return = partials_return_t; using T_partials_vec = @@ -141,7 +141,7 @@ inline return_type_t log_mix(const T_theta& theta, * @return log mixture of densities in specified proportion */ template * = nullptr> -inline return_type_t> log_mix( +return_type_t> log_mix( const T_theta& theta, const std::vector& lambda) { static constexpr const char* function = "log_mix"; using T_partials_return = partials_return_t>; diff --git a/stan/math/prim/fun/logb.hpp b/stan/math/prim/fun/logb.hpp index 24249d78ee9..491c01c3766 100644 --- a/stan/math/prim/fun/logb.hpp +++ b/stan/math/prim/fun/logb.hpp @@ -21,7 +21,7 @@ namespace math { * @return unbiased radix-independent exponent of the argument */ template > -inline double logb(const T& x) { +double logb(const T& x) { return std::logb(value_of_rec(x)); } diff --git a/stan/math/prim/fun/make_nu.hpp b/stan/math/prim/fun/make_nu.hpp index aec8781a38c..10e9a8a8415 100644 --- a/stan/math/prim/fun/make_nu.hpp +++ b/stan/math/prim/fun/make_nu.hpp @@ -16,7 +16,7 @@ namespace math { * @param K number of variables in correlation matrix */ template -inline Eigen::Array make_nu(const T& eta, size_t K) { +Eigen::Array make_nu(const T& eta, size_t K) { using size_type = index_type_t>; // Best (1978) implies nu = 2 * alpha for the dof in a t diff --git a/stan/math/prim/fun/matrix_exp_2x2.hpp b/stan/math/prim/fun/matrix_exp_2x2.hpp index 4f29bd5ecaa..8f020bf71c3 100644 --- a/stan/math/prim/fun/matrix_exp_2x2.hpp +++ b/stan/math/prim/fun/matrix_exp_2x2.hpp @@ -22,7 +22,7 @@ namespace math { * @return Matrix exponential of A. */ template * = nullptr> -inline Eigen::Matrix, Eigen::Dynamic, Eigen::Dynamic> +Eigen::Matrix, Eigen::Dynamic, Eigen::Dynamic> matrix_exp_2x2(const EigMat& A) { using T = value_type_t; T a = A(0, 0), b = A(0, 1), c = A(1, 0), d = A(1, 1), delta; diff --git a/stan/math/prim/fun/matrix_exp_pade.hpp b/stan/math/prim/fun/matrix_exp_pade.hpp index f9ea082ac8e..3a6e494c126 100644 --- a/stan/math/prim/fun/matrix_exp_pade.hpp +++ b/stan/math/prim/fun/matrix_exp_pade.hpp @@ -18,8 +18,8 @@ namespace math { * @return Matrix exponential of input matrix. */ template * = nullptr> -inline Eigen::Matrix, EigMat::RowsAtCompileTime, - EigMat::ColsAtCompileTime> +Eigen::Matrix, EigMat::RowsAtCompileTime, + EigMat::ColsAtCompileTime> matrix_exp_pade(const EigMat& arg) { using MatrixType = Eigen::Matrix, EigMat::RowsAtCompileTime, diff --git a/stan/math/prim/fun/max.hpp b/stan/math/prim/fun/max.hpp index 2f0af8187fc..7c236e60c9a 100644 --- a/stan/math/prim/fun/max.hpp +++ b/stan/math/prim/fun/max.hpp @@ -22,7 +22,7 @@ namespace math { * @return maximum value of the two arguments */ template * = nullptr> -inline auto max(T1 x, T2 y) { +auto max(T1 x, T2 y) { return std::max(x, y); } diff --git a/stan/math/prim/fun/min.hpp b/stan/math/prim/fun/min.hpp index a6e006f4c74..3ff2c6d0970 100644 --- a/stan/math/prim/fun/min.hpp +++ b/stan/math/prim/fun/min.hpp @@ -21,7 +21,7 @@ namespace math { * @return minimum value of the two arguments */ template * = nullptr> -inline auto min(T1 x, T2 y) { +auto min(T1 x, T2 y) { return std::min(x, y); } diff --git a/stan/math/prim/fun/poisson_binomial_log_probs.hpp b/stan/math/prim/fun/poisson_binomial_log_probs.hpp index 2e4cc9c79c9..312ae7efdfd 100644 --- a/stan/math/prim/fun/poisson_binomial_log_probs.hpp +++ b/stan/math/prim/fun/poisson_binomial_log_probs.hpp @@ -24,7 +24,7 @@ namespace math { */ template , require_vector_t* = nullptr> -inline Eigen::Matrix poisson_binomial_log_probs( +Eigen::Matrix poisson_binomial_log_probs( int y, const T_theta& theta) { int size_theta = theta.size(); plain_type_t log_theta = log(theta); @@ -54,7 +54,7 @@ inline Eigen::Matrix poisson_binomial_log_probs( } template * = nullptr> -inline auto poisson_binomial_log_probs(const T_y& y, const T_theta& theta) { +auto poisson_binomial_log_probs(const T_y& y, const T_theta& theta) { using T_scalar = scalar_type_t; size_t max_sizes = std::max(stan::math::size(y), size_mvt(theta)); std::vector> result(max_sizes); diff --git a/stan/math/prim/fun/prod.hpp b/stan/math/prim/fun/prod.hpp index 0dce5d0a780..12e02bd149b 100644 --- a/stan/math/prim/fun/prod.hpp +++ b/stan/math/prim/fun/prod.hpp @@ -16,7 +16,7 @@ namespace math { * @return the scalar */ template * = nullptr> -inline T prod(const T& v) { +T prod(const T& v) { return v; } diff --git a/stan/math/prim/fun/pseudo_eigenvalues.hpp b/stan/math/prim/fun/pseudo_eigenvalues.hpp index 7ad4d51cb2b..fd51f25f46e 100644 --- a/stan/math/prim/fun/pseudo_eigenvalues.hpp +++ b/stan/math/prim/fun/pseudo_eigenvalues.hpp @@ -8,8 +8,7 @@ namespace stan { namespace math { template -inline Eigen::Matrix pseudo_eigenvalues( - const Eigen::Matrix& m) { +Eigen::Matrix pseudo_eigenvalues(const Eigen::Matrix& m) { check_nonzero_size("pseudo_eigenvalues", "m", m); check_square("pseudo_eigenvalues", "m", m); diff --git a/stan/math/prim/fun/pseudo_eigenvectors.hpp b/stan/math/prim/fun/pseudo_eigenvectors.hpp index 3379c03c417..6b75f33691b 100644 --- a/stan/math/prim/fun/pseudo_eigenvectors.hpp +++ b/stan/math/prim/fun/pseudo_eigenvectors.hpp @@ -8,7 +8,7 @@ namespace stan { namespace math { template -inline Eigen::Matrix pseudo_eigenvectors( +Eigen::Matrix pseudo_eigenvectors( const Eigen::Matrix& m) { check_nonzero_size("pseudo_eigenvectors", "m", m); check_square("pseudo_eigenvectors", "m", m); diff --git a/stan/math/prim/fun/qr.hpp b/stan/math/prim/fun/qr.hpp index defc1d6570e..8b71e5ce02a 100644 --- a/stan/math/prim/fun/qr.hpp +++ b/stan/math/prim/fun/qr.hpp @@ -20,9 +20,8 @@ namespace math { * 2. Upper triangular matrix with maximal rows */ template * = nullptr> -inline std::tuple< - Eigen::Matrix, Eigen::Dynamic, Eigen::Dynamic>, - Eigen::Matrix, Eigen::Dynamic, Eigen::Dynamic>> +std::tuple, Eigen::Dynamic, Eigen::Dynamic>, + Eigen::Matrix, Eigen::Dynamic, Eigen::Dynamic>> qr(const EigMat& m) { using matrix_t = Eigen::Matrix, Eigen::Dynamic, Eigen::Dynamic>; diff --git a/stan/math/prim/fun/qr_Q.hpp b/stan/math/prim/fun/qr_Q.hpp index fe8b505aa09..2ba2ba747bc 100644 --- a/stan/math/prim/fun/qr_Q.hpp +++ b/stan/math/prim/fun/qr_Q.hpp @@ -17,7 +17,7 @@ namespace math { * @return Orthogonal matrix with maximal columns */ template * = nullptr> -inline Eigen::Matrix, Eigen::Dynamic, Eigen::Dynamic> qr_Q( +Eigen::Matrix, Eigen::Dynamic, Eigen::Dynamic> qr_Q( const EigMat& m) { using matrix_t = Eigen::Matrix, Eigen::Dynamic, Eigen::Dynamic>; diff --git a/stan/math/prim/fun/qr_R.hpp b/stan/math/prim/fun/qr_R.hpp index ffc2fcdd0ca..240e1346875 100644 --- a/stan/math/prim/fun/qr_R.hpp +++ b/stan/math/prim/fun/qr_R.hpp @@ -16,7 +16,7 @@ namespace math { * @return Upper triangular matrix with maximal rows */ template * = nullptr> -inline Eigen::Matrix, Eigen::Dynamic, Eigen::Dynamic> qr_R( +Eigen::Matrix, Eigen::Dynamic, Eigen::Dynamic> qr_R( const EigMat& m) { using matrix_t = Eigen::Matrix, Eigen::Dynamic, Eigen::Dynamic>; diff --git a/stan/math/prim/fun/qr_thin.hpp b/stan/math/prim/fun/qr_thin.hpp index 44cdc28a916..dabdc69f8c8 100644 --- a/stan/math/prim/fun/qr_thin.hpp +++ b/stan/math/prim/fun/qr_thin.hpp @@ -20,9 +20,8 @@ namespace math { * 2. Upper triangular matrix with minimal rows */ template * = nullptr> -inline std::tuple< - Eigen::Matrix, Eigen::Dynamic, Eigen::Dynamic>, - Eigen::Matrix, Eigen::Dynamic, Eigen::Dynamic>> +std::tuple, Eigen::Dynamic, Eigen::Dynamic>, + Eigen::Matrix, Eigen::Dynamic, Eigen::Dynamic>> qr_thin(const EigMat& m) { using matrix_t = Eigen::Matrix, Eigen::Dynamic, Eigen::Dynamic>; diff --git a/stan/math/prim/fun/qr_thin_Q.hpp b/stan/math/prim/fun/qr_thin_Q.hpp index 644283c133e..f7287fe0524 100644 --- a/stan/math/prim/fun/qr_thin_Q.hpp +++ b/stan/math/prim/fun/qr_thin_Q.hpp @@ -16,8 +16,8 @@ namespace math { * @return Orthogonal matrix with minimal columns */ template * = nullptr> -inline Eigen::Matrix, Eigen::Dynamic, Eigen::Dynamic> -qr_thin_Q(const EigMat& m) { +Eigen::Matrix, Eigen::Dynamic, Eigen::Dynamic> qr_thin_Q( + const EigMat& m) { using matrix_t = Eigen::Matrix, Eigen::Dynamic, Eigen::Dynamic>; if (unlikely(m.size() == 0)) { diff --git a/stan/math/prim/fun/qr_thin_R.hpp b/stan/math/prim/fun/qr_thin_R.hpp index be2df3aaecd..3f431b72597 100644 --- a/stan/math/prim/fun/qr_thin_R.hpp +++ b/stan/math/prim/fun/qr_thin_R.hpp @@ -16,8 +16,8 @@ namespace math { * @return Upper triangular matrix with minimal rows */ template * = nullptr> -inline Eigen::Matrix, Eigen::Dynamic, Eigen::Dynamic> -qr_thin_R(const EigMat& m) { +Eigen::Matrix, Eigen::Dynamic, Eigen::Dynamic> qr_thin_R( + const EigMat& m) { using matrix_t = Eigen::Matrix, Eigen::Dynamic, Eigen::Dynamic>; if (unlikely(m.size() == 0)) { diff --git a/stan/math/prim/fun/read_corr_L.hpp b/stan/math/prim/fun/read_corr_L.hpp index 1315e2b2158..5e646ef82ae 100644 --- a/stan/math/prim/fun/read_corr_L.hpp +++ b/stan/math/prim/fun/read_corr_L.hpp @@ -34,9 +34,9 @@ namespace math { * canonical partial correlations. */ template * = nullptr> -inline Eigen::Matrix, Eigen::Dynamic, Eigen::Dynamic> -read_corr_L(const T& CPCs, // on (-1, 1) - size_t K) { +Eigen::Matrix, Eigen::Dynamic, Eigen::Dynamic> read_corr_L( + const T& CPCs, // on (-1, 1) + size_t K) { using T_scalar = value_type_t; if (K == 0) { return {}; @@ -101,8 +101,8 @@ read_corr_L(const T& CPCs, // on (-1, 1) */ template * = nullptr, require_convertible_t, Lp>* = nullptr> -inline Eigen::Matrix, Eigen::Dynamic, Eigen::Dynamic> -read_corr_L(const T& CPCs, size_t K, Lp& log_prob) { +Eigen::Matrix, Eigen::Dynamic, Eigen::Dynamic> read_corr_L( + const T& CPCs, size_t K, Lp& log_prob) { using T_scalar = value_type_t; if (K == 0) { return {}; diff --git a/stan/math/prim/fun/read_corr_matrix.hpp b/stan/math/prim/fun/read_corr_matrix.hpp index cae9ee1303e..53b6e2cdff8 100644 --- a/stan/math/prim/fun/read_corr_matrix.hpp +++ b/stan/math/prim/fun/read_corr_matrix.hpp @@ -23,7 +23,7 @@ namespace math { * canonical partial correlations. */ template * = nullptr> -inline Eigen::Matrix, Eigen::Dynamic, Eigen::Dynamic> +Eigen::Matrix, Eigen::Dynamic, Eigen::Dynamic> read_corr_matrix(const T_CPCs& CPCs, size_t K) { if (K == 0) { return {}; @@ -56,7 +56,7 @@ read_corr_matrix(const T_CPCs& CPCs, size_t K) { template * = nullptr, require_convertible_t, Lp>* = nullptr> -inline Eigen::Matrix, Eigen::Dynamic, Eigen::Dynamic> +Eigen::Matrix, Eigen::Dynamic, Eigen::Dynamic> read_corr_matrix(const T_CPCs& CPCs, size_t K, Lp& log_prob) { if (K == 0) { return {}; diff --git a/stan/math/prim/fun/read_cov_L.hpp b/stan/math/prim/fun/read_cov_L.hpp index 6d5c4049610..f2421a7bc22 100644 --- a/stan/math/prim/fun/read_cov_L.hpp +++ b/stan/math/prim/fun/read_cov_L.hpp @@ -27,9 +27,8 @@ namespace math { template * = nullptr, require_vt_same* = nullptr> -inline Eigen::Matrix, Eigen::Dynamic, Eigen::Dynamic> -read_cov_L(const T_CPCs& CPCs, const T_sds& sds, - value_type_t& log_prob) { +Eigen::Matrix, Eigen::Dynamic, Eigen::Dynamic> read_cov_L( + const T_CPCs& CPCs, const T_sds& sds, value_type_t& log_prob) { size_t K = sds.rows(); // adjust due to transformation from correlations to covariances log_prob += (sum(log(sds)) + LOG_TWO) * K; diff --git a/stan/math/prim/fun/read_cov_matrix.hpp b/stan/math/prim/fun/read_cov_matrix.hpp index 5b86531043d..0e7e629845d 100644 --- a/stan/math/prim/fun/read_cov_matrix.hpp +++ b/stan/math/prim/fun/read_cov_matrix.hpp @@ -25,7 +25,7 @@ namespace math { template * = nullptr, require_vt_same* = nullptr> -inline Eigen::Matrix, Eigen::Dynamic, Eigen::Dynamic> +Eigen::Matrix, Eigen::Dynamic, Eigen::Dynamic> read_cov_matrix(const T_CPCs& CPCs, const T_sds& sds, value_type_t& log_prob) { Eigen::Matrix, Eigen::Dynamic, Eigen::Dynamic> L @@ -46,7 +46,7 @@ read_cov_matrix(const T_CPCs& CPCs, const T_sds& sds, template * = nullptr, require_vt_same* = nullptr> -inline Eigen::Matrix, Eigen::Dynamic, Eigen::Dynamic> +Eigen::Matrix, Eigen::Dynamic, Eigen::Dynamic> read_cov_matrix(const T_CPCs& CPCs, const T_sds& sds) { size_t K = sds.rows(); Eigen::DiagonalMatrix, Eigen::Dynamic> D(K); diff --git a/stan/math/prim/fun/real.hpp b/stan/math/prim/fun/real.hpp index f0a94ec6e87..9905d734a5c 100644 --- a/stan/math/prim/fun/real.hpp +++ b/stan/math/prim/fun/real.hpp @@ -15,7 +15,7 @@ namespace math { * @return real component of argument */ template > -inline T real(const std::complex& z) { +T real(const std::complex& z) { return z.real(); } diff --git a/stan/math/prim/fun/resize.hpp b/stan/math/prim/fun/resize.hpp index 00c9c0a7eed..ccd9214a3ec 100644 --- a/stan/math/prim/fun/resize.hpp +++ b/stan/math/prim/fun/resize.hpp @@ -8,18 +8,17 @@ namespace stan { namespace math { namespace internal { template -inline void resize(Eigen::Matrix& x, const std::vector& dims, - int pos) { +void resize(Eigen::Matrix& x, const std::vector& dims, int pos) { x.resize(dims[pos], dims[pos + 1]); } template -inline void resize(T /*x*/, const std::vector& /*dims*/, int /*pos*/) { +void resize(T /*x*/, const std::vector& /*dims*/, int /*pos*/) { // no-op } template -inline void resize(std::vector& x, const std::vector& dims, int pos) { +void resize(std::vector& x, const std::vector& dims, int pos) { x.resize(dims[pos]); ++pos; if (pos >= static_cast(dims.size())) { diff --git a/stan/math/prim/fun/scalbn.hpp b/stan/math/prim/fun/scalbn.hpp index ab56729a308..e953e388cf5 100644 --- a/stan/math/prim/fun/scalbn.hpp +++ b/stan/math/prim/fun/scalbn.hpp @@ -9,7 +9,7 @@ namespace stan { namespace math { template > -inline double scalbn(const T& x, int n) { +double scalbn(const T& x, int n) { return std::scalbn(value_of_rec(x), n); } diff --git a/stan/math/prim/fun/serializer.hpp b/stan/math/prim/fun/serializer.hpp index 62fcc866f4e..68388b90f4d 100644 --- a/stan/math/prim/fun/serializer.hpp +++ b/stan/math/prim/fun/serializer.hpp @@ -269,7 +269,7 @@ struct serializer { * @return deserializer based on specified values */ template -inline deserializer to_deserializer(const std::vector& vals) { +deserializer to_deserializer(const std::vector& vals) { return deserializer(vals); } @@ -281,20 +281,20 @@ inline deserializer to_deserializer(const std::vector& vals) { * @return deserializer based on specified values */ template * = nullptr> -inline deserializer> to_deserializer(const T& vals) { +deserializer> to_deserializer(const T& vals) { return deserializer>(vals); } template -inline deserializer to_deserializer(const std::complex& vals) { +deserializer to_deserializer(const std::complex& vals) { return to_deserializer(std::vector{vals.real(), vals.imag()}); } template -inline void serialize_helper(serializer& s) {} +void serialize_helper(serializer& s) {} template -inline void serialize_helper(serializer& s, const T& x, const Ts... xs) { +void serialize_helper(serializer& s, const T& x, const Ts... xs) { s.write(x); serialize_helper(s, xs...); } @@ -336,7 +336,7 @@ std::vector> serialize_return(const T& x) { * @return serialized form of arguments */ template -inline Eigen::VectorXd serialize_args(const Ts... xs) { +Eigen::VectorXd serialize_args(const Ts... xs) { return to_vector(serialize(xs...)); } diff --git a/stan/math/prim/fun/singular_values.hpp b/stan/math/prim/fun/singular_values.hpp index a65722fad64..7ade631048f 100644 --- a/stan/math/prim/fun/singular_values.hpp +++ b/stan/math/prim/fun/singular_values.hpp @@ -20,7 +20,7 @@ namespace math { */ template * = nullptr, require_not_st_var* = nullptr> -inline auto singular_values(const EigMat& m) { +auto singular_values(const EigMat& m) { if (unlikely(m.size() == 0)) { return Eigen::Matrix, Eigen::Dynamic, 1>(0, 1); } diff --git a/stan/math/prim/fun/stan_print.hpp b/stan/math/prim/fun/stan_print.hpp index 4c5b5f8f3cb..14deeec3779 100644 --- a/stan/math/prim/fun/stan_print.hpp +++ b/stan/math/prim/fun/stan_print.hpp @@ -12,12 +12,12 @@ namespace math { template * = nullptr, require_not_tuple_t* = nullptr> -inline void stan_print(std::ostream* o, const T& x) { +void stan_print(std::ostream* o, const T& x) { *o << x; } template * = nullptr> -inline void stan_print(std::ostream* o, const EigVec& x) { +void stan_print(std::ostream* o, const EigVec& x) { const auto& x_ref = to_ref(x); *o << '['; @@ -32,7 +32,7 @@ inline void stan_print(std::ostream* o, const EigVec& x) { template * = nullptr, require_not_eigen_vector_t* = nullptr> -inline void stan_print(std::ostream* o, const EigMat& x) { +void stan_print(std::ostream* o, const EigMat& x) { const auto& x_ref = to_ref(x); *o << '['; @@ -54,10 +54,10 @@ inline void stan_print(std::ostream* o, const EigMat& x) { // forward decl to allow the next two overloads to call each other template * = nullptr> -inline void stan_print(std::ostream* o, const T& x); +void stan_print(std::ostream* o, const T& x); template * = nullptr> -inline void stan_print(std::ostream* o, const T& x) { +void stan_print(std::ostream* o, const T& x) { *o << '['; for (size_t i = 0; i < x.size(); ++i) { if (i > 0) { @@ -69,7 +69,7 @@ inline void stan_print(std::ostream* o, const T& x) { } template *> -inline void stan_print(std::ostream* o, const T& x) { +void stan_print(std::ostream* o, const T& x) { *o << '('; size_t i = 0; stan::math::for_each( diff --git a/stan/math/prim/fun/svd_U.hpp b/stan/math/prim/fun/svd_U.hpp index b8127d557c8..ae4688bbb20 100644 --- a/stan/math/prim/fun/svd_U.hpp +++ b/stan/math/prim/fun/svd_U.hpp @@ -16,8 +16,8 @@ namespace math { */ template * = nullptr, require_not_st_var* = nullptr> -inline Eigen::Matrix, Eigen::Dynamic, Eigen::Dynamic> -svd_U(const EigMat& m) { +Eigen::Matrix, Eigen::Dynamic, Eigen::Dynamic> svd_U( + const EigMat& m) { using MatType = Eigen::Matrix, Eigen::Dynamic, Eigen::Dynamic>; if (unlikely(m.size() == 0)) { diff --git a/stan/math/prim/fun/svd_V.hpp b/stan/math/prim/fun/svd_V.hpp index 1f42bd62d9f..147390ed837 100644 --- a/stan/math/prim/fun/svd_V.hpp +++ b/stan/math/prim/fun/svd_V.hpp @@ -16,8 +16,8 @@ namespace math { */ template * = nullptr, require_not_st_var* = nullptr> -inline Eigen::Matrix, Eigen::Dynamic, Eigen::Dynamic> -svd_V(const EigMat& m) { +Eigen::Matrix, Eigen::Dynamic, Eigen::Dynamic> svd_V( + const EigMat& m) { using MatType = Eigen::Matrix, Eigen::Dynamic, Eigen::Dynamic>; if (unlikely(m.size() == 0)) { diff --git a/stan/math/prim/fun/transpose.hpp b/stan/math/prim/fun/transpose.hpp index fd2aa698146..39cb2dcaf73 100644 --- a/stan/math/prim/fun/transpose.hpp +++ b/stan/math/prim/fun/transpose.hpp @@ -14,7 +14,7 @@ namespace math { * @return transposed matrix */ template * = nullptr> -inline auto transpose(const T& m) { +auto inline transpose(const T& m) { return m.transpose(); } diff --git a/stan/math/prim/functor/finite_diff_gradient.hpp b/stan/math/prim/functor/finite_diff_gradient.hpp index 72237fd6c0e..47a794e4b46 100644 --- a/stan/math/prim/functor/finite_diff_gradient.hpp +++ b/stan/math/prim/functor/finite_diff_gradient.hpp @@ -40,9 +40,8 @@ namespace math { * @param[in] epsilon perturbation size */ template -inline void finite_diff_gradient(const F& f, const Eigen::VectorXd& x, - double& fx, Eigen::VectorXd& grad_fx, - double epsilon = 1e-03) { +void finite_diff_gradient(const F& f, const Eigen::VectorXd& x, double& fx, + Eigen::VectorXd& grad_fx, double epsilon = 1e-03) { Eigen::VectorXd x_temp(x); int d = x.size(); grad_fx.resize(d); diff --git a/stan/math/prim/functor/finite_diff_gradient_auto.hpp b/stan/math/prim/functor/finite_diff_gradient_auto.hpp index 8c9951ae37b..11f68bf350c 100644 --- a/stan/math/prim/functor/finite_diff_gradient_auto.hpp +++ b/stan/math/prim/functor/finite_diff_gradient_auto.hpp @@ -48,8 +48,8 @@ namespace math { */ template > -inline void finite_diff_gradient_auto(const F& f, VectorT&& x, ScalarT& fx, - GradVectorT& grad_fx) { +void finite_diff_gradient_auto(const F& f, VectorT&& x, ScalarT& fx, + GradVectorT& grad_fx) { using EigT = Eigen::Matrix; static constexpr int h_scale[6] = {3, 2, 1, -3, -2, -1}; static constexpr int mults[6] = {1, -9, 45, -1, 9, -45}; diff --git a/stan/math/prim/functor/map_rect.hpp b/stan/math/prim/functor/map_rect.hpp index 540ad410521..9fcc7ee7fde 100644 --- a/stan/math/prim/functor/map_rect.hpp +++ b/stan/math/prim/functor/map_rect.hpp @@ -123,8 +123,7 @@ namespace math { template * = nullptr> -inline Eigen::Matrix, Eigen::Dynamic, - 1> +Eigen::Matrix, Eigen::Dynamic, 1> map_rect(const T_shared_param& shared_params, const std::vector>& job_params, diff --git a/stan/math/prim/functor/map_rect_concurrent.hpp b/stan/math/prim/functor/map_rect_concurrent.hpp index 31dd3398747..06138845345 100644 --- a/stan/math/prim/functor/map_rect_concurrent.hpp +++ b/stan/math/prim/functor/map_rect_concurrent.hpp @@ -12,8 +12,7 @@ namespace internal { template * = nullptr> -inline Eigen::Matrix, Eigen::Dynamic, - 1> +Eigen::Matrix, Eigen::Dynamic, 1> map_rect_concurrent( const T_shared_param& shared_params, const std::vector>& diff --git a/stan/math/prim/functor/map_rect_mpi.hpp b/stan/math/prim/functor/map_rect_mpi.hpp index 3eba778b430..b208a55c9b6 100644 --- a/stan/math/prim/functor/map_rect_mpi.hpp +++ b/stan/math/prim/functor/map_rect_mpi.hpp @@ -17,8 +17,7 @@ namespace internal { template -inline Eigen::Matrix, Eigen::Dynamic, - 1> +Eigen::Matrix, Eigen::Dynamic, 1> map_rect_mpi(const T_shared_param& shared_params, const std::vector>& job_params, diff --git a/stan/math/prim/functor/ode_ckrk.hpp b/stan/math/prim/functor/ode_ckrk.hpp index 8fc6f5cb62e..10c7f901aa7 100644 --- a/stan/math/prim/functor/ode_ckrk.hpp +++ b/stan/math/prim/functor/ode_ckrk.hpp @@ -53,8 +53,8 @@ namespace math { */ template * = nullptr> -inline std::vector, - Eigen::Dynamic, 1>> +std::vector, + Eigen::Dynamic, 1>> ode_ckrk_tol_impl(const char* function_name, const F& f, const T_y0& y0_arg, T_t0 t0, const std::vector& ts, double relative_tolerance, double absolute_tolerance, @@ -194,8 +194,8 @@ ode_ckrk_tol_impl(const char* function_name, const F& f, const T_y0& y0_arg, */ template * = nullptr> -inline std::vector, - Eigen::Dynamic, 1>> +std::vector, + Eigen::Dynamic, 1>> ode_ckrk_tol(const F& f, const T_y0& y0_arg, T_t0 t0, const std::vector& ts, double relative_tolerance, double absolute_tolerance, @@ -240,8 +240,8 @@ ode_ckrk_tol(const F& f, const T_y0& y0_arg, T_t0 t0, */ template * = nullptr> -inline std::vector, - Eigen::Dynamic, 1>> +std::vector, + Eigen::Dynamic, 1>> ode_ckrk(const F& f, const T_y0& y0, T_t0 t0, const std::vector& ts, std::ostream* msgs, const Args&... args) { double relative_tolerance = 1e-6; diff --git a/stan/math/prim/functor/ode_rk45.hpp b/stan/math/prim/functor/ode_rk45.hpp index ab329c35556..4850b1169c6 100644 --- a/stan/math/prim/functor/ode_rk45.hpp +++ b/stan/math/prim/functor/ode_rk45.hpp @@ -54,8 +54,8 @@ namespace math { */ template * = nullptr> -inline std::vector, - Eigen::Dynamic, 1>> +std::vector, + Eigen::Dynamic, 1>> ode_rk45_tol_impl(const char* function_name, const F& f, const T_y0& y0_arg, T_t0 t0, const std::vector& ts, double relative_tolerance, double absolute_tolerance, @@ -196,8 +196,8 @@ ode_rk45_tol_impl(const char* function_name, const F& f, const T_y0& y0_arg, */ template * = nullptr> -inline std::vector, - Eigen::Dynamic, 1>> +std::vector, + Eigen::Dynamic, 1>> ode_rk45_tol(const F& f, const T_y0& y0_arg, T_t0 t0, const std::vector& ts, double relative_tolerance, double absolute_tolerance, @@ -242,8 +242,8 @@ ode_rk45_tol(const F& f, const T_y0& y0_arg, T_t0 t0, */ template * = nullptr> -inline std::vector, - Eigen::Dynamic, 1>> +std::vector, + Eigen::Dynamic, 1>> ode_rk45(const F& f, const T_y0& y0, T_t0 t0, const std::vector& ts, std::ostream* msgs, const Args&... args) { double relative_tolerance = 1e-6; diff --git a/stan/math/prim/functor/ode_store_sensitivities.hpp b/stan/math/prim/functor/ode_store_sensitivities.hpp index 52851cd00db..ec42a5506e4 100644 --- a/stan/math/prim/functor/ode_store_sensitivities.hpp +++ b/stan/math/prim/functor/ode_store_sensitivities.hpp @@ -32,7 +32,7 @@ template < typename F, typename T_y0_t0, typename T_t0, typename T_t, typename... Args, typename = require_all_arithmetic_t...>> -inline Eigen::VectorXd ode_store_sensitivities( +Eigen::VectorXd ode_store_sensitivities( const F& f, const std::vector& coupled_state, const Eigen::Matrix& y0, T_t0 t0, T_t t, std::ostream* msgs, const Args&... args) { diff --git a/stan/math/prim/functor/reduce_sum_static.hpp b/stan/math/prim/functor/reduce_sum_static.hpp index 7ad8648aad8..235a6d8c1b6 100644 --- a/stan/math/prim/functor/reduce_sum_static.hpp +++ b/stan/math/prim/functor/reduce_sum_static.hpp @@ -42,8 +42,8 @@ namespace math { */ template , typename... Args> -inline auto reduce_sum_static(Vec&& vmapped, int grainsize, std::ostream* msgs, - Args&&... args) { +auto reduce_sum_static(Vec&& vmapped, int grainsize, std::ostream* msgs, + Args&&... args) { using return_type = return_type_t; check_positive("reduce_sum", "grainsize", grainsize); diff --git a/stan/math/prim/meta.hpp b/stan/math/prim/meta.hpp index 5407f128133..dd6e3053eb6 100644 --- a/stan/math/prim/meta.hpp +++ b/stan/math/prim/meta.hpp @@ -95,9 +95,7 @@ #include #include #include -#include #include -#include #include #include #include @@ -130,8 +128,6 @@ #include #include #include -#include -#include #include #include #include diff --git a/stan/math/prim/meta/compiler_attributes.hpp b/stan/math/prim/meta/compiler_attributes.hpp index 0381b59bdd3..3c20c3e7fae 100644 --- a/stan/math/prim/meta/compiler_attributes.hpp +++ b/stan/math/prim/meta/compiler_attributes.hpp @@ -20,16 +20,7 @@ #endif #endif #endif -#ifndef STAN_DEPRECATED -#if __has_attribute(deprecated) -#define STAN_DEPRECATED __attribute__((deprecated)) -#else -#define STAN_DEPRECATED #endif -#endif - -#endif - #ifndef STAN_COLD_PATH #define STAN_COLD_PATH #endif @@ -39,9 +30,7 @@ #ifndef unlikely #define unlikely(x) x #endif -#ifndef STAN_DEPRECATED -#define STAN_DEPRECATED -#endif + /** * Turns all range and size checks into no-ops */ diff --git a/stan/math/prim/meta/forward_as.hpp b/stan/math/prim/meta/forward_as.hpp index 5e90da88ebf..fa3dff3f822 100644 --- a/stan/math/prim/meta/forward_as.hpp +++ b/stan/math/prim/meta/forward_as.hpp @@ -34,7 +34,7 @@ template , std::decay_t>::value && !is_eigen::value>> -STAN_DEPRECATED inline T_actual&& forward_as(T_actual&& a) { // NOLINT +inline T_actual&& forward_as(T_actual&& a) { // NOLINT return std::forward(a); } @@ -61,7 +61,7 @@ template < !std::is_same, std::decay>::value && !(std::is_floating_point_v> && std::is_integral_v>)>> -STAN_DEPRECATED inline T_desired forward_as(const T_actual& a) { +inline T_desired forward_as(const T_actual& a) { throw std::runtime_error( "Wrong type assumed! Please file a bug report. prim/meta/forward_as.hpp " "line " @@ -87,7 +87,7 @@ template > && std::is_integral_v>>> -STAN_DEPRECATED inline T_desired forward_as(const T_actual& a) { +inline T_desired forward_as(const T_actual& a) { return static_cast(a); } @@ -117,7 +117,7 @@ template < && internal::eigen_static_size_match( T_desired::ColsAtCompileTime, std::decay_t::ColsAtCompileTime)>* = nullptr> -STAN_DEPRECATED inline T_actual&& forward_as(T_actual&& a) { // NOLINT +inline T_actual&& forward_as(T_actual&& a) { // NOLINT return std::forward(a); } @@ -148,7 +148,7 @@ template < || !internal::eigen_static_size_match( T_desired::ColsAtCompileTime, std::decay_t::ColsAtCompileTime)>* = nullptr> -STAN_DEPRECATED inline T_desired forward_as(const T_actual& a) { +inline T_desired forward_as(const T_actual& a) { throw std::runtime_error( "Wrong type assumed! Please file a bug report. prim/meta/forward_as.hpp " "line " diff --git a/stan/math/prim/meta/is_floating_point.hpp b/stan/math/prim/meta/is_floating_point.hpp deleted file mode 100644 index 61d3a335833..00000000000 --- a/stan/math/prim/meta/is_floating_point.hpp +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef STAN_MATH_PRIM_META_IS_FLOATING_POINT_HPP -#define STAN_MATH_PRIM_META_IS_FLOATING_POINT_HPP - -#include - -namespace stan { - -/** - * Checks if decayed type is a floating point type - * @tparam The type to check - * @ingroup type_trait - */ -template -using is_floating_point = std::is_floating_point>; - -template -inline constexpr bool is_floating_point_v = stan::is_floating_point::value; - -template -inline constexpr bool is_all_floating_point_v - = (stan::is_floating_point_v && ...); - -template -inline constexpr bool is_any_floating_point_v - = (stan::is_floating_point_v || ...); - -} // namespace stan - -#endif diff --git a/stan/math/prim/meta/is_integral.hpp b/stan/math/prim/meta/is_integral.hpp deleted file mode 100644 index 51a4e54bf41..00000000000 --- a/stan/math/prim/meta/is_integral.hpp +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef STAN_MATH_PRIM_META_IS_INTEGRAL_HPP -#define STAN_MATH_PRIM_META_IS_INTEGRAL_HPP - -#include - -namespace stan { - -/** - * Checks if decayed type is integral - * @tparam The type to check - * @ingroup type_trait - */ -template -using is_integral = std::is_integral>; - -template -inline constexpr bool is_integral_v = stan::is_integral::value; - -template -inline constexpr bool is_all_integral_v = (stan::is_integral_v && ...); - -template -inline constexpr bool is_any_integral_v = (stan::is_integral_v || ...); - -} // namespace stan - -#endif diff --git a/stan/math/prim/meta/is_tuple.hpp b/stan/math/prim/meta/is_tuple.hpp index 93a043cc7d9..82ba01363e6 100644 --- a/stan/math/prim/meta/is_tuple.hpp +++ b/stan/math/prim/meta/is_tuple.hpp @@ -1,7 +1,6 @@ #ifndef STAN_MATH_PRIM_META_IS_TUPLE_HPP #define STAN_MATH_PRIM_META_IS_TUPLE_HPP -#include #include #include #include @@ -50,28 +49,6 @@ using require_all_not_tuple_t /*! @} */ } // namespace math -template -using is_tuple = math::is_tuple; - -template -inline constexpr bool is_tuple_v = math::is_tuple_v; - -/** - * Checks both that T is a tuple and that its size is N - * @tparam T type to retrieve the element from - * @tparam N expected size - * @ingroup type_trait - */ -template -struct is_tuple_of_size : std::false_type {}; - -template -struct is_tuple_of_size>> - : std::bool_constant> == N> {}; - -template -inline constexpr bool is_tuple_of_size_v = stan::is_tuple_of_size::value; - } // namespace stan #endif diff --git a/stan/math/prim/meta/static_select.hpp b/stan/math/prim/meta/static_select.hpp index f7cafc5aa4d..a594b41c1e9 100644 --- a/stan/math/prim/meta/static_select.hpp +++ b/stan/math/prim/meta/static_select.hpp @@ -21,13 +21,13 @@ namespace math { */ template * = nullptr> -inline T1 static_select(T1&& a, T2&& b) { +T1 static_select(T1&& a, T2&& b) { return std::forward(a); } template * = nullptr> -inline T2 static_select(T1&& a, T2&& b) { +T2 static_select(T1&& a, T2&& b) { return std::forward(b); } diff --git a/stan/math/prim/meta/tuple_element.hpp b/stan/math/prim/meta/tuple_element.hpp deleted file mode 100644 index 79082b7664c..00000000000 --- a/stan/math/prim/meta/tuple_element.hpp +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef STAN_MATH_PRIM_META_TUPLE_ELEMENT_HPP -#define STAN_MATH_PRIM_META_TUPLE_ELEMENT_HPP - -#include -#include - -#include -#include -#include - -namespace stan { - -/** - * Equivalent to std::tuple_element but returns void if N is out of range - * to avoid a static assertion failure in libstdc++. - * @tparam N index of the element to retrieve - * @tparam T type to retrieve the element from - * @ingroup type_trait - */ -template -struct tuple_element { - using type = void; -}; - -template -struct tuple_element< - N, T, - std::enable_if_t && (N < stan::tuple_size_v)>> { - using type = std::tuple_element_t>; -}; - -template -using tuple_element_t = typename stan::tuple_element::type; -} // namespace stan - -#endif diff --git a/stan/math/prim/meta/tuple_size.hpp b/stan/math/prim/meta/tuple_size.hpp deleted file mode 100644 index 354c3bbd745..00000000000 --- a/stan/math/prim/meta/tuple_size.hpp +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef STAN_MATH_PRIM_META_TUPLE_SIZE_HPP -#define STAN_MATH_PRIM_META_TUPLE_SIZE_HPP - -#include -#include -#include -#include - -namespace stan { - -/** - * Equivalent to std::tuple_size but returns 0 T is not a tuple - * @tparam T type to get tuple size of - * @ingroup type_trait - */ -template -struct tuple_size : std::integral_constant {}; - -template -struct tuple_size>> - : std::integral_constant>> { -}; - -template -constexpr std::size_t tuple_size_v = stan::tuple_size::value; -} // namespace stan - -#endif diff --git a/stan/math/prim/prob.hpp b/stan/math/prim/prob.hpp index be55ca6a8ef..664f97c6897 100644 --- a/stan/math/prim/prob.hpp +++ b/stan/math/prim/prob.hpp @@ -311,7 +311,11 @@ #include #include #include +#include +#include #include +#include +#include #include #include #include diff --git a/stan/math/prim/prob/bernoulli_ccdf_log.hpp b/stan/math/prim/prob/bernoulli_ccdf_log.hpp index 9b1bb7f5afa..187c76cedbb 100644 --- a/stan/math/prim/prob/bernoulli_ccdf_log.hpp +++ b/stan/math/prim/prob/bernoulli_ccdf_log.hpp @@ -11,8 +11,7 @@ namespace math { * @deprecated use bernoulli_lccdf */ template -inline return_type_t bernoulli_ccdf_log(const T_n& n, - const T_prob& theta) { +return_type_t bernoulli_ccdf_log(const T_n& n, const T_prob& theta) { return bernoulli_lccdf(n, theta); } } // namespace math diff --git a/stan/math/prim/prob/bernoulli_cdf.hpp b/stan/math/prim/prob/bernoulli_cdf.hpp index 649adcf674b..0250c3e7983 100644 --- a/stan/math/prim/prob/bernoulli_cdf.hpp +++ b/stan/math/prim/prob/bernoulli_cdf.hpp @@ -27,7 +27,7 @@ namespace math { template * = nullptr> -inline return_type_t bernoulli_cdf(const T_n& n, const T_prob& theta) { +return_type_t bernoulli_cdf(const T_n& n, const T_prob& theta) { using T_partials_return = partials_return_t; using T_theta_ref = ref_type_t; static constexpr const char* function = "bernoulli_cdf"; diff --git a/stan/math/prim/prob/bernoulli_cdf_log.hpp b/stan/math/prim/prob/bernoulli_cdf_log.hpp index 43cfdcb1e9d..3f3cf21a433 100644 --- a/stan/math/prim/prob/bernoulli_cdf_log.hpp +++ b/stan/math/prim/prob/bernoulli_cdf_log.hpp @@ -11,8 +11,7 @@ namespace math { * @deprecated use bernoulli_lcdf */ template -inline return_type_t bernoulli_cdf_log(const T_n& n, - const T_prob& theta) { +return_type_t bernoulli_cdf_log(const T_n& n, const T_prob& theta) { return bernoulli_lcdf(n, theta); } diff --git a/stan/math/prim/prob/bernoulli_lccdf.hpp b/stan/math/prim/prob/bernoulli_lccdf.hpp index e8e8b4dce30..23566158e36 100644 --- a/stan/math/prim/prob/bernoulli_lccdf.hpp +++ b/stan/math/prim/prob/bernoulli_lccdf.hpp @@ -29,8 +29,7 @@ namespace math { template * = nullptr> -inline return_type_t bernoulli_lccdf(const T_n& n, - const T_prob& theta) { +return_type_t bernoulli_lccdf(const T_n& n, const T_prob& theta) { using T_theta_ref = ref_type_t; static constexpr const char* function = "bernoulli_lccdf"; check_consistent_sizes(function, "Random variable", n, diff --git a/stan/math/prim/prob/bernoulli_lcdf.hpp b/stan/math/prim/prob/bernoulli_lcdf.hpp index a336a22aba6..3e370df9af1 100644 --- a/stan/math/prim/prob/bernoulli_lcdf.hpp +++ b/stan/math/prim/prob/bernoulli_lcdf.hpp @@ -27,7 +27,7 @@ namespace math { template * = nullptr> -inline return_type_t bernoulli_lcdf(const T_n& n, const T_prob& theta) { +return_type_t bernoulli_lcdf(const T_n& n, const T_prob& theta) { using T_theta_ref = ref_type_t; static constexpr const char* function = "bernoulli_lcdf"; check_consistent_sizes(function, "Random variable", n, diff --git a/stan/math/prim/prob/bernoulli_logit_glm_lpmf.hpp b/stan/math/prim/prob/bernoulli_logit_glm_lpmf.hpp index f380530303a..a476ba81262 100644 --- a/stan/math/prim/prob/bernoulli_logit_glm_lpmf.hpp +++ b/stan/math/prim/prob/bernoulli_logit_glm_lpmf.hpp @@ -48,7 +48,7 @@ namespace math { */ template * = nullptr> -inline return_type_t bernoulli_logit_glm_lpmf( +return_type_t bernoulli_logit_glm_lpmf( const T_y& y, const T_x& x, const T_alpha& alpha, const T_beta& beta) { using Eigen::Array; using Eigen::Dynamic; @@ -57,10 +57,14 @@ inline return_type_t bernoulli_logit_glm_lpmf( using std::exp; using std::isfinite; constexpr int T_x_rows = T_x::RowsAtCompileTime; + using T_xbeta_partials = partials_return_t; using T_partials_return = partials_return_t; using T_ytheta_tmp = typename std::conditional_t>; + using T_xbeta_tmp = + typename std::conditional_t>; using T_x_ref = ref_type_if_not_constant_t; using T_alpha_ref = ref_type_if_not_constant_t; using T_beta_ref = ref_type_if_not_constant_t; @@ -103,7 +107,8 @@ inline return_type_t bernoulli_logit_glm_lpmf( Array ytheta(N_instances); if constexpr (T_x_rows == 1) { - T_ytheta_tmp ytheta_tmp = (x_val * beta_val_vec)(0, 0); + T_ytheta_tmp ytheta_tmp + = forward_as((x_val * beta_val_vec)(0, 0)); ytheta = signs * (ytheta_tmp + as_array_or_scalar(alpha_val_vec)); } else { ytheta = (x_val * beta_val_vec).array(); @@ -137,14 +142,18 @@ inline return_type_t bernoulli_logit_glm_lpmf( signs * exp_m_ytheta / (exp_m_ytheta + 1))); if constexpr (is_autodiff_v) { if constexpr (T_x_rows == 1) { - edge<2>(ops_partials).partials_ = theta_derivative.sum() * x_val; + edge<2>(ops_partials).partials_ + = forward_as>( + theta_derivative.sum() * x_val); } else { partials<2>(ops_partials) = x_val.transpose() * theta_derivative; } } if constexpr (is_autodiff_v) { if constexpr (T_x_rows == 1) { - edge<0>(ops_partials).partials_ = beta_val_vec * theta_derivative.sum(); + edge<0>(ops_partials).partials_ + = forward_as>( + beta_val_vec * theta_derivative.sum()); } else { edge<0>(ops_partials).partials_ = (beta_val_vec * theta_derivative.transpose()).transpose(); diff --git a/stan/math/prim/prob/bernoulli_logit_glm_rng.hpp b/stan/math/prim/prob/bernoulli_logit_glm_rng.hpp index 5a65aad3e57..b62484352ea 100644 --- a/stan/math/prim/prob/bernoulli_logit_glm_rng.hpp +++ b/stan/math/prim/prob/bernoulli_logit_glm_rng.hpp @@ -67,7 +67,7 @@ inline typename VectorBuilder::type bernoulli_logit_glm_rng( if constexpr (is_vector::value) { x_beta = x_ref * beta_vector; } else { - x_beta = (x_ref.array() * beta_vector).rowwise().sum(); + x_beta = (x_ref.array() * forward_as(beta_vector)).rowwise().sum(); } scalar_seq_view alpha_vec(alpha_ref); diff --git a/stan/math/prim/prob/bernoulli_logit_lpmf.hpp b/stan/math/prim/prob/bernoulli_logit_lpmf.hpp index 7cd1ec910de..54eeba26068 100644 --- a/stan/math/prim/prob/bernoulli_logit_lpmf.hpp +++ b/stan/math/prim/prob/bernoulli_logit_lpmf.hpp @@ -33,8 +33,7 @@ namespace math { template * = nullptr> -inline return_type_t bernoulli_logit_lpmf(const T_n& n, - const T_prob& theta) { +return_type_t bernoulli_logit_lpmf(const T_n& n, const T_prob& theta) { using T_partials_return = partials_return_t; using T_partials_array = Eigen::Array; using std::exp; @@ -64,9 +63,10 @@ inline return_type_t bernoulli_logit_lpmf(const T_n& n, (2 * as_array_or_scalar(n_double) - 1)); T_partials_array ntheta; if constexpr (is_vector::value || is_vector::value) { - ntheta = signs * theta_val; + ntheta = forward_as(signs * theta_val); } else { - T_partials_return ntheta_s = signs * theta_val; + T_partials_return ntheta_s + = forward_as(signs * theta_val); ntheta = T_partials_array::Constant(1, 1, ntheta_s); } T_partials_array exp_m_ntheta = exp(-ntheta); diff --git a/stan/math/prim/prob/bernoulli_lpmf.hpp b/stan/math/prim/prob/bernoulli_lpmf.hpp index c13e4dee1ee..e0d3f166d10 100644 --- a/stan/math/prim/prob/bernoulli_lpmf.hpp +++ b/stan/math/prim/prob/bernoulli_lpmf.hpp @@ -31,7 +31,7 @@ namespace math { template * = nullptr> -inline return_type_t bernoulli_lpmf(const T_n& n, const T_prob& theta) { +return_type_t bernoulli_lpmf(const T_n& n, const T_prob& theta) { using T_partials_return = partials_return_t; using T_theta_ref = ref_type_t; using T_n_ref = ref_type_t; diff --git a/stan/math/prim/prob/beta_binomial_ccdf_log.hpp b/stan/math/prim/prob/beta_binomial_ccdf_log.hpp index c039ebd9168..5422a3d00a6 100644 --- a/stan/math/prim/prob/beta_binomial_ccdf_log.hpp +++ b/stan/math/prim/prob/beta_binomial_ccdf_log.hpp @@ -11,8 +11,10 @@ namespace math { * @deprecated use beta_binomial_lccdf */ template -inline return_type_t beta_binomial_ccdf_log( - const T_n& n, const T_N& N, const T_size1& alpha, const T_size2& beta) { +return_type_t beta_binomial_ccdf_log(const T_n& n, + const T_N& N, + const T_size1& alpha, + const T_size2& beta) { return beta_binomial_lccdf(n, N, alpha, beta); } diff --git a/stan/math/prim/prob/beta_binomial_cdf.hpp b/stan/math/prim/prob/beta_binomial_cdf.hpp index 7d90678d154..244e750d6c1 100644 --- a/stan/math/prim/prob/beta_binomial_cdf.hpp +++ b/stan/math/prim/prob/beta_binomial_cdf.hpp @@ -40,10 +40,9 @@ namespace math { * @throw std::invalid_argument if container sizes mismatch */ template -inline return_type_t beta_binomial_cdf(const T_n& n, - const T_N& N, - const T_size1& alpha, - const T_size2& beta) { +return_type_t beta_binomial_cdf(const T_n& n, const T_N& N, + const T_size1& alpha, + const T_size2& beta) { using T_partials_return = partials_return_t; using std::exp; using T_N_ref = ref_type_t; diff --git a/stan/math/prim/prob/beta_binomial_cdf_log.hpp b/stan/math/prim/prob/beta_binomial_cdf_log.hpp index 83e91971e6f..d881f4978f8 100644 --- a/stan/math/prim/prob/beta_binomial_cdf_log.hpp +++ b/stan/math/prim/prob/beta_binomial_cdf_log.hpp @@ -11,8 +11,10 @@ namespace math { * @deprecated use beta_binomial_lcdf */ template -inline return_type_t beta_binomial_cdf_log( - const T_n& n, const T_N& N, const T_size1& alpha, const T_size2& beta) { +return_type_t beta_binomial_cdf_log(const T_n& n, + const T_N& N, + const T_size1& alpha, + const T_size2& beta) { return beta_binomial_lcdf(n, N, alpha, beta); } diff --git a/stan/math/prim/prob/beta_binomial_lccdf.hpp b/stan/math/prim/prob/beta_binomial_lccdf.hpp index d611d23b700..ea49d864b83 100644 --- a/stan/math/prim/prob/beta_binomial_lccdf.hpp +++ b/stan/math/prim/prob/beta_binomial_lccdf.hpp @@ -41,8 +41,9 @@ namespace math { * @throw std::invalid_argument if container sizes mismatch */ template -inline return_type_t beta_binomial_lccdf( - const T_n& n, const T_N& N, const T_size1& alpha, const T_size2& beta) { +return_type_t beta_binomial_lccdf(const T_n& n, const T_N& N, + const T_size1& alpha, + const T_size2& beta) { using T_partials_return = partials_return_t; using std::exp; using std::log; diff --git a/stan/math/prim/prob/beta_binomial_lcdf.hpp b/stan/math/prim/prob/beta_binomial_lcdf.hpp index eea4ceb5e1e..44b6048a0b0 100644 --- a/stan/math/prim/prob/beta_binomial_lcdf.hpp +++ b/stan/math/prim/prob/beta_binomial_lcdf.hpp @@ -41,10 +41,9 @@ namespace math { * @throw std::invalid_argument if container sizes mismatch */ template -inline return_type_t beta_binomial_lcdf(const T_n& n, - const T_N& N, - const T_size1& alpha, - const T_size2& beta) { +return_type_t beta_binomial_lcdf(const T_n& n, const T_N& N, + const T_size1& alpha, + const T_size2& beta) { using T_partials_return = partials_return_t; using std::exp; using std::log; diff --git a/stan/math/prim/prob/beta_binomial_lpmf.hpp b/stan/math/prim/prob/beta_binomial_lpmf.hpp index 12065ce56aa..18e98ed59bd 100644 --- a/stan/math/prim/prob/beta_binomial_lpmf.hpp +++ b/stan/math/prim/prob/beta_binomial_lpmf.hpp @@ -40,10 +40,9 @@ template * = nullptr> -inline return_type_t beta_binomial_lpmf(const T_n& n, - const T_N& N, - const T_size1& alpha, - const T_size2& beta) { +return_type_t beta_binomial_lpmf(const T_n& n, const T_N& N, + const T_size1& alpha, + const T_size2& beta) { using T_partials_return = partials_return_t; using T_N_ref = ref_type_t; using T_alpha_ref = ref_type_t; @@ -166,10 +165,9 @@ inline return_type_t beta_binomial_lpmf(const T_n& n, } template -inline return_type_t beta_binomial_lpmf(const T_n& n, - const T_N& N, - const T_size1& alpha, - const T_size2& beta) { +return_type_t beta_binomial_lpmf(const T_n& n, const T_N& N, + const T_size1& alpha, + const T_size2& beta) { return beta_binomial_lpmf(n, N, alpha, beta); } diff --git a/stan/math/prim/prob/beta_ccdf_log.hpp b/stan/math/prim/prob/beta_ccdf_log.hpp index 36707a6cb16..ed5f3098192 100644 --- a/stan/math/prim/prob/beta_ccdf_log.hpp +++ b/stan/math/prim/prob/beta_ccdf_log.hpp @@ -11,7 +11,7 @@ namespace math { * @deprecated use beta_lccdf */ template -inline return_type_t beta_ccdf_log( +return_type_t beta_ccdf_log( const T_y& y, const T_scale_succ& alpha, const T_scale_fail& beta) { return beta_lccdf(y, alpha, beta); } diff --git a/stan/math/prim/prob/beta_cdf.hpp b/stan/math/prim/prob/beta_cdf.hpp index b099c8df6ab..3d7d6672dc2 100644 --- a/stan/math/prim/prob/beta_cdf.hpp +++ b/stan/math/prim/prob/beta_cdf.hpp @@ -33,7 +33,7 @@ namespace math { * @tparam T_scale_fail Type of beta. */ template -inline return_type_t beta_cdf( +return_type_t beta_cdf( const T_y& y, const T_scale_succ& alpha, const T_scale_fail& beta) { using T_partials_return = partials_return_t; using T_y_ref = ref_type_t; diff --git a/stan/math/prim/prob/beta_cdf_log.hpp b/stan/math/prim/prob/beta_cdf_log.hpp index 71c74676a33..b7568ece3a0 100644 --- a/stan/math/prim/prob/beta_cdf_log.hpp +++ b/stan/math/prim/prob/beta_cdf_log.hpp @@ -11,7 +11,7 @@ namespace math { * @deprecated use beta_lcdf */ template -inline return_type_t beta_cdf_log( +return_type_t beta_cdf_log( const T_y& y, const T_scale_succ& alpha, const T_scale_fail& beta) { return beta_lcdf(y, alpha, beta); } diff --git a/stan/math/prim/prob/beta_lccdf.hpp b/stan/math/prim/prob/beta_lccdf.hpp index 66232243893..009b2b5d906 100644 --- a/stan/math/prim/prob/beta_lccdf.hpp +++ b/stan/math/prim/prob/beta_lccdf.hpp @@ -38,7 +38,7 @@ namespace math { * @throw std::invalid_argument if container sizes mismatch */ template -inline return_type_t beta_lccdf( +return_type_t beta_lccdf( const T_y& y, const T_scale_succ& alpha, const T_scale_fail& beta_param) { using T_partials_return = partials_return_t; using std::exp; diff --git a/stan/math/prim/prob/beta_lcdf.hpp b/stan/math/prim/prob/beta_lcdf.hpp index c2a514a766c..051ed367116 100644 --- a/stan/math/prim/prob/beta_lcdf.hpp +++ b/stan/math/prim/prob/beta_lcdf.hpp @@ -29,7 +29,7 @@ namespace math { * @tparam T_scale_fail type of failure parameter */ template -inline return_type_t beta_lcdf( +return_type_t beta_lcdf( const T_y& y, const T_scale_succ& alpha, const T_scale_fail& beta_param) { using T_partials_return = partials_return_t; using T_y_ref = ref_type_t; diff --git a/stan/math/prim/prob/beta_lpdf.hpp b/stan/math/prim/prob/beta_lpdf.hpp index 1424d7f5703..e2211c0685b 100644 --- a/stan/math/prim/prob/beta_lpdf.hpp +++ b/stan/math/prim/prob/beta_lpdf.hpp @@ -44,7 +44,7 @@ template * = nullptr> -inline return_type_t beta_lpdf( +return_type_t beta_lpdf( const T_y& y, const T_scale_succ& alpha, const T_scale_fail& beta) { using T_partials_return = partials_return_t; using T_y_ref = ref_type_if_not_constant_t; diff --git a/stan/math/prim/prob/beta_proportion_ccdf_log.hpp b/stan/math/prim/prob/beta_proportion_ccdf_log.hpp index 48cbac8605f..922b3f3fc57 100644 --- a/stan/math/prim/prob/beta_proportion_ccdf_log.hpp +++ b/stan/math/prim/prob/beta_proportion_ccdf_log.hpp @@ -11,7 +11,7 @@ namespace math { * @deprecated use beta_proportion_lccdf */ template -inline return_type_t beta_proportion_ccdf_log( +return_type_t beta_proportion_ccdf_log( const T_y& y, const T_loc& mu, const T_prec& kappa) { return beta_proportion_lccdf(y, mu, kappa); } diff --git a/stan/math/prim/prob/beta_proportion_cdf_log.hpp b/stan/math/prim/prob/beta_proportion_cdf_log.hpp index e504b522604..1db4a6aa55f 100644 --- a/stan/math/prim/prob/beta_proportion_cdf_log.hpp +++ b/stan/math/prim/prob/beta_proportion_cdf_log.hpp @@ -11,8 +11,9 @@ namespace math { * @deprecated use beta_proportion_lcdf */ template -inline return_type_t beta_proportion_cdf_log( - const T_y& y, const T_loc& mu, const T_prec& kappa) { +return_type_t beta_proportion_cdf_log(const T_y& y, + const T_loc& mu, + const T_prec& kappa) { return beta_proportion_lcdf(y, mu, kappa); } diff --git a/stan/math/prim/prob/beta_proportion_lccdf.hpp b/stan/math/prim/prob/beta_proportion_lccdf.hpp index c615d23b0df..34299986203 100644 --- a/stan/math/prim/prob/beta_proportion_lccdf.hpp +++ b/stan/math/prim/prob/beta_proportion_lccdf.hpp @@ -41,8 +41,9 @@ namespace math { * @throw std::invalid_argument if container sizes mismatch */ template -inline return_type_t beta_proportion_lccdf( - const T_y& y, const T_loc& mu, const T_prec& kappa) { +return_type_t beta_proportion_lccdf(const T_y& y, + const T_loc& mu, + const T_prec& kappa) { using T_partials_return = partials_return_t; using std::exp; using std::log; diff --git a/stan/math/prim/prob/beta_proportion_lcdf.hpp b/stan/math/prim/prob/beta_proportion_lcdf.hpp index 5566b8e5fe2..1e177df8e32 100644 --- a/stan/math/prim/prob/beta_proportion_lcdf.hpp +++ b/stan/math/prim/prob/beta_proportion_lcdf.hpp @@ -42,8 +42,9 @@ namespace math { * @throw std::invalid_argument if container sizes mismatch */ template -inline return_type_t beta_proportion_lcdf( - const T_y& y, const T_loc& mu, const T_prec& kappa) { +return_type_t beta_proportion_lcdf(const T_y& y, + const T_loc& mu, + const T_prec& kappa) { using T_partials_return = partials_return_t; using std::exp; using std::log; diff --git a/stan/math/prim/prob/beta_proportion_lpdf.hpp b/stan/math/prim/prob/beta_proportion_lpdf.hpp index 1e60bf521a2..37325ce0b32 100644 --- a/stan/math/prim/prob/beta_proportion_lpdf.hpp +++ b/stan/math/prim/prob/beta_proportion_lpdf.hpp @@ -48,8 +48,9 @@ namespace math { template * = nullptr> -inline return_type_t beta_proportion_lpdf( - const T_y& y, const T_loc& mu, const T_prec& kappa) { +return_type_t beta_proportion_lpdf(const T_y& y, + const T_loc& mu, + const T_prec& kappa) { using T_partials_return = partials_return_t; using std::log; using T_y_ref = ref_type_if_not_constant_t; diff --git a/stan/math/prim/prob/binomial_ccdf_log.hpp b/stan/math/prim/prob/binomial_ccdf_log.hpp index 10d7ce46ea9..ab032100a25 100644 --- a/stan/math/prim/prob/binomial_ccdf_log.hpp +++ b/stan/math/prim/prob/binomial_ccdf_log.hpp @@ -11,8 +11,8 @@ namespace math { * @deprecated use binomial_lccdf */ template -inline return_type_t binomial_ccdf_log(const T_n& n, const T_N& N, - const T_prob& theta) { +return_type_t binomial_ccdf_log(const T_n& n, const T_N& N, + const T_prob& theta) { return binomial_lccdf(n, N, theta); } diff --git a/stan/math/prim/prob/binomial_cdf.hpp b/stan/math/prim/prob/binomial_cdf.hpp index b713a87f0f0..bacbfab8863 100644 --- a/stan/math/prim/prob/binomial_cdf.hpp +++ b/stan/math/prim/prob/binomial_cdf.hpp @@ -33,8 +33,8 @@ namespace math { * @throw std::invalid_argument if container sizes mismatch */ template -inline return_type_t binomial_cdf(const T_n& n, const T_N& N, - const T_prob& theta) { +return_type_t binomial_cdf(const T_n& n, const T_N& N, + const T_prob& theta) { using T_partials_return = partials_return_t; using T_n_ref = ref_type_t; using T_N_ref = ref_type_t; diff --git a/stan/math/prim/prob/binomial_cdf_log.hpp b/stan/math/prim/prob/binomial_cdf_log.hpp index b42a7fccd8e..11446688958 100644 --- a/stan/math/prim/prob/binomial_cdf_log.hpp +++ b/stan/math/prim/prob/binomial_cdf_log.hpp @@ -11,8 +11,8 @@ namespace math { * @deprecated use binomial_lcdf */ template -inline return_type_t binomial_cdf_log(const T_n& n, const T_N& N, - const T_prob& theta) { +return_type_t binomial_cdf_log(const T_n& n, const T_N& N, + const T_prob& theta) { return binomial_lcdf(n, N, theta); } diff --git a/stan/math/prim/prob/binomial_lccdf.hpp b/stan/math/prim/prob/binomial_lccdf.hpp index 5fe97006126..4ac755f762e 100644 --- a/stan/math/prim/prob/binomial_lccdf.hpp +++ b/stan/math/prim/prob/binomial_lccdf.hpp @@ -35,8 +35,8 @@ namespace math { * @throw std::invalid_argument if container sizes mismatch */ template -inline return_type_t binomial_lccdf(const T_n& n, const T_N& N, - const T_prob& theta) { +return_type_t binomial_lccdf(const T_n& n, const T_N& N, + const T_prob& theta) { using T_partials_return = partials_return_t; using T_n_ref = ref_type_t; using T_N_ref = ref_type_t; diff --git a/stan/math/prim/prob/binomial_lcdf.hpp b/stan/math/prim/prob/binomial_lcdf.hpp index bd0a4d882a6..ddd59d10717 100644 --- a/stan/math/prim/prob/binomial_lcdf.hpp +++ b/stan/math/prim/prob/binomial_lcdf.hpp @@ -35,8 +35,8 @@ namespace math { * @throw std::invalid_argument if container sizes mismatch */ template -inline return_type_t binomial_lcdf(const T_n& n, const T_N& N, - const T_prob& theta) { +return_type_t binomial_lcdf(const T_n& n, const T_N& N, + const T_prob& theta) { using T_partials_return = partials_return_t; using T_n_ref = ref_type_t; using T_N_ref = ref_type_t; diff --git a/stan/math/prim/prob/binomial_logit_glm_lpmf.hpp b/stan/math/prim/prob/binomial_logit_glm_lpmf.hpp index 63baf4d0439..95ee260f0bd 100644 --- a/stan/math/prim/prob/binomial_logit_glm_lpmf.hpp +++ b/stan/math/prim/prob/binomial_logit_glm_lpmf.hpp @@ -53,11 +53,15 @@ namespace math { */ template * = nullptr> -inline return_type_t binomial_logit_glm_lpmf( +return_type_t binomial_logit_glm_lpmf( const T_n& n, const T_N& N, const T_x& x, const T_alpha& alpha, const T_beta& beta) { constexpr int T_x_rows = T_x::RowsAtCompileTime; + using T_xbeta_partials = partials_return_t; using T_partials_return = partials_return_t; + using T_xbeta_tmp = + typename std::conditional_t>; using T_n_ref = ref_type_if_t, T_n>; using T_N_ref = ref_type_if_t, T_N>; using T_x_ref = ref_type_if_t, T_x>; @@ -100,7 +104,7 @@ inline return_type_t binomial_logit_glm_lpmf( auto&& x_val = value_of(x_ref); Eigen::Array theta(N_instances); if constexpr (T_x_rows == 1) { - theta = (x_val * beta_val)(0, 0) + alpha_val; + theta = forward_as((x_val * beta_val)(0, 0)) + alpha_val; } else { theta = (x_val * beta_val).array() + alpha_val; } @@ -130,7 +134,9 @@ inline return_type_t binomial_logit_glm_lpmf( if constexpr (is_autodiff_v) { if constexpr (T_x_rows == 1) { - edge<2>(ops_partials).partials_ = theta_derivative.sum() * x_val; + edge<2>(ops_partials).partials_ + = forward_as>( + theta_derivative.sum() * x_val); } else { partials<2>(ops_partials) = x_val.transpose() * theta_derivative; } @@ -138,7 +144,9 @@ inline return_type_t binomial_logit_glm_lpmf( if constexpr (is_autodiff_v) { if constexpr (T_x_rows == 1) { - edge<0>(ops_partials).partials_ = beta_val * theta_derivative.sum(); + edge<0>(ops_partials).partials_ + = forward_as>( + beta_val * theta_derivative.sum()); } else { edge<0>(ops_partials).partials_ = (beta_val * theta_derivative.transpose()).transpose(); diff --git a/stan/math/prim/prob/binomial_logit_lpmf.hpp b/stan/math/prim/prob/binomial_logit_lpmf.hpp index d441c1ec0dc..57725d05a3f 100644 --- a/stan/math/prim/prob/binomial_logit_lpmf.hpp +++ b/stan/math/prim/prob/binomial_logit_lpmf.hpp @@ -34,8 +34,8 @@ namespace math { template * = nullptr> -inline return_type_t binomial_logit_lpmf(const T_n& n, const T_N& N, - const T_prob& alpha) { +return_type_t binomial_logit_lpmf(const T_n& n, const T_N& N, + const T_prob& alpha) { using T_partials_return = partials_return_t; using T_n_ref = ref_type_if_not_constant_t; using T_N_ref = ref_type_if_not_constant_t; diff --git a/stan/math/prim/prob/binomial_lpmf.hpp b/stan/math/prim/prob/binomial_lpmf.hpp index c694df2abe4..06b96882cf9 100644 --- a/stan/math/prim/prob/binomial_lpmf.hpp +++ b/stan/math/prim/prob/binomial_lpmf.hpp @@ -36,8 +36,8 @@ namespace math { template * = nullptr> -inline return_type_t binomial_lpmf(const T_n& n, const T_N& N, - const T_prob& theta) { +return_type_t binomial_lpmf(const T_n& n, const T_N& N, + const T_prob& theta) { using T_partials_return = partials_return_t; using T_n_ref = ref_type_t; using T_N_ref = ref_type_t; diff --git a/stan/math/prim/prob/categorical_logit_glm_lpmf.hpp b/stan/math/prim/prob/categorical_logit_glm_lpmf.hpp index 3e0ffbed3fc..246a624e461 100644 --- a/stan/math/prim/prob/categorical_logit_glm_lpmf.hpp +++ b/stan/math/prim/prob/categorical_logit_glm_lpmf.hpp @@ -44,7 +44,7 @@ template * = nullptr, require_col_vector_t* = nullptr, require_matrix_t* = nullptr> -inline return_type_t categorical_logit_glm_lpmf( +return_type_t categorical_logit_glm_lpmf( const T_y& y, const T_x& x, const T_alpha& alpha, const T_beta& beta) { using T_partials_return = partials_return_t; using Eigen::Array; @@ -194,7 +194,7 @@ inline return_type_t categorical_logit_glm_lpmf( } template -inline return_type_t categorical_logit_glm_lpmf( +return_type_t categorical_logit_glm_lpmf( const T_y& y, const T_x& x, const T_alpha& alpha, const T_beta& beta) { return categorical_logit_glm_lpmf(y, x, alpha, beta); } diff --git a/stan/math/prim/prob/categorical_logit_lpmf.hpp b/stan/math/prim/prob/categorical_logit_lpmf.hpp index 849764a58ea..3483d0080e9 100644 --- a/stan/math/prim/prob/categorical_logit_lpmf.hpp +++ b/stan/math/prim/prob/categorical_logit_lpmf.hpp @@ -14,7 +14,7 @@ namespace math { // CategoricalLog(n|theta) [0 < n <= N, theta unconstrained], no checking template * = nullptr> -inline return_type_t categorical_logit_lpmf(int n, const T_prob& beta) { +return_type_t categorical_logit_lpmf(int n, const T_prob& beta) { static constexpr const char* function = "categorical_logit_lpmf"; check_bounded(function, "categorical outcome out of support", n, 1, beta.size()); @@ -31,8 +31,8 @@ inline return_type_t categorical_logit_lpmf(int n, const T_prob& beta) { } template * = nullptr> -inline return_type_t categorical_logit_lpmf(const std::vector& ns, - const T_prob& beta) { +return_type_t categorical_logit_lpmf(const std::vector& ns, + const T_prob& beta) { static constexpr const char* function = "categorical_logit_lpmf"; check_bounded(function, "categorical outcome out of support", ns, 1, diff --git a/stan/math/prim/prob/categorical_lpmf.hpp b/stan/math/prim/prob/categorical_lpmf.hpp index 637db0f1d04..3c1e57d3990 100644 --- a/stan/math/prim/prob/categorical_lpmf.hpp +++ b/stan/math/prim/prob/categorical_lpmf.hpp @@ -14,7 +14,7 @@ namespace math { // Categorical(n|theta) [0 < n <= N; 0 <= theta[n] <= 1; SUM theta = 1] template * = nullptr> -inline return_type_t categorical_lpmf(int n, const T_prob& theta) { +return_type_t categorical_lpmf(int n, const T_prob& theta) { static constexpr const char* function = "categorical_lpmf"; using std::log; @@ -30,8 +30,8 @@ inline return_type_t categorical_lpmf(int n, const T_prob& theta) { template * = nullptr> -inline return_type_t categorical_lpmf(const std::vector& ns, - const T_prob& theta) { +return_type_t categorical_lpmf(const std::vector& ns, + const T_prob& theta) { static constexpr const char* function = "categorical_lpmf"; check_bounded(function, "element of outcome array", ns, 1, theta.size()); diff --git a/stan/math/prim/prob/cauchy_ccdf_log.hpp b/stan/math/prim/prob/cauchy_ccdf_log.hpp index cbc7a185afd..03b6ca23cd7 100644 --- a/stan/math/prim/prob/cauchy_ccdf_log.hpp +++ b/stan/math/prim/prob/cauchy_ccdf_log.hpp @@ -11,8 +11,9 @@ namespace math { * @deprecated use cauchy_lccdf */ template -inline return_type_t cauchy_ccdf_log( - const T_y& y, const T_loc& mu, const T_scale& sigma) { +return_type_t cauchy_ccdf_log(const T_y& y, + const T_loc& mu, + const T_scale& sigma) { return cauchy_lccdf(y, mu, sigma); } diff --git a/stan/math/prim/prob/cauchy_cdf.hpp b/stan/math/prim/prob/cauchy_cdf.hpp index 2bcff3fadfd..59f8c79a033 100644 --- a/stan/math/prim/prob/cauchy_cdf.hpp +++ b/stan/math/prim/prob/cauchy_cdf.hpp @@ -32,9 +32,8 @@ namespace math { template * = nullptr> -inline return_type_t cauchy_cdf(const T_y& y, - const T_loc& mu, - const T_scale& sigma) { +return_type_t cauchy_cdf(const T_y& y, const T_loc& mu, + const T_scale& sigma) { using T_partials_return = partials_return_t; using std::atan; using T_y_ref = ref_type_t; diff --git a/stan/math/prim/prob/cauchy_cdf_log.hpp b/stan/math/prim/prob/cauchy_cdf_log.hpp index 3f14da9091e..bdcb2b0dfc8 100644 --- a/stan/math/prim/prob/cauchy_cdf_log.hpp +++ b/stan/math/prim/prob/cauchy_cdf_log.hpp @@ -11,9 +11,8 @@ namespace math { * @deprecated use cauchy_lcdf */ template -inline return_type_t cauchy_cdf_log(const T_y& y, - const T_loc& mu, - const T_scale& sigma) { +return_type_t cauchy_cdf_log(const T_y& y, const T_loc& mu, + const T_scale& sigma) { return cauchy_lcdf(y, mu, sigma); } diff --git a/stan/math/prim/prob/cauchy_lccdf.hpp b/stan/math/prim/prob/cauchy_lccdf.hpp index a5274780421..cb4fa9b16aa 100644 --- a/stan/math/prim/prob/cauchy_lccdf.hpp +++ b/stan/math/prim/prob/cauchy_lccdf.hpp @@ -34,9 +34,8 @@ namespace math { template * = nullptr> -inline return_type_t cauchy_lccdf(const T_y& y, - const T_loc& mu, - const T_scale& sigma) { +return_type_t cauchy_lccdf(const T_y& y, const T_loc& mu, + const T_scale& sigma) { using T_partials_return = partials_return_t; using T_y_ref = ref_type_t; using T_mu_ref = ref_type_t; diff --git a/stan/math/prim/prob/cauchy_lcdf.hpp b/stan/math/prim/prob/cauchy_lcdf.hpp index 7bf11474eda..84f0bac8618 100644 --- a/stan/math/prim/prob/cauchy_lcdf.hpp +++ b/stan/math/prim/prob/cauchy_lcdf.hpp @@ -34,9 +34,8 @@ namespace math { template * = nullptr> -inline return_type_t cauchy_lcdf(const T_y& y, - const T_loc& mu, - const T_scale& sigma) { +return_type_t cauchy_lcdf(const T_y& y, const T_loc& mu, + const T_scale& sigma) { using T_partials_return = partials_return_t; using T_y_ref = ref_type_t; using T_mu_ref = ref_type_t; diff --git a/stan/math/prim/prob/cauchy_lpdf.hpp b/stan/math/prim/prob/cauchy_lpdf.hpp index 703939adf9f..cffc8db8dec 100644 --- a/stan/math/prim/prob/cauchy_lpdf.hpp +++ b/stan/math/prim/prob/cauchy_lpdf.hpp @@ -40,9 +40,8 @@ namespace math { template * = nullptr> -inline return_type_t cauchy_lpdf(const T_y& y, - const T_loc& mu, - const T_scale& sigma) { +return_type_t cauchy_lpdf(const T_y& y, const T_loc& mu, + const T_scale& sigma) { using T_partials_return = partials_return_t; using std::log; using T_y_ref = ref_type_if_not_constant_t; diff --git a/stan/math/prim/prob/chi_square_ccdf_log.hpp b/stan/math/prim/prob/chi_square_ccdf_log.hpp index 11d87ca812e..845b8ce261e 100644 --- a/stan/math/prim/prob/chi_square_ccdf_log.hpp +++ b/stan/math/prim/prob/chi_square_ccdf_log.hpp @@ -11,8 +11,7 @@ namespace math { * @deprecated use chi_square_lccdf */ template -inline return_type_t chi_square_ccdf_log(const T_y& y, - const T_dof& nu) { +return_type_t chi_square_ccdf_log(const T_y& y, const T_dof& nu) { return chi_square_lccdf(y, nu); } diff --git a/stan/math/prim/prob/chi_square_cdf.hpp b/stan/math/prim/prob/chi_square_cdf.hpp index 46e0ea4e623..02313f673f2 100644 --- a/stan/math/prim/prob/chi_square_cdf.hpp +++ b/stan/math/prim/prob/chi_square_cdf.hpp @@ -34,7 +34,7 @@ namespace math { * @throw std::invalid_argument if container sizes mismatch */ template -inline return_type_t chi_square_cdf(const T_y& y, const T_dof& nu) { +return_type_t chi_square_cdf(const T_y& y, const T_dof& nu) { using T_partials_return = partials_return_t; using std::exp; using std::pow; diff --git a/stan/math/prim/prob/chi_square_cdf_log.hpp b/stan/math/prim/prob/chi_square_cdf_log.hpp index a026477de99..2eabcd2af8b 100644 --- a/stan/math/prim/prob/chi_square_cdf_log.hpp +++ b/stan/math/prim/prob/chi_square_cdf_log.hpp @@ -11,8 +11,7 @@ namespace math { * @deprecated use chi_square_lcdf */ template -inline return_type_t chi_square_cdf_log(const T_y& y, - const T_dof& nu) { +return_type_t chi_square_cdf_log(const T_y& y, const T_dof& nu) { return chi_square_lcdf(y, nu); } diff --git a/stan/math/prim/prob/chi_square_lccdf.hpp b/stan/math/prim/prob/chi_square_lccdf.hpp index 29da6302dc0..7c7ae4c47b6 100644 --- a/stan/math/prim/prob/chi_square_lccdf.hpp +++ b/stan/math/prim/prob/chi_square_lccdf.hpp @@ -35,8 +35,7 @@ namespace math { * @throw std::invalid_argument if container sizes mismatch */ template -inline return_type_t chi_square_lccdf(const T_y& y, - const T_dof& nu) { +return_type_t chi_square_lccdf(const T_y& y, const T_dof& nu) { using T_partials_return = partials_return_t; using std::exp; using std::log; diff --git a/stan/math/prim/prob/chi_square_lcdf.hpp b/stan/math/prim/prob/chi_square_lcdf.hpp index c75e14f8b14..3e0a6d363f5 100644 --- a/stan/math/prim/prob/chi_square_lcdf.hpp +++ b/stan/math/prim/prob/chi_square_lcdf.hpp @@ -35,8 +35,7 @@ namespace math { * @throw std::invalid_argument if container sizes mismatch */ template -inline return_type_t chi_square_lcdf(const T_y& y, - const T_dof& nu) { +return_type_t chi_square_lcdf(const T_y& y, const T_dof& nu) { using T_partials_return = partials_return_t; using std::exp; using std::log; diff --git a/stan/math/prim/prob/chi_square_lpdf.hpp b/stan/math/prim/prob/chi_square_lpdf.hpp index e8f1732c3aa..8642f1f91ca 100644 --- a/stan/math/prim/prob/chi_square_lpdf.hpp +++ b/stan/math/prim/prob/chi_square_lpdf.hpp @@ -43,9 +43,9 @@ namespace math { template * = nullptr> -inline return_type_t chi_square_lpdf(const T_y& y, - const T_dof& nu) { +return_type_t chi_square_lpdf(const T_y& y, const T_dof& nu) { using T_partials_return = partials_return_t; + using T_partials_array = Eigen::Array; using std::log; static constexpr const char* function = "chi_square_lpdf"; using T_y_ref = ref_type_t; @@ -88,8 +88,8 @@ inline return_type_t chi_square_lpdf(const T_y& y, } if constexpr (is_autodiff_v) { if constexpr (is_vector::value) { - partials<1>(ops_partials) - = (log_y - digamma(half_nu)) * 0.5 - HALF_LOG_TWO; + partials<1>(ops_partials) = forward_as( + (log_y - digamma(half_nu)) * 0.5 - HALF_LOG_TWO); } else { partials<1>(ops_partials)[0] = sum(log_y - digamma(half_nu)) * 0.5 - HALF_LOG_TWO * N; diff --git a/stan/math/prim/prob/dirichlet_lpdf.hpp b/stan/math/prim/prob/dirichlet_lpdf.hpp index 57d61668141..8339f532724 100644 --- a/stan/math/prim/prob/dirichlet_lpdf.hpp +++ b/stan/math/prim/prob/dirichlet_lpdf.hpp @@ -56,8 +56,8 @@ namespace math { template * = nullptr> -inline return_type_t dirichlet_lpdf( - const T_prob& theta, const T_prior_size& alpha) { +return_type_t dirichlet_lpdf(const T_prob& theta, + const T_prior_size& alpha) { using T_partials_return = partials_return_t; using T_partials_array = typename Eigen::Array; using T_theta_ref = ref_type_t; @@ -125,8 +125,8 @@ inline return_type_t dirichlet_lpdf( } template -inline return_type_t dirichlet_lpdf( - const T_prob& theta, const T_prior_size& alpha) { +return_type_t dirichlet_lpdf(const T_prob& theta, + const T_prior_size& alpha) { return dirichlet_lpdf(theta, alpha); } diff --git a/stan/math/prim/prob/dirichlet_multinomial_lpmf.hpp b/stan/math/prim/prob/dirichlet_multinomial_lpmf.hpp index b371cfb340d..3bebbb0bab0 100644 --- a/stan/math/prim/prob/dirichlet_multinomial_lpmf.hpp +++ b/stan/math/prim/prob/dirichlet_multinomial_lpmf.hpp @@ -57,7 +57,7 @@ namespace math { template * = nullptr> -inline return_type_t dirichlet_multinomial_lpmf( +return_type_t dirichlet_multinomial_lpmf( const std::vector& ns, const T_prior_size& alpha) { static const char* function = "dirichlet_multinomial_lpmf"; check_size_match(function, "Size of number of trials variable", ns.size(), @@ -98,7 +98,7 @@ inline return_type_t dirichlet_multinomial_lpmf( } template -inline return_type_t dirichlet_multinomial_lpmf( +return_type_t dirichlet_multinomial_lpmf( const std::vector& ns, const T_prior_size& alpha) { return dirichlet_multinomial_lpmf(ns, alpha); } diff --git a/stan/math/prim/prob/discrete_range_ccdf_log.hpp b/stan/math/prim/prob/discrete_range_ccdf_log.hpp index 1cca4e7072a..324192e8c72 100644 --- a/stan/math/prim/prob/discrete_range_ccdf_log.hpp +++ b/stan/math/prim/prob/discrete_range_ccdf_log.hpp @@ -10,8 +10,8 @@ namespace math { * @deprecated use discrete_range_lccdf */ template -inline double discrete_range_ccdf_log(const T_y& y, const T_lower& lower, - const T_upper& upper) { +double discrete_range_ccdf_log(const T_y& y, const T_lower& lower, + const T_upper& upper) { return discrete_range_lccdf(y, lower, upper); } diff --git a/stan/math/prim/prob/discrete_range_cdf.hpp b/stan/math/prim/prob/discrete_range_cdf.hpp index 777e3f21769..49c18842244 100644 --- a/stan/math/prim/prob/discrete_range_cdf.hpp +++ b/stan/math/prim/prob/discrete_range_cdf.hpp @@ -35,8 +35,8 @@ namespace math { * sizes. */ template -inline double discrete_range_cdf(const T_y& y, const T_lower& lower, - const T_upper& upper) { +double discrete_range_cdf(const T_y& y, const T_lower& lower, + const T_upper& upper) { static constexpr const char* function = "discrete_range_cdf"; check_consistent_sizes(function, "Lower bound parameter", lower, "Upper bound parameter", upper); diff --git a/stan/math/prim/prob/discrete_range_cdf_log.hpp b/stan/math/prim/prob/discrete_range_cdf_log.hpp index da08c1c6f40..c21d7e17014 100644 --- a/stan/math/prim/prob/discrete_range_cdf_log.hpp +++ b/stan/math/prim/prob/discrete_range_cdf_log.hpp @@ -10,8 +10,8 @@ namespace math { * @deprecated use discrete_range_lcdf */ template -inline double discrete_range_cdf_log(const T_y& y, const T_lower& lower, - const T_upper& upper) { +double discrete_range_cdf_log(const T_y& y, const T_lower& lower, + const T_upper& upper) { return discrete_range_lcdf(y, lower, upper); } diff --git a/stan/math/prim/prob/discrete_range_lccdf.hpp b/stan/math/prim/prob/discrete_range_lccdf.hpp index 54e82deb0de..1c67cee0417 100644 --- a/stan/math/prim/prob/discrete_range_lccdf.hpp +++ b/stan/math/prim/prob/discrete_range_lccdf.hpp @@ -35,8 +35,8 @@ namespace math { * sizes. */ template -inline double discrete_range_lccdf(const T_y& y, const T_lower& lower, - const T_upper& upper) { +double discrete_range_lccdf(const T_y& y, const T_lower& lower, + const T_upper& upper) { static constexpr const char* function = "discrete_range_lccdf"; check_consistent_sizes(function, "Lower bound parameter", lower, "Upper bound parameter", upper); diff --git a/stan/math/prim/prob/discrete_range_lcdf.hpp b/stan/math/prim/prob/discrete_range_lcdf.hpp index 5d73f051949..8a64df8bc29 100644 --- a/stan/math/prim/prob/discrete_range_lcdf.hpp +++ b/stan/math/prim/prob/discrete_range_lcdf.hpp @@ -35,8 +35,8 @@ namespace math { * sizes. */ template -inline double discrete_range_lcdf(const T_y& y, const T_lower& lower, - const T_upper& upper) { +double discrete_range_lcdf(const T_y& y, const T_lower& lower, + const T_upper& upper) { static constexpr const char* function = "discrete_range_lcdf"; check_consistent_sizes(function, "Lower bound parameter", lower, "Upper bound parameter", upper); diff --git a/stan/math/prim/prob/discrete_range_lpmf.hpp b/stan/math/prim/prob/discrete_range_lpmf.hpp index f847eb95396..87cfd110f2f 100644 --- a/stan/math/prim/prob/discrete_range_lpmf.hpp +++ b/stan/math/prim/prob/discrete_range_lpmf.hpp @@ -43,8 +43,8 @@ namespace math { * sizes. */ template -inline double discrete_range_lpmf(const T_y& y, const T_lower& lower, - const T_upper& upper) { +double discrete_range_lpmf(const T_y& y, const T_lower& lower, + const T_upper& upper) { using std::log; static constexpr const char* function = "discrete_range_lpmf"; check_not_nan(function, "Random variable", y); diff --git a/stan/math/prim/prob/double_exponential_ccdf_log.hpp b/stan/math/prim/prob/double_exponential_ccdf_log.hpp index c40404c7809..a66dfab81c6 100644 --- a/stan/math/prim/prob/double_exponential_ccdf_log.hpp +++ b/stan/math/prim/prob/double_exponential_ccdf_log.hpp @@ -11,7 +11,7 @@ namespace math { * @deprecated use double_exponential_lccdf */ template -inline return_type_t double_exponential_ccdf_log( +return_type_t double_exponential_ccdf_log( const T_y& y, const T_loc& mu, const T_scale& sigma) { return double_exponential_lccdf(y, mu, sigma); } diff --git a/stan/math/prim/prob/double_exponential_cdf.hpp b/stan/math/prim/prob/double_exponential_cdf.hpp index b092928d214..7b2ee5ff6fa 100644 --- a/stan/math/prim/prob/double_exponential_cdf.hpp +++ b/stan/math/prim/prob/double_exponential_cdf.hpp @@ -36,7 +36,7 @@ namespace math { template * = nullptr> -inline return_type_t double_exponential_cdf( +return_type_t double_exponential_cdf( const T_y& y, const T_loc& mu, const T_scale& sigma) { using T_partials_return = partials_return_t; using T_partials_array = Eigen::Array; @@ -75,21 +75,28 @@ inline return_type_t double_exponential_cdf( T_rep_deriv rep_deriv; if constexpr (is_vector::value || is_vector::value) { - cdf = (y_val < mu_val) - .select(exp_scaled_diff * 0.5, 1.0 - 0.5 / exp_scaled_diff) + using array_bool = Eigen::Array; + cdf = forward_as(y_val < mu_val) + .select(forward_as(exp_scaled_diff * 0.5), + 1.0 - 0.5 / exp_scaled_diff) .prod(); - rep_deriv = (y_val < mu_val) - .select((cdf * inv_sigma), - cdf * inv_sigma / (2 * exp_scaled_diff - 1)); + rep_deriv = forward_as( + forward_as(y_val < mu_val) + .select((cdf * inv_sigma), + forward_as(cdf * inv_sigma + / (2 * exp_scaled_diff - 1)))); } else { if constexpr (is_vector::value) { - cdf = (y_val < mu_val) ? (exp_scaled_diff * 0.5).prod() - : (1.0 - 0.5 / exp_scaled_diff).prod(); + cdf = forward_as(y_val < mu_val) + ? forward_as(exp_scaled_diff * 0.5).prod() + : forward_as(1.0 - 0.5 / exp_scaled_diff) + .prod(); } else { - cdf = (y_val < mu_val) ? exp_scaled_diff * 0.5 - : 1.0 - 0.5 / exp_scaled_diff; + cdf = forward_as(y_val < mu_val) + ? forward_as(exp_scaled_diff * 0.5) + : forward_as(1.0 - 0.5 / exp_scaled_diff); } - if (y_val < mu_val) { + if (forward_as(y_val < mu_val)) { rep_deriv = cdf * inv_sigma; } else { rep_deriv = cdf * inv_sigma / (2 * exp_scaled_diff - 1); diff --git a/stan/math/prim/prob/double_exponential_cdf_log.hpp b/stan/math/prim/prob/double_exponential_cdf_log.hpp index f4447ae0a08..ee209635f12 100644 --- a/stan/math/prim/prob/double_exponential_cdf_log.hpp +++ b/stan/math/prim/prob/double_exponential_cdf_log.hpp @@ -11,7 +11,7 @@ namespace math { * @deprecated use double_exponential_lcdf */ template -inline return_type_t double_exponential_cdf_log( +return_type_t double_exponential_cdf_log( const T_y& y, const T_loc& mu, const T_scale& sigma) { return double_exponential_lcdf(y, mu, sigma); } diff --git a/stan/math/prim/prob/double_exponential_lccdf.hpp b/stan/math/prim/prob/double_exponential_lccdf.hpp index 0c24a32825f..b39e7d66503 100644 --- a/stan/math/prim/prob/double_exponential_lccdf.hpp +++ b/stan/math/prim/prob/double_exponential_lccdf.hpp @@ -35,7 +35,7 @@ namespace math { template * = nullptr> -inline return_type_t double_exponential_lccdf( +return_type_t double_exponential_lccdf( const T_y& y, const T_loc& mu, const T_scale& sigma) { using T_partials_return = partials_return_t; using std::exp; diff --git a/stan/math/prim/prob/double_exponential_lcdf.hpp b/stan/math/prim/prob/double_exponential_lcdf.hpp index db264576c57..5ea11d1d25c 100644 --- a/stan/math/prim/prob/double_exponential_lcdf.hpp +++ b/stan/math/prim/prob/double_exponential_lcdf.hpp @@ -34,7 +34,7 @@ namespace math { template * = nullptr> -inline return_type_t double_exponential_lcdf( +return_type_t double_exponential_lcdf( const T_y& y, const T_loc& mu, const T_scale& sigma) { using T_partials_return = partials_return_t; using std::exp; diff --git a/stan/math/prim/prob/double_exponential_lpdf.hpp b/stan/math/prim/prob/double_exponential_lpdf.hpp index 6181e7853bf..fd88aa9e338 100644 --- a/stan/math/prim/prob/double_exponential_lpdf.hpp +++ b/stan/math/prim/prob/double_exponential_lpdf.hpp @@ -39,7 +39,7 @@ namespace math { template * = nullptr> -inline return_type_t double_exponential_lpdf( +return_type_t double_exponential_lpdf( const T_y& y, const T_loc& mu, const T_scale& sigma) { using T_partials_return = partials_return_t; using T_y_ref = ref_type_if_not_constant_t; @@ -105,7 +105,7 @@ inline return_type_t double_exponential_lpdf( } template -inline return_type_t double_exponential_lpdf( +return_type_t double_exponential_lpdf( const T_y& y, const T_loc& mu, const T_scale& sigma) { return double_exponential_lpdf(y, mu, sigma); } diff --git a/stan/math/prim/prob/exp_mod_normal_ccdf_log.hpp b/stan/math/prim/prob/exp_mod_normal_ccdf_log.hpp index c5a84309029..97be1160140 100644 --- a/stan/math/prim/prob/exp_mod_normal_ccdf_log.hpp +++ b/stan/math/prim/prob/exp_mod_normal_ccdf_log.hpp @@ -11,7 +11,7 @@ namespace math { * @deprecated use exp_mod_normal_lccdf */ template -inline return_type_t exp_mod_normal_ccdf_log( +return_type_t exp_mod_normal_ccdf_log( const T_y& y, const T_loc& mu, const T_scale& sigma, const T_inv_scale& lambda) { return exp_mod_normal_lccdf(y, mu, sigma, diff --git a/stan/math/prim/prob/exp_mod_normal_cdf.hpp b/stan/math/prim/prob/exp_mod_normal_cdf.hpp index 01719d716b2..ae7eb72ed8b 100644 --- a/stan/math/prim/prob/exp_mod_normal_cdf.hpp +++ b/stan/math/prim/prob/exp_mod_normal_cdf.hpp @@ -26,10 +26,11 @@ namespace math { template * = nullptr> -inline return_type_t exp_mod_normal_cdf( +return_type_t exp_mod_normal_cdf( const T_y& y, const T_loc& mu, const T_scale& sigma, const T_inv_scale& lambda) { using T_partials_return = partials_return_t; + using T_partials_array = Eigen::Array; using T_y_ref = ref_type_if_not_constant_t; using T_mu_ref = ref_type_if_not_constant_t; using T_sigma_ref = ref_type_if_not_constant_t; @@ -61,12 +62,15 @@ inline return_type_t exp_mod_normal_cdf( auto ops_partials = make_partials_propagator(y_ref, mu_ref, sigma_ref, lambda_ref); + using T_y_val_scalar = scalar_type_t; if constexpr (is_vector::value) { - if ((y_val == NEGATIVE_INFTY).any()) { + if ((forward_as>(y_val) + == NEGATIVE_INFTY) + .any()) { return ops_partials.build(0.0); } } else { - if (y_val == NEGATIVE_INFTY) { + if (forward_as(y_val) == NEGATIVE_INFTY) { return ops_partials.build(0.0); } } @@ -89,9 +93,9 @@ inline return_type_t exp_mod_normal_cdf( T_partials_return cdf(1.0); if constexpr (is_vector::value) { - cdf = cdf_n.prod(); + cdf = forward_as(cdf_n).prod(); } else { - cdf = cdf_n; + cdf = forward_as(cdf_n); } if constexpr (is_any_autodiff_v) { diff --git a/stan/math/prim/prob/exp_mod_normal_cdf_log.hpp b/stan/math/prim/prob/exp_mod_normal_cdf_log.hpp index 4908971ad37..e04f04f77c9 100644 --- a/stan/math/prim/prob/exp_mod_normal_cdf_log.hpp +++ b/stan/math/prim/prob/exp_mod_normal_cdf_log.hpp @@ -11,7 +11,7 @@ namespace math { * @deprecated use exp_mod_normal_lcdf */ template -inline return_type_t exp_mod_normal_cdf_log( +return_type_t exp_mod_normal_cdf_log( const T_y& y, const T_loc& mu, const T_scale& sigma, const T_inv_scale& lambda) { return exp_mod_normal_lcdf(y, mu, sigma, diff --git a/stan/math/prim/prob/exp_mod_normal_lccdf.hpp b/stan/math/prim/prob/exp_mod_normal_lccdf.hpp index 44d29b3cb67..4681e7ffef6 100644 --- a/stan/math/prim/prob/exp_mod_normal_lccdf.hpp +++ b/stan/math/prim/prob/exp_mod_normal_lccdf.hpp @@ -28,7 +28,7 @@ namespace math { template * = nullptr> -inline return_type_t exp_mod_normal_lccdf( +return_type_t exp_mod_normal_lccdf( const T_y& y, const T_loc& mu, const T_scale& sigma, const T_inv_scale& lambda) { using T_partials_return = partials_return_t; diff --git a/stan/math/prim/prob/exp_mod_normal_lcdf.hpp b/stan/math/prim/prob/exp_mod_normal_lcdf.hpp index fce9deae953..4e212fded85 100644 --- a/stan/math/prim/prob/exp_mod_normal_lcdf.hpp +++ b/stan/math/prim/prob/exp_mod_normal_lcdf.hpp @@ -28,7 +28,7 @@ namespace math { template * = nullptr> -inline return_type_t exp_mod_normal_lcdf( +return_type_t exp_mod_normal_lcdf( const T_y& y, const T_loc& mu, const T_scale& sigma, const T_inv_scale& lambda) { using T_partials_return = partials_return_t; diff --git a/stan/math/prim/prob/exp_mod_normal_lpdf.hpp b/stan/math/prim/prob/exp_mod_normal_lpdf.hpp index d0a59719072..f2b8b5f2867 100644 --- a/stan/math/prim/prob/exp_mod_normal_lpdf.hpp +++ b/stan/math/prim/prob/exp_mod_normal_lpdf.hpp @@ -26,7 +26,7 @@ template * = nullptr> -inline return_type_t exp_mod_normal_lpdf( +return_type_t exp_mod_normal_lpdf( const T_y& y, const T_loc& mu, const T_scale& sigma, const T_inv_scale& lambda) { using T_partials_return = partials_return_t; diff --git a/stan/math/prim/prob/exponential_ccdf_log.hpp b/stan/math/prim/prob/exponential_ccdf_log.hpp index 61047d3aa5c..dec72eff28d 100644 --- a/stan/math/prim/prob/exponential_ccdf_log.hpp +++ b/stan/math/prim/prob/exponential_ccdf_log.hpp @@ -11,8 +11,8 @@ namespace math { * @deprecated use exponential_lccdf */ template -inline return_type_t exponential_ccdf_log( - const T_y& y, const T_inv_scale& beta) { +return_type_t exponential_ccdf_log(const T_y& y, + const T_inv_scale& beta) { return exponential_lccdf(y, beta); } diff --git a/stan/math/prim/prob/exponential_cdf.hpp b/stan/math/prim/prob/exponential_cdf.hpp index aa7155bfe3d..26915bbffe5 100644 --- a/stan/math/prim/prob/exponential_cdf.hpp +++ b/stan/math/prim/prob/exponential_cdf.hpp @@ -32,9 +32,10 @@ namespace math { template * = nullptr> -inline return_type_t exponential_cdf( - const T_y& y, const T_inv_scale& beta) { +return_type_t exponential_cdf(const T_y& y, + const T_inv_scale& beta) { using T_partials_return = partials_return_t; + using T_partials_array = Eigen::Array; using T_y_ref = ref_type_if_not_constant_t; using T_beta_ref = ref_type_if_not_constant_t; static constexpr const char* function = "exponential_cdf"; @@ -59,9 +60,9 @@ inline return_type_t exponential_cdf( T_partials_return cdf(1.0); if constexpr (is_vector::value || is_vector::value) { - cdf = one_m_exp.prod(); + cdf = forward_as(one_m_exp).prod(); } else { - cdf = one_m_exp; + cdf = forward_as(one_m_exp); } if constexpr (any_derivatives) { diff --git a/stan/math/prim/prob/exponential_cdf_log.hpp b/stan/math/prim/prob/exponential_cdf_log.hpp index b2e53909d29..fd7d58ddad0 100644 --- a/stan/math/prim/prob/exponential_cdf_log.hpp +++ b/stan/math/prim/prob/exponential_cdf_log.hpp @@ -11,8 +11,8 @@ namespace math { * @deprecated use exponential_lcdf */ template -inline return_type_t exponential_cdf_log( - const T_y& y, const T_inv_scale& beta) { +return_type_t exponential_cdf_log(const T_y& y, + const T_inv_scale& beta) { return exponential_lcdf(y, beta); } diff --git a/stan/math/prim/prob/exponential_lccdf.hpp b/stan/math/prim/prob/exponential_lccdf.hpp index a672c357bb9..e6d4cdfc803 100644 --- a/stan/math/prim/prob/exponential_lccdf.hpp +++ b/stan/math/prim/prob/exponential_lccdf.hpp @@ -17,8 +17,8 @@ namespace math { template * = nullptr> -inline return_type_t exponential_lccdf( - const T_y& y, const T_inv_scale& beta) { +return_type_t exponential_lccdf(const T_y& y, + const T_inv_scale& beta) { using T_partials_return = partials_return_t; using T_partials_array = Eigen::Array; using T_y_ref = ref_type_if_not_constant_t; @@ -42,21 +42,25 @@ inline return_type_t exponential_lccdf( T_partials_return ccdf_log = -sum(beta_val * y_val); if constexpr (is_autodiff_v) { + using beta_val_scalar = scalar_type_t; + using beta_val_array = Eigen::Array; if constexpr (is_vector::value && !is_vector::value) { - partials<0>(ops_partials) - = T_partials_array::Constant(math::size(y), -beta_val); + partials<0>(ops_partials) = T_partials_array::Constant( + math::size(y), -forward_as(beta_val)); } else if constexpr (is_vector::value) { - partials<0>(ops_partials) = -beta_val; + partials<0>(ops_partials) = -forward_as(beta_val); } else { partials<0>(ops_partials)[0] = -sum(beta_val); } } if constexpr (is_autodiff_v) { + using y_val_scalar = scalar_type_t; + using y_val_array = Eigen::Array; if constexpr (is_vector::value && !is_vector::value) { - partials<1>(ops_partials) - = T_partials_array::Constant(math::size(beta), -y_val); + partials<1>(ops_partials) = T_partials_array::Constant( + math::size(beta), -forward_as(y_val)); } else if constexpr (is_vector::value) { - partials<1>(ops_partials) = -y_val; + partials<1>(ops_partials) = -forward_as(y_val); } else { partials<1>(ops_partials)[0] = -sum(y_val); } diff --git a/stan/math/prim/prob/exponential_lcdf.hpp b/stan/math/prim/prob/exponential_lcdf.hpp index 5236fc1a9e8..c0fc2243385 100644 --- a/stan/math/prim/prob/exponential_lcdf.hpp +++ b/stan/math/prim/prob/exponential_lcdf.hpp @@ -21,8 +21,8 @@ namespace math { template * = nullptr> -inline return_type_t exponential_lcdf( - const T_y& y, const T_inv_scale& beta) { +return_type_t exponential_lcdf(const T_y& y, + const T_inv_scale& beta) { using T_partials_return = partials_return_t; using T_y_ref = ref_type_if_not_constant_t; using T_beta_ref = ref_type_if_not_constant_t; diff --git a/stan/math/prim/prob/exponential_lpdf.hpp b/stan/math/prim/prob/exponential_lpdf.hpp index e3987fcbe46..1157b6397b4 100644 --- a/stan/math/prim/prob/exponential_lpdf.hpp +++ b/stan/math/prim/prob/exponential_lpdf.hpp @@ -49,8 +49,8 @@ namespace math { template * = nullptr> -inline return_type_t exponential_lpdf( - const T_y& y, const T_inv_scale& beta) { +return_type_t exponential_lpdf(const T_y& y, + const T_inv_scale& beta) { using T_partials_return = partials_return_t; using T_partials_array = Eigen::Array; using T_y_ref = ref_type_if_not_constant_t; @@ -82,13 +82,17 @@ inline return_type_t exponential_lpdf( } if constexpr (is_autodiff_v) { + using beta_val_scalar = scalar_type_t; + using beta_val_array = Eigen::Array; if constexpr (is_vector::value && !is_vector::value) { - partials<0>(ops_partials) - = T_partials_array::Constant(math::size(y), -beta_val); + partials<0>(ops_partials) = T_partials_array::Constant( + math::size(y), -forward_as(beta_val)); } else if constexpr (is_vector::value) { - partials<0>(ops_partials) = -beta_val; + partials<0>(ops_partials) = -forward_as(beta_val); } else { - partials<0>(ops_partials) = -beta_val; + forward_as>( + partials<0>(ops_partials)) + = -forward_as(beta_val); } } if constexpr (is_autodiff_v) { diff --git a/stan/math/prim/prob/frechet_ccdf_log.hpp b/stan/math/prim/prob/frechet_ccdf_log.hpp index 8ba109a2dc9..16888cdf6cf 100644 --- a/stan/math/prim/prob/frechet_ccdf_log.hpp +++ b/stan/math/prim/prob/frechet_ccdf_log.hpp @@ -11,8 +11,9 @@ namespace math { * @deprecated use frechet_lccdf */ template -inline return_type_t frechet_ccdf_log( - const T_y& y, const T_shape& alpha, const T_scale& sigma) { +return_type_t frechet_ccdf_log(const T_y& y, + const T_shape& alpha, + const T_scale& sigma) { return frechet_lccdf(y, alpha, sigma); } diff --git a/stan/math/prim/prob/frechet_cdf.hpp b/stan/math/prim/prob/frechet_cdf.hpp index e57a90f0bb0..d395e4fa4e9 100644 --- a/stan/math/prim/prob/frechet_cdf.hpp +++ b/stan/math/prim/prob/frechet_cdf.hpp @@ -25,9 +25,9 @@ namespace math { template * = nullptr> -inline return_type_t frechet_cdf(const T_y& y, - const T_shape& alpha, - const T_scale& sigma) { +return_type_t frechet_cdf(const T_y& y, + const T_shape& alpha, + const T_scale& sigma) { using T_partials_return = partials_return_t; using T_y_ref = ref_type_t; using T_alpha_ref = ref_type_t; diff --git a/stan/math/prim/prob/frechet_cdf_log.hpp b/stan/math/prim/prob/frechet_cdf_log.hpp index 53b9f0beec3..0474e32f96f 100644 --- a/stan/math/prim/prob/frechet_cdf_log.hpp +++ b/stan/math/prim/prob/frechet_cdf_log.hpp @@ -11,8 +11,9 @@ namespace math { * @deprecated use frechet_lcdf */ template -inline return_type_t frechet_cdf_log( - const T_y& y, const T_shape& alpha, const T_scale& sigma) { +return_type_t frechet_cdf_log(const T_y& y, + const T_shape& alpha, + const T_scale& sigma) { return frechet_lcdf(y, alpha, sigma); } diff --git a/stan/math/prim/prob/frechet_lccdf.hpp b/stan/math/prim/prob/frechet_lccdf.hpp index 6226d64c92d..ede31ddc105 100644 --- a/stan/math/prim/prob/frechet_lccdf.hpp +++ b/stan/math/prim/prob/frechet_lccdf.hpp @@ -25,8 +25,9 @@ namespace math { template * = nullptr> -inline return_type_t frechet_lccdf( - const T_y& y, const T_shape& alpha, const T_scale& sigma) { +return_type_t frechet_lccdf(const T_y& y, + const T_shape& alpha, + const T_scale& sigma) { using T_partials_return = partials_return_t; using T_y_ref = ref_type_t; using T_alpha_ref = ref_type_t; diff --git a/stan/math/prim/prob/frechet_lcdf.hpp b/stan/math/prim/prob/frechet_lcdf.hpp index 4770deaa202..72ae9d2f980 100644 --- a/stan/math/prim/prob/frechet_lcdf.hpp +++ b/stan/math/prim/prob/frechet_lcdf.hpp @@ -23,9 +23,9 @@ namespace math { template * = nullptr> -inline return_type_t frechet_lcdf(const T_y& y, - const T_shape& alpha, - const T_scale& sigma) { +return_type_t frechet_lcdf(const T_y& y, + const T_shape& alpha, + const T_scale& sigma) { using T_partials_return = partials_return_t; using T_y_ref = ref_type_t; using T_alpha_ref = ref_type_t; diff --git a/stan/math/prim/prob/frechet_lpdf.hpp b/stan/math/prim/prob/frechet_lpdf.hpp index 3dba3f3ffd9..20ae50fb899 100644 --- a/stan/math/prim/prob/frechet_lpdf.hpp +++ b/stan/math/prim/prob/frechet_lpdf.hpp @@ -28,9 +28,9 @@ namespace math { template * = nullptr> -inline return_type_t frechet_lpdf(const T_y& y, - const T_shape& alpha, - const T_scale& sigma) { +return_type_t frechet_lpdf(const T_y& y, + const T_shape& alpha, + const T_scale& sigma) { using T_partials_return = partials_return_t; using T_y_ref = ref_type_t; using T_alpha_ref = ref_type_t; diff --git a/stan/math/prim/prob/gamma_ccdf_log.hpp b/stan/math/prim/prob/gamma_ccdf_log.hpp index f7648535672..5de76f43a64 100644 --- a/stan/math/prim/prob/gamma_ccdf_log.hpp +++ b/stan/math/prim/prob/gamma_ccdf_log.hpp @@ -11,7 +11,7 @@ namespace math { * @deprecated use gamma_lccdf */ template -inline return_type_t gamma_ccdf_log( +return_type_t gamma_ccdf_log( const T_y& y, const T_shape& alpha, const T_inv_scale& beta) { return gamma_lccdf(y, alpha, beta); } diff --git a/stan/math/prim/prob/gamma_cdf.hpp b/stan/math/prim/prob/gamma_cdf.hpp index 4112a61ac39..f924707cf38 100644 --- a/stan/math/prim/prob/gamma_cdf.hpp +++ b/stan/math/prim/prob/gamma_cdf.hpp @@ -38,8 +38,9 @@ namespace math { * @throw std::domain_error if y is not greater than or equal to 0. */ template -inline return_type_t gamma_cdf( - const T_y& y, const T_shape& alpha, const T_inv_scale& beta) { +return_type_t gamma_cdf(const T_y& y, + const T_shape& alpha, + const T_inv_scale& beta) { using T_partials_return = partials_return_t; using T_y_ref = ref_type_t; using T_alpha_ref = ref_type_t; diff --git a/stan/math/prim/prob/gamma_cdf_log.hpp b/stan/math/prim/prob/gamma_cdf_log.hpp index 3ec0e7a1e48..37e67599f8a 100644 --- a/stan/math/prim/prob/gamma_cdf_log.hpp +++ b/stan/math/prim/prob/gamma_cdf_log.hpp @@ -11,7 +11,7 @@ namespace math { * @deprecated use gamma_lcdf */ template -inline return_type_t gamma_cdf_log( +return_type_t gamma_cdf_log( const T_y& y, const T_shape& alpha, const T_inv_scale& beta) { return gamma_lcdf(y, alpha, beta); } diff --git a/stan/math/prim/prob/gamma_lccdf.hpp b/stan/math/prim/prob/gamma_lccdf.hpp index a670cefcecf..c356209f898 100644 --- a/stan/math/prim/prob/gamma_lccdf.hpp +++ b/stan/math/prim/prob/gamma_lccdf.hpp @@ -22,8 +22,9 @@ namespace stan { namespace math { template -inline return_type_t gamma_lccdf( - const T_y& y, const T_shape& alpha, const T_inv_scale& beta) { +return_type_t gamma_lccdf(const T_y& y, + const T_shape& alpha, + const T_inv_scale& beta) { using T_partials_return = partials_return_t; using std::exp; using std::log; @@ -57,55 +58,53 @@ inline return_type_t gamma_lccdf( // The gradients are technically ill-defined, but treated as zero for (size_t i = 0; i < stan::math::size(y); i++) { if (y_vec.val(i) == 0) { - // LCCDF(0) = log(P(Y > 0)) = log(1) = 0 return ops_partials.build(0.0); } } + VectorBuilder, T_partials_return, T_shape> gamma_vec( + math::size(alpha)); + VectorBuilder, T_partials_return, T_shape> digamma_vec( + math::size(alpha)); + + if constexpr (is_autodiff_v) { + for (size_t i = 0; i < stan::math::size(alpha); i++) { + const T_partials_return alpha_dbl = alpha_vec.val(i); + gamma_vec[i] = tgamma(alpha_dbl); + digamma_vec[i] = digamma(alpha_dbl); + } + } + for (size_t n = 0; n < N; n++) { // Explicit results for extreme values // The gradients are technically ill-defined, but treated as zero if (y_vec.val(n) == INFTY) { - // LCCDF(∞) = log(P(Y > ∞)) = log(0) = -∞ return ops_partials.build(negative_infinity()); } const T_partials_return y_dbl = y_vec.val(n); const T_partials_return alpha_dbl = alpha_vec.val(n); const T_partials_return beta_dbl = beta_vec.val(n); - const T_partials_return beta_y_dbl = beta_dbl * y_dbl; - - // Qn = 1 - Pn - const T_partials_return Qn = gamma_q(alpha_dbl, beta_y_dbl); - const T_partials_return log_Qn = log(Qn); - - P += log_Qn; - - if constexpr (is_any_autodiff_v) { - const T_partials_return log_y_dbl = log(y_dbl); - const T_partials_return log_beta_dbl = log(beta_dbl); - const T_partials_return log_pdf - = alpha_dbl * log_beta_dbl - lgamma(alpha_dbl) - + (alpha_dbl - 1.0) * log_y_dbl - beta_y_dbl; - const T_partials_return common_term = exp(log_pdf - log_Qn); - - if constexpr (is_autodiff_v) { - // d/dy log(1-F(y)) = -f(y)/(1-F(y)) - partials<0>(ops_partials)[n] -= common_term; - } - if constexpr (is_autodiff_v) { - // d/dbeta log(1-F(y)) = -y*f(y)/(beta*(1-F(y))) - partials<2>(ops_partials)[n] -= y_dbl / beta_dbl * common_term; - } - } + const T_partials_return Pn = gamma_q(alpha_dbl, beta_dbl * y_dbl); + + P += log(Pn); + + if constexpr (is_autodiff_v) { + partials<0>(ops_partials)[n] -= beta_dbl * exp(-beta_dbl * y_dbl) + * pow(beta_dbl * y_dbl, alpha_dbl - 1) + / tgamma(alpha_dbl) / Pn; + } if constexpr (is_autodiff_v) { - const T_partials_return digamma_val = digamma(alpha_dbl); - const T_partials_return gamma_val = tgamma(alpha_dbl); - // d/dalpha log(1-F(y)) = grad_upper_inc_gamma / (1-F(y)) partials<1>(ops_partials)[n] - += grad_reg_inc_gamma(alpha_dbl, beta_y_dbl, gamma_val, digamma_val) - / Qn; + += grad_reg_inc_gamma(alpha_dbl, beta_dbl * y_dbl, gamma_vec[n], + digamma_vec[n]) + / Pn; + } + if constexpr (is_autodiff_v) { + partials<2>(ops_partials)[n] -= y_dbl * exp(-beta_dbl * y_dbl) + * pow(beta_dbl * y_dbl, alpha_dbl - 1) + / tgamma(alpha_dbl) / Pn; } } return ops_partials.build(P); diff --git a/stan/math/prim/prob/gamma_lcdf.hpp b/stan/math/prim/prob/gamma_lcdf.hpp index acac32bf92f..27d13619064 100644 --- a/stan/math/prim/prob/gamma_lcdf.hpp +++ b/stan/math/prim/prob/gamma_lcdf.hpp @@ -22,8 +22,9 @@ namespace stan { namespace math { template -inline return_type_t gamma_lcdf( - const T_y& y, const T_shape& alpha, const T_inv_scale& beta) { +return_type_t gamma_lcdf(const T_y& y, + const T_shape& alpha, + const T_inv_scale& beta) { using T_partials_return = partials_return_t; using std::exp; using std::log; @@ -54,7 +55,7 @@ inline return_type_t gamma_lcdf( size_t N = max_size(y, alpha, beta); // Explicit return for extreme values - // The gradients are technically ill-defined + // The gradients are technically ill-defined, but treated as zero for (size_t i = 0; i < stan::math::size(y); i++) { if (y_vec.val(i) == 0) { return ops_partials.build(negative_infinity()); @@ -69,6 +70,7 @@ inline return_type_t gamma_lcdf( } const T_partials_return y_dbl = y_vec.val(n); + const T_partials_return log_y_dbl = log(y_dbl); const T_partials_return alpha_dbl = alpha_vec.val(n); const T_partials_return beta_dbl = beta_vec.val(n); const T_partials_return log_beta_dbl = log(beta_dbl); @@ -80,7 +82,6 @@ inline return_type_t gamma_lcdf( P += log_Pn; if constexpr (is_any_autodiff_v) { - const T_partials_return log_y_dbl = log(y_dbl); const T_partials_return d_num = (-beta_y_dbl) + (alpha_dbl - 1) * (log_beta_dbl + log_y_dbl); const T_partials_return d_den = lgamma(alpha_dbl) + log_Pn; diff --git a/stan/math/prim/prob/gamma_lpdf.hpp b/stan/math/prim/prob/gamma_lpdf.hpp index 4c377665f46..9b5d325f144 100644 --- a/stan/math/prim/prob/gamma_lpdf.hpp +++ b/stan/math/prim/prob/gamma_lpdf.hpp @@ -49,8 +49,9 @@ namespace math { template * = nullptr> -inline return_type_t gamma_lpdf( - const T_y& y, const T_shape& alpha, const T_inv_scale& beta) { +return_type_t gamma_lpdf(const T_y& y, + const T_shape& alpha, + const T_inv_scale& beta) { using T_partials_return = partials_return_t; using T_y_ref = ref_type_if_not_constant_t; using T_alpha_ref = ref_type_if_not_constant_t; diff --git a/stan/math/prim/prob/gumbel_ccdf_log.hpp b/stan/math/prim/prob/gumbel_ccdf_log.hpp index 10300189bde..13a6280e380 100644 --- a/stan/math/prim/prob/gumbel_ccdf_log.hpp +++ b/stan/math/prim/prob/gumbel_ccdf_log.hpp @@ -11,9 +11,9 @@ namespace math { * @deprecated use gumbel_lccdf */ template -inline return_type_t gumbel_ccdf_log(const T_y& y, - const T_loc& mu, - const T_scale& beta) { +return_type_t gumbel_ccdf_log(const T_y& y, + const T_loc& mu, + const T_scale& beta) { return gumbel_lccdf(y, mu, beta); } diff --git a/stan/math/prim/prob/gumbel_cdf.hpp b/stan/math/prim/prob/gumbel_cdf.hpp index 2850945c9e4..87ad0b527e2 100644 --- a/stan/math/prim/prob/gumbel_cdf.hpp +++ b/stan/math/prim/prob/gumbel_cdf.hpp @@ -36,10 +36,10 @@ namespace math { template * = nullptr> -inline return_type_t gumbel_cdf(const T_y& y, - const T_loc& mu, - const T_scale& beta) { +return_type_t gumbel_cdf(const T_y& y, const T_loc& mu, + const T_scale& beta) { using T_partials_return = partials_return_t; + using T_partials_array = Eigen::Array; using T_y_ref = ref_type_if_not_constant_t; using T_mu_ref = ref_type_if_not_constant_t; using T_beta_ref = ref_type_if_not_constant_t; @@ -74,9 +74,9 @@ inline return_type_t gumbel_cdf(const T_y& y, T_partials_return cdf(1.0); if constexpr (is_vector::value || is_vector::value || is_vector::value) { - cdf = cdf_n.prod(); + cdf = forward_as(cdf_n).prod(); } else { - cdf = cdf_n; + cdf = forward_as(cdf_n); } if constexpr (is_any_autodiff_v) { diff --git a/stan/math/prim/prob/gumbel_cdf_log.hpp b/stan/math/prim/prob/gumbel_cdf_log.hpp index ceccfb62d69..adbeeefb110 100644 --- a/stan/math/prim/prob/gumbel_cdf_log.hpp +++ b/stan/math/prim/prob/gumbel_cdf_log.hpp @@ -11,9 +11,8 @@ namespace math { * @deprecated use gumbel_lcdf */ template -inline return_type_t gumbel_cdf_log(const T_y& y, - const T_loc& mu, - const T_scale& beta) { +return_type_t gumbel_cdf_log(const T_y& y, const T_loc& mu, + const T_scale& beta) { return gumbel_lcdf(y, mu, beta); } diff --git a/stan/math/prim/prob/gumbel_lccdf.hpp b/stan/math/prim/prob/gumbel_lccdf.hpp index 52da2565307..963b1b26135 100644 --- a/stan/math/prim/prob/gumbel_lccdf.hpp +++ b/stan/math/prim/prob/gumbel_lccdf.hpp @@ -36,9 +36,8 @@ namespace math { template * = nullptr> -inline return_type_t gumbel_lccdf(const T_y& y, - const T_loc& mu, - const T_scale& beta) { +return_type_t gumbel_lccdf(const T_y& y, const T_loc& mu, + const T_scale& beta) { using T_partials_return = partials_return_t; using T_y_ref = ref_type_if_not_constant_t; using T_mu_ref = ref_type_if_not_constant_t; diff --git a/stan/math/prim/prob/gumbel_lcdf.hpp b/stan/math/prim/prob/gumbel_lcdf.hpp index 91b710f18a5..e8e31fa4370 100644 --- a/stan/math/prim/prob/gumbel_lcdf.hpp +++ b/stan/math/prim/prob/gumbel_lcdf.hpp @@ -35,9 +35,8 @@ namespace math { template * = nullptr> -inline return_type_t gumbel_lcdf(const T_y& y, - const T_loc& mu, - const T_scale& beta) { +return_type_t gumbel_lcdf(const T_y& y, const T_loc& mu, + const T_scale& beta) { using T_partials_return = partials_return_t; using T_y_ref = ref_type_if_not_constant_t; using T_mu_ref = ref_type_if_not_constant_t; diff --git a/stan/math/prim/prob/gumbel_lpdf.hpp b/stan/math/prim/prob/gumbel_lpdf.hpp index e84f9dfecc8..ef0f175306c 100644 --- a/stan/math/prim/prob/gumbel_lpdf.hpp +++ b/stan/math/prim/prob/gumbel_lpdf.hpp @@ -37,9 +37,8 @@ namespace math { template * = nullptr> -inline return_type_t gumbel_lpdf(const T_y& y, - const T_loc& mu, - const T_scale& beta) { +return_type_t gumbel_lpdf(const T_y& y, const T_loc& mu, + const T_scale& beta) { using T_partials_return = partials_return_t; using T_y_ref = ref_type_if_not_constant_t; using T_mu_ref = ref_type_if_not_constant_t; diff --git a/stan/math/prim/prob/hypergeometric_lpmf.hpp b/stan/math/prim/prob/hypergeometric_lpmf.hpp index 123bde81bc8..ea27fb1e8ba 100644 --- a/stan/math/prim/prob/hypergeometric_lpmf.hpp +++ b/stan/math/prim/prob/hypergeometric_lpmf.hpp @@ -15,8 +15,8 @@ namespace math { // n: #white balls drawn; N: #balls drawn; // a: #white balls; b: #black balls template -inline double hypergeometric_lpmf(const T_n& n, const T_N& N, const T_a& a, - const T_b& b) { +double hypergeometric_lpmf(const T_n& n, const T_N& N, const T_a& a, + const T_b& b) { static constexpr const char* function = "hypergeometric_lpmf"; check_bounded(function, "Successes variable", value_of(n), 0, a); check_consistent_sizes(function, "Successes variable", n, "Draws parameter", diff --git a/stan/math/prim/prob/inv_chi_square_ccdf_log.hpp b/stan/math/prim/prob/inv_chi_square_ccdf_log.hpp index 75adf669605..80c3267d035 100644 --- a/stan/math/prim/prob/inv_chi_square_ccdf_log.hpp +++ b/stan/math/prim/prob/inv_chi_square_ccdf_log.hpp @@ -11,8 +11,8 @@ namespace math { * @deprecated use inv_chi_square_lccdf */ template -inline return_type_t inv_chi_square_ccdf_log(const T_y& y, - const T_dof& nu) { +return_type_t inv_chi_square_ccdf_log(const T_y& y, + const T_dof& nu) { return inv_chi_square_lccdf(y, nu); } diff --git a/stan/math/prim/prob/inv_chi_square_cdf.hpp b/stan/math/prim/prob/inv_chi_square_cdf.hpp index d017fc1390f..3c14fe1f1e8 100644 --- a/stan/math/prim/prob/inv_chi_square_cdf.hpp +++ b/stan/math/prim/prob/inv_chi_square_cdf.hpp @@ -34,8 +34,7 @@ namespace math { * @throw std::invalid_argument if container sizes mismatch */ template -inline return_type_t inv_chi_square_cdf(const T_y& y, - const T_dof& nu) { +return_type_t inv_chi_square_cdf(const T_y& y, const T_dof& nu) { using T_partials_return = partials_return_t; using std::exp; using std::pow; diff --git a/stan/math/prim/prob/inv_chi_square_cdf_log.hpp b/stan/math/prim/prob/inv_chi_square_cdf_log.hpp index 49900c93737..c5f7fb91ff9 100644 --- a/stan/math/prim/prob/inv_chi_square_cdf_log.hpp +++ b/stan/math/prim/prob/inv_chi_square_cdf_log.hpp @@ -11,8 +11,8 @@ namespace math { * @deprecated use inv_chi_square_lcdf */ template -inline return_type_t inv_chi_square_cdf_log(const T_y& y, - const T_dof& nu) { +return_type_t inv_chi_square_cdf_log(const T_y& y, + const T_dof& nu) { return inv_chi_square_lcdf(y, nu); } diff --git a/stan/math/prim/prob/inv_chi_square_lccdf.hpp b/stan/math/prim/prob/inv_chi_square_lccdf.hpp index 27f73e38512..c4f41a1bef4 100644 --- a/stan/math/prim/prob/inv_chi_square_lccdf.hpp +++ b/stan/math/prim/prob/inv_chi_square_lccdf.hpp @@ -35,8 +35,7 @@ namespace math { * @throw std::invalid_argument if container sizes mismatch */ template -inline return_type_t inv_chi_square_lccdf(const T_y& y, - const T_dof& nu) { +return_type_t inv_chi_square_lccdf(const T_y& y, const T_dof& nu) { using T_partials_return = partials_return_t; using std::exp; using std::log; diff --git a/stan/math/prim/prob/inv_chi_square_lcdf.hpp b/stan/math/prim/prob/inv_chi_square_lcdf.hpp index 86280b86ad2..d4446ca374a 100644 --- a/stan/math/prim/prob/inv_chi_square_lcdf.hpp +++ b/stan/math/prim/prob/inv_chi_square_lcdf.hpp @@ -35,8 +35,7 @@ namespace math { * @throw std::invalid_argument if container sizes mismatch */ template -inline return_type_t inv_chi_square_lcdf(const T_y& y, - const T_dof& nu) { +return_type_t inv_chi_square_lcdf(const T_y& y, const T_dof& nu) { using T_partials_return = partials_return_t; using std::exp; using std::log; diff --git a/stan/math/prim/prob/inv_chi_square_lpdf.hpp b/stan/math/prim/prob/inv_chi_square_lpdf.hpp index 91cced06de6..cfbb02d94e8 100644 --- a/stan/math/prim/prob/inv_chi_square_lpdf.hpp +++ b/stan/math/prim/prob/inv_chi_square_lpdf.hpp @@ -46,8 +46,7 @@ namespace math { template * = nullptr> -inline return_type_t inv_chi_square_lpdf(const T_y& y, - const T_dof& nu) { +return_type_t inv_chi_square_lpdf(const T_y& y, const T_dof& nu) { using T_partials_return = partials_return_t; using T_y_ref = ref_type_if_not_constant_t; using T_nu_ref = ref_type_if_not_constant_t; diff --git a/stan/math/prim/prob/inv_gamma_ccdf_log.hpp b/stan/math/prim/prob/inv_gamma_ccdf_log.hpp index 41a02319708..7dccc2cb7fb 100644 --- a/stan/math/prim/prob/inv_gamma_ccdf_log.hpp +++ b/stan/math/prim/prob/inv_gamma_ccdf_log.hpp @@ -11,8 +11,9 @@ namespace math { * @deprecated use inv_gamma_lccdf */ template -inline return_type_t inv_gamma_ccdf_log( - const T_y& y, const T_shape& alpha, const T_scale& beta) { +return_type_t inv_gamma_ccdf_log(const T_y& y, + const T_shape& alpha, + const T_scale& beta) { return inv_gamma_lccdf(y, alpha, beta); } diff --git a/stan/math/prim/prob/inv_gamma_cdf.hpp b/stan/math/prim/prob/inv_gamma_cdf.hpp index 9c801521d03..c0f625a96e8 100644 --- a/stan/math/prim/prob/inv_gamma_cdf.hpp +++ b/stan/math/prim/prob/inv_gamma_cdf.hpp @@ -37,9 +37,9 @@ namespace math { */ template -inline return_type_t inv_gamma_cdf(const T_y& y, - const T_shape& alpha, - const T_scale& beta) { +return_type_t inv_gamma_cdf(const T_y& y, + const T_shape& alpha, + const T_scale& beta) { using T_partials_return = partials_return_t; using T_y_ref = ref_type_t; using T_alpha_ref = ref_type_t; diff --git a/stan/math/prim/prob/inv_gamma_cdf_log.hpp b/stan/math/prim/prob/inv_gamma_cdf_log.hpp index 2863e2af9e7..83f56f27273 100644 --- a/stan/math/prim/prob/inv_gamma_cdf_log.hpp +++ b/stan/math/prim/prob/inv_gamma_cdf_log.hpp @@ -11,8 +11,9 @@ namespace math { * @deprecated use inv_gamma_lcdf */ template -inline return_type_t inv_gamma_cdf_log( - const T_y& y, const T_shape& alpha, const T_scale& beta) { +return_type_t inv_gamma_cdf_log(const T_y& y, + const T_shape& alpha, + const T_scale& beta) { return inv_gamma_lcdf(y, alpha, beta); } diff --git a/stan/math/prim/prob/inv_gamma_lccdf.hpp b/stan/math/prim/prob/inv_gamma_lccdf.hpp index 55d4485c8eb..9326d826f9e 100644 --- a/stan/math/prim/prob/inv_gamma_lccdf.hpp +++ b/stan/math/prim/prob/inv_gamma_lccdf.hpp @@ -22,8 +22,9 @@ namespace stan { namespace math { template -inline return_type_t inv_gamma_lccdf( - const T_y& y, const T_shape& alpha, const T_scale& beta) { +return_type_t inv_gamma_lccdf(const T_y& y, + const T_shape& alpha, + const T_scale& beta) { using T_partials_return = partials_return_t; using T_y_ref = ref_type_t; using T_alpha_ref = ref_type_t; diff --git a/stan/math/prim/prob/inv_gamma_lcdf.hpp b/stan/math/prim/prob/inv_gamma_lcdf.hpp index 5e0a78c192d..7873531cbd0 100644 --- a/stan/math/prim/prob/inv_gamma_lcdf.hpp +++ b/stan/math/prim/prob/inv_gamma_lcdf.hpp @@ -22,8 +22,9 @@ namespace stan { namespace math { template -inline return_type_t inv_gamma_lcdf( - const T_y& y, const T_shape& alpha, const T_scale& beta) { +return_type_t inv_gamma_lcdf(const T_y& y, + const T_shape& alpha, + const T_scale& beta) { using T_partials_return = partials_return_t; using T_y_ref = ref_type_t; using T_alpha_ref = ref_type_t; diff --git a/stan/math/prim/prob/inv_gamma_lpdf.hpp b/stan/math/prim/prob/inv_gamma_lpdf.hpp index 504a341da35..758f3363b34 100644 --- a/stan/math/prim/prob/inv_gamma_lpdf.hpp +++ b/stan/math/prim/prob/inv_gamma_lpdf.hpp @@ -41,8 +41,9 @@ namespace math { template * = nullptr> -inline return_type_t inv_gamma_lpdf( - const T_y& y, const T_shape& alpha, const T_scale& beta) { +return_type_t inv_gamma_lpdf(const T_y& y, + const T_shape& alpha, + const T_scale& beta) { using T_partials_return = partials_return_t; using T_y_ref = ref_type_if_not_constant_t; using T_alpha_ref = ref_type_if_not_constant_t; diff --git a/stan/math/prim/prob/inv_wishart_cholesky_lpdf.hpp b/stan/math/prim/prob/inv_wishart_cholesky_lpdf.hpp index a24e66891d6..10269b81da5 100644 --- a/stan/math/prim/prob/inv_wishart_cholesky_lpdf.hpp +++ b/stan/math/prim/prob/inv_wishart_cholesky_lpdf.hpp @@ -40,7 +40,7 @@ namespace math { template * = nullptr, require_all_matrix_t* = nullptr> -inline return_type_t inv_wishart_cholesky_lpdf( +return_type_t inv_wishart_cholesky_lpdf( const T_y& L_Y, const T_dof& nu, const T_scale& L_S) { using Eigen::Lower; using T_L_Y_ref = ref_type_t; diff --git a/stan/math/prim/prob/inv_wishart_lpdf.hpp b/stan/math/prim/prob/inv_wishart_lpdf.hpp index 6fff68d7c6c..f9cb03de64a 100644 --- a/stan/math/prim/prob/inv_wishart_lpdf.hpp +++ b/stan/math/prim/prob/inv_wishart_lpdf.hpp @@ -42,9 +42,9 @@ namespace math { * semi-positive definite. */ template -inline return_type_t inv_wishart_lpdf(const T_y& W, - const T_dof& nu, - const T_scale& S) { +return_type_t inv_wishart_lpdf(const T_y& W, + const T_dof& nu, + const T_scale& S) { using Eigen::Dynamic; using Eigen::Matrix; using T_W_ref = ref_type_t; diff --git a/stan/math/prim/prob/lkj_corr_cholesky_lpdf.hpp b/stan/math/prim/prob/lkj_corr_cholesky_lpdf.hpp index a675f42d4e1..85adc58e728 100644 --- a/stan/math/prim/prob/lkj_corr_cholesky_lpdf.hpp +++ b/stan/math/prim/prob/lkj_corr_cholesky_lpdf.hpp @@ -15,8 +15,8 @@ namespace math { // LKJ_Corr(L|eta) [ L Cholesky factor of correlation matrix // eta > 0; eta == 1 <-> uniform] template -inline return_type_t lkj_corr_cholesky_lpdf( - const T_covar& L, const T_shape& eta) { +return_type_t lkj_corr_cholesky_lpdf(const T_covar& L, + const T_shape& eta) { using lp_ret = return_type_t; static constexpr const char* function = "lkj_corr_cholesky_lpdf"; check_positive(function, "Shape parameter", eta); diff --git a/stan/math/prim/prob/lkj_corr_lpdf.hpp b/stan/math/prim/prob/lkj_corr_lpdf.hpp index f10d55ba204..4314a11e47c 100644 --- a/stan/math/prim/prob/lkj_corr_lpdf.hpp +++ b/stan/math/prim/prob/lkj_corr_lpdf.hpp @@ -13,8 +13,8 @@ namespace stan { namespace math { template -inline return_type_t do_lkj_constant(const T_shape& eta, - const unsigned int& K) { +return_type_t do_lkj_constant(const T_shape& eta, + const unsigned int& K) { // Lewandowski, Kurowicka, and Joe (2009) theorem 5 return_type_t constant; const int Km1 = K - 1; @@ -46,8 +46,7 @@ inline return_type_t do_lkj_constant(const T_shape& eta, // LKJ_Corr(y|eta) [ y correlation matrix (not covariance matrix) // eta > 0; eta == 1 <-> uniform] template -inline return_type_t lkj_corr_lpdf(const T_y& y, - const T_shape& eta) { +return_type_t lkj_corr_lpdf(const T_y& y, const T_shape& eta) { static constexpr const char* function = "lkj_corr_lpdf"; return_type_t lp(0.0); diff --git a/stan/math/prim/prob/lkj_cov_lpdf.hpp b/stan/math/prim/prob/lkj_cov_lpdf.hpp index 8172f0ff62e..951e1bf53b7 100644 --- a/stan/math/prim/prob/lkj_cov_lpdf.hpp +++ b/stan/math/prim/prob/lkj_cov_lpdf.hpp @@ -18,8 +18,10 @@ namespace math { template * = nullptr, require_all_eigen_col_vector_t* = nullptr> -inline return_type_t lkj_cov_lpdf( - const T_y& y, const T_loc& mu, const T_scale& sigma, const T_shape& eta) { +return_type_t lkj_cov_lpdf(const T_y& y, + const T_loc& mu, + const T_scale& sigma, + const T_shape& eta) { static constexpr const char* function = "lkj_cov_lpdf"; check_size_match(function, "Rows of location parameter", mu.rows(), "columns of scale parameter", sigma.rows()); @@ -63,8 +65,10 @@ inline return_type_t lkj_cov_lpdf( template * = nullptr, require_all_stan_scalar_t* = nullptr> -inline return_type_t lkj_cov_lpdf( - const T_y& y, const T_loc& mu, const T_scale& sigma, const T_shape& eta) { +return_type_t lkj_cov_lpdf(const T_y& y, + const T_loc& mu, + const T_scale& sigma, + const T_shape& eta) { static constexpr const char* function = "lkj_cov_lpdf"; check_positive(function, "Shape parameter", eta); check_finite(function, "Location parameter", mu); diff --git a/stan/math/prim/prob/logistic_ccdf_log.hpp b/stan/math/prim/prob/logistic_ccdf_log.hpp index 01fb5a7038a..d1016cab4cf 100644 --- a/stan/math/prim/prob/logistic_ccdf_log.hpp +++ b/stan/math/prim/prob/logistic_ccdf_log.hpp @@ -11,8 +11,9 @@ namespace math { * @deprecated use logistic_lccdf */ template -inline return_type_t logistic_ccdf_log( - const T_y& y, const T_loc& mu, const T_scale& sigma) { +return_type_t logistic_ccdf_log(const T_y& y, + const T_loc& mu, + const T_scale& sigma) { return logistic_lccdf(y, mu, sigma); } diff --git a/stan/math/prim/prob/logistic_cdf.hpp b/stan/math/prim/prob/logistic_cdf.hpp index 3465e44eae6..9d61d7bcc59 100644 --- a/stan/math/prim/prob/logistic_cdf.hpp +++ b/stan/math/prim/prob/logistic_cdf.hpp @@ -22,9 +22,8 @@ namespace math { template * = nullptr> -inline return_type_t logistic_cdf(const T_y& y, - const T_loc& mu, - const T_scale& sigma) { +return_type_t logistic_cdf(const T_y& y, const T_loc& mu, + const T_scale& sigma) { using T_partials_return = partials_return_t; using std::exp; using T_y_ref = ref_type_t; diff --git a/stan/math/prim/prob/logistic_cdf_log.hpp b/stan/math/prim/prob/logistic_cdf_log.hpp index bdde192e5ff..eb3b2757f13 100644 --- a/stan/math/prim/prob/logistic_cdf_log.hpp +++ b/stan/math/prim/prob/logistic_cdf_log.hpp @@ -11,8 +11,9 @@ namespace math { * @deprecated use logistic_lcdf */ template -inline return_type_t logistic_cdf_log( - const T_y& y, const T_loc& mu, const T_scale& sigma) { +return_type_t logistic_cdf_log(const T_y& y, + const T_loc& mu, + const T_scale& sigma) { return logistic_lcdf(y, mu, sigma); } diff --git a/stan/math/prim/prob/logistic_lccdf.hpp b/stan/math/prim/prob/logistic_lccdf.hpp index 016da2da39d..408db8ec58b 100644 --- a/stan/math/prim/prob/logistic_lccdf.hpp +++ b/stan/math/prim/prob/logistic_lccdf.hpp @@ -22,9 +22,8 @@ namespace math { template * = nullptr> -inline return_type_t logistic_lccdf(const T_y& y, - const T_loc& mu, - const T_scale& sigma) { +return_type_t logistic_lccdf(const T_y& y, const T_loc& mu, + const T_scale& sigma) { using T_partials_return = partials_return_t; using std::exp; using std::log; diff --git a/stan/math/prim/prob/logistic_lcdf.hpp b/stan/math/prim/prob/logistic_lcdf.hpp index 10b9be9e78c..727f33d2160 100644 --- a/stan/math/prim/prob/logistic_lcdf.hpp +++ b/stan/math/prim/prob/logistic_lcdf.hpp @@ -22,9 +22,8 @@ namespace math { template * = nullptr> -inline return_type_t logistic_lcdf(const T_y& y, - const T_loc& mu, - const T_scale& sigma) { +return_type_t logistic_lcdf(const T_y& y, const T_loc& mu, + const T_scale& sigma) { using T_partials_return = partials_return_t; using std::exp; using std::log; diff --git a/stan/math/prim/prob/logistic_lpdf.hpp b/stan/math/prim/prob/logistic_lpdf.hpp index 181ce1c5650..a220fb397b2 100644 --- a/stan/math/prim/prob/logistic_lpdf.hpp +++ b/stan/math/prim/prob/logistic_lpdf.hpp @@ -25,9 +25,8 @@ namespace math { template * = nullptr> -inline return_type_t logistic_lpdf(const T_y& y, - const T_loc& mu, - const T_scale& sigma) { +return_type_t logistic_lpdf(const T_y& y, const T_loc& mu, + const T_scale& sigma) { using T_partials_return = partials_return_t; using T_y_ref = ref_type_if_not_constant_t; using T_mu_ref = ref_type_if_not_constant_t; diff --git a/stan/math/prim/prob/loglogistic_cdf.hpp b/stan/math/prim/prob/loglogistic_cdf.hpp index da7f8a950a0..dc630aaca0d 100644 --- a/stan/math/prim/prob/loglogistic_cdf.hpp +++ b/stan/math/prim/prob/loglogistic_cdf.hpp @@ -43,8 +43,9 @@ namespace math { template * = nullptr> -inline return_type_t loglogistic_cdf( - const T_y& y, const T_scale& alpha, const T_shape& beta) { +return_type_t loglogistic_cdf(const T_y& y, + const T_scale& alpha, + const T_shape& beta) { using T_partials_return = partials_return_t; using T_y_ref = ref_type_t; using T_alpha_ref = ref_type_t; diff --git a/stan/math/prim/prob/loglogistic_lpdf.hpp b/stan/math/prim/prob/loglogistic_lpdf.hpp index 047f35a414a..81735aca52d 100644 --- a/stan/math/prim/prob/loglogistic_lpdf.hpp +++ b/stan/math/prim/prob/loglogistic_lpdf.hpp @@ -42,8 +42,9 @@ namespace math { template * = nullptr> -inline return_type_t loglogistic_lpdf( - const T_y& y, const T_scale& alpha, const T_shape& beta) { +return_type_t loglogistic_lpdf(const T_y& y, + const T_scale& alpha, + const T_shape& beta) { using T_partials_return = partials_return_t; using T_y_ref = ref_type_if_not_constant_t; using T_scale_ref = ref_type_if_not_constant_t; diff --git a/stan/math/prim/prob/lognormal_ccdf_log.hpp b/stan/math/prim/prob/lognormal_ccdf_log.hpp index 04288340b21..d85fe848ec9 100644 --- a/stan/math/prim/prob/lognormal_ccdf_log.hpp +++ b/stan/math/prim/prob/lognormal_ccdf_log.hpp @@ -11,8 +11,9 @@ namespace math { * @deprecated use lognormal_lccdf */ template -inline return_type_t lognormal_ccdf_log( - const T_y& y, const T_loc& mu, const T_scale& sigma) { +return_type_t lognormal_ccdf_log(const T_y& y, + const T_loc& mu, + const T_scale& sigma) { return lognormal_lccdf(y, mu, sigma); } diff --git a/stan/math/prim/prob/lognormal_cdf.hpp b/stan/math/prim/prob/lognormal_cdf.hpp index f739cc98acb..11cf048b63c 100644 --- a/stan/math/prim/prob/lognormal_cdf.hpp +++ b/stan/math/prim/prob/lognormal_cdf.hpp @@ -25,9 +25,8 @@ namespace math { template * = nullptr> -inline return_type_t lognormal_cdf(const T_y& y, - const T_loc& mu, - const T_scale& sigma) { +return_type_t lognormal_cdf(const T_y& y, const T_loc& mu, + const T_scale& sigma) { using T_partials_return = partials_return_t; using T_y_ref = ref_type_if_not_constant_t; using T_mu_ref = ref_type_if_not_constant_t; diff --git a/stan/math/prim/prob/lognormal_cdf_log.hpp b/stan/math/prim/prob/lognormal_cdf_log.hpp index effbc38c8ec..ef4ab1983b2 100644 --- a/stan/math/prim/prob/lognormal_cdf_log.hpp +++ b/stan/math/prim/prob/lognormal_cdf_log.hpp @@ -11,8 +11,9 @@ namespace math { * @deprecated use lognormal_lcdf */ template -inline return_type_t lognormal_cdf_log( - const T_y& y, const T_loc& mu, const T_scale& sigma) { +return_type_t lognormal_cdf_log(const T_y& y, + const T_loc& mu, + const T_scale& sigma) { return lognormal_lcdf(y, mu, sigma); } diff --git a/stan/math/prim/prob/lognormal_lccdf.hpp b/stan/math/prim/prob/lognormal_lccdf.hpp index 39391bedb0f..8cd9bfabbc7 100644 --- a/stan/math/prim/prob/lognormal_lccdf.hpp +++ b/stan/math/prim/prob/lognormal_lccdf.hpp @@ -25,8 +25,9 @@ namespace math { template * = nullptr> -inline return_type_t lognormal_lccdf( - const T_y& y, const T_loc& mu, const T_scale& sigma) { +return_type_t lognormal_lccdf(const T_y& y, + const T_loc& mu, + const T_scale& sigma) { using T_partials_return = partials_return_t; using T_y_ref = ref_type_if_not_constant_t; using T_mu_ref = ref_type_if_not_constant_t; diff --git a/stan/math/prim/prob/lognormal_lcdf.hpp b/stan/math/prim/prob/lognormal_lcdf.hpp index 482f79885bd..08f89430ad3 100644 --- a/stan/math/prim/prob/lognormal_lcdf.hpp +++ b/stan/math/prim/prob/lognormal_lcdf.hpp @@ -25,9 +25,8 @@ namespace math { template * = nullptr> -inline return_type_t lognormal_lcdf(const T_y& y, - const T_loc& mu, - const T_scale& sigma) { +return_type_t lognormal_lcdf(const T_y& y, const T_loc& mu, + const T_scale& sigma) { using T_partials_return = partials_return_t; using T_y_ref = ref_type_if_not_constant_t; using T_mu_ref = ref_type_if_not_constant_t; diff --git a/stan/math/prim/prob/lognormal_lpdf.hpp b/stan/math/prim/prob/lognormal_lpdf.hpp index e9052070e31..92b545ca67d 100644 --- a/stan/math/prim/prob/lognormal_lpdf.hpp +++ b/stan/math/prim/prob/lognormal_lpdf.hpp @@ -25,9 +25,8 @@ namespace math { template * = nullptr> -inline return_type_t lognormal_lpdf(const T_y& y, - const T_loc& mu, - const T_scale& sigma) { +return_type_t lognormal_lpdf(const T_y& y, const T_loc& mu, + const T_scale& sigma) { using T_partials_return = partials_return_t; using T_y_ref = ref_type_if_not_constant_t; using T_mu_ref = ref_type_if_not_constant_t; diff --git a/stan/math/prim/prob/matrix_normal_prec_lpdf.hpp b/stan/math/prim/prob/matrix_normal_prec_lpdf.hpp index 329abd940d9..76d9718ccd3 100644 --- a/stan/math/prim/prob/matrix_normal_prec_lpdf.hpp +++ b/stan/math/prim/prob/matrix_normal_prec_lpdf.hpp @@ -33,7 +33,7 @@ namespace math { template * = nullptr> -inline return_type_t matrix_normal_prec_lpdf( +return_type_t matrix_normal_prec_lpdf( const T_y& y, const T_Mu& Mu, const T_Sigma& Sigma, const T_D& D) { static constexpr const char* function = "matrix_normal_prec_lpdf"; check_positive(function, "Sigma rows", Sigma.rows()); @@ -81,7 +81,7 @@ inline return_type_t matrix_normal_prec_lpdf( template * = nullptr> -inline return_type_t matrix_normal_prec_lpdf( +return_type_t matrix_normal_prec_lpdf( const T_y& y, const T_Mu& Mu, const T_Sigma& Sigma, const T_D& D) { return matrix_normal_prec_lpdf(y, Mu, Sigma, D); } diff --git a/stan/math/prim/prob/multi_gp_cholesky_lpdf.hpp b/stan/math/prim/prob/multi_gp_cholesky_lpdf.hpp index 09c6fd58597..c3066358b7a 100644 --- a/stan/math/prim/prob/multi_gp_cholesky_lpdf.hpp +++ b/stan/math/prim/prob/multi_gp_cholesky_lpdf.hpp @@ -38,9 +38,9 @@ namespace math { template * = nullptr, require_eigen_col_vector_t* = nullptr> -inline return_type_t multi_gp_cholesky_lpdf(const T_y& y, - const T_covar& L, - const T_w& w) { +return_type_t multi_gp_cholesky_lpdf(const T_y& y, + const T_covar& L, + const T_w& w) { using T_lp = return_type_t; static constexpr const char* function = "multi_gp_cholesky_lpdf"; check_size_match(function, "Size of random variable (rows y)", y.rows(), diff --git a/stan/math/prim/prob/multi_gp_lpdf.hpp b/stan/math/prim/prob/multi_gp_lpdf.hpp index 16364be328f..4a505e40937 100644 --- a/stan/math/prim/prob/multi_gp_lpdf.hpp +++ b/stan/math/prim/prob/multi_gp_lpdf.hpp @@ -33,9 +33,9 @@ namespace math { template * = nullptr, require_col_vector_t* = nullptr> -inline return_type_t multi_gp_lpdf(const T_y& y, - const T_covar& Sigma, - const T_w& w) { +return_type_t multi_gp_lpdf(const T_y& y, + const T_covar& Sigma, + const T_w& w) { using T_lp = return_type_t; static constexpr const char* function = "multi_gp_lpdf"; check_size_match(function, "Size of random variable (rows y)", y.rows(), diff --git a/stan/math/prim/prob/multi_normal_cholesky_lpdf.hpp b/stan/math/prim/prob/multi_normal_cholesky_lpdf.hpp index 59ca107df6d..04bbc8baba8 100644 --- a/stan/math/prim/prob/multi_normal_cholesky_lpdf.hpp +++ b/stan/math/prim/prob/multi_normal_cholesky_lpdf.hpp @@ -45,7 +45,7 @@ template * = nullptr, require_all_not_nonscalar_prim_or_rev_kernel_expression_t< T_y, T_loc, T_covar>* = nullptr> -inline return_type_t multi_normal_cholesky_lpdf( +return_type_t multi_normal_cholesky_lpdf( const T_y& y, const T_loc& mu, const T_covar& L) { static constexpr const char* function = "multi_normal_cholesky_lpdf"; using T_covar_elem = typename scalar_type::type; @@ -204,7 +204,7 @@ template * = nullptr, require_all_not_nonscalar_prim_or_rev_kernel_expression_t< T_y, T_loc, T_covar>* = nullptr> -inline return_type_t multi_normal_cholesky_lpdf( +return_type_t multi_normal_cholesky_lpdf( const T_y& y, const T_loc& mu, const T_covar& L) { static constexpr const char* function = "multi_normal_cholesky_lpdf"; using T_covar_elem = typename scalar_type::type; diff --git a/stan/math/prim/prob/multi_normal_lpdf.hpp b/stan/math/prim/prob/multi_normal_lpdf.hpp index 297e1e918d7..95e3b272705 100644 --- a/stan/math/prim/prob/multi_normal_lpdf.hpp +++ b/stan/math/prim/prob/multi_normal_lpdf.hpp @@ -25,8 +25,9 @@ template * = nullptr, require_all_not_nonscalar_prim_or_rev_kernel_expression_t< T_y, T_loc, T_covar>* = nullptr> -inline return_type_t multi_normal_lpdf( - const T_y& y, const T_loc& mu, const T_covar& Sigma) { +return_type_t multi_normal_lpdf(const T_y& y, + const T_loc& mu, + const T_covar& Sigma) { using T_covar_elem = typename scalar_type::type; using T_return = return_type_t; using T_partials_return = partials_return_t; @@ -158,8 +159,9 @@ template * = nullptr, require_all_not_nonscalar_prim_or_rev_kernel_expression_t< T_y, T_loc, T_covar>* = nullptr> -inline return_type_t multi_normal_lpdf( - const T_y& y, const T_loc& mu, const T_covar& Sigma) { +return_type_t multi_normal_lpdf(const T_y& y, + const T_loc& mu, + const T_covar& Sigma) { using T_covar_elem = typename scalar_type::type; using T_return = return_type_t; using T_partials_return = partials_return_t; diff --git a/stan/math/prim/prob/multi_normal_prec_lpdf.hpp b/stan/math/prim/prob/multi_normal_prec_lpdf.hpp index cf2d7d048a6..2bedbe52c7a 100644 --- a/stan/math/prim/prob/multi_normal_prec_lpdf.hpp +++ b/stan/math/prim/prob/multi_normal_prec_lpdf.hpp @@ -17,7 +17,7 @@ namespace stan { namespace math { template -inline return_type_t multi_normal_prec_lpdf( +return_type_t multi_normal_prec_lpdf( const T_y& y, const T_loc& mu, const T_covar& Sigma) { using T_covar_elem = typename scalar_type::type; using lp_type = return_type_t; diff --git a/stan/math/prim/prob/multi_student_t_cholesky_lpdf.hpp b/stan/math/prim/prob/multi_student_t_cholesky_lpdf.hpp index d119460be62..acbbdf4f5ec 100644 --- a/stan/math/prim/prob/multi_student_t_cholesky_lpdf.hpp +++ b/stan/math/prim/prob/multi_student_t_cholesky_lpdf.hpp @@ -54,7 +54,7 @@ template < require_any_not_vector_vt* = nullptr, require_all_not_nonscalar_prim_or_rev_kernel_expression_t< T_y, T_loc, T_covar>* = nullptr> -inline return_type_t multi_student_t_cholesky_lpdf( +return_type_t multi_student_t_cholesky_lpdf( const T_y& y, const T_dof& nu, const T_loc& mu, const T_covar& L) { static constexpr const char* function = "multi_student_t_cholesky"; using T_covar_elem = typename scalar_type::type; @@ -242,7 +242,7 @@ template * = nullptr, require_all_not_nonscalar_prim_or_rev_kernel_expression_t< T_y, T_dof, T_loc, T_covar>* = nullptr> -inline return_type_t multi_student_t_cholesky_lpdf( +return_type_t multi_student_t_cholesky_lpdf( const T_y& y, const T_dof& nu, const T_loc& mu, const T_covar& L) { static const char* function = "multi_student_t_cholesky"; using T_covar_elem = typename scalar_type::type; diff --git a/stan/math/prim/prob/multi_student_t_lpdf.hpp b/stan/math/prim/prob/multi_student_t_lpdf.hpp index f4e0798d9c2..a14c3313875 100644 --- a/stan/math/prim/prob/multi_student_t_lpdf.hpp +++ b/stan/math/prim/prob/multi_student_t_lpdf.hpp @@ -40,7 +40,7 @@ namespace math { */ template -inline return_type_t multi_student_t_lpdf( +return_type_t multi_student_t_lpdf( const T_y& y, const T_dof& nu, const T_loc& mu, const T_scale& Sigma) { using T_scale_elem = typename scalar_type::type; using lp_type = return_type_t; diff --git a/stan/math/prim/prob/multinomial_logit_lpmf.hpp b/stan/math/prim/prob/multinomial_logit_lpmf.hpp index b4d10e1195e..0ee9a867424 100644 --- a/stan/math/prim/prob/multinomial_logit_lpmf.hpp +++ b/stan/math/prim/prob/multinomial_logit_lpmf.hpp @@ -22,8 +22,8 @@ namespace math { */ template , require_eigen_col_vector_t* = nullptr> -inline return_type_t multinomial_logit_lpmf(const std::vector& ns, - const T_beta& beta) { +return_type_t multinomial_logit_lpmf(const std::vector& ns, + const T_beta& beta) { static constexpr const char* function = "multinomial_logit_lpmf"; check_size_match(function, "Size of number of trials variable", ns.size(), "rows of log-probabilities parameter", beta.rows()); @@ -52,8 +52,8 @@ inline return_type_t multinomial_logit_lpmf(const std::vector& ns, } template * = nullptr> -inline return_type_t multinomial_logit_lpmf(const std::vector& ns, - const T_beta& beta) { +return_type_t multinomial_logit_lpmf(const std::vector& ns, + const T_beta& beta) { return multinomial_logit_lpmf(ns, beta); } diff --git a/stan/math/prim/prob/multinomial_lpmf.hpp b/stan/math/prim/prob/multinomial_lpmf.hpp index c941118f60f..38af773d002 100644 --- a/stan/math/prim/prob/multinomial_lpmf.hpp +++ b/stan/math/prim/prob/multinomial_lpmf.hpp @@ -14,8 +14,8 @@ namespace math { // 0 <= theta[n] <= 1; SUM theta = 1] template * = nullptr> -inline return_type_t multinomial_lpmf(const std::vector& ns, - const T_prob& theta) { +return_type_t multinomial_lpmf(const std::vector& ns, + const T_prob& theta) { static constexpr const char* function = "multinomial_lpmf"; check_size_match(function, "Size of number of trials variable", ns.size(), "rows of probabilities parameter", theta.rows()); @@ -42,8 +42,8 @@ inline return_type_t multinomial_lpmf(const std::vector& ns, } template -inline return_type_t multinomial_lpmf(const std::vector& ns, - const T_prob& theta) { +return_type_t multinomial_lpmf(const std::vector& ns, + const T_prob& theta) { return multinomial_lpmf(ns, theta); } diff --git a/stan/math/prim/prob/neg_binomial_2_ccdf_log.hpp b/stan/math/prim/prob/neg_binomial_2_ccdf_log.hpp index 6e603e961e7..bf65c709fee 100644 --- a/stan/math/prim/prob/neg_binomial_2_ccdf_log.hpp +++ b/stan/math/prim/prob/neg_binomial_2_ccdf_log.hpp @@ -11,7 +11,7 @@ namespace math { * @deprecated use neg_binomial_2_lccdf */ template -inline return_type_t neg_binomial_2_ccdf_log( +return_type_t neg_binomial_2_ccdf_log( const T_n& n, const T_location& mu, const T_precision& phi) { return neg_binomial_2_lccdf(n, mu, phi); } diff --git a/stan/math/prim/prob/neg_binomial_2_cdf.hpp b/stan/math/prim/prob/neg_binomial_2_cdf.hpp index 47cab11d76d..6f25c513454 100644 --- a/stan/math/prim/prob/neg_binomial_2_cdf.hpp +++ b/stan/math/prim/prob/neg_binomial_2_cdf.hpp @@ -21,7 +21,7 @@ namespace stan { namespace math { template -inline return_type_t neg_binomial_2_cdf( +return_type_t neg_binomial_2_cdf( const T_n& n, const T_location& mu, const T_precision& phi) { using T_partials_return = partials_return_t; using T_n_ref = ref_type_t; diff --git a/stan/math/prim/prob/neg_binomial_2_cdf_log.hpp b/stan/math/prim/prob/neg_binomial_2_cdf_log.hpp index 80b88ead1d6..850e862fb1e 100644 --- a/stan/math/prim/prob/neg_binomial_2_cdf_log.hpp +++ b/stan/math/prim/prob/neg_binomial_2_cdf_log.hpp @@ -11,7 +11,7 @@ namespace math { * @deprecated use neg_binomial_2_lcdf */ template -inline return_type_t neg_binomial_2_cdf_log( +return_type_t neg_binomial_2_cdf_log( const T_n& n, const T_location& mu, const T_precision& phi) { return neg_binomial_2_lcdf(n, mu, phi); } diff --git a/stan/math/prim/prob/neg_binomial_2_lccdf.hpp b/stan/math/prim/prob/neg_binomial_2_lccdf.hpp index 0da477fee7c..2154e96a44d 100644 --- a/stan/math/prim/prob/neg_binomial_2_lccdf.hpp +++ b/stan/math/prim/prob/neg_binomial_2_lccdf.hpp @@ -14,7 +14,7 @@ namespace math { // Temporary neg_binomial_2_ccdf implementation that // transforms the input parameters and calls neg_binomial_ccdf template -inline return_type_t neg_binomial_2_lccdf( +return_type_t neg_binomial_2_lccdf( const T_n& n, const T_location& mu, const T_precision& phi) { using T_mu_ref = ref_type_t; using T_phi_ref = ref_type_t; diff --git a/stan/math/prim/prob/neg_binomial_2_lcdf.hpp b/stan/math/prim/prob/neg_binomial_2_lcdf.hpp index 207e5532730..86eee78c5de 100644 --- a/stan/math/prim/prob/neg_binomial_2_lcdf.hpp +++ b/stan/math/prim/prob/neg_binomial_2_lcdf.hpp @@ -15,7 +15,7 @@ namespace stan { namespace math { template -inline return_type_t neg_binomial_2_lcdf( +return_type_t neg_binomial_2_lcdf( const T_n& n, const T_location& mu, const T_precision& phi) { using std::log; using T_n_ref = ref_type_t; diff --git a/stan/math/prim/prob/neg_binomial_2_log_glm_lpmf.hpp b/stan/math/prim/prob/neg_binomial_2_log_glm_lpmf.hpp index 3e7254f0262..d7c39d1704d 100644 --- a/stan/math/prim/prob/neg_binomial_2_log_glm_lpmf.hpp +++ b/stan/math/prim/prob/neg_binomial_2_log_glm_lpmf.hpp @@ -64,15 +64,16 @@ namespace math { template * = nullptr> -inline return_type_t -neg_binomial_2_log_glm_lpmf(const T_y& y, const T_x& x, const T_alpha& alpha, - const T_beta& beta, const T_precision& phi) { +return_type_t neg_binomial_2_log_glm_lpmf( + const T_y& y, const T_x& x, const T_alpha& alpha, const T_beta& beta, + const T_precision& phi) { using Eigen::Array; using Eigen::Dynamic; using Eigen::exp; using Eigen::log1p; using Eigen::Matrix; constexpr int T_x_rows = T_x::RowsAtCompileTime; + using T_xbeta_partials = partials_return_t; using T_partials_return = partials_return_t; using T_precision_val = typename std::conditional_t< @@ -86,6 +87,9 @@ neg_binomial_2_log_glm_lpmf(const T_y& y, const T_x& x, const T_alpha& alpha, using T_theta_tmp = typename std::conditional_t>; + using T_xbeta_tmp = + typename std::conditional_t>; using T_x_ref = ref_type_if_not_constant_t; using T_alpha_ref = ref_type_if_not_constant_t; using T_beta_ref = ref_type_if_not_constant_t; @@ -139,7 +143,8 @@ neg_binomial_2_log_glm_lpmf(const T_y& y, const T_x& x, const T_alpha& alpha, Array theta(N_instances); if constexpr (T_x_rows == 1) { - T_theta_tmp theta_tmp = (x_val * beta_val_vec)(0, 0); + T_theta_tmp theta_tmp + = forward_as((x_val * beta_val_vec)(0, 0)); theta = theta_tmp + as_array_or_scalar(alpha_val_vec); } else { theta = (x_val * beta_val_vec).array(); @@ -170,7 +175,11 @@ neg_binomial_2_log_glm_lpmf(const T_y& y, const T_x& x, const T_alpha& alpha, logp += multiply_log(phi_vec[n], phi_vec[n]) - lgamma(phi_vec[n]); } } else { - logp += N_instances * (multiply_log(phi_val, phi_val) - lgamma(phi_val)); + using T_phi_scalar = scalar_type_t; + logp += N_instances + * (multiply_log(forward_as(phi_val), + forward_as(phi_val)) + - lgamma(forward_as(phi_val))); } } logp -= sum(y_plus_phi * logsumexp_theta_logphi); @@ -196,7 +205,9 @@ neg_binomial_2_log_glm_lpmf(const T_y& y, const T_x& x, const T_alpha& alpha, = y_arr - theta_exp * y_plus_phi / (theta_exp + phi_arr); if constexpr (is_autodiff_v) { if constexpr (T_x_rows == 1) { - edge<2>(ops_partials).partials_ = theta_derivative.sum() * x_val; + edge<2>(ops_partials).partials_ + = forward_as>( + theta_derivative.sum() * x_val); } else { edge<2>(ops_partials).partials_ = x_val.transpose() * theta_derivative; @@ -205,7 +216,8 @@ neg_binomial_2_log_glm_lpmf(const T_y& y, const T_x& x, const T_alpha& alpha, if constexpr (is_autodiff_v) { if constexpr (T_x_rows == 1) { edge<0>(ops_partials).partials_ - = beta_val_vec * theta_derivative.sum(); + = forward_as>( + beta_val_vec * theta_derivative.sum()); } else { edge<0>(ops_partials).partials_ = (beta_val_vec * theta_derivative.transpose()).transpose(); diff --git a/stan/math/prim/prob/neg_binomial_2_log_lpmf.hpp b/stan/math/prim/prob/neg_binomial_2_log_lpmf.hpp index 44564538fbf..d6629faedac 100644 --- a/stan/math/prim/prob/neg_binomial_2_log_lpmf.hpp +++ b/stan/math/prim/prob/neg_binomial_2_log_lpmf.hpp @@ -25,7 +25,7 @@ template * = nullptr> -inline return_type_t neg_binomial_2_log_lpmf( +return_type_t neg_binomial_2_log_lpmf( const T_n& n, const T_log_location& eta, const T_precision& phi) { using T_partials_return = partials_return_t; using std::exp; diff --git a/stan/math/prim/prob/neg_binomial_2_lpmf.hpp b/stan/math/prim/prob/neg_binomial_2_lpmf.hpp index 0b6808c060f..b10f4db185f 100644 --- a/stan/math/prim/prob/neg_binomial_2_lpmf.hpp +++ b/stan/math/prim/prob/neg_binomial_2_lpmf.hpp @@ -22,7 +22,7 @@ namespace math { template * = nullptr> -inline return_type_t neg_binomial_2_lpmf( +return_type_t neg_binomial_2_lpmf( const T_n& n, const T_location& mu, const T_precision& phi) { using T_partials_return = partials_return_t; using std::log; diff --git a/stan/math/prim/prob/neg_binomial_ccdf_log.hpp b/stan/math/prim/prob/neg_binomial_ccdf_log.hpp index 3bb604a2a6d..edba938ed20 100644 --- a/stan/math/prim/prob/neg_binomial_ccdf_log.hpp +++ b/stan/math/prim/prob/neg_binomial_ccdf_log.hpp @@ -11,7 +11,7 @@ namespace math { * @deprecated use neg_binomial_lccdf */ template -inline return_type_t neg_binomial_ccdf_log( +return_type_t neg_binomial_ccdf_log( const T_n& n, const T_shape& alpha, const T_inv_scale& beta) { return neg_binomial_lccdf(n, alpha, beta); } diff --git a/stan/math/prim/prob/neg_binomial_cdf.hpp b/stan/math/prim/prob/neg_binomial_cdf.hpp index 31163102be1..72e15ac4747 100644 --- a/stan/math/prim/prob/neg_binomial_cdf.hpp +++ b/stan/math/prim/prob/neg_binomial_cdf.hpp @@ -22,8 +22,9 @@ namespace stan { namespace math { template -inline return_type_t neg_binomial_cdf( - const T_n& n, const T_shape& alpha, const T_inv_scale& beta) { +return_type_t neg_binomial_cdf(const T_n& n, + const T_shape& alpha, + const T_inv_scale& beta) { using T_partials_return = partials_return_t; using T_n_ref = ref_type_t; using T_alpha_ref = ref_type_t; diff --git a/stan/math/prim/prob/neg_binomial_cdf_log.hpp b/stan/math/prim/prob/neg_binomial_cdf_log.hpp index 2f9a11fdeac..e1b5ae8a552 100644 --- a/stan/math/prim/prob/neg_binomial_cdf_log.hpp +++ b/stan/math/prim/prob/neg_binomial_cdf_log.hpp @@ -11,7 +11,7 @@ namespace math { * @deprecated use neg_binomial_lcdf */ template -inline return_type_t neg_binomial_cdf_log( +return_type_t neg_binomial_cdf_log( const T_n& n, const T_shape& alpha, const T_inv_scale& beta) { return neg_binomial_lcdf(n, alpha, beta); } diff --git a/stan/math/prim/prob/neg_binomial_lccdf.hpp b/stan/math/prim/prob/neg_binomial_lccdf.hpp index cc24a6b79a7..7f6c6313ee6 100644 --- a/stan/math/prim/prob/neg_binomial_lccdf.hpp +++ b/stan/math/prim/prob/neg_binomial_lccdf.hpp @@ -24,7 +24,7 @@ namespace stan { namespace math { template -inline return_type_t neg_binomial_lccdf( +return_type_t neg_binomial_lccdf( const T_n& n, const T_shape& alpha, const T_inv_scale& beta_param) { using T_partials_return = partials_return_t; using std::exp; diff --git a/stan/math/prim/prob/neg_binomial_lcdf.hpp b/stan/math/prim/prob/neg_binomial_lcdf.hpp index ba85ba41d0d..480a8b5527e 100644 --- a/stan/math/prim/prob/neg_binomial_lcdf.hpp +++ b/stan/math/prim/prob/neg_binomial_lcdf.hpp @@ -24,7 +24,7 @@ namespace stan { namespace math { template -inline return_type_t neg_binomial_lcdf( +return_type_t neg_binomial_lcdf( const T_n& n, const T_shape& alpha, const T_inv_scale& beta_param) { using T_partials_return = partials_return_t; using std::exp; diff --git a/stan/math/prim/prob/neg_binomial_lpmf.hpp b/stan/math/prim/prob/neg_binomial_lpmf.hpp index 61c88160c6b..438116ada48 100644 --- a/stan/math/prim/prob/neg_binomial_lpmf.hpp +++ b/stan/math/prim/prob/neg_binomial_lpmf.hpp @@ -30,8 +30,9 @@ constexpr double neg_binomial_alpha_cutoff = 1e10; template * = nullptr> -inline return_type_t neg_binomial_lpmf( - const T_n& n, const T_shape& alpha, const T_inv_scale& beta) { +return_type_t neg_binomial_lpmf(const T_n& n, + const T_shape& alpha, + const T_inv_scale& beta) { using T_partials_return = partials_return_t; using std::log; using T_n_ref = ref_type_t; diff --git a/stan/math/prim/prob/normal_id_glm_lpdf.hpp b/stan/math/prim/prob/normal_id_glm_lpdf.hpp index 7732b79f763..d653222e682 100644 --- a/stan/math/prim/prob/normal_id_glm_lpdf.hpp +++ b/stan/math/prim/prob/normal_id_glm_lpdf.hpp @@ -53,7 +53,7 @@ namespace math { */ template * = nullptr> -inline return_type_t normal_id_glm_lpdf( +return_type_t normal_id_glm_lpdf( const T_y& y, const T_x& x, const T_alpha& alpha, const T_beta& beta, const T_scale& sigma) { using Eigen::Array; @@ -122,7 +122,8 @@ inline return_type_t normal_id_glm_lpdf( Array y_scaled(N_instances); if constexpr (T_x_rows == 1) { - T_y_scaled_tmp y_scaled_tmp = (x_val * beta_val_vec).coeff(0, 0); + T_y_scaled_tmp y_scaled_tmp + = forward_as((x_val * beta_val_vec).coeff(0, 0)); y_scaled = (as_array_or_scalar(y_val_vec) - y_scaled_tmp - as_array_or_scalar(alpha_val_vec)) * inv_sigma; @@ -147,7 +148,9 @@ inline return_type_t normal_id_glm_lpdf( } if constexpr (is_autodiff_v) { if constexpr (T_x_rows == 1) { - edge<1>(ops_partials).partials_ = beta_val_vec * sum(mu_derivative); + edge<1>(ops_partials).partials_ + = forward_as>( + beta_val_vec * sum(mu_derivative)); } else { edge<1>(ops_partials).partials_ = (beta_val_vec * mu_derivative.transpose()).transpose(); @@ -155,7 +158,9 @@ inline return_type_t normal_id_glm_lpdf( } if constexpr (is_autodiff_v) { if constexpr (T_x_rows == 1) { - edge<3>(ops_partials).partials_ = mu_derivative.sum() * x_val; + edge<3>(ops_partials).partials_ + = forward_as>( + mu_derivative.sum() * x_val); } else { partials<3>(ops_partials) = mu_derivative.transpose() * x_val; } @@ -175,7 +180,8 @@ inline return_type_t normal_id_glm_lpdf( } else { y_scaled_sq_sum = sum(y_scaled * y_scaled); partials<4>(ops_partials)[0] - = (y_scaled_sq_sum - N_instances) * inv_sigma; + = (y_scaled_sq_sum - N_instances) + * forward_as>(inv_sigma); } } else { y_scaled_sq_sum = sum(y_scaled * y_scaled); @@ -201,7 +207,8 @@ inline return_type_t normal_id_glm_lpdf( if constexpr (is_vector::value) { logp -= sum(log(sigma_val_vec)); } else { - logp -= N_instances * log(sigma_val_vec); + logp -= N_instances + * log(forward_as>(sigma_val_vec)); } } logp -= 0.5 * y_scaled_sq_sum; diff --git a/stan/math/prim/prob/normal_sufficient_lpdf.hpp b/stan/math/prim/prob/normal_sufficient_lpdf.hpp index 996b5e2d052..37e1365f169 100644 --- a/stan/math/prim/prob/normal_sufficient_lpdf.hpp +++ b/stan/math/prim/prob/normal_sufficient_lpdf.hpp @@ -51,7 +51,7 @@ namespace math { */ template -inline return_type_t normal_sufficient_lpdf( +return_type_t normal_sufficient_lpdf( const T_y& y_bar, const T_s& s_squared, const T_n& n_obs, const T_loc& mu, const T_scale& sigma) { using T_partials_return = partials_return_t; @@ -132,13 +132,15 @@ inline return_type_t normal_sufficient_lpdf( using T_sigma_value_vector = Eigen::Array; if constexpr (is_vector::value) { - edge<1>(ops_partials).partials_ = -0.5 / sigma_squared; + edge<1>(ops_partials).partials_ + = -0.5 / forward_as(sigma_squared); } else { if constexpr (is_vector::value) { - partials<1>(ops_partials) - = T_sigma_value_vector::Constant(N, -0.5 / sigma_squared); + partials<1>(ops_partials) = T_sigma_value_vector::Constant( + N, -0.5 / forward_as(sigma_squared)); } else { - partials<1>(ops_partials) + forward_as>( + partials<1>(ops_partials)) = -0.5 / sigma_squared * N / math::size(sigma); } } diff --git a/stan/math/prim/prob/ordered_logistic_glm_lpmf.hpp b/stan/math/prim/prob/ordered_logistic_glm_lpmf.hpp index b90b50020c5..8bb3f3cef09 100644 --- a/stan/math/prim/prob/ordered_logistic_glm_lpmf.hpp +++ b/stan/math/prim/prob/ordered_logistic_glm_lpmf.hpp @@ -46,7 +46,7 @@ namespace math { template * = nullptr, require_all_col_vector_t* = nullptr> -inline return_type_t ordered_logistic_glm_lpmf( +return_type_t ordered_logistic_glm_lpmf( const T_y& y, const T_x& x, const T_beta& beta, const T_cuts& cuts) { using Eigen::Array; using Eigen::Dynamic; @@ -210,7 +210,7 @@ inline return_type_t ordered_logistic_glm_lpmf( } template -inline return_type_t ordered_logistic_glm_lpmf( +return_type_t ordered_logistic_glm_lpmf( const T_y& y, const T_x& x, const T_beta& beta, const T_cuts& cuts) { return ordered_logistic_glm_lpmf(y, x, beta, cuts); } diff --git a/stan/math/prim/prob/ordered_logistic_lpmf.hpp b/stan/math/prim/prob/ordered_logistic_lpmf.hpp index dfc550ed883..d102fbbd068 100644 --- a/stan/math/prim/prob/ordered_logistic_lpmf.hpp +++ b/stan/math/prim/prob/ordered_logistic_lpmf.hpp @@ -72,9 +72,9 @@ namespace math { template * = nullptr> -inline return_type_t ordered_logistic_lpmf(const T_y& y, - const T_loc& lambda, - const T_cut& c) { +return_type_t ordered_logistic_lpmf(const T_y& y, + const T_loc& lambda, + const T_cut& c) { using T_partials_return = partials_return_t; using T_cuts_val = partials_return_t; using T_y_ref = ref_type_t; @@ -204,9 +204,9 @@ inline return_type_t ordered_logistic_lpmf(const T_y& y, } template -inline return_type_t ordered_logistic_lpmf(const T_y& y, - const T_loc& lambda, - const T_cut& c) { +return_type_t ordered_logistic_lpmf(const T_y& y, + const T_loc& lambda, + const T_cut& c) { return ordered_logistic_lpmf(y, lambda, c); } diff --git a/stan/math/prim/prob/ordered_probit_lpmf.hpp b/stan/math/prim/prob/ordered_probit_lpmf.hpp index 8cf027f2baf..0ba3dcfd71b 100644 --- a/stan/math/prim/prob/ordered_probit_lpmf.hpp +++ b/stan/math/prim/prob/ordered_probit_lpmf.hpp @@ -45,9 +45,9 @@ namespace math { * of different lengths. */ template -inline return_type_t ordered_probit_lpmf(const T_y& y, - const T_loc& lambda, - const T_cut& c) { +return_type_t ordered_probit_lpmf(const T_y& y, + const T_loc& lambda, + const T_cut& c) { using std::exp; using std::log; using T_lambda_ref = ref_type_t; @@ -101,9 +101,9 @@ inline return_type_t ordered_probit_lpmf(const T_y& y, } template -inline return_type_t ordered_probit_lpmf(const T_y& y, - const T_loc& lambda, - const T_cut& c) { +return_type_t ordered_probit_lpmf(const T_y& y, + const T_loc& lambda, + const T_cut& c) { return ordered_probit_lpmf(y, lambda, c); } } // namespace math diff --git a/stan/math/prim/prob/pareto_ccdf_log.hpp b/stan/math/prim/prob/pareto_ccdf_log.hpp index 0fe2a270f71..e36ed34f4c4 100644 --- a/stan/math/prim/prob/pareto_ccdf_log.hpp +++ b/stan/math/prim/prob/pareto_ccdf_log.hpp @@ -11,8 +11,9 @@ namespace math { * @deprecated use pareto_lccdf */ template -inline return_type_t pareto_ccdf_log( - const T_y& y, const T_scale& y_min, const T_shape& alpha) { +return_type_t pareto_ccdf_log(const T_y& y, + const T_scale& y_min, + const T_shape& alpha) { return pareto_lccdf(y, y_min, alpha); } diff --git a/stan/math/prim/prob/pareto_cdf.hpp b/stan/math/prim/prob/pareto_cdf.hpp index 37d850a6138..66cc2feafe1 100644 --- a/stan/math/prim/prob/pareto_cdf.hpp +++ b/stan/math/prim/prob/pareto_cdf.hpp @@ -20,9 +20,9 @@ namespace math { template * = nullptr> -inline return_type_t pareto_cdf(const T_y& y, - const T_scale& y_min, - const T_shape& alpha) { +return_type_t pareto_cdf(const T_y& y, + const T_scale& y_min, + const T_shape& alpha) { using T_partials_return = partials_return_t; using T_y_ref = ref_type_t; using T_y_min_ref = ref_type_t; diff --git a/stan/math/prim/prob/pareto_cdf_log.hpp b/stan/math/prim/prob/pareto_cdf_log.hpp index d256b721345..1a6359ec49d 100644 --- a/stan/math/prim/prob/pareto_cdf_log.hpp +++ b/stan/math/prim/prob/pareto_cdf_log.hpp @@ -11,8 +11,9 @@ namespace math { * @deprecated use pareto_lcdf */ template -inline return_type_t pareto_cdf_log( - const T_y& y, const T_scale& y_min, const T_shape& alpha) { +return_type_t pareto_cdf_log(const T_y& y, + const T_scale& y_min, + const T_shape& alpha) { return pareto_lcdf(y, y_min, alpha); } diff --git a/stan/math/prim/prob/pareto_lccdf.hpp b/stan/math/prim/prob/pareto_lccdf.hpp index 4c002b0dd0d..d8be81d1685 100644 --- a/stan/math/prim/prob/pareto_lccdf.hpp +++ b/stan/math/prim/prob/pareto_lccdf.hpp @@ -24,9 +24,9 @@ namespace math { template * = nullptr> -inline return_type_t pareto_lccdf(const T_y& y, - const T_scale& y_min, - const T_shape& alpha) { +return_type_t pareto_lccdf(const T_y& y, + const T_scale& y_min, + const T_shape& alpha) { using T_partials_return = partials_return_t; using T_y_ref = ref_type_if_not_constant_t; using T_y_min_ref = ref_type_if_not_constant_t; @@ -83,12 +83,16 @@ inline return_type_t pareto_lccdf(const T_y& y, using Log_quot_scalar = partials_return_t; using Log_quot_array = Eigen::Array; if constexpr (is_vector::value || is_vector::value) { - edge<2>(ops_partials).partials_ = std::move(log_quot); + edge<2>(ops_partials).partials_ + = forward_as(std::move(log_quot)); } else { - partials<2>(ops_partials) = Log_quot_array::Constant(N, 1, log_quot); + partials<2>(ops_partials) = Log_quot_array::Constant( + N, 1, forward_as(log_quot)); } } else { - partials<2>(ops_partials) = log_quot * N / max_size(y, y_min); + forward_as>( + partials<2>(ops_partials)) + = log_quot * N / max_size(y, y_min); } } return ops_partials.build(P); diff --git a/stan/math/prim/prob/pareto_lcdf.hpp b/stan/math/prim/prob/pareto_lcdf.hpp index 6313c6778c6..45d42e1c8e4 100644 --- a/stan/math/prim/prob/pareto_lcdf.hpp +++ b/stan/math/prim/prob/pareto_lcdf.hpp @@ -24,9 +24,9 @@ namespace math { template * = nullptr> -inline return_type_t pareto_lcdf(const T_y& y, - const T_scale& y_min, - const T_shape& alpha) { +return_type_t pareto_lcdf(const T_y& y, + const T_scale& y_min, + const T_shape& alpha) { using T_partials_return = partials_return_t; using T_y_ref = ref_type_if_not_constant_t; using T_y_min_ref = ref_type_if_not_constant_t; diff --git a/stan/math/prim/prob/pareto_lpdf.hpp b/stan/math/prim/prob/pareto_lpdf.hpp index 1bb2cdab1b4..602d5a54a6a 100644 --- a/stan/math/prim/prob/pareto_lpdf.hpp +++ b/stan/math/prim/prob/pareto_lpdf.hpp @@ -24,9 +24,9 @@ namespace math { template * = nullptr> -inline return_type_t pareto_lpdf(const T_y& y, - const T_scale& y_min, - const T_shape& alpha) { +return_type_t pareto_lpdf(const T_y& y, + const T_scale& y_min, + const T_shape& alpha) { using T_partials_return = partials_return_t; using T_y_ref = ref_type_if_not_constant_t; using T_y_min_ref = ref_type_if_not_constant_t; diff --git a/stan/math/prim/prob/pareto_type_2_ccdf_log.hpp b/stan/math/prim/prob/pareto_type_2_ccdf_log.hpp index 15e0e949a25..3f298b323c7 100644 --- a/stan/math/prim/prob/pareto_type_2_ccdf_log.hpp +++ b/stan/math/prim/prob/pareto_type_2_ccdf_log.hpp @@ -11,7 +11,7 @@ namespace math { * @deprecated use pareto_type_2_lccdf */ template -inline return_type_t pareto_type_2_ccdf_log( +return_type_t pareto_type_2_ccdf_log( const T_y& y, const T_loc& mu, const T_scale& lambda, const T_shape& alpha) { return pareto_type_2_lccdf(y, mu, lambda, diff --git a/stan/math/prim/prob/pareto_type_2_cdf.hpp b/stan/math/prim/prob/pareto_type_2_cdf.hpp index 7a492ee9cb8..c94d3f3078f 100644 --- a/stan/math/prim/prob/pareto_type_2_cdf.hpp +++ b/stan/math/prim/prob/pareto_type_2_cdf.hpp @@ -21,7 +21,7 @@ namespace math { template * = nullptr> -inline return_type_t pareto_type_2_cdf( +return_type_t pareto_type_2_cdf( const T_y& y, const T_loc& mu, const T_scale& lambda, const T_shape& alpha) { using T_partials_return = partials_return_t; diff --git a/stan/math/prim/prob/pareto_type_2_cdf_log.hpp b/stan/math/prim/prob/pareto_type_2_cdf_log.hpp index 89128ff5a2c..ef23dd83c8d 100644 --- a/stan/math/prim/prob/pareto_type_2_cdf_log.hpp +++ b/stan/math/prim/prob/pareto_type_2_cdf_log.hpp @@ -11,7 +11,7 @@ namespace math { * @deprecated use pareto_type_2_lcdf */ template -inline return_type_t pareto_type_2_cdf_log( +return_type_t pareto_type_2_cdf_log( const T_y& y, const T_loc& mu, const T_scale& lambda, const T_shape& alpha) { return pareto_type_2_lcdf(y, mu, lambda, alpha); diff --git a/stan/math/prim/prob/pareto_type_2_lccdf.hpp b/stan/math/prim/prob/pareto_type_2_lccdf.hpp index 746d1b17f83..2dc651b2ba9 100644 --- a/stan/math/prim/prob/pareto_type_2_lccdf.hpp +++ b/stan/math/prim/prob/pareto_type_2_lccdf.hpp @@ -21,7 +21,7 @@ namespace math { template * = nullptr> -inline return_type_t pareto_type_2_lccdf( +return_type_t pareto_type_2_lccdf( const T_y& y, const T_loc& mu, const T_scale& lambda, const T_shape& alpha) { using T_partials_return = partials_return_t; @@ -83,12 +83,15 @@ inline return_type_t pareto_type_2_lccdf( using Log_temp_array = Eigen::Array; if constexpr (is_vector::value || is_vector::value || is_vector::value) { - partials<3>(ops_partials) = -log_temp; + partials<3>(ops_partials) = -forward_as(log_temp); } else { - partials<3>(ops_partials) = Log_temp_array::Constant(N, 1, -log_temp); + partials<3>(ops_partials) = Log_temp_array::Constant( + N, 1, -forward_as(log_temp)); } } else { - partials<3>(ops_partials) = -log_temp * N / max_size(y, mu, lambda); + forward_as>( + partials<3>(ops_partials)) + = -log_temp * N / max_size(y, mu, lambda); } } diff --git a/stan/math/prim/prob/pareto_type_2_lcdf.hpp b/stan/math/prim/prob/pareto_type_2_lcdf.hpp index 9d1c175a3a0..286ea5ee6d9 100644 --- a/stan/math/prim/prob/pareto_type_2_lcdf.hpp +++ b/stan/math/prim/prob/pareto_type_2_lcdf.hpp @@ -21,7 +21,7 @@ namespace math { template * = nullptr> -inline return_type_t pareto_type_2_lcdf( +return_type_t pareto_type_2_lcdf( const T_y& y, const T_loc& mu, const T_scale& lambda, const T_shape& alpha) { using T_partials_return = partials_return_t; diff --git a/stan/math/prim/prob/pareto_type_2_lpdf.hpp b/stan/math/prim/prob/pareto_type_2_lpdf.hpp index 9cac66a418e..4a4e9e85360 100644 --- a/stan/math/prim/prob/pareto_type_2_lpdf.hpp +++ b/stan/math/prim/prob/pareto_type_2_lpdf.hpp @@ -24,7 +24,7 @@ template * = nullptr> -inline return_type_t pareto_type_2_lpdf( +return_type_t pareto_type_2_lpdf( const T_y& y, const T_loc& mu, const T_scale& lambda, const T_shape& alpha) { using T_partials_return = partials_return_t; diff --git a/stan/math/prim/prob/poisson_binomial_ccdf_log.hpp b/stan/math/prim/prob/poisson_binomial_ccdf_log.hpp index bca8a5ab76e..c0909344e10 100644 --- a/stan/math/prim/prob/poisson_binomial_ccdf_log.hpp +++ b/stan/math/prim/prob/poisson_binomial_ccdf_log.hpp @@ -11,8 +11,8 @@ namespace math { * @deprecated use poisson_binomial_lccdf */ template -inline return_type_t poisson_binomial_ccdf_log(const T_y& y, - const T_theta& theta) { +return_type_t poisson_binomial_ccdf_log(const T_y& y, + const T_theta& theta) { return poisson_binomial_lccdf(y, theta); } diff --git a/stan/math/prim/prob/poisson_binomial_cdf.hpp b/stan/math/prim/prob/poisson_binomial_cdf.hpp index e11c9d57bd7..f47abf7472d 100644 --- a/stan/math/prim/prob/poisson_binomial_cdf.hpp +++ b/stan/math/prim/prob/poisson_binomial_cdf.hpp @@ -33,8 +33,8 @@ namespace math { * @throw std::invalid_argument If y and theta are different lengths */ template -inline return_type_t poisson_binomial_cdf(const T_y& y, - const T_theta& theta) { +return_type_t poisson_binomial_cdf(const T_y& y, + const T_theta& theta) { static constexpr const char* function = "poisson_binomial_cdf"; auto size_theta = size_mvt(theta); @@ -63,8 +63,8 @@ inline return_type_t poisson_binomial_cdf(const T_y& y, } template -inline return_type_t poisson_binomial_cdf(const T_y& y, - const T_theta& theta) { +return_type_t poisson_binomial_cdf(const T_y& y, + const T_theta& theta) { return poisson_binomial_cdf(y, theta); } diff --git a/stan/math/prim/prob/poisson_binomial_cdf_log.hpp b/stan/math/prim/prob/poisson_binomial_cdf_log.hpp index 068563956f0..e82a26c0ce0 100644 --- a/stan/math/prim/prob/poisson_binomial_cdf_log.hpp +++ b/stan/math/prim/prob/poisson_binomial_cdf_log.hpp @@ -11,8 +11,8 @@ namespace math { * @deprecated use poisson_binomial_lcdf */ template -inline return_type_t poisson_binomial_cdf_log(const T_y& y, - const T_theta& theta) { +return_type_t poisson_binomial_cdf_log(const T_y& y, + const T_theta& theta) { return poisson_binomial_lcdf(y, theta); } diff --git a/stan/math/prim/prob/poisson_binomial_lccdf.hpp b/stan/math/prim/prob/poisson_binomial_lccdf.hpp index aa2787951a3..8d946f1a4c6 100644 --- a/stan/math/prim/prob/poisson_binomial_lccdf.hpp +++ b/stan/math/prim/prob/poisson_binomial_lccdf.hpp @@ -34,8 +34,8 @@ namespace math { * @throw std::invalid_argument If y and theta are different lengths */ template -inline return_type_t poisson_binomial_lccdf(const T_y& y, - const T_theta& theta) { +return_type_t poisson_binomial_lccdf(const T_y& y, + const T_theta& theta) { static constexpr const char* function = "poisson_binomial_lccdf"; auto size_theta = size_mvt(theta); @@ -74,8 +74,8 @@ inline return_type_t poisson_binomial_lccdf(const T_y& y, } template -inline return_type_t poisson_binomial_lccdf(const T_y& y, - const T_theta& theta) { +return_type_t poisson_binomial_lccdf(const T_y& y, + const T_theta& theta) { return poisson_binomial_lccdf(y, theta); } diff --git a/stan/math/prim/prob/poisson_binomial_lcdf.hpp b/stan/math/prim/prob/poisson_binomial_lcdf.hpp index 116c01144c1..7d449aa0caa 100644 --- a/stan/math/prim/prob/poisson_binomial_lcdf.hpp +++ b/stan/math/prim/prob/poisson_binomial_lcdf.hpp @@ -33,8 +33,8 @@ namespace math { * @throw std::invalid_argument If y and theta are different lengths */ template -inline return_type_t poisson_binomial_lcdf(const T_y& y, - const T_theta& theta) { +return_type_t poisson_binomial_lcdf(const T_y& y, + const T_theta& theta) { static constexpr const char* function = "poisson_binomial_lcdf"; auto size_theta = size_mvt(theta); @@ -64,8 +64,8 @@ inline return_type_t poisson_binomial_lcdf(const T_y& y, } template -inline return_type_t poisson_binomial_lcdf(const T_y& y, - const T_theta& theta) { +return_type_t poisson_binomial_lcdf(const T_y& y, + const T_theta& theta) { return poisson_binomial_lcdf(y, theta); } diff --git a/stan/math/prim/prob/poisson_binomial_lpmf.hpp b/stan/math/prim/prob/poisson_binomial_lpmf.hpp index f672823f859..709a709c756 100644 --- a/stan/math/prim/prob/poisson_binomial_lpmf.hpp +++ b/stan/math/prim/prob/poisson_binomial_lpmf.hpp @@ -25,8 +25,8 @@ namespace math { * @throw std::invalid_argument If y and theta are different lengths */ template -inline return_type_t poisson_binomial_lpmf(const T_y& y, - const T_theta& theta) { +return_type_t poisson_binomial_lpmf(const T_y& y, + const T_theta& theta) { static constexpr const char* function = "poisson_binomial_lpmf"; auto size_theta = size_mvt(theta); @@ -57,8 +57,8 @@ inline return_type_t poisson_binomial_lpmf(const T_y& y, } template -inline return_type_t poisson_binomial_lpmf(const T_y& y, - const T_theta& theta) { +return_type_t poisson_binomial_lpmf(const T_y& y, + const T_theta& theta) { return poisson_binomial_lpmf(y, theta); } diff --git a/stan/math/prim/prob/poisson_ccdf_log.hpp b/stan/math/prim/prob/poisson_ccdf_log.hpp index cc478a34131..a07a343acc3 100644 --- a/stan/math/prim/prob/poisson_ccdf_log.hpp +++ b/stan/math/prim/prob/poisson_ccdf_log.hpp @@ -11,8 +11,7 @@ namespace math { * @deprecated use poisson_lccdf */ template -inline return_type_t poisson_ccdf_log(const T_n& n, - const T_rate& lambda) { +return_type_t poisson_ccdf_log(const T_n& n, const T_rate& lambda) { return poisson_lccdf(n, lambda); } diff --git a/stan/math/prim/prob/poisson_cdf.hpp b/stan/math/prim/prob/poisson_cdf.hpp index c6ba4b866e0..0db9a18dd41 100644 --- a/stan/math/prim/prob/poisson_cdf.hpp +++ b/stan/math/prim/prob/poisson_cdf.hpp @@ -24,7 +24,7 @@ namespace math { // Poisson CDF template -inline return_type_t poisson_cdf(const T_n& n, const T_rate& lambda) { +return_type_t poisson_cdf(const T_n& n, const T_rate& lambda) { using T_partials_return = partials_return_t; using T_n_ref = ref_type_if_not_constant_t; using T_lambda_ref = ref_type_if_not_constant_t; diff --git a/stan/math/prim/prob/poisson_cdf_log.hpp b/stan/math/prim/prob/poisson_cdf_log.hpp index d7ec5be6f1d..bccca07aa31 100644 --- a/stan/math/prim/prob/poisson_cdf_log.hpp +++ b/stan/math/prim/prob/poisson_cdf_log.hpp @@ -11,8 +11,7 @@ namespace math { * @deprecated use poisson_lcdf */ template -inline return_type_t poisson_cdf_log(const T_n& n, - const T_rate& lambda) { +return_type_t poisson_cdf_log(const T_n& n, const T_rate& lambda) { return poisson_lcdf(n, lambda); } diff --git a/stan/math/prim/prob/poisson_lccdf.hpp b/stan/math/prim/prob/poisson_lccdf.hpp index c3a622cfb9d..94fb6469c98 100644 --- a/stan/math/prim/prob/poisson_lccdf.hpp +++ b/stan/math/prim/prob/poisson_lccdf.hpp @@ -25,7 +25,7 @@ namespace stan { namespace math { template -inline return_type_t poisson_lccdf(const T_n& n, const T_rate& lambda) { +return_type_t poisson_lccdf(const T_n& n, const T_rate& lambda) { using T_partials_return = partials_return_t; using T_n_ref = ref_type_if_not_constant_t; using T_lambda_ref = ref_type_if_not_constant_t; diff --git a/stan/math/prim/prob/poisson_lcdf.hpp b/stan/math/prim/prob/poisson_lcdf.hpp index 31baff192c3..b9aec6efe45 100644 --- a/stan/math/prim/prob/poisson_lcdf.hpp +++ b/stan/math/prim/prob/poisson_lcdf.hpp @@ -25,7 +25,7 @@ namespace stan { namespace math { template -inline return_type_t poisson_lcdf(const T_n& n, const T_rate& lambda) { +return_type_t poisson_lcdf(const T_n& n, const T_rate& lambda) { using T_partials_return = partials_return_t; using T_n_ref = ref_type_if_not_constant_t; using T_lambda_ref = ref_type_if_not_constant_t; diff --git a/stan/math/prim/prob/poisson_log_glm_lpmf.hpp b/stan/math/prim/prob/poisson_log_glm_lpmf.hpp index 1fb93913b8f..be44d4a7ecd 100644 --- a/stan/math/prim/prob/poisson_log_glm_lpmf.hpp +++ b/stan/math/prim/prob/poisson_log_glm_lpmf.hpp @@ -50,18 +50,24 @@ namespace math { */ template * = nullptr> -inline return_type_t poisson_log_glm_lpmf( - const T_y& y, const T_x& x, const T_alpha& alpha, const T_beta& beta) { +return_type_t poisson_log_glm_lpmf(const T_y& y, + const T_x& x, + const T_alpha& alpha, + const T_beta& beta) { using Eigen::Array; using Eigen::Dynamic; using Eigen::Matrix; using std::exp; using std::isfinite; constexpr int T_x_rows = T_x::RowsAtCompileTime; + using T_xbeta_partials = partials_return_t; using T_partials_return = partials_return_t; using T_theta_tmp = typename std::conditional_t>; + using T_xbeta_tmp = + typename std::conditional_t>; using T_x_ref = ref_type_if_not_constant_t; using T_alpha_ref = ref_type_if_not_constant_t; using T_beta_ref = ref_type_if_not_constant_t; @@ -100,7 +106,8 @@ inline return_type_t poisson_log_glm_lpmf( Array theta(N_instances); if constexpr (T_x_rows == 1) { - T_theta_tmp theta_tmp = (x_val * beta_val_vec).coeff(0, 0); + T_theta_tmp theta_tmp + = forward_as((x_val * beta_val_vec).coeff(0, 0)); theta = theta_tmp + as_array_or_scalar(alpha_val_vec); } else { theta = x_val * beta_val_vec; @@ -128,14 +135,18 @@ inline return_type_t poisson_log_glm_lpmf( // Compute the necessary derivatives. if constexpr (is_autodiff_v) { if constexpr (T_x_rows == 1) { - edge<2>(ops_partials).partials_ = theta_derivative.sum() * x_val; + edge<2>(ops_partials).partials_ + = forward_as>( + theta_derivative.sum() * x_val); } else { partials<2>(ops_partials) = x_val.transpose() * theta_derivative; } } if constexpr (is_autodiff_v) { if constexpr (T_x_rows == 1) { - edge<0>(ops_partials).partials_ = beta_val_vec * theta_derivative.sum(); + edge<0>(ops_partials).partials_ + = forward_as>( + beta_val_vec * theta_derivative.sum()); } else { edge<0>(ops_partials).partials_ = (beta_val_vec * theta_derivative.transpose()).transpose(); diff --git a/stan/math/prim/prob/poisson_log_lpmf.hpp b/stan/math/prim/prob/poisson_log_lpmf.hpp index 0a169647e92..a0450197af5 100644 --- a/stan/math/prim/prob/poisson_log_lpmf.hpp +++ b/stan/math/prim/prob/poisson_log_lpmf.hpp @@ -26,8 +26,8 @@ namespace math { template * = nullptr> -inline return_type_t poisson_log_lpmf(const T_n& n, - const T_log_rate& alpha) { +return_type_t poisson_log_lpmf(const T_n& n, + const T_log_rate& alpha) { using T_partials_return = partials_return_t; using T_n_ref = ref_type_if_not_constant_t; using T_alpha_ref = ref_type_if_not_constant_t; diff --git a/stan/math/prim/prob/poisson_lpmf.hpp b/stan/math/prim/prob/poisson_lpmf.hpp index a235c16be5a..a35ef780a03 100644 --- a/stan/math/prim/prob/poisson_lpmf.hpp +++ b/stan/math/prim/prob/poisson_lpmf.hpp @@ -26,7 +26,7 @@ namespace math { template * = nullptr> -inline return_type_t poisson_lpmf(const T_n& n, const T_rate& lambda) { +return_type_t poisson_lpmf(const T_n& n, const T_rate& lambda) { using T_partials_return = partials_return_t; using T_n_ref = ref_type_if_not_constant_t; using T_lambda_ref = ref_type_if_not_constant_t; diff --git a/stan/math/prim/prob/rayleigh_ccdf_log.hpp b/stan/math/prim/prob/rayleigh_ccdf_log.hpp index b74373bff23..b966f1e3901 100644 --- a/stan/math/prim/prob/rayleigh_ccdf_log.hpp +++ b/stan/math/prim/prob/rayleigh_ccdf_log.hpp @@ -11,8 +11,8 @@ namespace math { * @deprecated use rayleigh_lccdf */ template -inline return_type_t rayleigh_ccdf_log(const T_y& y, - const T_scale& sigma) { +return_type_t rayleigh_ccdf_log(const T_y& y, + const T_scale& sigma) { return rayleigh_lccdf(y, sigma); } diff --git a/stan/math/prim/prob/rayleigh_cdf.hpp b/stan/math/prim/prob/rayleigh_cdf.hpp index 84a17050667..38eba480df7 100644 --- a/stan/math/prim/prob/rayleigh_cdf.hpp +++ b/stan/math/prim/prob/rayleigh_cdf.hpp @@ -22,8 +22,7 @@ namespace math { template * = nullptr> -inline return_type_t rayleigh_cdf(const T_y& y, - const T_scale& sigma) { +return_type_t rayleigh_cdf(const T_y& y, const T_scale& sigma) { using T_partials_return = partials_return_t; using T_y_ref = ref_type_if_not_constant_t; using T_sigma_ref = ref_type_if_not_constant_t; diff --git a/stan/math/prim/prob/rayleigh_cdf_log.hpp b/stan/math/prim/prob/rayleigh_cdf_log.hpp index 1e5643a5633..831bb8a188e 100644 --- a/stan/math/prim/prob/rayleigh_cdf_log.hpp +++ b/stan/math/prim/prob/rayleigh_cdf_log.hpp @@ -11,8 +11,8 @@ namespace math { * @deprecated use rayleigh_lcdf */ template -inline return_type_t rayleigh_cdf_log(const T_y& y, - const T_scale& sigma) { +return_type_t rayleigh_cdf_log(const T_y& y, + const T_scale& sigma) { return rayleigh_lcdf(y, sigma); } diff --git a/stan/math/prim/prob/rayleigh_lccdf.hpp b/stan/math/prim/prob/rayleigh_lccdf.hpp index 082f72a2522..e8f8dc0b9c8 100644 --- a/stan/math/prim/prob/rayleigh_lccdf.hpp +++ b/stan/math/prim/prob/rayleigh_lccdf.hpp @@ -20,8 +20,7 @@ namespace math { template * = nullptr> -inline return_type_t rayleigh_lccdf(const T_y& y, - const T_scale& sigma) { +return_type_t rayleigh_lccdf(const T_y& y, const T_scale& sigma) { using T_partials_return = partials_return_t; using T_y_ref = ref_type_if_not_constant_t; using T_sigma_ref = ref_type_if_not_constant_t; diff --git a/stan/math/prim/prob/rayleigh_lcdf.hpp b/stan/math/prim/prob/rayleigh_lcdf.hpp index a3e66b71ff3..93ff1463ec8 100644 --- a/stan/math/prim/prob/rayleigh_lcdf.hpp +++ b/stan/math/prim/prob/rayleigh_lcdf.hpp @@ -22,8 +22,7 @@ namespace math { template * = nullptr> -inline return_type_t rayleigh_lcdf(const T_y& y, - const T_scale& sigma) { +return_type_t rayleigh_lcdf(const T_y& y, const T_scale& sigma) { using T_partials_return = partials_return_t; using T_y_ref = ref_type_if_not_constant_t; using T_sigma_ref = ref_type_if_not_constant_t; diff --git a/stan/math/prim/prob/rayleigh_lpdf.hpp b/stan/math/prim/prob/rayleigh_lpdf.hpp index 2ac376d4179..1316d81d520 100644 --- a/stan/math/prim/prob/rayleigh_lpdf.hpp +++ b/stan/math/prim/prob/rayleigh_lpdf.hpp @@ -22,8 +22,7 @@ namespace math { template * = nullptr> -inline return_type_t rayleigh_lpdf(const T_y& y, - const T_scale& sigma) { +return_type_t rayleigh_lpdf(const T_y& y, const T_scale& sigma) { using T_partials_return = partials_return_t; using T_y_ref = ref_type_if_not_constant_t; using T_sigma_ref = ref_type_if_not_constant_t; diff --git a/stan/math/prim/prob/scaled_inv_chi_square_ccdf_log.hpp b/stan/math/prim/prob/scaled_inv_chi_square_ccdf_log.hpp index f507a380483..3a02fa58bcc 100644 --- a/stan/math/prim/prob/scaled_inv_chi_square_ccdf_log.hpp +++ b/stan/math/prim/prob/scaled_inv_chi_square_ccdf_log.hpp @@ -11,7 +11,7 @@ namespace math { * @deprecated use scaled_inv_chi_square_lccdf */ template -inline return_type_t scaled_inv_chi_square_ccdf_log( +return_type_t scaled_inv_chi_square_ccdf_log( const T_y& y, const T_dof& nu, const T_scale& s) { return scaled_inv_chi_square_lccdf(y, nu, s); } diff --git a/stan/math/prim/prob/scaled_inv_chi_square_cdf.hpp b/stan/math/prim/prob/scaled_inv_chi_square_cdf.hpp index 1ba20033d68..62389b900cf 100644 --- a/stan/math/prim/prob/scaled_inv_chi_square_cdf.hpp +++ b/stan/math/prim/prob/scaled_inv_chi_square_cdf.hpp @@ -35,8 +35,9 @@ namespace math { * @throw std::domain_error if y is not greater than 0. */ template -inline return_type_t scaled_inv_chi_square_cdf( - const T_y& y, const T_dof& nu, const T_scale& s) { +return_type_t scaled_inv_chi_square_cdf(const T_y& y, + const T_dof& nu, + const T_scale& s) { using T_partials_return = partials_return_t; using std::exp; using std::pow; diff --git a/stan/math/prim/prob/scaled_inv_chi_square_cdf_log.hpp b/stan/math/prim/prob/scaled_inv_chi_square_cdf_log.hpp index 087cd5e1f4b..61ac261e1e1 100644 --- a/stan/math/prim/prob/scaled_inv_chi_square_cdf_log.hpp +++ b/stan/math/prim/prob/scaled_inv_chi_square_cdf_log.hpp @@ -11,7 +11,7 @@ namespace math { * @deprecated use scaled_inv_chi_square_lcdf */ template -inline return_type_t scaled_inv_chi_square_cdf_log( +return_type_t scaled_inv_chi_square_cdf_log( const T_y& y, const T_dof& nu, const T_scale& s) { return scaled_inv_chi_square_lcdf(y, nu, s); } diff --git a/stan/math/prim/prob/scaled_inv_chi_square_lccdf.hpp b/stan/math/prim/prob/scaled_inv_chi_square_lccdf.hpp index 5d14e326e18..dfaa148e9c7 100644 --- a/stan/math/prim/prob/scaled_inv_chi_square_lccdf.hpp +++ b/stan/math/prim/prob/scaled_inv_chi_square_lccdf.hpp @@ -22,7 +22,7 @@ namespace stan { namespace math { template -inline return_type_t scaled_inv_chi_square_lccdf( +return_type_t scaled_inv_chi_square_lccdf( const T_y& y, const T_dof& nu, const T_scale& s) { using T_partials_return = partials_return_t; using std::exp; diff --git a/stan/math/prim/prob/scaled_inv_chi_square_lcdf.hpp b/stan/math/prim/prob/scaled_inv_chi_square_lcdf.hpp index ad017867c8d..07dae6187ab 100644 --- a/stan/math/prim/prob/scaled_inv_chi_square_lcdf.hpp +++ b/stan/math/prim/prob/scaled_inv_chi_square_lcdf.hpp @@ -22,7 +22,7 @@ namespace stan { namespace math { template -inline return_type_t scaled_inv_chi_square_lcdf( +return_type_t scaled_inv_chi_square_lcdf( const T_y& y, const T_dof& nu, const T_scale& s) { using T_partials_return = partials_return_t; using std::exp; diff --git a/stan/math/prim/prob/scaled_inv_chi_square_lpdf.hpp b/stan/math/prim/prob/scaled_inv_chi_square_lpdf.hpp index d2a19422727..75f19f82908 100644 --- a/stan/math/prim/prob/scaled_inv_chi_square_lpdf.hpp +++ b/stan/math/prim/prob/scaled_inv_chi_square_lpdf.hpp @@ -44,7 +44,7 @@ namespace math { template * = nullptr> -inline return_type_t scaled_inv_chi_square_lpdf( +return_type_t scaled_inv_chi_square_lpdf( const T_y& y, const T_dof& nu, const T_scale& s) { using T_partials_return = partials_return_t; using std::log; diff --git a/stan/math/prim/prob/skew_double_exponential_cdf.hpp b/stan/math/prim/prob/skew_double_exponential_cdf.hpp index 8a96fc901a1..47f2a7957f1 100644 --- a/stan/math/prim/prob/skew_double_exponential_cdf.hpp +++ b/stan/math/prim/prob/skew_double_exponential_cdf.hpp @@ -38,9 +38,9 @@ namespace math { template * = nullptr> -inline return_type_t -skew_double_exponential_cdf(const T_y& y, const T_loc& mu, const T_scale& sigma, - const T_skewness& tau) { +return_type_t skew_double_exponential_cdf( + const T_y& y, const T_loc& mu, const T_scale& sigma, + const T_skewness& tau) { using T_partials_return = partials_return_t; static constexpr const char* function = "skew_double_exponential_lcdf"; check_consistent_sizes(function, "Random variable", y, "Location parameter", diff --git a/stan/math/prim/prob/skew_double_exponential_lccdf.hpp b/stan/math/prim/prob/skew_double_exponential_lccdf.hpp index abcf1b76c35..7a1eff6d51a 100644 --- a/stan/math/prim/prob/skew_double_exponential_lccdf.hpp +++ b/stan/math/prim/prob/skew_double_exponential_lccdf.hpp @@ -37,9 +37,9 @@ namespace math { template * = nullptr> -inline return_type_t -skew_double_exponential_lccdf(const T_y& y, const T_loc& mu, - const T_scale& sigma, const T_skewness& tau) { +return_type_t skew_double_exponential_lccdf( + const T_y& y, const T_loc& mu, const T_scale& sigma, + const T_skewness& tau) { static constexpr const char* function = "skew_double_exponential_lccdf"; using T_partials_return = partials_return_t; check_consistent_sizes(function, "Random variable", y, "Location parameter", diff --git a/stan/math/prim/prob/skew_double_exponential_lcdf.hpp b/stan/math/prim/prob/skew_double_exponential_lcdf.hpp index a84ac2ca2b2..68d1df8014f 100644 --- a/stan/math/prim/prob/skew_double_exponential_lcdf.hpp +++ b/stan/math/prim/prob/skew_double_exponential_lcdf.hpp @@ -38,9 +38,9 @@ namespace math { template * = nullptr> -inline return_type_t -skew_double_exponential_lcdf(const T_y& y, const T_loc& mu, - const T_scale& sigma, const T_skewness& tau) { +return_type_t skew_double_exponential_lcdf( + const T_y& y, const T_loc& mu, const T_scale& sigma, + const T_skewness& tau) { using std::exp; using std::log; using T_partials_return = partials_return_t; diff --git a/stan/math/prim/prob/skew_double_exponential_lpdf.hpp b/stan/math/prim/prob/skew_double_exponential_lpdf.hpp index b83753f7168..2ae881b7466 100644 --- a/stan/math/prim/prob/skew_double_exponential_lpdf.hpp +++ b/stan/math/prim/prob/skew_double_exponential_lpdf.hpp @@ -40,9 +40,9 @@ template * = nullptr> -inline return_type_t -skew_double_exponential_lpdf(const T_y& y, const T_loc& mu, - const T_scale& sigma, const T_skewness& tau) { +return_type_t skew_double_exponential_lpdf( + const T_y& y, const T_loc& mu, const T_scale& sigma, + const T_skewness& tau) { using T_partials_return = partials_return_t; using T_y_ref = ref_type_if_not_constant_t; using T_mu_ref = ref_type_if_not_constant_t; @@ -126,9 +126,9 @@ skew_double_exponential_lpdf(const T_y& y, const T_loc& mu, } template -inline return_type_t -skew_double_exponential_lpdf(const T_y& y, const T_loc& mu, - const T_scale& sigma, const T_skewness& tau) { +return_type_t skew_double_exponential_lpdf( + const T_y& y, const T_loc& mu, const T_scale& sigma, + const T_skewness& tau) { return skew_double_exponential_lpdf(y, mu, sigma, tau); } diff --git a/stan/math/prim/prob/skew_normal_ccdf_log.hpp b/stan/math/prim/prob/skew_normal_ccdf_log.hpp index b261d7d3efb..fd911ea9bad 100644 --- a/stan/math/prim/prob/skew_normal_ccdf_log.hpp +++ b/stan/math/prim/prob/skew_normal_ccdf_log.hpp @@ -11,7 +11,7 @@ namespace math { * @deprecated use skew_normal_lccdf */ template -inline return_type_t skew_normal_ccdf_log( +return_type_t skew_normal_ccdf_log( const T_y& y, const T_loc& mu, const T_scale& sigma, const T_shape& alpha) { return skew_normal_lccdf(y, mu, sigma, alpha); } diff --git a/stan/math/prim/prob/skew_normal_cdf.hpp b/stan/math/prim/prob/skew_normal_cdf.hpp index 5fe8e76582d..259c097dbdc 100644 --- a/stan/math/prim/prob/skew_normal_cdf.hpp +++ b/stan/math/prim/prob/skew_normal_cdf.hpp @@ -25,7 +25,7 @@ namespace stan { namespace math { template -inline return_type_t skew_normal_cdf( +return_type_t skew_normal_cdf( const T_y& y, const T_loc& mu, const T_scale& sigma, const T_shape& alpha) { using T_partials_return = partials_return_t; using T_y_ref = ref_type_if_not_constant_t; diff --git a/stan/math/prim/prob/skew_normal_cdf_log.hpp b/stan/math/prim/prob/skew_normal_cdf_log.hpp index b6962bb0117..e3326eb1cad 100644 --- a/stan/math/prim/prob/skew_normal_cdf_log.hpp +++ b/stan/math/prim/prob/skew_normal_cdf_log.hpp @@ -11,7 +11,7 @@ namespace math { * @deprecated use skew_normal_lcdf */ template -inline return_type_t skew_normal_cdf_log( +return_type_t skew_normal_cdf_log( const T_y& y, const T_loc& mu, const T_scale& sigma, const T_shape& alpha) { return skew_normal_lcdf(y, mu, sigma, alpha); } diff --git a/stan/math/prim/prob/skew_normal_lccdf.hpp b/stan/math/prim/prob/skew_normal_lccdf.hpp index 63bc3943e9f..4d96775f6bc 100644 --- a/stan/math/prim/prob/skew_normal_lccdf.hpp +++ b/stan/math/prim/prob/skew_normal_lccdf.hpp @@ -23,7 +23,7 @@ namespace stan { namespace math { template -inline return_type_t skew_normal_lccdf( +return_type_t skew_normal_lccdf( const T_y& y, const T_loc& mu, const T_scale& sigma, const T_shape& alpha) { using T_partials_return = partials_return_t; using T_y_ref = ref_type_if_not_constant_t; diff --git a/stan/math/prim/prob/skew_normal_lcdf.hpp b/stan/math/prim/prob/skew_normal_lcdf.hpp index 97457163b4e..f6ee6066c90 100644 --- a/stan/math/prim/prob/skew_normal_lcdf.hpp +++ b/stan/math/prim/prob/skew_normal_lcdf.hpp @@ -25,7 +25,7 @@ namespace stan { namespace math { template -inline return_type_t skew_normal_lcdf( +return_type_t skew_normal_lcdf( const T_y& y, const T_loc& mu, const T_scale& sigma, const T_shape& alpha) { using T_partials_return = partials_return_t; using T_y_ref = ref_type_if_not_constant_t; diff --git a/stan/math/prim/prob/skew_normal_lpdf.hpp b/stan/math/prim/prob/skew_normal_lpdf.hpp index 473f93dd306..58f1f63d1ae 100644 --- a/stan/math/prim/prob/skew_normal_lpdf.hpp +++ b/stan/math/prim/prob/skew_normal_lpdf.hpp @@ -26,7 +26,7 @@ template * = nullptr> -inline return_type_t skew_normal_lpdf( +return_type_t skew_normal_lpdf( const T_y& y, const T_loc& mu, const T_scale& sigma, const T_shape& alpha) { using T_partials_return = partials_return_t; using T_y_ref = ref_type_if_not_constant_t; diff --git a/stan/math/prim/prob/std_normal_lpdf.hpp b/stan/math/prim/prob/std_normal_lpdf.hpp index 02c86b87a32..50cc1fd5a26 100644 --- a/stan/math/prim/prob/std_normal_lpdf.hpp +++ b/stan/math/prim/prob/std_normal_lpdf.hpp @@ -29,7 +29,7 @@ namespace math { template < bool propto, typename T_y, require_all_not_nonscalar_prim_or_rev_kernel_expression_t* = nullptr> -inline return_type_t std_normal_lpdf(const T_y& y) { +return_type_t std_normal_lpdf(const T_y& y) { using T_partials_return = partials_return_t; using T_y_ref = ref_type_t; static constexpr const char* function = "std_normal_lpdf"; diff --git a/stan/math/prim/prob/student_t_ccdf_log.hpp b/stan/math/prim/prob/student_t_ccdf_log.hpp index 372305a97c3..7512ba1d33e 100644 --- a/stan/math/prim/prob/student_t_ccdf_log.hpp +++ b/stan/math/prim/prob/student_t_ccdf_log.hpp @@ -11,7 +11,7 @@ namespace math { * @deprecated use student_t_lccdf */ template -inline return_type_t student_t_ccdf_log( +return_type_t student_t_ccdf_log( const T_y& y, const T_dof& nu, const T_loc& mu, const T_scale& sigma) { return student_t_lccdf(y, nu, mu, sigma); } diff --git a/stan/math/prim/prob/student_t_cdf.hpp b/stan/math/prim/prob/student_t_cdf.hpp index f9720c61209..d8517f0f76f 100644 --- a/stan/math/prim/prob/student_t_cdf.hpp +++ b/stan/math/prim/prob/student_t_cdf.hpp @@ -20,8 +20,10 @@ namespace stan { namespace math { template -inline return_type_t student_t_cdf( - const T_y& y, const T_dof& nu, const T_loc& mu, const T_scale& sigma) { +return_type_t student_t_cdf(const T_y& y, + const T_dof& nu, + const T_loc& mu, + const T_scale& sigma) { using T_partials_return = partials_return_t; using T_y_ref = ref_type_t; using T_nu_ref = ref_type_t; diff --git a/stan/math/prim/prob/student_t_cdf_log.hpp b/stan/math/prim/prob/student_t_cdf_log.hpp index 85d06eba156..b9b7e181ddc 100644 --- a/stan/math/prim/prob/student_t_cdf_log.hpp +++ b/stan/math/prim/prob/student_t_cdf_log.hpp @@ -11,7 +11,7 @@ namespace math { * @deprecated use student_t_lcdf */ template -inline return_type_t student_t_cdf_log( +return_type_t student_t_cdf_log( const T_y& y, const T_dof& nu, const T_loc& mu, const T_scale& sigma) { return student_t_lcdf(y, nu, mu, sigma); } diff --git a/stan/math/prim/prob/student_t_lccdf.hpp b/stan/math/prim/prob/student_t_lccdf.hpp index af8cb6208b0..e513ada28dd 100644 --- a/stan/math/prim/prob/student_t_lccdf.hpp +++ b/stan/math/prim/prob/student_t_lccdf.hpp @@ -21,7 +21,7 @@ namespace stan { namespace math { template -inline return_type_t student_t_lccdf( +return_type_t student_t_lccdf( const T_y& y, const T_dof& nu, const T_loc& mu, const T_scale& sigma) { using T_partials_return = partials_return_t; using T_y_ref = ref_type_t; diff --git a/stan/math/prim/prob/student_t_lcdf.hpp b/stan/math/prim/prob/student_t_lcdf.hpp index 793b23273ed..d9390702751 100644 --- a/stan/math/prim/prob/student_t_lcdf.hpp +++ b/stan/math/prim/prob/student_t_lcdf.hpp @@ -21,8 +21,10 @@ namespace stan { namespace math { template -inline return_type_t student_t_lcdf( - const T_y& y, const T_dof& nu, const T_loc& mu, const T_scale& sigma) { +return_type_t student_t_lcdf(const T_y& y, + const T_dof& nu, + const T_loc& mu, + const T_scale& sigma) { using T_partials_return = partials_return_t; using T_y_ref = ref_type_t; using T_nu_ref = ref_type_t; diff --git a/stan/math/prim/prob/student_t_lpdf.hpp b/stan/math/prim/prob/student_t_lpdf.hpp index b2c625840b9..0ea4f569007 100644 --- a/stan/math/prim/prob/student_t_lpdf.hpp +++ b/stan/math/prim/prob/student_t_lpdf.hpp @@ -56,8 +56,10 @@ template * = nullptr> -inline return_type_t student_t_lpdf( - const T_y& y, const T_dof& nu, const T_loc& mu, const T_scale& sigma) { +return_type_t student_t_lpdf(const T_y& y, + const T_dof& nu, + const T_loc& mu, + const T_scale& sigma) { using T_partials_return = partials_return_t; using T_y_ref = ref_type_if_not_constant_t; using T_nu_ref = ref_type_if_not_constant_t; diff --git a/stan/math/prim/prob/uniform_ccdf_log.hpp b/stan/math/prim/prob/uniform_ccdf_log.hpp index d492743bb50..166750fa448 100644 --- a/stan/math/prim/prob/uniform_ccdf_log.hpp +++ b/stan/math/prim/prob/uniform_ccdf_log.hpp @@ -11,9 +11,9 @@ namespace math { * @deprecated use uniform_lccdf */ template -inline return_type_t uniform_ccdf_log(const T_y& y, - const T_low& alpha, - const T_high& beta) { +return_type_t uniform_ccdf_log(const T_y& y, + const T_low& alpha, + const T_high& beta) { return uniform_lccdf(y, alpha, beta); } diff --git a/stan/math/prim/prob/uniform_cdf.hpp b/stan/math/prim/prob/uniform_cdf.hpp index 52c2660ec1f..eb3811cd81b 100644 --- a/stan/math/prim/prob/uniform_cdf.hpp +++ b/stan/math/prim/prob/uniform_cdf.hpp @@ -20,9 +20,8 @@ namespace math { template * = nullptr> -inline return_type_t uniform_cdf(const T_y& y, - const T_low& alpha, - const T_high& beta) { +return_type_t uniform_cdf(const T_y& y, const T_low& alpha, + const T_high& beta) { using T_partials_return = partials_return_t; using T_y_ref = ref_type_if_not_constant_t; using T_alpha_ref = ref_type_if_not_constant_t; diff --git a/stan/math/prim/prob/uniform_cdf_log.hpp b/stan/math/prim/prob/uniform_cdf_log.hpp index 10e9f30fe09..2047ed4d6d9 100644 --- a/stan/math/prim/prob/uniform_cdf_log.hpp +++ b/stan/math/prim/prob/uniform_cdf_log.hpp @@ -11,9 +11,9 @@ namespace math { * @deprecated use uniform_lcdf */ template -inline return_type_t uniform_cdf_log(const T_y& y, - const T_low& alpha, - const T_high& beta) { +return_type_t uniform_cdf_log(const T_y& y, + const T_low& alpha, + const T_high& beta) { return uniform_lcdf(y, alpha, beta); } diff --git a/stan/math/prim/prob/uniform_lccdf.hpp b/stan/math/prim/prob/uniform_lccdf.hpp index 0dd1f8c0b57..06656a69333 100644 --- a/stan/math/prim/prob/uniform_lccdf.hpp +++ b/stan/math/prim/prob/uniform_lccdf.hpp @@ -22,9 +22,9 @@ namespace math { template * = nullptr> -inline return_type_t uniform_lccdf(const T_y& y, - const T_low& alpha, - const T_high& beta) { +return_type_t uniform_lccdf(const T_y& y, + const T_low& alpha, + const T_high& beta) { using T_partials_return = partials_return_t; using T_y_ref = ref_type_if_not_constant_t; using T_alpha_ref = ref_type_if_not_constant_t; diff --git a/stan/math/prim/prob/uniform_lcdf.hpp b/stan/math/prim/prob/uniform_lcdf.hpp index 883d71bafea..b31c24f6b08 100644 --- a/stan/math/prim/prob/uniform_lcdf.hpp +++ b/stan/math/prim/prob/uniform_lcdf.hpp @@ -22,9 +22,8 @@ namespace math { template * = nullptr> -inline return_type_t uniform_lcdf(const T_y& y, - const T_low& alpha, - const T_high& beta) { +return_type_t uniform_lcdf(const T_y& y, const T_low& alpha, + const T_high& beta) { using T_partials_return = partials_return_t; using T_y_ref = ref_type_if_not_constant_t; using T_alpha_ref = ref_type_if_not_constant_t; diff --git a/stan/math/prim/prob/uniform_lpdf.hpp b/stan/math/prim/prob/uniform_lpdf.hpp index a681c3db40b..39174904a26 100644 --- a/stan/math/prim/prob/uniform_lpdf.hpp +++ b/stan/math/prim/prob/uniform_lpdf.hpp @@ -44,9 +44,8 @@ namespace math { template * = nullptr> -inline return_type_t uniform_lpdf(const T_y& y, - const T_low& alpha, - const T_high& beta) { +return_type_t uniform_lpdf(const T_y& y, const T_low& alpha, + const T_high& beta) { using T_partials_return = partials_return_t; using T_y_ref = ref_type_if_not_constant_t; using T_alpha_ref = ref_type_if_not_constant_t; diff --git a/stan/math/prim/prob/von_mises_cdf.hpp b/stan/math/prim/prob/von_mises_cdf.hpp index c1c34a2c21b..545d502e950 100644 --- a/stan/math/prim/prob/von_mises_cdf.hpp +++ b/stan/math/prim/prob/von_mises_cdf.hpp @@ -20,8 +20,7 @@ namespace internal { * scipy. */ template -inline return_type_t von_mises_cdf_series(const T_x& x, - const T_k& k) { +return_type_t von_mises_cdf_series(const T_x& x, const T_k& k) { const double pi = stan::math::pi(); int p = value_of_rec(28 + 0.5 * k - 100 / (k + 5) + 1); auto s = sin(x); @@ -50,8 +49,7 @@ inline return_type_t von_mises_cdf_series(const T_x& x, * is well-approximated by a normal distribution. */ template -inline return_type_t von_mises_cdf_normalapprox(const T_x& x, - const T_k& k) { +return_type_t von_mises_cdf_normalapprox(const T_x& x, const T_k& k) { using std::exp; using std::sqrt; @@ -70,8 +68,7 @@ inline return_type_t von_mises_cdf_normalapprox(const T_x& x, * the cdf with a Gaussian. Otherwise, use the expansion from scipy. */ template -inline return_type_t von_mises_cdf_centered(const T_x& x, - const T_k& k) { +return_type_t von_mises_cdf_centered(const T_x& x, const T_k& k) { using return_t = return_type_t; return_t f; if (k < 49) { diff --git a/stan/math/prim/prob/von_mises_lpdf.hpp b/stan/math/prim/prob/von_mises_lpdf.hpp index b8d5a1ab63b..fbf01e3cf84 100644 --- a/stan/math/prim/prob/von_mises_lpdf.hpp +++ b/stan/math/prim/prob/von_mises_lpdf.hpp @@ -23,9 +23,8 @@ namespace stan { namespace math { template -inline return_type_t von_mises_lpdf(T_y const& y, - T_loc const& mu, - T_scale const& kappa) { +return_type_t von_mises_lpdf(T_y const& y, T_loc const& mu, + T_scale const& kappa) { using T_partials_return = partials_return_t; using T_y_ref = ref_type_if_not_constant_t; using T_mu_ref = ref_type_if_not_constant_t; diff --git a/stan/math/prim/prob/weibull_ccdf_log.hpp b/stan/math/prim/prob/weibull_ccdf_log.hpp index d9dc7bdb0c7..6f7f5aef93c 100644 --- a/stan/math/prim/prob/weibull_ccdf_log.hpp +++ b/stan/math/prim/prob/weibull_ccdf_log.hpp @@ -11,8 +11,9 @@ namespace math { * @deprecated use weibull_lccdf */ template -inline return_type_t weibull_ccdf_log( - const T_y& y, const T_shape& alpha, const T_scale& sigma) { +return_type_t weibull_ccdf_log(const T_y& y, + const T_shape& alpha, + const T_scale& sigma) { return weibull_lccdf(y, alpha, sigma); } diff --git a/stan/math/prim/prob/weibull_cdf.hpp b/stan/math/prim/prob/weibull_cdf.hpp index 6c6be0bdb78..1cb33774dd1 100644 --- a/stan/math/prim/prob/weibull_cdf.hpp +++ b/stan/math/prim/prob/weibull_cdf.hpp @@ -36,9 +36,9 @@ namespace math { template * = nullptr> -inline return_type_t weibull_cdf(const T_y& y, - const T_shape& alpha, - const T_scale& sigma) { +return_type_t weibull_cdf(const T_y& y, + const T_shape& alpha, + const T_scale& sigma) { using T_partials_return = partials_return_t; using T_y_ref = ref_type_if_not_constant_t; using T_alpha_ref = ref_type_if_not_constant_t; diff --git a/stan/math/prim/prob/weibull_cdf_log.hpp b/stan/math/prim/prob/weibull_cdf_log.hpp index 66a02f20f20..bad0dcfcbb8 100644 --- a/stan/math/prim/prob/weibull_cdf_log.hpp +++ b/stan/math/prim/prob/weibull_cdf_log.hpp @@ -11,8 +11,9 @@ namespace math { * @deprecated use weibull_lcdf */ template -inline return_type_t weibull_cdf_log( - const T_y& y, const T_shape& alpha, const T_scale& sigma) { +return_type_t weibull_cdf_log(const T_y& y, + const T_shape& alpha, + const T_scale& sigma) { return weibull_lcdf(y, alpha, sigma); } diff --git a/stan/math/prim/prob/weibull_lccdf.hpp b/stan/math/prim/prob/weibull_lccdf.hpp index 9fa25a575ea..cc73f1819da 100644 --- a/stan/math/prim/prob/weibull_lccdf.hpp +++ b/stan/math/prim/prob/weibull_lccdf.hpp @@ -34,8 +34,9 @@ namespace math { template * = nullptr> -inline return_type_t weibull_lccdf( - const T_y& y, const T_shape& alpha, const T_scale& sigma) { +return_type_t weibull_lccdf(const T_y& y, + const T_shape& alpha, + const T_scale& sigma) { using T_partials_return = partials_return_t; using T_y_ref = ref_type_if_not_constant_t; using T_alpha_ref = ref_type_if_not_constant_t; diff --git a/stan/math/prim/prob/weibull_lcdf.hpp b/stan/math/prim/prob/weibull_lcdf.hpp index 12b70cf76e6..5ba9ac23471 100644 --- a/stan/math/prim/prob/weibull_lcdf.hpp +++ b/stan/math/prim/prob/weibull_lcdf.hpp @@ -36,9 +36,9 @@ namespace math { template * = nullptr> -inline return_type_t weibull_lcdf(const T_y& y, - const T_shape& alpha, - const T_scale& sigma) { +return_type_t weibull_lcdf(const T_y& y, + const T_shape& alpha, + const T_scale& sigma) { using T_y_ref = ref_type_if_not_constant_t; using T_alpha_ref = ref_type_if_not_constant_t; using T_sigma_ref = ref_type_if_not_constant_t; diff --git a/stan/math/prim/prob/weibull_lpdf.hpp b/stan/math/prim/prob/weibull_lpdf.hpp index e5313765f13..906eec39418 100644 --- a/stan/math/prim/prob/weibull_lpdf.hpp +++ b/stan/math/prim/prob/weibull_lpdf.hpp @@ -37,9 +37,9 @@ namespace math { template * = nullptr> -inline return_type_t weibull_lpdf(const T_y& y, - const T_shape& alpha, - const T_scale& sigma) { +return_type_t weibull_lpdf(const T_y& y, + const T_shape& alpha, + const T_scale& sigma) { using T_partials_return = partials_return_t; using T_y_ref = ref_type_if_not_constant_t; using T_alpha_ref = ref_type_if_not_constant_t; diff --git a/stan/math/prim/prob/wiener4_lccdf.hpp b/stan/math/prim/prob/wiener4_lccdf.hpp new file mode 100644 index 00000000000..5fa2a357ab8 --- /dev/null +++ b/stan/math/prim/prob/wiener4_lccdf.hpp @@ -0,0 +1,368 @@ +#ifndef STAN_MATH_PRIM_PROB_WIENER4_LCCDF_HPP +#define STAN_MATH_PRIM_PROB_WIENER4_LCCDF_HPP + +#include + +namespace stan { +namespace math { +namespace internal { + +/** + * Log of probability of reaching the upper bound in diffusion process + * + * @tparam T_a type of boundary + * @tparam T_w type of relative starting point + * @tparam T_v type of drift rate + * + * @param a The boundary separation + * @param w The relative starting point + * @param v The drift rate + * @return log probability to reach the upper bound + */ +template +inline auto log_wiener_prob_hit_upper(const T_a& a, const T_v& v, + const T_w& w) { + using ret_t = return_type_t; + const auto neg_v = -v; + const auto one_m_w = 1.0 - w; + if (fabs(v) == 0.0) { + return ret_t(log1m(one_m_w)); + } + const auto exponent = 2.0 * v * a * w; + // This branch is for numeric stability + if (exponent < 0) { + return ret_t(log1m_exp(exponent) + - log_diff_exp(2.0 * neg_v * a * one_m_w, exponent)); + } else { + return ret_t(log1m_exp(-exponent) - log1m_exp(2.0 * neg_v * a)); + } +} + +/** + * Calculate parts of the partial derivatives for wiener_prob_grad_a and + * wiener_prob_grad_v (on log-scale) + * + * @tparam T_a type of boundary + * @tparam T_w type of relative starting point + * @tparam T_v type of drift rate + * + * @param a The boundary separation + * @param w The relative starting point + * @param v The drift rate + * @return 'ans' term + */ +template +inline auto wiener_prob_derivative_term(const T_a& a, const T_v& v, + const T_w& w) noexcept { + using ret_t = return_type_t; + const auto exponent_m1 = log1m(1.1 * 1.0e-8); + ret_t ans; + const auto neg_v = -v; + const auto one_m_w = 1 - w; + int sign_v = neg_v < 0 ? 1 : -1; + const auto two_a_neg_v = 2.0 * a * neg_v; + const auto exponent_with_1mw = sign_v * two_a_neg_v * w; + const auto exponent = (sign_v * two_a_neg_v); + const auto exponent_with_w = two_a_neg_v * one_m_w; + // truncating longer calculations, for numerical stability + if (unlikely((exponent_with_1mw >= exponent_m1) + || ((exponent_with_w >= exponent_m1) && (sign_v == 1)) + || (exponent >= exponent_m1) || neg_v == 0)) { + return ret_t(-one_m_w); + } + ret_t diff_term; + const auto log_w = log(one_m_w); + if (neg_v < 0) { + ans = LOG_TWO + exponent_with_1mw - log1m_exp(exponent_with_1mw); + diff_term = log1m_exp(exponent_with_w) - log1m_exp(exponent); + } else if (neg_v > 0) { + ans = LOG_TWO - log1m_exp(exponent_with_1mw); + diff_term = log_diff_exp(exponent_with_1mw, exponent) - log1m_exp(exponent); + } + if (log_w > diff_term) { + ans = sign_v * exp(ans + log_diff_exp(log_w, diff_term)); + } else { + ans = -sign_v * exp(ans + log_diff_exp(diff_term, log_w)); + } + if (unlikely(!is_scal_finite(ans))) { + return ret_t(NEGATIVE_INFTY); + } + return ans; +} + +/** + * Calculate wiener4 ccdf (natural-scale) + * + * @param y The reaction time in seconds + * @param a The boundary separation + * @param v The relative starting point + * @param w The drift rate + * @param err The log error tolerance + * @return ccdf + */ +template +inline auto wiener4_ccdf(const T_y& y, const T_a& a, const T_v& v, const T_w& w, + T_err&& err = log(1e-12)) noexcept { + const auto prob_hit_upper = exp(log_wiener_prob_hit_upper(a, v, w)); + const auto cdf + = internal::wiener4_distribution(y, a, v, w, err); + return prob_hit_upper - cdf; +} + +/** + * Calculate derivative of the wiener4 ccdf w.r.t. 'a' (natural-scale) + * + * @param y The reaction time in seconds + * @param a The boundary separation + * @param v The relative starting point + * @param w The drift rate + * @param cdf The CDF value + * @param err The log error tolerance + * @return Gradient with respect to a + */ +template +inline auto wiener4_ccdf_grad_a(const T_y& y, const T_a& a, const T_v& v, + const T_w& w, T_cdf&& cdf, + T_err&& err = log(1e-12)) noexcept { + using ret_t = return_type_t; + + // derivative of the wiener probability w.r.t. 'a' (on log-scale) + auto prob_grad_a = -wiener_prob_derivative_term(a, v, w) * v; + if (!is_scal_finite(prob_grad_a)) { + prob_grad_a = ret_t(NEGATIVE_INFTY); + } + const auto log_prob_hit_upper = log_wiener_prob_hit_upper(a, v, w); + const auto cdf_grad_a = wiener4_cdf_grad_a(y, a, v, w, cdf, err); + return prob_grad_a * exp(log_prob_hit_upper) - cdf_grad_a; +} + +/** + * Calculate derivative of the wiener4 ccdf w.r.t. 'v' (natural-scale) + * + * @param y The reaction time in seconds + * @param a The boundary separation + * @param v The relative starting point + * @param w The drift rate + * @param cdf The CDF value + * @param err The log error tolerance + * @return Gradient with respect to v + */ +template +inline auto wiener4_ccdf_grad_v(const T_y& y, const T_a& a, const T_v& v, + const T_w& w, T_cdf&& cdf, + T_err&& err = log(1e-12)) noexcept { + using ret_t = return_type_t; + const auto log_prob_hit_upper = log_wiener_prob_hit_upper(a, v, w); + // derivative of the wiener probability w.r.t. 'v' (on log-scale) + auto prob_grad_v = -wiener_prob_derivative_term(a, v, w) * a; + if (!is_scal_finite(fabs(prob_grad_v))) { + prob_grad_v = ret_t(NEGATIVE_INFTY); + } + + const auto cdf_grad_v = wiener4_cdf_grad_v(y, a, v, w, cdf, err); + return prob_grad_v * exp(log_prob_hit_upper) - cdf_grad_v; +} + +/** + * Calculate derivative of the wiener4 ccdf w.r.t. 'w' (natural-scale) + * + * @param y The reaction time in seconds + * @param a The boundary separation + * @param v The relative starting point + * @param w The drift rate + * @param cdf The CDF value + * @param err The log error tolerance + * @return Gradient with respect to w + */ +template +inline auto wiener4_ccdf_grad_w(const T_y& y, const T_a& a, const T_v& v, + const T_w& w, T_cdf&& cdf, + T_err&& err = log(1e-12)) noexcept { + using ret_t = return_type_t; + const auto log_prob_hit_upper = log_wiener_prob_hit_upper(a, v, w); + // derivative of the wiener probability w.r.t. 'v' (on log-scale) + const auto exponent = -sign(v) * 2.0 * v * a * w; + auto prob_grad_w + = (v != 0) ? exp(LOG_TWO + log(fabs(v)) + log(a) - log1m_exp(exponent)) + : ret_t(1 / w); + if (v > 0) { + prob_grad_w *= exp(exponent); + } + + const auto cdf_grad_w = wiener4_cdf_grad_w(y, a, v, w, cdf, err); + return prob_grad_w * exp(log_prob_hit_upper) - cdf_grad_w; +} + +} // namespace internal + +/** + * Log-CCDF for the 4-parameter Wiener distribution. + * See 'wiener_full_lpdf' for more comprehensive documentation. + * + * @tparam T_y type of reaction time + * @tparam T_a type of boundary + * @tparam T_t0 type of non-decision time + * @tparam T_w type of relative starting point + * @tparam T_v type of drift rate + * + * @param y The reaction time in seconds + * @param a The boundary separation + * @param t0 The non-decision time + * @param w The relative starting point + * @param v The drift rate + * @param precision_derivatives Level of precision in estimation + * @return The log of the Wiener first passage time distribution with + * the specified arguments for upper boundary responses + */ +template +inline auto wiener_lccdf(const T_y& y, const T_a& a, const T_t0& t0, + const T_w& w, const T_v& v, + const double& precision_derivatives) { + using T_partials_return = partials_return_t; + using ret_t = return_type_t; + using T_y_ref = ref_type_if_t::value, T_y>; + using T_a_ref = ref_type_if_t::value, T_a>; + using T_t0_ref = ref_type_if_t::value, T_t0>; + using T_w_ref = ref_type_if_t::value, T_w>; + using T_v_ref = ref_type_if_t::value, T_v>; + using internal::GradientCalc; + + T_y_ref y_ref = y; + T_a_ref a_ref = a; + T_t0_ref t0_ref = t0; + T_w_ref w_ref = w; + T_v_ref v_ref = v; + + decltype(auto) y_val = to_ref(as_value_column_array_or_scalar(y_ref)); + decltype(auto) a_val = to_ref(as_value_column_array_or_scalar(a_ref)); + decltype(auto) v_val = to_ref(as_value_column_array_or_scalar(v_ref)); + decltype(auto) w_val = to_ref(as_value_column_array_or_scalar(w_ref)); + decltype(auto) t0_val = to_ref(as_value_column_array_or_scalar(t0_ref)); + + static constexpr const char* function_name = "wiener4_lccdf"; + if (size_zero(y, a, t0, w, v)) { + return ret_t(0.0); + } + + if (!include_summand::value) { + return ret_t(0.0); + } + + check_consistent_sizes(function_name, "Random variable", y, + "Boundary separation", a, "Drift rate", v, + "A-priori bias", w, "Nondecision time", t0); + check_positive_finite(function_name, "Random variable", y_val); + check_positive_finite(function_name, "Boundary separation", a_val); + check_finite(function_name, "Drift rate", v_val); + check_less(function_name, "A-priori bias", w_val, 1); + check_greater(function_name, "A-priori bias", w_val, 0); + check_nonnegative(function_name, "Nondecision time", t0_val); + check_finite(function_name, "Nondecision time", t0_val); + + const size_t N = max_size(y, a, t0, w, v); + + scalar_seq_view y_vec(y_ref); + scalar_seq_view a_vec(a_ref); + scalar_seq_view t0_vec(t0_ref); + scalar_seq_view w_vec(w_ref); + scalar_seq_view v_vec(v_ref); + const size_t N_y_t0 = max_size(y, t0); + + for (size_t i = 0; i < N_y_t0; ++i) { + if (y_vec[i] <= t0_vec[i]) { + std::stringstream msg; + msg << ", but must be greater than nondecision time = " << t0_vec[i]; + std::string msg_str(msg.str()); + throw_domain_error(function_name, "Random variable", y_vec[i], " = ", + msg_str.c_str()); + } + } + + // for precs. 1e-6, 1e-12, see Hartmann et al. (2021), Henrich et al. (2023) + const auto log_error_cdf = log(1e-6); + const auto log_error_derivative = log(precision_derivatives); + const T_partials_return log_error_absolute = log(1e-12); + T_partials_return lccdf = 0.0; + auto ops_partials + = make_partials_propagator(y_ref, a_ref, t0_ref, w_ref, v_ref); + + const double LOG_FOUR = std::log(4.0); + + // calculate distribution and partials + for (size_t i = 0; i < N; i++) { + const auto y_value = y_vec.val(i); + const auto a_value = a_vec.val(i); + const auto t0_value = t0_vec.val(i); + const auto w_value = w_vec.val(i); + const auto v_value = v_vec.val(i); + + const T_partials_return cdf + = internal::estimate_with_err_check<4, 0, GradientCalc::OFF, + GradientCalc::OFF>( + [](auto&&... args) { + return internal::wiener4_distribution(args...); + }, + log_error_cdf - LOG_TWO, y_value - t0_value, a_value, v_value, + w_value, log_error_absolute); + + const auto prob_hit_upper + = exp(internal::log_wiener_prob_hit_upper(a_value, v_value, w_value)); + const auto ccdf = prob_hit_upper - cdf; + const auto log_ccdf_single_value = log(ccdf); + + lccdf += log_ccdf_single_value; + + const auto new_est_err + = log_ccdf_single_value + log_error_derivative - LOG_FOUR; + + if (!is_constant_all::value || !is_constant_all::value) { + const auto deriv_y = internal::estimate_with_err_check<5, 0>( + [](auto&&... args) { + return internal::wiener5_density(args...); + }, + new_est_err, y_value - t0_value, a_value, v_value, w_value, 0.0, + log_error_absolute); + if (!is_constant_all::value) { + partials<0>(ops_partials)[i] = -deriv_y / ccdf; + } + if (!is_constant_all::value) { + partials<2>(ops_partials)[i] = deriv_y / ccdf; + } + } + if (!is_constant_all::value) { + partials<1>(ops_partials)[i] + = internal::estimate_with_err_check<5, 0>( + [](auto&&... args) { + return internal::wiener4_ccdf_grad_a(args...); + }, + new_est_err, y_value - t0_value, a_value, v_value, w_value, cdf, + log_error_absolute) + / ccdf; + } + if (!is_constant_all::value) { + partials<3>(ops_partials)[i] + = internal::estimate_with_err_check<5, 0>( + [](auto&&... args) { + return internal::wiener4_ccdf_grad_w(args...); + }, + new_est_err, y_value - t0_value, a_value, v_value, w_value, cdf, + log_error_absolute) + / ccdf; + } + if (!is_constant_all::value) { + partials<4>(ops_partials)[i] + = internal::wiener4_ccdf_grad_v(y_value - t0_value, a_value, v_value, + w_value, cdf, log_error_absolute) + / ccdf; + } + } // for loop + return ops_partials.build(lccdf); +} +} // namespace math +} // namespace stan +#endif diff --git a/stan/math/prim/prob/wiener4_lcdf.hpp b/stan/math/prim/prob/wiener4_lcdf.hpp new file mode 100644 index 00000000000..7522f323049 --- /dev/null +++ b/stan/math/prim/prob/wiener4_lcdf.hpp @@ -0,0 +1,744 @@ +#ifndef STAN_MATH_PRIM_PROB_WIENER4_LCDF_HPP +#define STAN_MATH_PRIM_PROB_WIENER4_LCDF_HPP + +#include + +namespace stan { +namespace math { +namespace internal { + +/** + * Calculate the probability term 'P' on log scale for distribution + * + * @param a The boundary separation + * @param v The drift rate + * @param w The relative starting point + * @return 'P' term + */ +template +inline auto log_probability_distribution(const T_a& a, const T_v& v, + const T_w& w) { + using ret_t = return_type_t; + if (fabs(v) == 0.0) { + return ret_t(log1m(w)); + } + auto two_va = 2.0 * v * a; + auto minus_two_va_one_minus_w = -two_va * (1.0 - w); + // This split prevents abort errors + if (minus_two_va_one_minus_w < 0) { + const auto exp_arg = exp(minus_two_va_one_minus_w); + auto two_vaw = two_va * w; + if (two_vaw > minus_two_va_one_minus_w) { + return log1m(exp_arg) - log_diff_exp(two_vaw, minus_two_va_one_minus_w); + } else if (two_vaw < minus_two_va_one_minus_w) { + return log1m(exp_arg) - log_diff_exp(minus_two_va_one_minus_w, two_vaw); + } else { + return log1m(exp_arg) - NEGATIVE_INFTY; + } + } else { + return log1m_exp(-minus_two_va_one_minus_w) - log1m_exp(two_va); + } +} + +/** + * Calculate the probability term 'P' on log scale for grad_a and grad_v + * + * @param a The boundary separation + * @param v The drift rate + * @param w The relative starting point + * @return 'P' term + */ +template +inline auto log_probability_GradAV(const T_a& a, const T_v& v, const T_w& w) { + using ret_t = return_type_t; + if (fabs(v) == 0.0) { + return ret_t(-w); + } + auto nearly_one = ret_t(1.0 - 1.1 * 1.0e-5); + ret_t prob; + if (v < 0) { + const auto two_av = 2.0 * a * v; + const auto two_va_one_minus_w = (two_av * (1.0 - w)); + const auto two_avw = two_av * w; + const auto exp_two_va_one_minus_w = exp(two_va_one_minus_w); + const auto exp_two_avw = exp(two_avw); + const auto exp_two_av = exp(two_av); + if (((exp_two_va_one_minus_w >= nearly_one) || (exp_two_avw >= nearly_one)) + || (exp_two_av >= nearly_one)) { + return ret_t(-w); + } + prob = LOG_TWO + two_va_one_minus_w - log1m(exp_two_va_one_minus_w); + auto log_quotient = log1m(exp_two_avw) - log1m(exp_two_av); + if (log(w) > log_quotient) { + prob += log_diff_exp(log(w), log_quotient); + return exp(prob); + } else { + prob += log_diff_exp(log_quotient, log(w)); + return -exp(prob); + } + } else { + const auto minus_two_av = -2.0 * a * v; + const auto minus_two_va_one_minus_w = minus_two_av * (1.0 - w); + const auto exp_minus_two_va_one_minus_w = exp(minus_two_va_one_minus_w); + const auto exp_minus_two_av = exp(minus_two_av); + if ((exp_minus_two_va_one_minus_w >= nearly_one) + || (exp_minus_two_av >= nearly_one)) { + return ret_t(-w); + } + prob = LOG_TWO - log1m(exp_minus_two_va_one_minus_w); + ret_t log_quotient; + if (minus_two_va_one_minus_w > minus_two_av) { + log_quotient = log_diff_exp(minus_two_va_one_minus_w, minus_two_av) + - log1m(exp_minus_two_av); + } else if (minus_two_va_one_minus_w < minus_two_av) { + log_quotient = log_diff_exp(minus_two_av, minus_two_va_one_minus_w) + - log1m(exp_minus_two_av); + } else { + log_quotient = NEGATIVE_INFTY; + } + if (log(w) > log_quotient) { + prob += log_diff_exp(log(w), log_quotient); + return -exp(prob); + } else { + prob += log_diff_exp(log_quotient, log(w)); + return exp(prob); + } + } +} + +/** + * Log of Mill's ratio for the normal distribution + * + * @param x A scalar + * @return The natural logarithm of Mill's ratio + */ +template +inline auto logMill(T_x&& x) { + return std_normal_lcdf(-x) - std_normal_lpdf(x); +} + +/** + * Calculate the wiener4 distribution + * + * @tparam NaturalScale Whether to return the distribution on natural or + * log-scale + * + * @param y The reaction time in seconds + * @param a The boundary separation + * @param v The relative starting point + * @param w The drift rate + * @param err The log error tolerance + * @return distribution + */ +template +inline auto wiener4_distribution(const T_y& y, const T_a& a, const T_v& v, + const T_w& w, T_err&& err = log(1e-12)) { + using ret_t = return_type_t; + const auto neg_v = -v; + const auto one_m_w = 1.0 - w; + + const auto one_m_w_a_neg_v = one_m_w * a * neg_v; + + const auto K1 = 0.5 * (fabs(neg_v) / a * y - one_m_w); + const auto arg = fmax( + 0.0, + fmin(1.0, exp(one_m_w_a_neg_v + square(neg_v) * y / 2.0 + err) / 2.0)); + const auto K2 = (arg == 0) ? INFTY + : (arg == 1) ? NEGATIVE_INFTY + : -sqrt(y) / 2.0 / a * inv_Phi(arg); + const auto K_small_value = ceil(fmax(K1, K1 + K2)); + + const auto api = a / pi(); + const auto v_square = square(neg_v); + const auto sqrtL1 = sqrt(1.0 / y) * api; + const auto sqrtL2 = sqrt( + fmax(1.0, -2.0 / y * square(api) + * (err + log(pi() * y / 2.0 * (v_square + square(pi() / a))) + + one_m_w_a_neg_v + v_square * y / 2.0))); + const auto K_large_value = ceil(fmax(sqrtL1, sqrtL2)); + + auto lg = LOG_TWO + LOG_PI - 2.0 * log(a); + + if (3 * K_small_value < K_large_value) { + const auto sqrt_y = sqrt(y); + const auto neg_vy = neg_v * y; + ret_t fplus = NEGATIVE_INFTY; + ret_t fminus = NEGATIVE_INFTY; + for (auto k = K_small_value; k >= 0; --k) { + auto rj = a * (2.0 * k + one_m_w); + auto dj = std_normal_lpdf(rj / sqrt_y); + auto pos1 = dj + logMill((rj - neg_vy) / sqrt_y); + auto pos2 = dj + logMill((rj + neg_vy) / sqrt_y); + fplus = log_sum_exp(fplus, log_sum_exp(pos1, pos2)); + rj = a * (2.0 * k + 2.0 - one_m_w); + dj = std_normal_lpdf(rj / sqrt_y); + auto neg1 = dj + logMill((rj - neg_vy) / sqrt_y); + auto neg2 = dj + logMill((rj + neg_vy) / sqrt_y); + fminus = log_sum_exp(fminus, log_sum_exp(neg1, neg2)); + } + auto ans = ret_t(0.0); + if (fplus > fminus) { + ans = log_diff_exp(fplus, fminus); + } else if (fplus < fminus) { + ans = log_diff_exp(fminus, fplus); + } else { + ans = NEGATIVE_INFTY; + } + ret_t log_distribution = ans - one_m_w_a_neg_v - square(neg_v) * y / 2; + return NaturalScale ? exp(log_distribution) : log_distribution; + } + const auto log_a = log(a); + const auto log_v = log(fabs(neg_v)); + ret_t fplus = NEGATIVE_INFTY; + ret_t fminus = NEGATIVE_INFTY; + for (auto k = K_large_value; k > 0; --k) { + auto log_k = log(k); + auto k_pi = k * pi(); + auto sin_k_pi_w = sin(k_pi * one_m_w); + if (sin_k_pi_w > 0) { + fplus = log_sum_exp( + fplus, log_k + - log_sum_exp(2.0 * log_v, 2.0 * (log_k + LOG_PI - log_a)) + - 0.5 * square(k_pi / a) * y + log(sin_k_pi_w)); + } else if (sin_k_pi_w < 0) { + fminus = log_sum_exp( + fminus, log_k + - log_sum_exp(2.0 * log_v, 2.0 * (log_k + LOG_PI - log_a)) + - 0.5 * square(k_pi / a) * y + log(-sin_k_pi_w)); + } + } + ret_t ans = NEGATIVE_INFTY; + if (fplus > fminus) { + ans = log_diff_exp(fplus, fminus); + } else if (fplus < fminus) { + ans = log_diff_exp(fminus, fplus); + } + auto summand_1 = log_probability_distribution(a, neg_v, one_m_w); + auto summand_2 = lg + (ans - one_m_w_a_neg_v - 0.5 * square(neg_v) * y); + ret_t log_distribution = NEGATIVE_INFTY; + if (summand_1 > summand_2) { + log_distribution = log_diff_exp(summand_1, summand_2); + } else if (summand_1 < summand_2) { + log_distribution = log_diff_exp(summand_2, summand_1); + } + return NaturalScale ? exp(log_distribution) : log_distribution; +} + +/** + * Calculate derivative of the wiener4 distribution w.r.t. 'a' (natural-scale) + * + * @param y The reaction time in seconds + * @param a The boundary separation + * @param v The relative starting point + * @param w The drift rate + * @param cdf The value of the distribution + * @param err The log error tolerance + * @return Gradient with respect to a + */ +template +inline auto wiener4_cdf_grad_a(const T_y& y, const T_a& a, const T_v& v, + const T_w& w, T_cdf&& cdf, + T_err&& err = log(1e-12)) { + using ret_t = return_type_t; + const auto neg_v = -v; + const auto one_m_w = 1 - w; + + const auto one_m_w_neg_v = one_m_w * neg_v; + const auto one_m_w_a_neg_v = one_m_w_neg_v * a; + + const auto log_y = log(y); + const auto log_a = log(a); + auto C1 = ret_t( + LOG_TWO - log_sum_exp(2.0 * log(fabs(neg_v)), 2.0 * (LOG_PI - log_a))); + C1 = log_sum_exp(C1, log_y); + const auto factor = one_m_w_a_neg_v + square(neg_v) * y / 2.0 + err; + const auto alphK = fmin(factor + LOG_PI + log_y + log_a - LOG_TWO - C1, 0.0); + const auto K = a / pi() / sqrt(y); + const auto K_large_value + = ceil(fmax(fmax(sqrt(-2.0 * alphK / y) * a / pi(), K), ret_t(1.0))); + + const auto sqrt_y = sqrt(y); + const auto wdash = fmin(one_m_w, w); + const auto ueps + = fmin(-1.0, 2.0 * (factor + log(a) - log1p(square(neg_v) * y)) + LOG_PI); + const auto K_small + = (sqrt_y * sqrt(-(ueps - sqrt(-2.0 * ueps - 2.0))) - a * wdash) / a; + const auto K_large = sqrt_y / a - wdash; + const auto K_small_value = ceil(fmax(fmax(K_small, K_large), ret_t(1.0))); + + if (K_large_value > 4 * K_small_value) { + const auto neg_vy = neg_v * y; + auto ans = ret_t(0.0); + auto F_k = ret_t(0.0); + for (auto k = K_small_value; k >= 0; --k) { + auto r_k = a * (2.0 * k + one_m_w); + auto x = r_k - neg_vy; + auto xsqrt_y = x / sqrt_y; + auto d_k = std_normal_lpdf(r_k / sqrt_y); + auto temp = fmin(exp(d_k + logMill(xsqrt_y)), + std::numeric_limits::max()); + auto temp2 = exp(d_k); + auto temp3 = -temp * neg_vy - sqrt_y * temp2; + const auto factor = (2.0 * k + one_m_w); + const auto t1 = temp3 * factor; + x = r_k + neg_vy; + xsqrt_y = x / sqrt_y; + temp = fmin(exp(d_k + logMill(xsqrt_y)), + std::numeric_limits::max()); + temp3 = temp * neg_vy - sqrt_y * temp2; + const auto t2 = temp3 * factor; + r_k = a * (2.0 * k + 1.0 + w); + d_k = std_normal_lpdf(r_k / sqrt_y); + x = r_k - neg_vy; + xsqrt_y = x / sqrt_y; + temp = fmin(exp(d_k + logMill(xsqrt_y)), + std::numeric_limits::max()); + temp2 = exp(d_k); + temp3 = -temp * neg_vy - sqrt_y * temp2; + const auto t3 = temp3 * 2.0 * (k + one_m_w); + x = r_k + neg_vy; + xsqrt_y = x / sqrt_y; + temp = fmin(exp(d_k + logMill(xsqrt_y)), + std::numeric_limits::max()); + temp3 = temp * neg_vy - sqrt_y * temp2; + const auto t4 = -temp3 * factor; + ans += t1 + t2 + t3 + t4; + } + F_k = fmin(exp(one_m_w_a_neg_v + 0.5 * square(neg_v) * y), + std::numeric_limits::max()); + const auto summands_small_y = ans / (y * F_k); + return -one_m_w_neg_v * cdf + summands_small_y; + } + ret_t ans = 0.0; + for (auto k = K_large_value; k > 0; --k) { + const auto kpi = k * pi(); + const auto kpia2 = square(kpi / a); + const auto denom = square(neg_v) + kpia2; + auto last = (square(kpi) / pow(a, 3) * (y + 2.0 / denom)) * k / denom + * exp(-0.5 * kpia2 * y); + ans -= last * sin(kpi * one_m_w); + } + const ret_t prob = fmin(exp(log_probability_distribution(a, neg_v, one_m_w)), + std::numeric_limits::max()); + const auto dav = log_probability_GradAV(a, neg_v, one_m_w); + auto dav_neg_v = dav * neg_v; + auto prob_deriv = fabs(neg_v) == 0 + ? ret_t(0.0) + : is_inf(dav_neg_v) ? NEGATIVE_INFTY : dav_neg_v * prob; + ans = (-2.0 / a - one_m_w_neg_v) * (cdf - prob) + + ans * (2.0 * pi() / square(a)) + * exp(-one_m_w_a_neg_v - 0.5 * square(neg_v) * y); + return prob_deriv + ans; +} + +/** + * Calculate derivative of the wiener4 distribution w.r.t. 'v' (natural-scale) + * + * @param y The reaction time in seconds + * @param a The boundary separation + * @param v The relative starting point + * @param w The drift rate + * @param cdf The value of the distribution + * @param err The log error tolerance + * @return Gradient with respect to v + */ +template +inline auto wiener4_cdf_grad_v(const T_y& y, const T_a& a, const T_v& v, + const T_w& w, T_cdf&& cdf, + T_err&& err = log(1e-12)) { + using ret_t = return_type_t; + const auto neg_v = -v; + const auto one_m_w = 1.0 - w; + + const auto one_m_w_a = one_m_w * a; + const auto one_m_w_a_neg_v = one_m_w_a * neg_v; + + const auto log_y = log(y); + const auto factor = one_m_w_a_neg_v + square(neg_v) * y / 2.0 + err; + + const auto log_a = log(a); + auto K_large_value = ret_t(1.0); + if (neg_v != 0) { + const auto temp = -fmin(exp(log_a - LOG_PI - 0.5 * log_y), + std::numeric_limits::max()); + const auto log_v = log(fabs(neg_v)); + auto alphK_large = fmin(exp(factor + 0.5 * (7 * LOG_PI + log_y) + - 2.5 * LOG_TWO - 3 * log_a - log_v), + 1.0); + K_large_value + = fmax(ceil((alphK_large == 0) + ? ret_t(INFTY) + : (alphK_large == 1) ? ret_t(NEGATIVE_INFTY) + : temp * inv_Phi(alphK_large)), + ret_t(1.0)); + } + + const auto sqrt_y = sqrt(y); + const auto wdash = fmin(one_m_w, w); + auto K_large = fabs(neg_v) / a * y - wdash; + const auto alphK_small = factor + 0.5 * (LOG_TWO - log_y + LOG_PI); + const auto K_small + = (alphK_small < 0) ? sqrt_y * sqrt(-2.0 * alphK_small) / a - wdash : 0; + const auto K_small_value = ceil(fmax(fmax(K_small, K_large), ret_t(1.0))); + if (K_large_value > 4 * K_small_value) { + const auto sqrt_y = sqrt(y); + const auto neg_vy = neg_v * y; + auto ans = ret_t(0.0); + auto F_k = ret_t(0.0); + for (auto k = K_small_value; k >= 0; --k) { + auto r_k = a * (2.0 * k + one_m_w); + auto d_k = std_normal_lpdf(r_k / sqrt_y); + auto x = r_k - neg_vy; + auto xsqrt_y = x / sqrt_y; + auto temp = fmin(exp(d_k + logMill(xsqrt_y)), + std::numeric_limits::max()); + const auto t1 = -temp * x; + x = r_k + neg_vy; + xsqrt_y = x / sqrt_y; + temp = fmin(exp(d_k + logMill(xsqrt_y)), + std::numeric_limits::max()); + const auto t2 = temp * x; + r_k = a * (2.0 * k + 1.0 + w); + d_k = std_normal_lpdf(r_k / sqrt_y); + x = r_k - neg_vy; + xsqrt_y = x / sqrt_y; + temp = fmin(exp(d_k + logMill(xsqrt_y)), + std::numeric_limits::max()); + const auto t3 = temp * x; + x = r_k + neg_vy; + xsqrt_y = x / sqrt_y; + temp = fmin(exp(d_k + logMill(xsqrt_y)), + std::numeric_limits::max()); + const auto t4 = -temp * x; + ans += t1 + t2 + t3 + t4; + } + F_k = fmin(exp(one_m_w_a_neg_v + 0.5 * square(neg_v) * y), + std::numeric_limits::max()); + const auto summands_small_y = ans / F_k; + return (one_m_w_a + neg_vy) * cdf - summands_small_y; + } + ret_t ans = 0.0; + for (auto k = K_large_value; k > 0; --k) { + const auto kpi = k * pi(); + const auto kpia2 = square(kpi / a); + const auto ekpia2y = exp(-0.5 * kpia2 * y); + const auto denom = square(neg_v) + kpia2; + const auto denomk = k / denom; + auto last = denomk * ekpia2y / denom; + ans -= last * sin(kpi * one_m_w); + } + const ret_t prob = fmin(exp(log_probability_distribution(a, neg_v, one_m_w)), + std::numeric_limits::max()); + const auto dav = log_probability_GradAV(a, neg_v, one_m_w); + auto dav_a = dav * a; + auto prob_deriv = is_inf(dav_a) ? ret_t(NEGATIVE_INFTY) : dav_a * prob; + ans = (-one_m_w_a + v * y) * (cdf - prob) + + ans * 4.0 * v * pi() / square(a) + * exp(-one_m_w_a_neg_v - 0.5 * square(neg_v) * y); + return -(prob_deriv + ans); +} + +/** + * Calculate derivative of the wiener4 distribution w.r.t. 'w' (natural-scale) + * + * @param y The reaction time in seconds + * @param a The boundary separation + * @param v The relative starting point + * @param w The drift rate + * @param cdf The value of the distribution + * @param err The log error tolerance + * @return Gradient with respect to w + */ +template +inline auto wiener4_cdf_grad_w(const T_y& y, const T_a& a, const T_v& v, + const T_w& w, T_cdf&& cdf, + T_err&& err = log(1e-12)) { + using ret_t = return_type_t; + const auto neg_v = -v; + const auto one_m_w = 1 - w; + + const auto one_m_w_a_neg_v = one_m_w * a * neg_v; + + const auto factor = one_m_w_a_neg_v + square(neg_v) * y / 2.0 + err; + + const auto log_y = log(y); + const auto log_a = log(a); + const auto temp = -fmin(exp(log_a - LOG_PI - 0.5 * log_y), + std::numeric_limits::max()); + auto alphK_large + = fmin(exp(factor + 0.5 * (LOG_PI + log_y) - 1.5 * LOG_TWO - log_a), 1.0); + alphK_large = fmax(0.0, alphK_large); + const auto K_large_value + = fmax(ceil((alphK_large == 0) + ? ret_t(INFTY) + : (alphK_large == 1) ? ret_t(NEGATIVE_INFTY) + : temp * inv_Phi(alphK_large)), + ret_t(1.0)); + + const auto sqrt_y = sqrt(y); + const auto wdash = fmin(one_m_w, w); + const auto K_large = fabs(neg_v) / a * y - wdash; + const auto lv = log1p(square(neg_v) * y); + const auto alphK_small = factor - LOG_TWO - lv; + const auto arg = fmin(exp(alphK_small), 1.0); + const auto K_small + = (arg == 0) + ? INFTY + : (arg == 1) ? NEGATIVE_INFTY : -sqrt_y / a * inv_Phi(arg) - wdash; + const auto K_small_value = ceil(fmax(fmax(K_small, K_large), ret_t(1.0))); + + if (K_large_value > 4 * K_small_value) { + const auto sqrt_y = sqrt(y); + const auto neg_vy = neg_v * y; + auto ans = ret_t(0.0); + auto F_k = ret_t(0.0); + for (auto k = K_small_value; k >= 0; --k) { + auto r_k = a * (2.0 * k + one_m_w); + auto d_k = std_normal_lpdf(r_k / sqrt_y); + auto x = r_k - neg_vy; + auto xsqrt_y = x / sqrt_y; + auto temp = fmin(exp(d_k + logMill(xsqrt_y)), + std::numeric_limits::max()); + auto temp2 = exp(d_k); + auto temp3 = -temp * neg_vy - sqrt_y * temp2; + const auto t1 = temp3 * a; + x = r_k + neg_vy; + xsqrt_y = x / sqrt_y; + temp = fmin(exp(d_k + logMill(xsqrt_y)), + std::numeric_limits::max()); + temp3 = temp * neg_vy - sqrt_y * temp2; + const auto t2 = temp3 * a; + r_k = a * (2.0 * k + 1.0 + w); + d_k = std_normal_lpdf(r_k / sqrt_y); + x = r_k - neg_vy; + xsqrt_y = x / sqrt_y; + temp = fmin(exp(d_k + logMill(xsqrt_y)), + std::numeric_limits::max()); + temp2 = exp(d_k); + temp3 = -temp * neg_vy - sqrt_y * temp2; + const auto t3 = temp3 * a; + x = r_k + neg_vy; + xsqrt_y = x / sqrt_y; + temp = fmin(exp(d_k + logMill(xsqrt_y)), + std::numeric_limits::max()); + temp3 = temp * neg_vy - sqrt_y * temp2; + const auto t4 = -temp3 * a; + ans += t1 + t2 + t3 + t4; + } + F_k = fmin(exp(one_m_w_a_neg_v + 0.5 * square(neg_v) * y), + std::numeric_limits::max()); + const auto summands_small_y = ans / (y * F_k); + return neg_v * a * cdf - summands_small_y; + } + ret_t ans = 0.0; + for (auto k = K_large_value; k > 0; --k) { + const auto kpi = k * pi(); + const auto kpia2 = square(kpi / a); + const auto ekpia2y = exp(-0.5 * kpia2 * y); + const auto denom = square(neg_v) + kpia2; + const auto denomk = k / denom; + auto last = kpi; + last *= denomk * ekpia2y; + ans -= last * cos(kpi * one_m_w); + } + const auto evaw = exp(-one_m_w_a_neg_v - 0.5 * square(neg_v) * y); + const ret_t prob = fmin(exp(log_probability_distribution(a, neg_v, one_m_w)), + std::numeric_limits::max()); + + // Calculate the probability term 'P' on log scale + auto dav = ret_t(-1 / w); + if (neg_v != 0) { + auto nearly_one = ret_t(1.0 - 1.0e-6); + const auto sign_v = (neg_v < 0) ? 1 : -1; + const auto sign_two_va_one_minus_w = sign_v * (2.0 * neg_v * a * w); + const auto exp_arg = exp(sign_two_va_one_minus_w); + if (exp_arg >= nearly_one) { + dav = -1.0 / w; + } else { + auto prob = LOG_TWO + log(fabs(neg_v)) + log(a) - log1m(exp_arg); + if (neg_v < 0) { + prob += sign_two_va_one_minus_w; + } + dav = -exp(prob); + } + } + + const auto pia2 = 2.0 * pi() / square(a); + auto prob_deriv = dav * prob; + ans = v * a * (cdf - prob) + ans * pia2 * evaw; + return -(prob_deriv + ans); +} +} // namespace internal + +/** + * Log-CDF function for the 4-parameter Wiener distribution. + * See 'wiener_lpdf' for more comprehensive documentation. + * + * @tparam T_y type of reaction time + * @tparam T_a type of boundary + * @tparam T_t0 type of non-decision time + * @tparam T_w type of relative starting point + * @tparam T_v type of drift rate + * + * @param y The reaction time in seconds + * @param a The boundary separation + * @param t0 The non-decision time + * @param w The relative starting point + * @param v The drift rate + * @param precision_derivatives Level of precision in estimation + * @return The log of the Wiener first passage time distribution with + * the specified arguments for upper boundary responses + */ +template +inline auto wiener_lcdf(const T_y& y, const T_a& a, const T_t0& t0, + const T_w& w, const T_v& v, + const double& precision_derivatives = 1e-4) { + using T_partials_return = partials_return_t; + using T_y_ref = ref_type_if_t::value, T_y>; + using T_a_ref = ref_type_if_t::value, T_a>; + using T_t0_ref = ref_type_if_t::value, T_t0>; + using T_w_ref = ref_type_if_t::value, T_w>; + using T_v_ref = ref_type_if_t::value, T_v>; + using internal::GradientCalc; + using ret_t = return_type_t; + + T_y_ref y_ref = y; + T_a_ref a_ref = a; + T_t0_ref t0_ref = t0; + T_w_ref w_ref = w; + T_v_ref v_ref = v; + + decltype(auto) y_val = to_ref(as_value_column_array_or_scalar(y_ref)); + decltype(auto) a_val = to_ref(as_value_column_array_or_scalar(a_ref)); + decltype(auto) v_val = to_ref(as_value_column_array_or_scalar(v_ref)); + decltype(auto) w_val = to_ref(as_value_column_array_or_scalar(w_ref)); + decltype(auto) t0_val = to_ref(as_value_column_array_or_scalar(t0_ref)); + + if (!include_summand::value) { + return ret_t(0.0); + } + + static constexpr const char* function_name = "wiener4_lcdf"; + if (size_zero(y, a, t0, w, v)) { + return ret_t(0.0); + } + + check_consistent_sizes(function_name, "Random variable", y, + "Boundary separation", a, "Drift rate", v, + "A-priori bias", w, "Nondecision time", t0); + check_positive_finite(function_name, "Random variable", y_val); + check_positive_finite(function_name, "Boundary separation", a_val); + check_finite(function_name, "Drift rate", v_val); + check_less(function_name, "A-priori bias", w_val, 1); + check_greater(function_name, "A-priori bias", w_val, 0); + check_nonnegative(function_name, "Nondecision time", t0_val); + check_finite(function_name, "Nondecision time", t0_val); + + const size_t N = max_size(y, a, t0, w, v); + + scalar_seq_view y_vec(y_ref); + scalar_seq_view a_vec(a_ref); + scalar_seq_view t0_vec(t0_ref); + scalar_seq_view w_vec(w_ref); + scalar_seq_view v_vec(v_ref); + const size_t N_y_t0 = max_size(y, t0); + + for (size_t i = 0; i < N_y_t0; ++i) { + if (y_vec[i] <= t0_vec[i]) { + std::stringstream msg; + msg << ", but must be greater than nondecision time = " << t0_vec[i]; + std::string msg_str(msg.str()); + throw_domain_error(function_name, "Random variable", y_vec[i], " = ", + msg_str.c_str()); + } + } + + // for precs. 1e-6, 1e-12, see Hartmann et al. (2021), Henrich et al. (2023) + const auto log_error_cdf = log(1e-6); + const auto log_error_derivative = log(precision_derivatives); + const T_partials_return log_error_absolute = log(1e-12); + T_partials_return lcdf = 0.0; + auto ops_partials + = make_partials_propagator(y_ref, a_ref, t0_ref, w_ref, v_ref); + + const double LOG_FOUR = std::log(4.0); + + // calculate distribution and partials + for (size_t i = 0; i < N; i++) { + const auto y_value = y_vec.val(i); + const auto a_value = a_vec.val(i); + const auto t0_value = t0_vec.val(i); + const auto w_value = w_vec.val(i); + const auto v_value = v_vec.val(i); + + const T_partials_return log_cdf + = internal::estimate_with_err_check<4, 0, GradientCalc::OFF, + GradientCalc::OFF>( + [](auto&&... args) { + return internal::wiener4_distribution(args...); + }, + log_error_cdf - LOG_TWO, y_value - t0_value, a_value, v_value, + w_value, log_error_absolute); + + const T_partials_return cdf = exp(log_cdf); + + lcdf += log_cdf; + + const auto new_est_err = log_cdf + log_error_derivative - LOG_FOUR; + + if (!is_constant_all::value || !is_constant_all::value) { + const auto deriv_y + = internal::estimate_with_err_check<5, 0, GradientCalc::OFF, + GradientCalc::ON>( + [](auto&&... args) { + return internal::wiener5_density(args...); + }, + new_est_err, y_value - t0_value, a_value, v_value, w_value, 0, + log_error_absolute); + + if (!is_constant_all::value) { + partials<0>(ops_partials)[i] = deriv_y / cdf; + } + if (!is_constant_all::value) { + partials<2>(ops_partials)[i] = -deriv_y / cdf; + } + } + if (!is_constant_all::value) { + partials<1>(ops_partials)[i] + = internal::estimate_with_err_check<5, 0, GradientCalc::OFF, + GradientCalc::ON>( + [](auto&&... args) { + return internal::wiener4_cdf_grad_a(args...); + }, + new_est_err, y_value - t0_value, a_value, v_value, w_value, cdf, + log_error_absolute) + / cdf; + } + if (!is_constant_all::value) { + partials<3>(ops_partials)[i] + = internal::estimate_with_err_check<5, 0, GradientCalc::OFF, + GradientCalc::ON>( + [](auto&&... args) { + return internal::wiener4_cdf_grad_w(args...); + }, + new_est_err, y_value - t0_value, a_value, v_value, w_value, cdf, + log_error_absolute) + / cdf; + } + if (!is_constant_all::value) { + partials<4>(ops_partials)[i] + = internal::wiener4_cdf_grad_v(y_value - t0_value, a_value, v_value, + w_value, cdf, log_error_absolute) + / cdf; + } + } // for loop + return ops_partials.build(lcdf); +} +} // namespace math +} // namespace stan +#endif diff --git a/stan/math/prim/prob/wiener5_lpdf.hpp b/stan/math/prim/prob/wiener5_lpdf.hpp index 689e5c1e2fd..5b84ee620f9 100644 --- a/stan/math/prim/prob/wiener5_lpdf.hpp +++ b/stan/math/prim/prob/wiener5_lpdf.hpp @@ -13,61 +13,62 @@ enum GradientCalc { OFF = 0, ON = 1 }; /** * Calculate the 'error_term' term for a wiener5 density or gradient * - * @tparam T_y type of scalar variable + * @tparam T_y type of reaction time * @tparam T_a type of boundary separation * @tparam T_v type of drift rate * @tparam T_w type of relative starting point * @tparam T_sv type of inter-trial variability in v * - * @param y A scalar variable; the reaction time in seconds + * @param y The reaction time in seconds * @param a The boundary separation - * @param v_value The drift rate - * @param w_value The relative starting point + * @param v The drift rate + * @param w The relative starting point * @param sv The inter-trial variability of the drift rate * @return 'error_term' term */ template -inline auto wiener5_compute_error_term(T_y&& y, T_a&& a, T_v&& v_value, - T_w&& w_value, T_sv&& sv) noexcept { - const auto w = 1.0 - w_value; - const auto v = -v_value; +inline auto wiener5_compute_error_term(T_y&& y, T_a&& a, T_v&& v, T_w&& w, + T_sv&& sv) noexcept { + const auto one_m_w = 1.0 - w; + const auto neg_v = -v; const auto sv_sqr = square(sv); const auto one_plus_svsqr_y = 1 + sv_sqr * y; - const auto two_avw = 2.0 * a * v * w; + const auto two_avw = 2.0 * a * neg_v * one_m_w; const auto two_log_a = 2.0 * log(a); - return stan::math::eval((sv_sqr * square(a * w) - two_avw - square(v) * y) - / 2.0 / one_plus_svsqr_y - - two_log_a - 0.5 * log(one_plus_svsqr_y)); + return stan::math::eval( + (sv_sqr * square(a * one_m_w) - two_avw - square(neg_v) * y) / 2.0 + / one_plus_svsqr_y + - two_log_a - 0.5 * log(one_plus_svsqr_y)); } /** * Calculate the 'n_terms_small_t' term for a wiener5 density or gradient * * @tparam Density Whether the calculation is for the density - * @tparam GradW Whether the calculation is for gradient w.r.t. 'w' - * @tparam T_y type of scalar variable + * @tparam GradW Whether the calculation is for gradient with respect to 'w' + * @tparam T_y type of reaction time * @tparam T_a type of boundary separation - * @tparam T_w_value type of relative starting point + * @tparam T_w type of relative starting point * @tparam T_err type of error * - * @param y A scalar variable; the reaction time in seconds + * @param y The reaction time in seconds * @param a The boundary separation - * @param w_value The relative starting point + * @param w The relative starting point * @param error The error tolerance * @return 'n_terms_small_t' term */ template -inline auto wiener5_n_terms_small_t(T_y&& y, T_a&& a, T_w_value&& w_value, + typename T_w, typename T_err> +inline auto wiener5_n_terms_small_t(T_y&& y, T_a&& a, T_w&& w, T_err&& error) noexcept { const auto two_error = 2.0 * error; const auto y_asq = y / square(a); - const auto two_log_a = 2 * log(a); + const auto two_log_a = 2.0 * log(a); const auto log_y_asq = log(y) - two_log_a; - const auto w = 1.0 - w_value; + const auto one_m_w = 1.0 - w; - const auto n_1_factor = Density ? 2 : 3; - const auto n_1 = (sqrt(n_1_factor * y_asq) + w) / 2.0; + constexpr auto n_1_factor = Density ? 2.0 : 3.0; + const auto n_1 = (sqrt(n_1_factor * y_asq) + one_m_w) / 2.0; auto u_eps = (Density || GradW) ? fmin(-1.0, LOG_TWO + LOG_PI + 2.0 * log_y_asq + two_error) : fmin(-3.0, (log(8.0) - log(27.0) + LOG_PI + 4.0 * log_y_asq @@ -75,8 +76,9 @@ inline auto wiener5_n_terms_small_t(T_y&& y, T_a&& a, T_w_value&& w_value, const auto arg_mult = (Density || GradW) ? 1 : 3; const auto arg = -arg_mult * y_asq * (u_eps - sqrt(-2.0 * u_eps - 2.0)); - const auto n_2 - = (arg > 0) ? GradW ? 0.5 * (sqrt(arg) + w) : 0.5 * (sqrt(arg) - w) : n_1; + const auto n_2 = (arg > 0) ? GradW ? 0.5 * (sqrt(arg) + one_m_w) + : 0.5 * (sqrt(arg) - one_m_w) + : n_1; return ceil(fmax(n_1, n_2)); } @@ -84,23 +86,22 @@ inline auto wiener5_n_terms_small_t(T_y&& y, T_a&& a, T_w_value&& w_value, /** * Calculate the 'n_terms_large_t' term for a wiener5 density * - * @tparam T_y type of scalar variable + * @tparam T_y type of reaction time * @tparam T_a type of boundary separation - * @tparam T_w_value type of relative starting point + * @tparam T_w type of relative starting point * @tparam T_err type of error * - * @param y A scalar variable; the reaction time in seconds + * @param y The reaction time in seconds * @param a The boundary separation - * @param w_value The relative starting point + * @param w The relative starting point * @param error The error tolerance * @return 'n_terms_large_t' term */ -template -inline auto wiener5_density_large_reaction_time_terms(T_y&& y, T_a&& a, - T_w_value&& w_value, +template +inline auto wiener5_density_large_reaction_time_terms(T_y&& y, T_a&& a, T_w&& w, T_err&& error) noexcept { const auto y_asq = y / square(a); - const auto log_y_asq = log(y) - 2 * log(a); + const auto log_y_asq = log(y) - 2.0 * log(a); static constexpr double PI_SQUARED = pi() * pi(); auto n_1 = 1.0 / (pi() * sqrt(y_asq)); const auto two_log_piy = -2.0 * (LOG_PI + log_y_asq + error); @@ -112,79 +113,85 @@ inline auto wiener5_density_large_reaction_time_terms(T_y&& y, T_a&& a, /** * Calculate the 'n_terms_large_t' term for a wiener5 gradient * - * @tparam GradW Whether the calculation is for gradient w.r.t. 'w' - * @tparam T_y type of scalar variable + * @tparam GradW Whether the calculation is for gradient with respect to 'w' + * @tparam T_y type of reaction time * @tparam T_a type of boundary separation - * @tparam T_w_value type of relative starting point + * @tparam T_w type of relative starting point * @tparam T_err type of error * - * @param y A scalar variable; the reaction time in seconds + * @param y The reaction time in seconds * @param a The boundary separation - * @param w_value The relative starting point + * @param w The relative starting point * @param error The error tolerance * @return 'n_terms_large_t' term */ -template inline auto wiener5_gradient_large_reaction_time_terms(T_y&& y, T_a&& a, - T_w_value&& w_value, + T_w&& w, T_err&& error) noexcept { const auto y_asq = y / square(a); - const auto log_y_asq = log(y) - 2 * log(a); + const auto log_y_asq = log(y) - 2.0 * log(a); static constexpr double PI_SQUARED = pi() * pi(); - const auto n_1_factor = GradW ? 2 : 3; + constexpr auto n_1_factor = GradW ? 2.0 : 3.0; auto n_1 = sqrt(n_1_factor / y_asq) / pi(); const auto two_error = 2.0 * error; const auto u_eps_arg = GradW ? log(4.0) - log(9.0) + 2.0 * LOG_PI + 3.0 * log_y_asq + two_error : log(3.0) - log(5.0) + LOG_PI + 2.0 * log_y_asq + error; const auto u_eps = fmin(-1, u_eps_arg); - const auto arg_mult = GradW ? 1 : (2.0 / PI_SQUARED / y_asq); - const auto arg = -arg_mult * (u_eps - sqrt(-2.0 * u_eps - 2.0)); - auto n_2 = GradW ? ((arg > 0) ? sqrt(arg / y_asq) / pi() : n_1) - : ((arg > 0) ? sqrt(arg) : n_1); - return ceil(fmax(n_1, n_2)); + if constexpr (GradW) { + const auto arg = -(u_eps - sqrt(-2.0 * u_eps - 2.0)); + auto n_2 = (arg > 0) ? sqrt(arg / y_asq) / pi() : n_1; + return ceil(fmax(n_1, n_2)); + } else { + const auto arg + = -(2.0 / PI_SQUARED / y_asq) * (u_eps - sqrt(-2.0 * u_eps - 2.0)); + auto n_2 = (arg > 0) ? sqrt(arg) : n_1; + return ceil(fmax(n_1, n_2)); + } } /** * Calculate the 'result' term and its sign for a wiener5 density or gradient * * @tparam Density Whether the calculation is for the density - * @tparam GradW Whether the calculation is for gradient w.r.t. 'w' - * @tparam T_y type of scalar variable + * @tparam GradW Whether the calculation is for gradient with respect to 'w' + * @tparam T_y type of reaction time * @tparam T_a type of boundary separation * @tparam T_w type of relative starting point * @tparam T_nsmall type of term number_small_terms * @tparam T_nlarge type of term number_large_terms * - * @param y A scalar variable; the reaction time in seconds + * @param y The reaction time in seconds * @param a The boundary separation - * @param w_value The relative starting point + * @param w The relative starting point * @param n_terms_small_t The n_terms_small_t term * @param n_terms_large_t The n_terms_large_t term * @return 'result' sum and its sign */ template -inline auto wiener5_log_sum_exp(T_y&& y, T_a&& a, T_w&& w_value, +inline auto wiener5_log_sum_exp(T_y&& y, T_a&& a, T_w&& w, T_nsmall&& n_terms_small_t, T_nlarge&& n_terms_large_t) noexcept { + using ret_t = return_type_t; + const auto y_asq = y / square(a); - const auto w = 1.0 - w_value; + const auto one_m_w = 1.0 - w; const bool small_n_terms_small_t - = Density ? (2 * n_terms_small_t <= n_terms_large_t) - : (2 * n_terms_small_t < n_terms_large_t); + = Density ? (2.0 * n_terms_small_t <= n_terms_large_t) + : (2.0 * n_terms_small_t < n_terms_large_t); const auto scaling = small_n_terms_small_t ? inv(2.0 * y_asq) : y_asq / 2.0; - using ret_t = return_type_t; ret_t fplus = NEGATIVE_INFTY; ret_t fminus = NEGATIVE_INFTY; int current_sign; if (small_n_terms_small_t) { constexpr double mult = Density ? 1.0 : 3.0; - if (GradW) { + if constexpr (GradW) { for (auto k = n_terms_small_t; k >= 1; k--) { - const auto w_plus_2_k = w + 2.0 * k; - const auto w_minus_2_k = w - 2.0 * k; + const auto w_plus_2_k = one_m_w + 2.0 * k; + const auto w_minus_2_k = one_m_w - 2.0 * k; const auto square_w_plus_2_k_minus_offset = square(w_plus_2_k) - y_asq; if (square_w_plus_2_k_minus_offset > 0) { const auto summand_plus = log(square_w_plus_2_k_minus_offset) @@ -207,18 +214,20 @@ inline auto wiener5_log_sum_exp(T_y&& y, T_a&& a, T_w&& w_value, fminus = log_sum_exp(fminus, summand_minus); } } - const auto square_w_minus_offset = square(w) - y_asq; + const auto square_w_minus_offset = square(one_m_w) - y_asq; if (square_w_minus_offset > 0) { - const auto new_val = log(square_w_minus_offset) - square(w) * scaling; + const auto new_val + = log(square_w_minus_offset) - square(one_m_w) * scaling; fplus = log_sum_exp(fplus, new_val); } else if (square_w_minus_offset < 0) { - const auto new_val = log(-square_w_minus_offset) - square(w) * scaling; + const auto new_val + = log(-square_w_minus_offset) - square(one_m_w) * scaling; fminus = log_sum_exp(fminus, new_val); } } else { for (auto k = n_terms_small_t; k >= 1; k--) { - const auto w_plus_2_k = w + 2.0 * k; - const auto w_minus_2_k = w - 2.0 * k; + const auto w_plus_2_k = one_m_w + 2.0 * k; + const auto w_minus_2_k = one_m_w - 2.0 * k; const auto summand_plus = mult * log(w_plus_2_k) - square(w_plus_2_k) * scaling; fplus = log_sum_exp(fplus, summand_plus); @@ -234,14 +243,14 @@ inline auto wiener5_log_sum_exp(T_y&& y, T_a&& a, T_w&& w_value, fminus = summand_minus + log1p_exp(fminus - summand_minus); } } - const auto new_val = mult * log(w) - square(w) * scaling; + const auto new_val = mult * log(one_m_w) - square(one_m_w) * scaling; fplus = log_sum_exp(fplus, new_val); } } else { // for large t - constexpr double mult = (Density ? 1 : (GradW ? 2 : 3)); + constexpr double mult = (Density ? 1.0 : (GradW ? 2.0 : 3.0)); for (auto k = n_terms_large_t; k >= 1; k--) { const auto pi_k = k * pi(); - const auto check = (GradW) ? cos(pi_k * w) : sin(pi_k * w); + const auto check = (GradW) ? cos(pi_k * one_m_w) : sin(pi_k * one_m_w); if (check > 0) { fplus = log_sum_exp( fplus, mult * log(k) - square(pi_k) * scaling + log(check)); @@ -270,41 +279,40 @@ inline auto wiener5_log_sum_exp(T_y&& y, T_a&& a, T_w&& w_value, * * @tparam NaturalScale Whether to return the density on natural (true) or * log-scale (false) - * @tparam T_y type of scalar variable + * @tparam T_y type of reaction time * @tparam T_a type of boundary separation * @tparam T_w type of relative starting point * @tparam T_v type of drift rate * @tparam T_sv type of inter-trial variability in v * @tparam T_err type of log error * - * @param y A scalar variable; the reaction time in seconds + * @param y The reaction time in seconds * @param a The boundary separation - * @param v_value The drift rate - * @param w_value The relative starting point + * @param v The drift rate + * @param w The relative starting point * @param sv The inter-trial variability of the drift rate * @param err The log error tolerance * @return density */ template -inline auto wiener5_density(const T_y& y, const T_a& a, const T_v& v_value, - const T_w& w_value, const T_sv& sv, +inline auto wiener5_density(const T_y& y, const T_a& a, const T_v& v, + const T_w& w, const T_sv& sv, T_err&& err = log(1e-12)) noexcept { - const auto error_term - = wiener5_compute_error_term(y, a, v_value, w_value, sv); + const auto error_term = wiener5_compute_error_term(y, a, v, w, sv); const auto error = (err - error_term); const auto n_terms_small_t - = wiener5_n_terms_small_t( - y, a, w_value, error); + = wiener5_n_terms_small_t(y, a, w, + error); const auto n_terms_large_t - = wiener5_density_large_reaction_time_terms(y, a, w_value, error); + = wiener5_density_large_reaction_time_terms(y, a, w, error); auto res = wiener5_log_sum_exp( - y, a, w_value, n_terms_small_t, n_terms_large_t) + y, a, w, n_terms_small_t, n_terms_large_t) .first; if (2 * n_terms_small_t <= n_terms_large_t) { auto log_density = error_term - 0.5 * LOG_TWO - LOG_SQRT_PI - - 1.5 * (log(y) - 2 * log(a)) + res; + - 1.5 * (log(y) - 2.0 * log(a)) + res; return NaturalScale ? exp(log_density) : log_density; } else { auto log_density = error_term + res + LOG_PI; @@ -315,57 +323,56 @@ inline auto wiener5_density(const T_y& y, const T_a& a, const T_v& v_value, /** * Calculate the derivative of the wiener5 density w.r.t. 't' * - * @tparam WrtLog Whether to return the derivative w.r.t. + * @tparam WrtLog Whether to return the derivative with respect to * the natural (true) or log-scale (false) density - * @tparam T_y type of scalar variable + * @tparam T_y type of reaction time * @tparam T_a type of boundary separation * @tparam T_v type of drift rate * @tparam T_w type of relative starting point * @tparam T_sv type of inter-trial variability in v * @tparam T_err type of log error * - * @param y A scalar variable; the reaction time in seconds + * @param y The reaction time in seconds * @param a The boundary separation - * @param v_value The drift rate - * @param w_value The relative starting point + * @param v The drift rate + * @param w The relative starting point * @param sv The inter-trial variability of the drift rate * @param err The log error tolerance - * @return Gradient w.r.t. t + * @return Gradient with respect to t */ template -inline auto wiener5_grad_t(const T_y& y, const T_a& a, const T_v& v_value, - const T_w& w_value, const T_sv& sv, +inline auto wiener5_grad_t(const T_y& y, const T_a& a, const T_v& v, + const T_w& w, const T_sv& sv, T_err&& err = log(1e-12)) noexcept { - const auto two_log_a = 2 * log(a); + const auto two_log_a = 2.0 * log(a); const auto log_y_asq = log(y) - two_log_a; - const auto error_term - = wiener5_compute_error_term(y, a, v_value, w_value, sv); - const auto w = 1.0 - w_value; - const auto v = -v_value; + const auto error_term = wiener5_compute_error_term(y, a, v, w, sv); + const auto one_m_w = 1.0 - w; + const auto neg_v = -v; const auto sv_sqr = square(sv); const auto one_plus_svsqr_y = 1 + sv_sqr * y; const auto density_part_one = -0.5 - * (square(sv_sqr) * (y + square(a * w)) - + sv_sqr * (1 - (2.0 * a * v * w)) + square(v)) + * (square(sv_sqr) * (y + square(a * one_m_w)) + + sv_sqr * (1.0 - (2.0 * a * neg_v * one_m_w)) + square(neg_v)) / square(one_plus_svsqr_y); const auto error = (err - error_term) + two_log_a; const auto n_terms_small_t - = wiener5_n_terms_small_t( - y, a, w_value, error); + = wiener5_n_terms_small_t(y, a, w, + error); const auto n_terms_large_t - = wiener5_gradient_large_reaction_time_terms( - y, a, w_value, error); + = wiener5_gradient_large_reaction_time_terms(y, a, w, + error); auto wiener_res = wiener5_log_sum_exp( - y, a, w_value, n_terms_small_t, n_terms_large_t); + y, a, w, n_terms_small_t, n_terms_large_t); auto&& result = wiener_res.first; auto&& newsign = wiener_res.second; const auto error_log_density = log(fmax(fabs(density_part_one - 1.5 / y), fabs(density_part_one))); const auto log_density = wiener5_density( - y, a, v_value, w_value, sv, err - error_log_density); - if (2 * n_terms_small_t < n_terms_large_t) { + y, a, v, w, sv, err - error_log_density); + if (2.0 * n_terms_small_t < n_terms_large_t) { auto ans = density_part_one - 1.5 / y + newsign * exp(error_term - two_log_a - 1.5 * LOG_TWO - LOG_SQRT_PI @@ -383,54 +390,52 @@ inline auto wiener5_grad_t(const T_y& y, const T_a& a, const T_v& v_value, /** * Calculate the derivative of the wiener5 density w.r.t. 'a' * - * @tparam WrtLog Whether to return the derivative w.r.t. + * @tparam WrtLog Whether to return the derivative with respect to * the natural (true) or log-scale (false) density - * @tparam T_y type of scalar variable + * @tparam T_y type of reaction time * @tparam T_a type of boundary separation * @tparam T_v type of drift rate * @tparam T_w type of relative starting point * @tparam T_sv type of inter-trial variability in v * @tparam T_err type of log error * - * @param y A scalar variable; the reaction time in seconds + * @param y The reaction time in seconds * @param a The boundary separation - * @param v_value The drift rate - * @param w_value The relative starting point + * @param v The drift rate + * @param w The relative starting point * @param sv The inter-trial variability of the drift rate * @param err The log error tolerance - * @return Gradient w.r.t. a + * @return Gradient with respect to a */ template -inline auto wiener5_grad_a(const T_y& y, const T_a& a, const T_v& v_value, - const T_w& w_value, const T_sv& sv, +inline auto wiener5_grad_a(const T_y& y, const T_a& a, const T_v& v, + const T_w& w, const T_sv& sv, T_err&& err = log(1e-12)) noexcept { - const auto two_log_a = 2 * log(a); - const auto error_term - = wiener5_compute_error_term(y, a, v_value, w_value, sv); - const auto w = 1.0 - w_value; - const auto v = -v_value; + const auto two_log_a = 2.0 * log(a); + const auto error_term = wiener5_compute_error_term(y, a, v, w, sv); + const auto one_m_w = 1.0 - w; const auto sv_sqr = square(sv); - const auto one_plus_svsqr_y = 1 + sv_sqr * y; + const auto one_plus_svsqr_y = 1.0 + sv_sqr * y; const auto density_part_one - = (-v * w + sv_sqr * square(w) * a) / one_plus_svsqr_y; - const auto error = err - error_term + 3 * log(a) - log(y) - LOG_TWO; + = (v * one_m_w + sv_sqr * square(one_m_w) * a) / one_plus_svsqr_y; + const auto error = err - error_term + 3.0 * log(a) - log(y) - LOG_TWO; const auto n_terms_small_t - = wiener5_n_terms_small_t( - y, a, w_value, error); + = wiener5_n_terms_small_t(y, a, w, + error); const auto n_terms_large_t - = wiener5_gradient_large_reaction_time_terms( - y, a, w_value, error); + = wiener5_gradient_large_reaction_time_terms(y, a, w, + error); auto wiener_res = wiener5_log_sum_exp( - y, a, w_value, n_terms_small_t, n_terms_large_t); + y, a, w, n_terms_small_t, n_terms_large_t); auto&& result = wiener_res.first; auto&& newsign = wiener_res.second; const auto error_log_density = log( fmax(fabs(density_part_one + 1.0 / a), fabs(density_part_one - 2.0 / a))); const auto log_density = wiener5_density( - y, a, v_value, w_value, sv, err - error_log_density); - if (2 * n_terms_small_t < n_terms_large_t) { + y, a, v, w, sv, err - error_log_density); + if (2.0 * n_terms_small_t < n_terms_large_t) { auto ans = density_part_one + 1.0 / a - newsign @@ -440,8 +445,8 @@ inline auto wiener5_grad_a(const T_y& y, const T_a& a, const T_v& v_value, } else { auto ans = density_part_one - 2.0 / a + newsign - * exp(log(y) + error_term - 3 * (log(a) - LOG_PI) + result - - log_density); + * exp(log(y) + error_term - 3.0 * (log(a) - LOG_PI) + + result - log_density); return WrtLog ? ans * exp(log_density) : ans; } } @@ -449,31 +454,31 @@ inline auto wiener5_grad_a(const T_y& y, const T_a& a, const T_v& v_value, /** * Calculate the derivative of the wiener5 density w.r.t. 'v' * - * @tparam WrtLog Whether to return the derivative w.r.t. + * @tparam WrtLog Whether to return the derivative with respect to * the natural (true) or log-scale (false) density - * @tparam T_y type of scalar variable + * @tparam T_y type of reaction time * @tparam T_a type of boundary separation * @tparam T_v type of drift rate * @tparam T_w type of relative starting point * @tparam T_sv type of inter-trial variability in v * @tparam T_err type of log error * - * @param y A scalar variable; the reaction time in seconds + * @param y The reaction time in seconds * @param a The boundary separation - * @param v_value The drift rate - * @param w_value The relative starting point + * @param v The drift rate + * @param w The relative starting point * @param sv The inter-trial variability of the drift rate * @param err The log error tolerance - * @return Gradient w.r.t. v + * @return Gradient with respect to v */ template -inline auto wiener5_grad_v(const T_y& y, const T_a& a, const T_v& v_value, - const T_w& w_value, const T_sv& sv, +inline auto wiener5_grad_v(const T_y& y, const T_a& a, const T_v& v, + const T_w& w, const T_sv& sv, T_err&& err = log(1e-12)) noexcept { - auto ans = (a * (1 - w_value) - v_value * y) / (1.0 + square(sv) * y); - if (WrtLog) { - return ans * wiener5_density(y, a, v_value, w_value, sv, err); + auto ans = (a * (1 - w) - v * y) / (1.0 + square(sv) * y); + if constexpr (WrtLog) { + return ans * wiener5_density(y, a, v, w, sv, err); } else { return ans; } @@ -482,62 +487,60 @@ inline auto wiener5_grad_v(const T_y& y, const T_a& a, const T_v& v_value, /** * Calculate the derivative of the wiener5 density w.r.t. 'w' * - * @tparam WrtLog Whether to return the derivative w.r.t. + * @tparam WrtLog Whether to return the derivative with respect to * the natural (true) or log-scale (false) density - * @tparam T_y type of scalar variable + * @tparam T_y type of reaction time * @tparam T_a type of boundary separation * @tparam T_v type of drift rate * @tparam T_w type of relative starting point * @tparam T_sv type of inter-trial variability in v * @tparam T_err type of log error * - * @param y A scalar variable; the reaction time in seconds + * @param y The reaction time in seconds * @param a The boundary separation - * @param v_value The drift rate - * @param w_value The relative starting point + * @param v The drift rate + * @param w The relative starting point * @param sv The inter-trial variability of the drift rate * @param err The log error tolerance - * @return Gradient w.r.t. w + * @return Gradient with respect to w */ template -inline auto wiener5_grad_w(const T_y& y, const T_a& a, const T_v& v_value, - const T_w& w_value, const T_sv& sv, +inline auto wiener5_grad_w(const T_y& y, const T_a& a, const T_v& v, + const T_w& w, const T_sv& sv, T_err&& err = log(1e-12)) noexcept { - const auto two_log_a = 2 * log(a); + const auto two_log_a = 2.0 * log(a); const auto log_y_asq = log(y) - two_log_a; - const auto error_term - = wiener5_compute_error_term(y, a, v_value, w_value, sv); - const auto w = 1.0 - w_value; - const auto v = -v_value; + const auto error_term = wiener5_compute_error_term(y, a, v, w, sv); + const auto one_m_w = 1.0 - w; const auto sv_sqr = square(sv); - const auto one_plus_svsqr_y = 1 + sv_sqr * y; + const auto one_plus_svsqr_y = 1.0 + sv_sqr * y; const auto density_part_one - = (-v * a + sv_sqr * square(a) * w) / one_plus_svsqr_y; + = (v * a + sv_sqr * square(a) * one_m_w) / one_plus_svsqr_y; const auto error = (err - error_term); const auto n_terms_small_t - = wiener5_n_terms_small_t( - y, a, w_value, error); + = wiener5_n_terms_small_t(y, a, w, + error); const auto n_terms_large_t - = wiener5_gradient_large_reaction_time_terms( - y, a, w_value, error); + = wiener5_gradient_large_reaction_time_terms(y, a, w, + error); auto wiener_res = wiener5_log_sum_exp( - y, a, w_value, n_terms_small_t, n_terms_large_t); + y, a, w, n_terms_small_t, n_terms_large_t); auto&& result = wiener_res.first; auto&& newsign = wiener_res.second; const auto log_density = wiener5_density( - y, a, v_value, w_value, sv, err - log(fabs(density_part_one))); - if (2 * n_terms_small_t < n_terms_large_t) { + y, a, v, w, sv, err - log(fabs(density_part_one))); + if (2.0 * n_terms_small_t < n_terms_large_t) { auto ans = -(density_part_one - newsign * exp(result - (log_density - error_term) - 2.5 * log_y_asq - 0.5 * LOG_TWO - 0.5 * LOG_PI)); return WrtLog ? ans * exp(log_density) : ans; } else { - auto ans - = -(density_part_one - + newsign * exp(result - (log_density - error_term) + 2 * LOG_PI)); + auto ans = -( + density_part_one + + newsign * exp(result - (log_density - error_term) + 2.0 * LOG_PI)); return WrtLog ? ans * exp(log_density) : ans; } } @@ -545,37 +548,37 @@ inline auto wiener5_grad_w(const T_y& y, const T_a& a, const T_v& v_value, /** * Calculate the derivative of the wiener5 density w.r.t. 'sv' * - * @tparam WrtLog Whether to return the derivative w.r.t. + * @tparam WrtLog Whether to return the derivative with respect to * the natural (true) or log-scale (false) density - * @tparam T_y type of scalar variable + * @tparam T_y type of reaction time * @tparam T_a type of boundary separation * @tparam T_v type of drift rate * @tparam T_w type of relative starting point * @tparam T_sv type of inter-trial variability in v * @tparam T_err type of log error * - * @param y A scalar variable; the reaction time in seconds + * @param y The reaction time in seconds * @param a The boundary separation - * @param v_value The drift rate - * @param w_value The relative starting point + * @param v The drift rate + * @param w The relative starting point * @param sv The inter-trial variability of the drift rate * @param err The log error tolerance - * @return Gradient w.r.t. sv + * @return Gradient with respect to sv */ template -inline auto wiener5_grad_sv(const T_y& y, const T_a& a, const T_v& v_value, - const T_w& w_value, const T_sv& sv, +inline auto wiener5_grad_sv(const T_y& y, const T_a& a, const T_v& v, + const T_w& w, const T_sv& sv, T_err&& err = log(1e-12)) noexcept { - const auto one_plus_svsqr_y = 1 + square(sv) * y; - const auto w = 1.0 - w_value; - const auto v = -v_value; + const auto one_plus_svsqr_y = 1.0 + square(sv) * y; + const auto one_m_w = 1.0 - w; + const auto neg_v = -v; const auto t1 = -y / one_plus_svsqr_y; - const auto t2 = (square(a * w) + 2 * a * v * w * y + square(v * y)) + const auto t2 = (square(a * one_m_w) + 2.0 * a * neg_v * one_m_w * y + + square(neg_v * y)) / square(one_plus_svsqr_y); const auto ans = sv * (t1 + t2); - return WrtLog ? ans * wiener5_density(y, a, v_value, w_value, sv, err) - : ans; + return WrtLog ? ans * wiener5_density(y, a, v, w, sv, err) : ans; } /** @@ -626,7 +629,7 @@ inline void assign_err(std::tuple& args_tuple, Scalar err) { * @param err Error value to check against * @param args_tuple Tuple of arguments to pass to functor */ -template inline auto estimate_with_err_check(F&& functor, T_err&& err, @@ -638,7 +641,9 @@ inline auto estimate_with_err_check(F&& functor, T_err&& err, auto err_args_tuple = std::make_tuple(args_tuple...); const auto new_error = GradW7 ? err + log_fabs_result + LOG_TWO : err + log_fabs_result; - assign_err(std::get(err_args_tuple), new_error); + if constexpr (NestedIndex != -1) { + assign_err(std::get(err_args_tuple), new_error); + } result = math::apply([](auto&& func, auto&&... args) { return func(args...); }, err_args_tuple, functor); @@ -649,9 +654,9 @@ inline auto estimate_with_err_check(F&& functor, T_err&& err, /** * Log-density function for the 5-parameter Wiener density. - * See 'wiener_lpdf' for more comprehensive documentation + * See 'wiener_lpdf' for more comprehensive documentation. * - * @tparam T_y type of scalar + * @tparam T_y type of reaction time * @tparam T_a type of boundary * @tparam T_t0 type of non-decision time * @tparam T_w type of relative starting point @@ -659,7 +664,7 @@ inline auto estimate_with_err_check(F&& functor, T_err&& err, * @tparam T_sv type of inter-trial variability of drift rate * @tparam T_precision type of precision * - * @param y A scalar variable; the reaction time in seconds + * @param y The reaction time in seconds * @param a The boundary separation * @param t0 The non-decision time * @param w The relative starting point @@ -676,23 +681,13 @@ inline auto wiener_lpdf(const T_y& y, const T_a& a, const T_t0& t0, const double& precision_derivatives = 1e-4) { using T_partials_return = partials_return_t; using ret_t = return_type_t; - if constexpr (!include_summand::value) { - return ret_t(0.0); - } using T_y_ref = ref_type_t; using T_a_ref = ref_type_t; using T_t0_ref = ref_type_t; using T_w_ref = ref_type_t; using T_v_ref = ref_type_t; using T_sv_ref = ref_type_t; - - static constexpr const char* function_name = "wiener5_lpdf"; - - check_consistent_sizes(function_name, "Random variable", y, - "Boundary separation", a, "Drift rate", v, - "A-priori bias", w, "Nondecision time", t0, - "Inter-trial variability in drift rate", sv); + using internal::GradientCalc; T_y_ref y_ref = y; T_a_ref a_ref = a; @@ -707,6 +702,18 @@ inline auto wiener_lpdf(const T_y& y, const T_a& a, const T_t0& t0, decltype(auto) w_val = to_ref(as_value_column_array_or_scalar(w_ref)); decltype(auto) t0_val = to_ref(as_value_column_array_or_scalar(t0_ref)); decltype(auto) sv_val = to_ref(as_value_column_array_or_scalar(sv_ref)); + + if constexpr (!include_summand::value) { + return ret_t(0.0); + } + + static constexpr const char* function_name = "wiener5_lpdf"; + + check_consistent_sizes(function_name, "Random variable", y, + "Boundary separation", a, "Drift rate", v, + "A-priori bias", w, "Nondecision time", t0, + "Inter-trial variability in drift rate", sv); check_positive_finite(function_name, "Random variable", y_val); check_positive_finite(function_name, "Boundary separation", a_val); check_finite(function_name, "Drift rate", v_val); @@ -744,6 +751,7 @@ inline auto wiener_lpdf(const T_y& y, const T_a& a, const T_t0& t0, } } + // for precs. 1e-6, 1e-12, see Hartmann et al. (2021), Henrich et al. (2023) const auto log_error_density = log(1e-6); const auto log_error_derivative = log(precision_derivatives); const double log_error_absolute_val = log(1e-12); @@ -752,7 +760,7 @@ inline auto wiener_lpdf(const T_y& y, const T_a& a, const T_t0& t0, auto ops_partials = make_partials_propagator(y_ref, a_ref, t0_ref, w_ref, v_ref, sv_ref); - static constexpr double LOG_FOUR = LOG_TWO + LOG_TWO; + const double LOG_FOUR = std::log(4.0); // calculate density and partials for (size_t i = 0; i < N; i++) { @@ -766,7 +774,6 @@ inline auto wiener_lpdf(const T_y& y, const T_a& a, const T_t0& t0, const auto w_value = w_vec.val(i); const auto v_value = v_vec.val(i); const auto sv_value = sv_vec.val(i); - using internal::GradientCalc; auto l_density = internal::estimate_with_err_check<5, 0, GradientCalc::OFF, GradientCalc::OFF>( [](auto&&... args) { @@ -779,6 +786,7 @@ inline auto wiener_lpdf(const T_y& y, const T_a& a, const T_t0& t0, const auto new_est_err = l_density + log_error_derivative - LOG_FOUR; + // computation of derivatives and precision checks // computation of derivative for t and precision check in order to give // the value as deriv_y to edge1 and as -deriv_y to edge5 const auto deriv_y @@ -833,15 +841,6 @@ inline auto wiener_lpdf(const T_y& y, const T_a& a, const T_t0& t0, return ops_partials.build(log_density); } // end wiener_lpdf -// ToDo: delete old wiener_lpdf implementation to use this one -// template -// inline auto wiener_lpdf(const T_y& y, const T_a& a, const T_t0& t0, -// const T_w& w, const T_v& v, -// const double& precision_derivatives = 1e-4) { -// return wiener_lpdf(y, a, t0, w, v, 0, precision_derivatives); -//} // end wiener_lpdf - } // namespace math } // namespace stan #endif diff --git a/stan/math/prim/prob/wiener_full_lccdf.hpp b/stan/math/prim/prob/wiener_full_lccdf.hpp new file mode 100644 index 00000000000..f9aa6a97fea --- /dev/null +++ b/stan/math/prim/prob/wiener_full_lccdf.hpp @@ -0,0 +1,409 @@ +#ifndef STAN_MATH_PRIM_PROB_WIENER_FULL_LCCDF_HPP +#define STAN_MATH_PRIM_PROB_WIENER_FULL_LCCDF_HPP + +#include +#include + +namespace stan { +namespace math { +namespace internal { + +/** + * Calculate the derivative of the wiener7 density w.r.t. 'sw' + * + * @tparam T_y type of reaction time + * @tparam T_a type of boundary separation + * @tparam T_v type of drift rate + * @tparam T_w type of relative starting point + * @tparam T_sv type of inter-trial variability in v + * @tparam T_err type of log error tolerance + * + * @param y The reaction time in seconds + * @param a The boundary separation + * @param v The drift rate + * @param w The relative starting point + * @param sw The inter-trial variability of the relative starting point + * @param wildcard This parameter space is needed for a functor. Could be + * deleted when another solution is found + * @param log_error The log error tolerance + * @return Gradient with respect to sw + */ +template +inline auto wiener7_ccdf_grad_sw(const T_y& y, const T_a& a, const T_v& v, + const T_w& w, const T_sw& sw, + T_err&& log_error) { + auto low = w - sw / 2.0; + low = (0 > low) ? 0 : low; + auto high = w + sw / 2.0; + high = (1 < high) ? 1 : high; + + const auto lower_value = wiener4_ccdf(y, a, v, low, log_error); + const auto upper_value = wiener4_ccdf(y, a, v, high, log_error); + return 0.5 * (lower_value + upper_value) / sw; +} + +} // namespace internal + +/** \ingroup prob_dists + * Returns the log CCDF of the Wiener distribution for a + * (Wiener) drift diffusion model with up to 7 parameters. If containers + * are supplied, returns the log sum of the probabilities. + * See 'wiener_full_lpdf' for more comprehensive documentation + * As the CDF goes to the probability to hit the upper bound + * (instead of 1, as it is usually the case) when the reaction time + * goes to infinity, the CCDF is defined as + * ccdf = probability_to_hit_the_upper_bound - cdf. + * + * @tparam T_y type of reaction time + * @tparam T_a type of boundary separation + * @tparam T_t0 type of non-decision time + * @tparam T_w type of relative starting point + * @tparam T_v type of drift rate + * @tparam T_sv type of inter-trial variability of drift rate + * @tparam T_sw type of inter-trial variability of relative starting point + * @tparam T_st0 type of inter-trial variability of non-decision time + * + * @param y The reaction time in seconds + * @param a The boundary separation + * @param t0 The non-decision time + * @param w The relative starting point + * @param v The drift rate + * @param sv The inter-trial variability of the drift rate + * @param sw The inter-trial variability of the relative starting point + * @param st0 The inter-trial variability of the non-decision time + * @param precision_derivatives Level of precision in estimation of partial + * derivatives + * + * @return log probability or log sum of probabilities for upper + * boundary responses + * @throw std::domain_error if non-decision time \c t0 is greater than reaction + * time \c y. + * @throw std::domain_error if \c 1-sw/2 is smaller than or equal to \c w. + * @throw std::domain_error if \c sw/2 is larger than or equal to \c w. + */ + +template +inline auto wiener_lccdf(const T_y& y, const T_a& a, const T_t0& t0, + const T_w& w, const T_v& v, const T_sv& sv, + const T_sw& sw, const T_st0& st0, + const double& precision_derivatives = 1e-8) { + using ret_t = return_type_t; + using T_y_ref = ref_type_if_t::value, T_y>; + using T_a_ref = ref_type_if_t::value, T_a>; + using T_v_ref = ref_type_if_t::value, T_v>; + using T_w_ref = ref_type_if_t::value, T_w>; + using T_t0_ref = ref_type_if_t::value, T_t0>; + using T_sv_ref = ref_type_if_t::value, T_sv>; + using T_sw_ref = ref_type_if_t::value, T_sw>; + using T_st0_ref = ref_type_if_t::value, T_st0>; + using internal::GradientCalc; + using T_partials_return + = partials_return_t; + + T_y_ref y_ref = y; + T_a_ref a_ref = a; + T_v_ref v_ref = v; + T_w_ref w_ref = w; + T_t0_ref t0_ref = t0; + T_sv_ref sv_ref = sv; + T_sw_ref sw_ref = sw; + T_st0_ref st0_ref = st0; + + decltype(auto) y_val = to_ref(as_value_column_array_or_scalar(y_ref)); + decltype(auto) a_val = to_ref(as_value_column_array_or_scalar(a_ref)); + decltype(auto) v_val = to_ref(as_value_column_array_or_scalar(v_ref)); + decltype(auto) w_val = to_ref(as_value_column_array_or_scalar(w_ref)); + decltype(auto) t0_val = to_ref(as_value_column_array_or_scalar(t0_ref)); + decltype(auto) sv_val = to_ref(as_value_column_array_or_scalar(sv_ref)); + decltype(auto) sw_val = to_ref(as_value_column_array_or_scalar(sw_ref)); + decltype(auto) st0_val = to_ref(as_value_column_array_or_scalar(st0_ref)); + + if (!include_summand::value) { + return ret_t(0.0); + } + + static constexpr const char* function_name = "wiener_lccdf"; + check_consistent_sizes(function_name, "Random variable", y, + "Boundary separation", a, "Drift rate", v, + "A-priori bias", w, "Nondecision time", t0, + "Inter-trial variability in drift rate", sv, + "Inter-trial variability in A-priori bias", sw, + "Inter-trial variability in Nondecision time", st0); + check_positive_finite(function_name, "Random variable", y_val); + check_positive_finite(function_name, "Boundary separation", a_val); + check_finite(function_name, "Drift rate", v_val); + check_less(function_name, "A-priori bias", w_val, 1); + check_greater(function_name, "A-priori bias", w_val, 0); + check_nonnegative(function_name, "Nondecision time", t0_val); + check_finite(function_name, "Nondecision time", t0_val); + check_nonnegative(function_name, "Inter-trial variability in drift rate", + sv_val); + check_finite(function_name, "Inter-trial variability in drift rate", sv_val); + check_bounded(function_name, "Inter-trial variability in A-priori bias", + sw_val, 0, 1); + check_nonnegative(function_name, + "Inter-trial variability in Nondecision time", st0_val); + check_finite(function_name, "Inter-trial variability in Nondecision time", + st0_val); + + const size_t N = max_size(y, a, v, w, t0, sv, sw, st0); + if (!N) { + return ret_t(0.0); + } + scalar_seq_view y_vec(y_ref); + scalar_seq_view a_vec(a_ref); + scalar_seq_view v_vec(v_ref); + scalar_seq_view w_vec(w_ref); + scalar_seq_view t0_vec(t0_ref); + scalar_seq_view sv_vec(sv_ref); + scalar_seq_view sw_vec(sw_ref); + scalar_seq_view st0_vec(st0_ref); + const size_t N_y_t0 = max_size(y, t0, st0); + + for (size_t i = 0; i < N_y_t0; ++i) { + if (y_vec[i] <= t0_vec[i]) { + std::stringstream msg; + msg << ", but must be greater than nondecision time = " << t0_vec[i]; + std::string msg_str(msg.str()); + throw_domain_error(function_name, "Random variable", y_vec[i], " = ", + msg_str.c_str()); + } + } + size_t N_beta_sw = max_size(w, sw); + for (size_t i = 0; i < N_beta_sw; ++i) { + if (unlikely(w_vec[i] - .5 * sw_vec[i] <= 0)) { + std::stringstream msg; + msg << ", but must be smaller than 2*(A-priori bias) = " + << 2.0 * w_vec[i]; + std::string msg_str(msg.str()); + throw_domain_error(function_name, + "Inter-trial variability in A-priori bias", sw_vec[i], + " = ", msg_str.c_str()); + } + if (unlikely(w_vec[i] + .5 * sw_vec[i] >= 1)) { + std::stringstream msg; + msg << ", but must be smaller than 2*(1-A-priori bias) = " + << 2.0 * (1.0 - w_vec[i]); + std::string msg_str(msg.str()); + throw_domain_error(function_name, + "Inter-trial variability in A-priori bias", sw_vec[i], + " = ", msg_str.c_str()); + } + } + + // for precs. 1e-6, 1e-12, see Hartmann et al. (2021), Henrich et al. (2023) + const T_partials_return log_error_cdf = log(1e-6); // precision for density + const auto error_bound = precision_derivatives; // precision for + // derivatives (controllable by user) + const auto log_error_derivatives = log(error_bound); + const T_partials_return absolute_error_hcubature = 0.0; + const T_partials_return relative_error_hcubature + = .9 * error_bound; // eps_rel(Integration) + const T_partials_return log_error_absolute = log(1e-12); + const int maximal_evaluations_hcubature = 6000; + T_partials_return lccdf = 0.0; + auto ops_partials = make_partials_propagator(y_ref, a_ref, t0_ref, w_ref, + v_ref, sv_ref, sw_ref, st0_ref); + ret_t result = 0.0; + + // calculate density and partials + for (size_t i = 0; i < N; i++) { + if (sv_vec[i] == 0 && sw_vec[i] == 0 && st0_vec[i] == 0) { + result += wiener_lccdf(y_vec[i], a_vec[i], t0_vec[i], w_vec[i], + v_vec[i], precision_derivatives); + continue; + } + const T_partials_return y_value = y_vec.val(i); + const T_partials_return a_value = a_vec.val(i); + const T_partials_return v_value = v_vec.val(i); + const T_partials_return w_value = w_vec.val(i); + const T_partials_return t0_value = t0_vec.val(i); + const T_partials_return sv_value = sv_vec.val(i); + const T_partials_return sw_value = sw_vec.val(i); + const T_partials_return st0_value = st0_vec.val(i); + const int dim = (sv_value != 0) + (sw_value != 0) + (st0_value != 0); + check_positive(function_name, + "(Inter-trial variability in drift rate) + " + "(Inter-trial variability in A-priori bias) + " + "(Inter-trial variability in nondecision time)", + dim); + + Eigen::Matrix xmin = Eigen::VectorXd::Zero(dim); + Eigen::Matrix xmax = Eigen::VectorXd::Ones(dim); + for (int i = 0; i < dim; i++) { + xmin[i] = 0; + xmax[i] = 1; + } + if (sv_value != 0) { + xmin[0] = -1; + xmax[0] = 1; + } + if (st0_value != 0) { + xmax[dim - 1] = fmin(1.0, (y_value - t0_value) / st0_value); + } + + T_partials_return hcubature_err + = log_error_absolute - log_error_cdf + LOG_TWO + 1; + + const auto params = std::make_tuple(y_value, a_value, v_value, w_value, + t0_value, sv_value, sw_value, st0_value, + log_error_absolute - LOG_TWO); + + const T_partials_return ccdf + = internal::wiener7_integrate_cdf( + [&](auto&&... args) { return internal::wiener4_ccdf(args...); }, + hcubature_err, params, dim, xmin, xmax, + maximal_evaluations_hcubature, absolute_error_hcubature, + relative_error_hcubature / 2); + lccdf += log(ccdf); + + hcubature_err = log_error_absolute - log_error_derivatives + log(fabs(ccdf)) + + LOG_TWO + 1; + + // computation of derivative for t and precision check in order to give + // the value as deriv_t to edge1 and as -deriv_t to edge5 + const auto params_dt7 = std::make_tuple( + y_value, a_value, v_value, w_value, t0_value, sv_value, sw_value, + st0_value, log_error_absolute - LOG_TWO - 9 * LOG_TWO); + // computation of derivatives and precision checks + if (!is_constant_all::value || !is_constant_all::value) { + const T_partials_return deriv_t_7 + = -internal::wiener7_integrate_cdf< + GradientCalc::OFF, GradientCalc::OFF, GradientCalc::OFF, + GradientCalc::OFF, GradientCalc::ON>( + [&](auto&&... args) { + return internal::wiener5_density(args...); + }, + hcubature_err, params, dim, xmin, xmax, + maximal_evaluations_hcubature, absolute_error_hcubature, + relative_error_hcubature / 2) + / ccdf; + if (!is_constant_all::value) { + partials<0>(ops_partials)[i] = deriv_t_7; + } + if (!is_constant_all::value) { + partials<2>(ops_partials)[i] = -deriv_t_7; + } + } + T_partials_return deriv; + if (!is_constant_all::value) { + partials<1>(ops_partials)[i] + = internal::wiener7_integrate_cdf( + [&](auto&&... args) { + return internal::wiener4_ccdf_grad_a(args...); + }, + hcubature_err, params, dim, xmin, xmax, + maximal_evaluations_hcubature, absolute_error_hcubature, + relative_error_hcubature / 2) + / ccdf; + } + if (!is_constant_all::value) { + partials<3>(ops_partials)[i] + = internal::wiener7_integrate_cdf( + [&](auto&&... args) { + return internal::wiener4_ccdf_grad_w(args...); + }, + hcubature_err, params, dim, xmin, xmax, + maximal_evaluations_hcubature, absolute_error_hcubature, + relative_error_hcubature / 2) + / ccdf; + } + if (!is_constant_all::value) { + partials<4>(ops_partials)[i] + = internal::wiener7_integrate_cdf( + [&](auto&&... args) { + return internal::wiener4_ccdf_grad_v(args...); + }, + hcubature_err, params, dim, xmin, xmax, + maximal_evaluations_hcubature, absolute_error_hcubature, + relative_error_hcubature / 2) + / ccdf; + } + if (!is_constant_all::value) { + if (sv_value == 0) { + partials<5>(ops_partials)[i] = 0.0; + } else { + partials<5>(ops_partials)[i] + = internal::wiener7_integrate_cdf< + GradientCalc::OFF, GradientCalc::OFF, GradientCalc::ON>( + [&](auto&&... args) { + return internal::wiener4_ccdf_grad_v(args...); + }, + hcubature_err, params, dim, xmin, xmax, + maximal_evaluations_hcubature, absolute_error_hcubature, + relative_error_hcubature / 2) + / ccdf; + } + } + if (!is_constant_all::value) { + if (sw_value == 0) { + partials<6>(ops_partials)[i] = 0.0; + } else { + if (st0_value == 0 && sv_value == 0) { + deriv = internal::estimate_with_err_check<5, 0, GradientCalc::OFF, + GradientCalc::ON>( + [](auto&&... args) { + return internal::wiener7_ccdf_grad_sw(args...); + }, + hcubature_err, y_value - t0_value, a_value, v_value, w_value, + sw_value, log_error_absolute - LOG_TWO); + deriv = deriv / ccdf - 1 / sw_value; + } else { + deriv = internal::wiener7_integrate_cdf< + GradientCalc::OFF, GradientCalc::OFF, GradientCalc::OFF, + GradientCalc::ON>( + [&](auto&&... args) { + return internal::wiener4_ccdf_grad_w(args...); + }, + hcubature_err, params, dim, xmin, xmax, + maximal_evaluations_hcubature, absolute_error_hcubature, + relative_error_hcubature / 2) + / ccdf; + } + partials<6>(ops_partials)[i] = deriv; + } + } + if (!is_constant_all::value) { + if (st0_value == 0) { + partials<7>(ops_partials)[i] = 0.0; + } else if (y_value - (t0_value + st0_value) <= 0) { + partials<7>(ops_partials)[i] = -1 / st0_value; + } else { + const auto t0_st0 = t0_value + st0_value; + if (sw_value == 0 && sv_value == 0) { + deriv = internal::estimate_with_err_check<4, 0>( + [](auto&&... args) { return internal::wiener4_ccdf(args...); }, + log_error_derivatives + log(st0_value), y_value - t0_st0, a_value, + v_value, w_value, log_error_absolute - LOG_TWO); + deriv = deriv / st0_value / ccdf - 1 / st0_value; + } else { + const int dim_st = (sv_value != 0) + (sw_value != 0); + const auto new_error = log_error_absolute - LOG_TWO; + const auto& params_st + = std::make_tuple(y_value, a_value, v_value, w_value, t0_st0, + sv_value, sw_value, 0.0, new_error); + deriv = internal::wiener7_integrate_cdf< + GradientCalc::OFF, GradientCalc::OFF, GradientCalc::OFF, + GradientCalc::OFF, GradientCalc::OFF, GradientCalc::OFF>( + [&](auto&&... args) { return internal::wiener4_ccdf(args...); }, + hcubature_err, params_st, dim_st, xmin, xmax, + maximal_evaluations_hcubature, absolute_error_hcubature, + relative_error_hcubature / 2); + deriv = deriv / st0_value / ccdf - 1 / st0_value; + } + partials<7>(ops_partials)[i] = deriv; + } + } + } + return result + ops_partials.build(lccdf); +} +} // namespace math +} // namespace stan +#endif diff --git a/stan/math/prim/prob/wiener_full_lcdf.hpp b/stan/math/prim/prob/wiener_full_lcdf.hpp new file mode 100644 index 00000000000..3b8f0d7738c --- /dev/null +++ b/stan/math/prim/prob/wiener_full_lcdf.hpp @@ -0,0 +1,601 @@ +#ifndef STAN_MATH_PRIM_PROB_WIENER_FULL_LCDF_HPP +#define STAN_MATH_PRIM_PROB_WIENER_FULL_LCDF_HPP + +#include +#include + +namespace stan { +namespace math { +namespace internal { + +/** + * Calculate the derivative of the wiener7 density w.r.t. 'sw' + * + * @tparam T_y type of reaction time + * @tparam T_a type of boundary separation + * @tparam T_v type of drift rate + * @tparam T_w type of relative starting point + * @tparam T_sv type of inter-trial variability in v + * @tparam T_err type of log error tolerance + * + * @param y The reaction time in seconds + * @param a The boundary separation + * @param v The drift rate + * @param w The relative starting point + * @param sw The inter-trial variability of the relative starting point + * @param wildcard This parameter space is needed for a functor. Could be + * deleted when another solution is found + * @param log_error The log error tolerance + * @return Gradient with respect to sw + */ +template +inline auto wiener7_cdf_grad_sw(const T_y& y, const T_a& a, const T_v& v, + const T_w& w, const T_sw& sw, + T_err&& log_error) { + auto low = w - sw / 2.0; + low = (0 > low) ? 0 : low; + auto high = w + sw / 2.0; + high = (1 < high) ? 1 : high; + const auto lower_value + = wiener4_distribution(y, a, v, low, log_error); + const auto upper_value + = wiener4_distribution(y, a, v, high, log_error); + return 0.5 * (lower_value + upper_value) / sw; +} + +/** + * Helper function for agnostically calling wiener4 functions + * (to be integrated over) or directly calling wiener7 functions, + * accounting for the different number of arguments. + * + * Specialisation for wiener4 functions + * + * @tparam GradSW Whether the gradient of sw is computed + * @tparam F Type of Gradient/density functor + * @tparam T_y type of reaction time + * @tparam T_a type of boundary separation + * @tparam T_v type of drift rate + * @tparam T_w type of relative starting point + * @tparam T_sv type of inter-trial variability in v + * @tparam T_sw type of inter-trial variability in w + * @tparam T_err type of log error tolerance + * + * @param functor Gradient/density functor to apply + * @param y_diff A scalar variable; the reaction time in seconds without + * non-decision time + * @param a The boundary separation + * @param v The drift rate + * @param w The relative starting point + * @param sv The inter-trial variability of the drift rate + * @param sw The inter-trial variability of the relative starting point + * @param log_error The log error tolerance + * @return Functor applied to arguments + */ +template * = nullptr> +inline auto conditionally_grad_sw_cdf(F&& functor, T_y&& y_diff, T_a&& a, + T_v&& v, T_w&& w, T_sv&& sv, T_sw&& sw, + T_err&& log_error) { + return functor(y_diff, a, v, w, log_error); +} + +/** + * Helper function for agnostically calling wiener4 functions + * (to be integrated over) or directly calling wiener7 functions, + * accounting for the different number of arguments. + * + * Specialisation for wiener7 functions + * + * @tparam GradSW Whether the gradient of sw is computed + * @tparam F Type of Gradient/density functor + * @tparam T_y type of reaction time + * @tparam T_a type of boundary separation + * @tparam T_v type of drift rate + * @tparam T_w type of relative starting point + * @tparam T_sv type of inter-trial variability in v + * @tparam T_sw type of inter-trial variability in w + * @tparam T_err type of log error tolerance + * + * @param functor Gradient/density functor to apply + * @param y_diff A scalar variable; the reaction time in seconds without + * non-decision time + * @param a The boundary separation + * @param v The drift rate + * @param w The relative starting point + * @param sv The inter-trial variability of the drift rate + * @param sw The inter-trial variability of the relative starting point + * @param log_error The log error tolerance + * @return Functor applied to arguments + */ +template * = nullptr> +inline auto conditionally_grad_sw_cdf(F&& functor, T_y&& y_diff, T_a&& a, + T_v&& v, T_w&& w, T_sv&& sv, T_sw&& sw, + T_err&& log_error) { + return functor(y_diff, a, v, w, sv, log_error); +} + +/** + * Implementation function for preparing arguments and functor to be passed + * to the hcubature() function for calculating wiener7 parameters via + * integration + * + * @tparam GradSW Whether the wiener7 gradient function is passed + * @tparam Wiener7FunctorT Type of functor + * @tparam Targs... Types of arguments in parameter pack + * + * @param wiener7_functor Gradient/density functor to apply + * @param hcubature_err Error tolerance for calculation + * @param args Additional arguments to be passed to the hcubature function + * @return Wiener7 density or gradient calculated by integration + */ +template +inline auto wiener7_integrate_cdf(const Wiener7FunctorT& wiener7_functor, + T_err&& hcubature_err, TArgs&&... args) { + const auto functor = [&wiener7_functor](auto&&... integration_args) { + return hcubature( + [&wiener7_functor](auto&& x, auto&& y, auto&& a, auto&& v, auto&& w, + auto&& t0, auto&& sv, auto&& sw, auto&& st0, + auto&& lerr) { + using ret_t + = return_type_t; + scalar_seq_view x_vec(x); + const auto temp = (sv != 0) ? square(x_vec[0]) : 0; + const auto factor = (sv != 0) ? x_vec[0] / (1 - temp) : 0; + const auto new_v = (sv != 0) ? v + sv * factor : v; + const auto new_w = (sv != 0) + ? ((sw != 0) ? w + sw * (x_vec[1] - 0.5) : w) + : ((sw != 0) ? w + sw * (x_vec[0] - 0.5) : w); + const auto new_t0 + = (sv != 0) + ? ((sw != 0) ? ((st0 != 0) ? t0 + st0 * x_vec[2] : t0) + : ((st0 != 0) ? t0 + st0 * x_vec[1] : t0)) + : ((sw != 0) ? ((st0 != 0) ? t0 + st0 * x_vec[1] : t0) + : ((st0 != 0) ? t0 + st0 * x_vec[0] : t0)); + if (y - new_t0 <= 0) { + return ret_t(0.0); + } else { + const auto dist = GradT ? 0 + : wiener4_distribution( + y - new_t0, a, new_v, new_w, lerr); + const auto temp2 = (sv != 0) ? -0.5 * square(factor) - LOG_SQRT_PI + - 0.5 * LOG_TWO + log1p(temp) + - 2.0 * log1m(temp) + : 0; + const auto factor_sv = GradSV ? factor : 1; + const auto factor_sw + = GradSW ? ((sv != 0) ? (x_vec[1] - 0.5) : (x_vec[0] - 0.5)) + : 1; + const auto integrand + = Distribution ? dist + : GradT ? conditionally_grad_sw_cdf< + Conditionally_cdf>( // deleted internal:: + wiener7_functor, y - new_t0, a, v, new_w, + sv, sw, lerr) + : factor_sv * factor_sw + * conditionally_grad_sw_cdf< + Conditionally_cdf>( + wiener7_functor, y - new_t0, a, + new_v, new_w, dist, sw, lerr); + return ret_t(integrand * exp(temp2)); + } + }, + integration_args...); + }; + + return estimate_with_err_check<0, 8, GradW7, GradientCalc::ON>( + functor, hcubature_err, args...); +} +} // namespace internal + +/** \ingroup prob_dists + * Returns the log CDF of the Wiener distribution for a + * (Wiener) drift diffusion model with up to 7 parameters. If containers + * are supplied, returns the log sum of the probabilities. + * See 'wiener_lpdf' for more comprehensive documentation + * If the reaction time goes to infinity, the CDF goes to the probability to + * hit the upper bound (instead of 1, as it is usually the case) + * + * @tparam T_y type of reaction time + * @tparam T_a type of boundary separation + * @tparam T_t0 type of non-decision time + * @tparam T_w type of relative starting point + * @tparam T_v type of drift rate + * @tparam T_sv type of inter-trial variability of drift rate + * @tparam T_sw type of inter-trial variability of relative starting point + * @tparam T_st0 type of inter-trial variability of non-decision time + * + * @param y The reaction time in seconds + * @param a The boundary separation + * @param t0 The non-decision time + * @param w The relative starting point + * @param v The drift rate + * @param sv The inter-trial variability of the drift rate + * @param sw The inter-trial variability of the relative starting point + * @param st0 The inter-trial variability of the non-decision time + * @param precision_derivatives Level of precision in estimation of partial + * derivatives + * + * @return log probability or log sum of probabilities for upper + * boundary responses + * @throw std::domain_error if non-decision time \c t0 is greater than reaction + * time \c y. + * @throw std::domain_error if \c 1-sw/2 is smaller than or equal to \c w. + * @throw std::domain_error if \c sw/2 is larger than or equal to \c w. + + + **References** + * - Blurton, S. P., Kesselmeier, M., & Gondan, M. (2017). The first-passage + * time distribution for the diffusion model with variable drift. + * *Journal of Mathematical Psychology, 76*, 7–12. + * https://doi.org/10.1016/j.jmp.2016.11.003 + * - Foster, K., & Singmann, H. (2021). Another Approximation of the + * First-Passage + * Time Densities for the Ratcliff Diffusion Decision Model. + * *arXiv preprint arXiv:2104.01902* + * - Gondan, M., Blurton, S. P., & Kesselmeier, M. (2014). Even faster and even + * more accurate first-passage time densities and distributions for the Wiener + * diffusion model. *Journal of Mathematical Psychology, 60*, 20–22. + * https://doi.org/10.1016/j.jmp.2014.05.002 + * - Hartmann, R., & Klauer, K. C. (2021). Partial derivatives for the + * first-passage time distribution in Wiener diffusion models. + * *Journal of Mathematical Psychology, 103*, 102550. + * https://doi.org/10.1016/j.jmp.2021.102550 + * - Henrich, F., Hartmann, R., Pratz, V., Voss, A., & Klauer, K.C. (2023). + * The Seven-parameter Diffusion Model: An Implementation in Stan for Bayesian + * Analyses. *Behavior Research Methods*. + * https://doi.org/10.3758/s13428-023-02179-1 + * - Henrich, F., & Klauer, K. C. (in press). Modeling Truncated and Censored + * Data With the Diffusion Model in Stan. *Behavior Research Methods*. + * - Linhart, J. M. (2008). Algorithm 885: Computing the Logarithm of the + * Normal Distribution. *ACM Transactions on Mathematical Software*. + * http://doi.acm.org/10.1145/1391989.1391993 + * - Navarro, D. J., & Fuss, I. G. (2009). Fast and accurate calculations for + * first-passage times in Wiener diffusion models. + * *Journal of Mathematical Psychology, 53*(4), 222–230. + * https://doi.org/10.1016/j.jmp.2009.02.003 + */ +template +inline auto wiener_lcdf(const T_y& y, const T_a& a, const T_t0& t0, + const T_w& w, const T_v& v, const T_sv& sv, + const T_sw& sw, const T_st0& st0, + const double& precision_derivatives = 1e-8) { + using ret_t = return_type_t; + using T_y_ref = ref_type_if_t::value, T_y>; + using T_a_ref = ref_type_if_t::value, T_a>; + using T_v_ref = ref_type_if_t::value, T_v>; + using T_w_ref = ref_type_if_t::value, T_w>; + using T_t0_ref = ref_type_if_t::value, T_t0>; + using T_sv_ref = ref_type_if_t::value, T_sv>; + using T_sw_ref = ref_type_if_t::value, T_sw>; + using T_st0_ref = ref_type_if_t::value, T_st0>; + using internal::GradientCalc; + using T_partials_return + = partials_return_t; + + T_y_ref y_ref = y; + T_a_ref a_ref = a; + T_v_ref v_ref = v; + T_w_ref w_ref = w; + T_t0_ref t0_ref = t0; + T_sv_ref sv_ref = sv; + T_sw_ref sw_ref = sw; + T_st0_ref st0_ref = st0; + + decltype(auto) y_val = to_ref(as_value_column_array_or_scalar(y_ref)); + decltype(auto) a_val = to_ref(as_value_column_array_or_scalar(a_ref)); + decltype(auto) v_val = to_ref(as_value_column_array_or_scalar(v_ref)); + decltype(auto) w_val = to_ref(as_value_column_array_or_scalar(w_ref)); + decltype(auto) t0_val = to_ref(as_value_column_array_or_scalar(t0_ref)); + decltype(auto) sv_val = to_ref(as_value_column_array_or_scalar(sv_ref)); + decltype(auto) sw_val = to_ref(as_value_column_array_or_scalar(sw_ref)); + decltype(auto) st0_val = to_ref(as_value_column_array_or_scalar(st0_ref)); + + if (!include_summand::value) { + return ret_t(0); + } + + static constexpr const char* function_name = "wiener_lcdf"; + check_consistent_sizes(function_name, "Random variable", y, + "Boundary separation", a, "Drift rate", v, + "A-priori bias", w, "Nondecision time", t0, + "Inter-trial variability in drift rate", sv, + "Inter-trial variability in A-priori bias", sw, + "Inter-trial variability in Nondecision time", st0); + check_positive_finite(function_name, "Random variable", y_val); + check_positive_finite(function_name, "Boundary separation", a_val); + check_finite(function_name, "Drift rate", v_val); + check_less(function_name, "A-priori bias", w_val, 1); + check_greater(function_name, "A-priori bias", w_val, 0); + check_nonnegative(function_name, "Nondecision time", t0_val); + check_finite(function_name, "Nondecision time", t0_val); + check_nonnegative(function_name, "Inter-trial variability in drift rate", + sv_val); + check_finite(function_name, "Inter-trial variability in drift rate", sv_val); + check_bounded(function_name, "Inter-trial variability in A-priori bias", + sw_val, 0, 1); + check_nonnegative(function_name, + "Inter-trial variability in Nondecision time", st0_val); + check_finite(function_name, "Inter-trial variability in Nondecision time", + st0_val); + + const size_t N = max_size(y, a, v, w, t0, sv, sw, st0); + if (!N) { + return ret_t(0); + } + scalar_seq_view y_vec(y_ref); + scalar_seq_view a_vec(a_ref); + scalar_seq_view v_vec(v_ref); + scalar_seq_view w_vec(w_ref); + scalar_seq_view t0_vec(t0_ref); + scalar_seq_view sv_vec(sv_ref); + scalar_seq_view sw_vec(sw_ref); + scalar_seq_view st0_vec(st0_ref); + const size_t N_y_t0 = max_size(y, t0, st0); + + for (size_t i = 0; i < N_y_t0; ++i) { + if (y_vec[i] <= t0_vec[i]) { + std::stringstream msg; + msg << ", but must be greater than nondecision time = " << t0_vec[i]; + std::string msg_str(msg.str()); + throw_domain_error(function_name, "Random variable", y_vec[i], " = ", + msg_str.c_str()); + } + } + size_t N_beta_sw = max_size(w, sw); + for (size_t i = 0; i < N_beta_sw; ++i) { + if (unlikely(w_vec[i] - .5 * sw_vec[i] <= 0)) { + std::stringstream msg; + msg << ", but must be smaller than 2*(A-priori bias) = " + << 2.0 * w_vec[i]; + std::string msg_str(msg.str()); + throw_domain_error(function_name, + "Inter-trial variability in A-priori bias", sw_vec[i], + " = ", msg_str.c_str()); + } + if (unlikely(w_vec[i] + .5 * sw_vec[i] >= 1)) { + std::stringstream msg; + msg << ", but must be smaller than 2*(1-A-priori bias) = " + << 2 * (1 - w_vec[i]); + std::string msg_str(msg.str()); + throw_domain_error(function_name, + "Inter-trial variability in A-priori bias", sw_vec[i], + " = ", msg_str.c_str()); + } + } + + // for precs. 1e-6, 1e-12, see Hartmann et al. (2021), Henrich et al. (2023) + const T_partials_return log_error_cdf = log(1e-6); // precision for density + const auto error_bound = precision_derivatives; // precision for + // derivatives (controllable by user) + const auto lerror_bound = log(error_bound); + const T_partials_return absolute_error_hcubature = 0.0; + const T_partials_return relative_error_hcubature + = .9 * error_bound; // eps_rel(Integration) + const T_partials_return log_error_absolute = log(1e-12); + const int maximal_evaluations_hcubature = 6000; + T_partials_return lcdf = 0.0; + auto ops_partials = make_partials_propagator(y_ref, a_ref, t0_ref, w_ref, + v_ref, sv_ref, sw_ref, st0_ref); + ret_t result = 0.0; + + // calculate density and partials + for (size_t i = 0; i < N; i++) { + if (sv_vec[i] == 0 && sw_vec[i] == 0 && st0_vec[i] == 0) { + result += wiener_lcdf(y_vec[i], a_vec[i], t0_vec[i], w_vec[i], + v_vec[i], precision_derivatives); + continue; + } + const T_partials_return y_value = y_vec.val(i); + const T_partials_return a_value = a_vec.val(i); + const T_partials_return v_value = v_vec.val(i); + const T_partials_return w_value = w_vec.val(i); + const T_partials_return t0_value = t0_vec.val(i); + const T_partials_return sv_value = sv_vec.val(i); + const T_partials_return sw_value = sw_vec.val(i); + const T_partials_return st0_value = st0_vec.val(i); + const int dim = (sv_value != 0) + (sw_value != 0) + (st0_value != 0); + check_positive(function_name, + "(Inter-trial variability in drift rate) + " + "(Inter-trial variability in A-priori bias) + " + "(Inter-trial variability in nondecision time)", + dim); + + Eigen::Matrix xmin = Eigen::VectorXd::Zero(dim); + Eigen::Matrix xmax = Eigen::VectorXd::Ones(dim); + for (int i = 0; i < dim; i++) { + xmin[i] = 0; + xmax[i] = 1; + } + if (sv_value != 0) { + xmin[0] = -1; + xmax[0] = 1; + } + if (st0_value != 0) { + xmax[dim - 1] = fmin(1.0, (y_value - t0_value) / st0_value); + } + + T_partials_return hcubature_err + = log_error_absolute - log_error_cdf + LOG_TWO + 1; + + const auto params = std::make_tuple(y_value, a_value, v_value, w_value, + t0_value, sv_value, sw_value, st0_value, + log_error_absolute - LOG_TWO); + + const T_partials_return cdf + = internal::wiener7_integrate_cdf( + [&](auto&&... args) { + return internal::wiener4_distribution(args...); + }, + hcubature_err, params, dim, xmin, xmax, + maximal_evaluations_hcubature, absolute_error_hcubature, + relative_error_hcubature / 2); + lcdf += log(cdf); + + hcubature_err + = log_error_absolute - lerror_bound + log(fabs(cdf)) + LOG_TWO + 1; + + // computation of derivatives and precision checks + // computation of derivative for t and precision check in order to give + // the value as deriv_t to edge1 and as -deriv_t to edge5 + const auto params_dt7 = std::make_tuple( + y_value, a_value, v_value, w_value, t0_value, sv_value, sw_value, + st0_value, log_error_absolute - LOG_TWO - 9 * LOG_TWO); + if (!is_constant_all::value || !is_constant_all::value) { + T_partials_return deriv_t_7 + = internal::wiener7_integrate_cdf< + GradientCalc::OFF, GradientCalc::OFF, GradientCalc::OFF, + GradientCalc::OFF, GradientCalc::ON>( + [&](auto&&... args) { + return internal::wiener5_density(args...); + }, + hcubature_err, params, dim, xmin, xmax, + maximal_evaluations_hcubature, absolute_error_hcubature, + relative_error_hcubature / 2) + / cdf; + if (!is_constant_all::value) { + partials<0>(ops_partials)[i] = deriv_t_7; + } + if (!is_constant_all::value) { + partials<2>(ops_partials)[i] = -deriv_t_7; + } + } + T_partials_return deriv; + if (!is_constant_all::value) { + partials<1>(ops_partials)[i] + = internal::wiener7_integrate_cdf( + [&](auto&&... args) { + return internal::wiener4_cdf_grad_a(args...); + }, + hcubature_err, params, dim, xmin, xmax, + maximal_evaluations_hcubature, absolute_error_hcubature, + relative_error_hcubature / 2) + / cdf; + } + if (!is_constant_all::value) { + partials<3>(ops_partials)[i] + = internal::wiener7_integrate_cdf( + [&](auto&&... args) { + return internal::wiener4_cdf_grad_w(args...); + }, + hcubature_err, params, dim, xmin, xmax, + maximal_evaluations_hcubature, absolute_error_hcubature, + relative_error_hcubature / 2) + / cdf; + } + if (!is_constant_all::value) { + partials<4>(ops_partials)[i] + = internal::wiener7_integrate_cdf( + [&](auto&&... args) { + return internal::wiener4_cdf_grad_v(args...); + }, + hcubature_err, params, dim, xmin, xmax, + maximal_evaluations_hcubature, absolute_error_hcubature, + relative_error_hcubature / 2) + / cdf; + } + if (!is_constant_all::value) { + if (sv_value == 0) { + partials<5>(ops_partials)[i] = 0; + } else { + partials<5>(ops_partials)[i] + = internal::wiener7_integrate_cdf< + GradientCalc::OFF, GradientCalc::OFF, GradientCalc::ON>( + [&](auto&&... args) { + return internal::wiener4_cdf_grad_v(args...); + }, + hcubature_err, params, dim, xmin, xmax, + maximal_evaluations_hcubature, absolute_error_hcubature, + relative_error_hcubature / 2) + / cdf; + } + } + if (!is_constant_all::value) { + if (sw_value == 0) { + partials<6>(ops_partials)[i] = 0; + } else { + if (st0_value == 0 && sv_value == 0) { + deriv = internal::estimate_with_err_check<5, 0, GradientCalc::OFF, + GradientCalc::ON>( + [](auto&&... args) { + return internal::wiener7_cdf_grad_sw(args...); + }, + hcubature_err, y_value - t0_value, a_value, v_value, w_value, + sw_value, log_error_absolute - LOG_TWO); + deriv = deriv / cdf - 1 / sw_value; + } else { + deriv = internal::wiener7_integrate_cdf< + GradientCalc::OFF, GradientCalc::OFF, GradientCalc::OFF, + GradientCalc::ON>( + [&](auto&&... args) { + return internal::wiener4_cdf_grad_w(args...); + }, + hcubature_err, params, dim, xmin, xmax, + maximal_evaluations_hcubature, absolute_error_hcubature, + relative_error_hcubature / 2) + / cdf; + } + partials<6>(ops_partials)[i] = deriv; + } + } + if (!is_constant_all::value) { + if (st0_value == 0) { + partials<7>(ops_partials)[i] = 0; + } else if (y_value - (t0_value + st0_value) <= 0) { + partials<7>(ops_partials)[i] = -1 / st0_value; + } else { + const T_partials_return t0_st0 = t0_value + st0_value; + if (sw_value == 0 && sv_value == 0) { + deriv = internal::estimate_with_err_check<4, 0, GradientCalc::OFF, + GradientCalc::ON>( + [](auto&&... args) { + return internal::wiener4_distribution( + args...); + }, + lerror_bound + log(st0_value), y_value - t0_st0, a_value, v_value, + w_value, log_error_absolute - LOG_TWO); + deriv = deriv / st0_value / cdf - 1 / st0_value; + } else { + const int dim_st = (sv_value != 0) + (sw_value != 0); + const T_partials_return new_error = log_error_absolute - LOG_TWO; + const auto& params_st + = std::make_tuple(y_value, a_value, v_value, w_value, t0_st0, + sv_value, sw_value, 0, new_error); + deriv = internal::wiener7_integrate_cdf< + GradientCalc::OFF, GradientCalc::OFF, GradientCalc::OFF, + GradientCalc::OFF, GradientCalc::OFF, GradientCalc::OFF>( + [&](auto&&... args) { + return internal::wiener4_distribution( + args...); + }, + hcubature_err, params_st, dim_st, xmin, xmax, + maximal_evaluations_hcubature, absolute_error_hcubature, + relative_error_hcubature / 2); + deriv = deriv / st0_value / cdf - 1 / st0_value; + } + partials<7>(ops_partials)[i] = deriv; + } + } + } + return result + ops_partials.build(lcdf); +} +} // namespace math +} // namespace stan +#endif diff --git a/stan/math/prim/prob/wiener_full_lpdf.hpp b/stan/math/prim/prob/wiener_full_lpdf.hpp index 0097163650e..ba019c648db 100644 --- a/stan/math/prim/prob/wiener_full_lpdf.hpp +++ b/stan/math/prim/prob/wiener_full_lpdf.hpp @@ -12,7 +12,7 @@ namespace internal { /** * Calculate the derivative of the wiener7 density w.r.t. 'sw' * - * @tparam T_y type of scalar variable + * @tparam T_y type of reaction time * @tparam T_a type of boundary separation * @tparam T_v type of drift rate * @tparam T_w type of relative starting point @@ -20,14 +20,14 @@ namespace internal { * @tparam T_sw type of inter-trial variability in w * @tparam T_err type of log error tolerance * - * @param y A scalar variable; the reaction time in seconds + * @param y The reaction time in seconds * @param a The boundary separation * @param v The drift rate * @param w The relative starting point * @param sv The inter-trial variability of the drift rate * @param sw The inter-trial variability of the relative starting point * @param log_error The log error tolerance - * @return Gradient w.r.t. sw + * @return Gradient with respect to sw */ template @@ -52,7 +52,7 @@ inline auto wiener7_grad_sw(const T_y& y, const T_a& a, const T_v& v, * * @tparam GradSW Whether the gradient of sw is computed * @tparam F Type of Gradient/density functor - * @tparam T_y type of scalar variable + * @tparam T_y type of reaction time * @tparam T_a type of boundary separation * @tparam T_v type of drift rate * @tparam T_w type of relative starting point @@ -89,7 +89,7 @@ inline auto conditionally_grad_sw(F&& functor, T_y&& y_diff, T_a&& a, T_v&& v, * * @tparam GradSW Whether the gradient of sw is computed * @tparam F Type of Gradient/density functor - * @tparam T_y type of scalar variable + * @tparam T_y type of reaction time * @tparam T_a type of boundary separation * @tparam T_v type of drift rate * @tparam T_w type of relative starting point @@ -212,7 +212,7 @@ inline auto wiener7_integrate(const Wiener7FunctorT& wiener7_functor, * * See \b Details below for more details on how to use \c wiener_lpdf(). * - * @tparam T_y type of scalar + * @tparam T_y type of reaction time * @tparam T_a type of boundary separation * @tparam T_t0 type of non-decision time * @tparam T_w type of relative starting point @@ -221,7 +221,7 @@ inline auto wiener7_integrate(const Wiener7FunctorT& wiener7_functor, * @tparam T_sw type of inter-trial variability of relative starting point * @tparam T_st0 type of inter-trial variability of non-decision time * - * @param y A scalar variable; the reaction time in seconds + * @param y The reaction time in seconds * @param a The boundary separation * @param t0 The non-decision time * @param w The relative starting point @@ -322,11 +322,6 @@ inline auto wiener_lpdf(const T_y& y, const T_a& a, const T_t0& t0, const T_sw& sw, const T_st0& st0, const double& precision_derivatives = 1e-4) { using ret_t = return_type_t; - if (!include_summand::value) { - return ret_t(0); - } - using T_y_ref = ref_type_t; using T_a_ref = ref_type_t; using T_v_ref = ref_type_t; @@ -335,18 +330,10 @@ inline auto wiener_lpdf(const T_y& y, const T_a& a, const T_t0& t0, using T_sv_ref = ref_type_t; using T_sw_ref = ref_type_t; using T_st0_ref = ref_type_t; - + using internal::GradientCalc; using T_partials_return = partials_return_t; - static constexpr const char* function_name = "wiener_lpdf"; - check_consistent_sizes(function_name, "Random variable", y, - "Boundary separation", a, "Drift rate", v, - "A-priori bias", w, "Nondecision time", t0, - "Inter-trial variability in drift rate", sv, - "Inter-trial variability in A-priori bias", sw, - "Inter-trial variability in Nondecision time", st0); - T_y_ref y_ref = y; T_a_ref a_ref = a; T_v_ref v_ref = v; @@ -364,6 +351,19 @@ inline auto wiener_lpdf(const T_y& y, const T_a& a, const T_t0& t0, decltype(auto) sv_val = to_ref(as_value_column_array_or_scalar(sv_ref)); decltype(auto) sw_val = to_ref(as_value_column_array_or_scalar(sw_ref)); decltype(auto) st0_val = to_ref(as_value_column_array_or_scalar(st0_ref)); + + if (!include_summand::value) { + return ret_t(0); + } + + static constexpr const char* function_name = "wiener_lpdf"; + check_consistent_sizes(function_name, "Random variable", y, + "Boundary separation", a, "Drift rate", v, + "A-priori bias", w, "Nondecision time", t0, + "Inter-trial variability in drift rate", sv, + "Inter-trial variability in A-priori bias", sw, + "Inter-trial variability in Nondecision time", st0); check_positive_finite(function_name, "Random variable", y_val); check_positive_finite(function_name, "Boundary separation", a_val); check_finite(function_name, "Drift rate", v_val); @@ -412,7 +412,7 @@ inline auto wiener_lpdf(const T_y& y, const T_a& a, const T_t0& t0, [&]() STAN_COLD_PATH { std::stringstream msg; msg << ", but must be smaller than 2*(A-priori bias) = " - << 2 * w_vec[i]; + << 2.0 * w_vec[i]; std::string msg_str(msg.str()); throw_domain_error(function_name, "Inter-trial variability in A-priori bias", @@ -423,7 +423,7 @@ inline auto wiener_lpdf(const T_y& y, const T_a& a, const T_t0& t0, [&]() STAN_COLD_PATH { std::stringstream msg; msg << ", but must be smaller than 2*(1-A-priori bias) = " - << 2 * (1 - w_vec[i]); + << 2.0 * (1.0 - w_vec[i]); std::string msg_str(msg.str()); throw_domain_error(function_name, "Inter-trial variability in A-priori bias", @@ -431,6 +431,8 @@ inline auto wiener_lpdf(const T_y& y, const T_a& a, const T_t0& t0, }(); } } + + // for precs. 1e-6, 1e-12, see Hartmann et al. (2021), Henrich et al. (2023) // precision for density const T_partials_return log_error_density = log(1e-6); // precision for derivatives (controllable by user) @@ -478,7 +480,6 @@ inline auto wiener_lpdf(const T_y& y, const T_a& a, const T_t0& t0, T_partials_return hcubature_err = log_error_absolute - log_error_density + LOG_TWO + 1; - using internal::GradientCalc; const auto params = std::make_tuple(y_value, a_value, v_value, w_value, t0_value, sv_value, sw_value, st0_value, log_error_absolute - LOG_TWO); diff --git a/stan/math/prim/prob/wiener_lpdf.hpp b/stan/math/prim/prob/wiener_lpdf.hpp index 5c2f113a07e..05c785691cf 100644 --- a/stan/math/prim/prob/wiener_lpdf.hpp +++ b/stan/math/prim/prob/wiener_lpdf.hpp @@ -76,7 +76,7 @@ namespace math { */ template -inline return_type_t wiener_lpdf( +return_type_t wiener_lpdf( const T_y& y, const T_alpha& alpha, const T_tau& tau, const T_beta& beta, const T_delta& delta) { using T_return_type = return_type_t; diff --git a/stan/math/prim/prob/wishart_cholesky_lpdf.hpp b/stan/math/prim/prob/wishart_cholesky_lpdf.hpp index 794e45c67ac..8c2cf0107e7 100644 --- a/stan/math/prim/prob/wishart_cholesky_lpdf.hpp +++ b/stan/math/prim/prob/wishart_cholesky_lpdf.hpp @@ -39,8 +39,9 @@ namespace math { template * = nullptr, require_all_matrix_t* = nullptr> -inline return_type_t wishart_cholesky_lpdf( - const T_y& L_Y, const T_dof& nu, const T_scale& L_S) { +return_type_t wishart_cholesky_lpdf(const T_y& L_Y, + const T_dof& nu, + const T_scale& L_S) { using Eigen::Lower; using T_L_Y_ref = ref_type_t; using T_nu_ref = ref_type_t; diff --git a/stan/math/prim/prob/wishart_lpdf.hpp b/stan/math/prim/prob/wishart_lpdf.hpp index 4f37d579b99..145bf7552cd 100644 --- a/stan/math/prim/prob/wishart_lpdf.hpp +++ b/stan/math/prim/prob/wishart_lpdf.hpp @@ -46,9 +46,8 @@ namespace math { template * = nullptr, require_all_matrix_t* = nullptr> -inline return_type_t wishart_lpdf(const T_y& W, - const T_dof& nu, - const T_scale& S) { +return_type_t wishart_lpdf(const T_y& W, const T_dof& nu, + const T_scale& S) { using Eigen::Dynamic; using Eigen::Lower; using Eigen::Matrix; diff --git a/stan/math/prim/prob/yule_simon_lccdf.hpp b/stan/math/prim/prob/yule_simon_lccdf.hpp deleted file mode 100644 index 335fa158e8c..00000000000 --- a/stan/math/prim/prob/yule_simon_lccdf.hpp +++ /dev/null @@ -1,84 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_YULE_SIMON_LCCDF_HPP -#define STAN_MATH_PRIM_PROB_YULE_SIMON_LCCDF_HPP - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace stan { -namespace math { - -/** \ingroup prob_dists - * Returns the log CCDF of the Yule-Simon distribution with shape parameter. - * Given containers of matching sizes, returns the log sum of probabilities. - * - * @tparam T_n type of outcome parameter - * @tparam T_alpha type of shape parameter - * - * @param n outcome variable - * @param alpha shape parameter - * @return log probability or log sum of probabilities - * @throw std::domain_error if alpha fails to be positive - * @throw std::invalid_argument if container sizes mismatch - */ -template -inline return_type_t yule_simon_lccdf(const T_n& n, - const T_alpha& alpha) { - using T_partials_return = partials_return_t; - using T_n_ref = ref_type_t; - using T_alpha_ref = ref_type_t; - static constexpr const char* function = "yule_simon_lccdf"; - - check_consistent_sizes(function, "Outcome variable", n, "Shape parameter", - alpha); - if (size_zero(n, alpha)) { - return 0.0; - } - - T_n_ref n_ref = n; - T_alpha_ref alpha_ref = alpha; - check_positive_finite(function, "Shape parameter", alpha_ref); - - scalar_seq_view n_vec(n); - scalar_seq_view alpha_vec(alpha_ref); - const size_t max_size_seq_view = max_size(n_ref, alpha_ref); - - // Explicit return for invalid or extreme values - // The gradients are technically ill-defined, but treated as zero - for (int i = 0; i < stan::math::size(n); i++) { - if (n_vec.val(i) < 1.0) { - return 0.0; - } - if (n_vec.val(i) == std::numeric_limits::max()) { - return negative_infinity(); - } - } - - T_partials_return log_ccdf(0.0); - auto ops_partials = make_partials_propagator(alpha_ref); - for (size_t i = 0; i < max_size_seq_view; i++) { - auto np1 = n_vec.val(i) + 1.0; - auto ap1 = alpha_vec.val(i) + 1.0; - auto nap1 = n_vec.val(i) + ap1; - log_ccdf += lgamma(ap1) + lgamma(np1) - lgamma(nap1); - - if constexpr (is_autodiff_v) { - partials<0>(ops_partials)[i] += digamma(ap1) - digamma(nap1); - } - } - - return ops_partials.build(log_ccdf); -} - -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/rev/constraint/cholesky_corr_constrain.hpp b/stan/math/rev/constraint/cholesky_corr_constrain.hpp index 2adc688263c..e61fcbc5cbd 100644 --- a/stan/math/rev/constraint/cholesky_corr_constrain.hpp +++ b/stan/math/rev/constraint/cholesky_corr_constrain.hpp @@ -25,7 +25,7 @@ namespace math { * @return Cholesky factor of correlation matrix */ template * = nullptr> -inline var_value cholesky_corr_constrain(const T& y, int K) { +var_value cholesky_corr_constrain(const T& y, int K) { using std::sqrt; int k_choose_2 = (K * (K - 1)) / 2; check_size_match("cholesky_corr_constrain", "y.size()", y.size(), @@ -89,8 +89,8 @@ inline var_value cholesky_corr_constrain(const T& y, int K) { * @return Cholesky factor of correlation matrix */ template * = nullptr> -inline var_value cholesky_corr_constrain( - const T& y, int K, scalar_type_t& lp) { +var_value cholesky_corr_constrain(const T& y, int K, + scalar_type_t& lp) { using Eigen::Dynamic; using Eigen::Matrix; using std::sqrt; diff --git a/stan/math/rev/constraint/cholesky_factor_constrain.hpp b/stan/math/rev/constraint/cholesky_factor_constrain.hpp index fcf26477fb5..17d18d7ee0e 100644 --- a/stan/math/rev/constraint/cholesky_factor_constrain.hpp +++ b/stan/math/rev/constraint/cholesky_factor_constrain.hpp @@ -27,8 +27,7 @@ namespace math { * @return Cholesky factor */ template * = nullptr> -inline var_value cholesky_factor_constrain(const T& x, int M, - int N) { +var_value cholesky_factor_constrain(const T& x, int M, int N) { using std::exp; check_greater_or_equal("cholesky_factor_constrain", "num rows (must be greater or equal to num cols)", M, @@ -87,8 +86,8 @@ inline var_value cholesky_factor_constrain(const T& x, int M, * @return Cholesky factor */ template * = nullptr> -inline var_value cholesky_factor_constrain( - const T& x, int M, int N, scalar_type_t& lp) { +var_value cholesky_factor_constrain(const T& x, int M, int N, + scalar_type_t& lp) { check_size_match("cholesky_factor_constrain", "x.size()", x.size(), "((N * (N + 1)) / 2 + (M - N) * N)", ((N * (N + 1)) / 2 + (M - N) * N)); diff --git a/stan/math/rev/constraint/corr_matrix_constrain.hpp b/stan/math/rev/constraint/corr_matrix_constrain.hpp index 8b8a028c9a5..c3d1b8d2f7d 100644 --- a/stan/math/rev/constraint/corr_matrix_constrain.hpp +++ b/stan/math/rev/constraint/corr_matrix_constrain.hpp @@ -38,8 +38,7 @@ namespace math { * matrix. */ template * = nullptr> -inline var_value corr_matrix_constrain(const T& x, - Eigen::Index k) { +var_value corr_matrix_constrain(const T& x, Eigen::Index k) { Eigen::Index k_choose_2 = (k * (k - 1)) / 2; check_size_match("cov_matrix_constrain", "x.size()", x.size(), "k_choose_2", k_choose_2); @@ -67,9 +66,8 @@ inline var_value corr_matrix_constrain(const T& x, * @param lp Log probability reference to increment. */ template * = nullptr> -inline var_value corr_matrix_constrain(const T& x, - Eigen::Index k, - scalar_type_t& lp) { +var_value corr_matrix_constrain(const T& x, Eigen::Index k, + scalar_type_t& lp) { Eigen::Index k_choose_2 = (k * (k - 1)) / 2; check_size_match("cov_matrix_constrain", "x.size()", x.size(), "k_choose_2", k_choose_2); diff --git a/stan/math/rev/constraint/cov_matrix_constrain.hpp b/stan/math/rev/constraint/cov_matrix_constrain.hpp index b71913f2d8a..ccf4ac496ba 100644 --- a/stan/math/rev/constraint/cov_matrix_constrain.hpp +++ b/stan/math/rev/constraint/cov_matrix_constrain.hpp @@ -29,8 +29,7 @@ namespace math { * @throws std::invalid_argument if (x.size() != K + (K choose 2)). */ template * = nullptr> -inline var_value cov_matrix_constrain(const T& x, - Eigen::Index K) { +var_value cov_matrix_constrain(const T& x, Eigen::Index K) { using std::exp; check_size_match("cov_matrix_constrain", "x.size()", x.size(), @@ -75,9 +74,8 @@ inline var_value cov_matrix_constrain(const T& x, * @throws std::domain_error if (x.size() != K + (K choose 2)). */ template * = nullptr> -inline var_value cov_matrix_constrain(const T& x, - Eigen::Index K, - scalar_type_t& lp) { +var_value cov_matrix_constrain(const T& x, Eigen::Index K, + scalar_type_t& lp) { using std::exp; using std::log; diff --git a/stan/math/rev/constraint/cov_matrix_constrain_lkj.hpp b/stan/math/rev/constraint/cov_matrix_constrain_lkj.hpp index 115a396cf6c..1e8d8ea3e8c 100644 --- a/stan/math/rev/constraint/cov_matrix_constrain_lkj.hpp +++ b/stan/math/rev/constraint/cov_matrix_constrain_lkj.hpp @@ -32,8 +32,7 @@ namespace math { * correlations and deviations. */ template * = nullptr> -inline var_value cov_matrix_constrain_lkj(const T& x, - size_t k) { +var_value cov_matrix_constrain_lkj(const T& x, size_t k) { size_t k_choose_2 = (k * (k - 1)) / 2; return read_cov_matrix(corr_constrain(x.head(k_choose_2)), positive_constrain(x.tail(k))); @@ -65,8 +64,8 @@ inline var_value cov_matrix_constrain_lkj(const T& x, * correlations and deviations. */ template * = nullptr> -inline var_value cov_matrix_constrain_lkj( - const T& x, size_t k, scalar_type_t& lp) { +var_value cov_matrix_constrain_lkj(const T& x, size_t k, + scalar_type_t& lp) { size_t k_choose_2 = (k * (k - 1)) / 2; return read_cov_matrix(corr_constrain(x.head(k_choose_2)), positive_constrain(x.tail(k)), lp); diff --git a/stan/math/rev/constraint/lub_constrain.hpp b/stan/math/rev/constraint/lub_constrain.hpp index df5d9f9dd46..7116b9c9e08 100644 --- a/stan/math/rev/constraint/lub_constrain.hpp +++ b/stan/math/rev/constraint/lub_constrain.hpp @@ -49,19 +49,20 @@ inline auto lub_constrain(const T& x, const L& lb, const U& ub) { check_less("lub_constrain", "lb", lb_val, ub_val); auto diff = ub_val - lb_val; double inv_logit_x = inv_logit(value_of(x)); - return make_callback_var(diff * inv_logit_x + lb_val, - [x, ub, lb, diff, inv_logit_x](auto& vi) mutable { - if constexpr (is_autodiff_v) { - x.adj() += vi.adj() * diff * inv_logit_x - * (1.0 - inv_logit_x); - } - if constexpr (is_autodiff_v) { - lb.adj() += vi.adj() * (1.0 - inv_logit_x); - } - if constexpr (is_autodiff_v) { - ub.adj() += vi.adj() * inv_logit_x; - } - }); + return make_callback_var( + diff * inv_logit_x + lb_val, + [x, ub, lb, diff, inv_logit_x](auto& vi) mutable { + if constexpr (is_autodiff_v) { + forward_as(x).adj() + += vi.adj() * diff * inv_logit_x * (1.0 - inv_logit_x); + } + if constexpr (is_autodiff_v) { + forward_as(lb).adj() += vi.adj() * (1.0 - inv_logit_x); + } + if constexpr (is_autodiff_v) { + forward_as(ub).adj() += vi.adj() * inv_logit_x; + } + }); } } @@ -124,19 +125,22 @@ inline auto lub_constrain(const T& x, const L& lb, const U& ub, diff * inv_logit_x + lb_val, [x, ub, lb, diff, lp, inv_logit_x](auto& vi) mutable { if constexpr (is_autodiff_v) { - x.adj() += vi.adj() * diff * inv_logit_x * (1.0 - inv_logit_x) - + lp.adj() * (1.0 - 2.0 * inv_logit_x); + forward_as(x).adj() + += vi.adj() * diff * inv_logit_x * (1.0 - inv_logit_x) + + lp.adj() * (1.0 - 2.0 * inv_logit_x); } if constexpr (is_autodiff_v && is_autodiff_v) { const auto one_over_diff = 1.0 / diff; - lb.adj() + forward_as(lb).adj() += vi.adj() * (1.0 - inv_logit_x) + -one_over_diff * lp.adj(); - ub.adj() += vi.adj() * inv_logit_x + one_over_diff * lp.adj(); + forward_as(ub).adj() + += vi.adj() * inv_logit_x + one_over_diff * lp.adj(); } else if constexpr (is_autodiff_v) { - lb.adj() + forward_as(lb).adj() += vi.adj() * (1.0 - inv_logit_x) + (-1.0 / diff) * lp.adj(); } else if constexpr (is_autodiff_v) { - ub.adj() += vi.adj() * inv_logit_x + (1.0 / diff) * lp.adj(); + forward_as(ub).adj() + += vi.adj() * inv_logit_x + (1.0 / diff) * lp.adj(); } }); } @@ -169,14 +173,16 @@ inline auto lub_constrain(const T& x, const L& lb, const U& ub) { arena_t ret = diff * inv_logit_x + lb_val; reverse_pass_callback([arena_x, ub, lb, ret, diff, inv_logit_x]() mutable { if constexpr (is_autodiff_v) { - arena_x.adj().array() + using T_var = arena_t>; + forward_as(arena_x).adj().array() += ret.adj().array() * diff * inv_logit_x * (1.0 - inv_logit_x); } if constexpr (is_autodiff_v) { - lb.adj() += (ret.adj().array() * (1.0 - inv_logit_x)).sum(); + forward_as(lb).adj() + += (ret.adj().array() * (1.0 - inv_logit_x)).sum(); } if constexpr (is_autodiff_v) { - ub.adj() += (ret.adj().array() * inv_logit_x).sum(); + forward_as(ub).adj() += (ret.adj().array() * inv_logit_x).sum(); } }); return ret_type(ret); @@ -214,23 +220,25 @@ inline auto lub_constrain(const T& x, const L& lb, const U& ub, reverse_pass_callback( [arena_x, ub, lb, ret, lp, diff, inv_logit_x]() mutable { if constexpr (is_autodiff_v) { - arena_x.adj().array() + forward_as>>(arena_x).adj().array() += ret.adj().array() * diff * inv_logit_x * (1.0 - inv_logit_x) + lp.adj() * (1.0 - 2.0 * inv_logit_x); } if constexpr (is_autodiff_v && is_autodiff_v) { const auto lp_calc = lp.adj() * ret.size(); const auto one_over_diff = 1.0 / diff; - lb.adj() += (ret.adj().array() * (1.0 - inv_logit_x)).sum() - + -one_over_diff * lp_calc; - ub.adj() += (ret.adj().array() * inv_logit_x).sum() - + one_over_diff * lp_calc; + forward_as(lb).adj() + += (ret.adj().array() * (1.0 - inv_logit_x)).sum() + + -one_over_diff * lp_calc; + forward_as(ub).adj() += (ret.adj().array() * inv_logit_x).sum() + + one_over_diff * lp_calc; } else if constexpr (is_autodiff_v) { - lb.adj() += (ret.adj().array() * (1.0 - inv_logit_x)).sum() - + -(1.0 / diff) * lp.adj() * ret.size(); + forward_as(lb).adj() + += (ret.adj().array() * (1.0 - inv_logit_x)).sum() + + -(1.0 / diff) * lp.adj() * ret.size(); } else if constexpr (is_autodiff_v) { - ub.adj() += (ret.adj().array() * inv_logit_x).sum() - + (1.0 / diff) * lp.adj() * ret.size(); + forward_as(ub).adj() += (ret.adj().array() * inv_logit_x).sum() + + (1.0 / diff) * lp.adj() * ret.size(); } }); return ret_type(ret); @@ -264,19 +272,21 @@ inline auto lub_constrain(const T& x, const L& lb, const U& ub) { ub_val - value_of(arena_x).array().exp(), diff * inv_logit_x + lb_val); reverse_pass_callback([arena_x, ub, arena_lb, ret, diff, inv_logit_x, is_lb_inf]() mutable { + using T_var = arena_t>; + using L_var = arena_t>; if constexpr (is_autodiff_v) { - arena_x.adj().array() += (is_lb_inf).select( + forward_as(arena_x).adj().array() += (is_lb_inf).select( ret.adj().array() * -value_of(arena_x).array().exp(), ret.adj().array() * diff * inv_logit_x * (1.0 - inv_logit_x)); } if constexpr (is_autodiff_v) { - ub.adj() + forward_as(ub).adj() += (is_lb_inf) .select(ret.adj().array(), ret.adj().array() * inv_logit_x) .sum(); } if constexpr (is_autodiff_v) { - arena_lb.adj().array() + forward_as(arena_lb).adj().array() += (is_lb_inf).select(0, ret.adj().array() * (1.0 - inv_logit_x)); } }); @@ -318,21 +328,23 @@ inline auto lub_constrain(const T& x, const L& lb, const U& ub, .sum(); 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 constexpr (is_autodiff_v) { const auto x_sign = arena_x_val.sign().eval(); - arena_x.adj().array() += (is_lb_inf).select( + forward_as(arena_x).adj().array() += (is_lb_inf).select( 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)); } if constexpr (is_autodiff_v) { - arena_lb.adj().array() + forward_as(arena_lb).adj().array() += (is_lb_inf).select(0, ret.adj().array() * (1.0 - inv_logit_x) + -(1.0 / diff) * lp_adj); } if constexpr (is_autodiff_v) { - ub.adj() + forward_as(ub).adj() += (is_lb_inf) .select(ret.adj().array(), ret.adj().array() * inv_logit_x + (1.0 / diff) * lp_adj) @@ -371,19 +383,22 @@ inline auto lub_constrain(const T& x, const L& lb, const U& ub) { arena_x_val.array().exp() + lb_val, diff * inv_logit_x + lb_val); reverse_pass_callback([arena_x, arena_x_val, arena_ub, lb, ret, is_ub_inf, inv_logit_x, diff]() mutable { + using T_var = arena_t>; + using U_var = arena_t>; if constexpr (is_autodiff_v) { - arena_x.adj().array() += (is_ub_inf).select( + forward_as(arena_x).adj().array() += (is_ub_inf).select( ret.adj().array() * arena_x_val.array().exp(), ret.adj().array() * diff * inv_logit_x * (1.0 - inv_logit_x)); } if constexpr (is_autodiff_v) { - lb.adj() += (is_ub_inf) - .select(ret.adj().array(), - ret.adj().array() * (1.0 - inv_logit_x)) - .sum(); + forward_as(lb).adj() + += (is_ub_inf) + .select(ret.adj().array(), + ret.adj().array() * (1.0 - inv_logit_x)) + .sum(); } if constexpr (is_autodiff_v) { - arena_ub.adj().array() + forward_as(arena_ub).adj().array() += (is_ub_inf).select(0, ret.adj().array() * inv_logit_x); } }); @@ -425,22 +440,25 @@ inline auto lub_constrain(const T& x, const L& lb, const U& ub, arena_x_val.array().exp() + lb_val, diff * inv_logit_x + lb_val); reverse_pass_callback([arena_x, arena_x_val, diff, inv_logit_x, arena_ub, lb, ret, lp, is_ub_inf]() mutable { + using T_var = arena_t>; + using U_var = arena_t>; const auto lp_adj = lp.adj(); if constexpr (is_autodiff_v) { - arena_x.adj().array() += (is_ub_inf).select( + forward_as(arena_x).adj().array() += (is_ub_inf).select( ret.adj().array() * arena_x_val.array().exp() + lp_adj, ret.adj().array() * diff * inv_logit_x * (1.0 - inv_logit_x) + lp.adj() * (1.0 - 2.0 * inv_logit_x)); } if constexpr (is_autodiff_v) { - lb.adj() += (is_ub_inf) - .select(ret.adj().array(), - ret.adj().array() * (1.0 - inv_logit_x) - + -(1.0 / diff) * lp_adj) - .sum(); + forward_as(lb).adj() + += (is_ub_inf) + .select(ret.adj().array(), + ret.adj().array() * (1.0 - inv_logit_x) + + -(1.0 / diff) * lp_adj) + .sum(); } if constexpr (is_autodiff_v) { - arena_ub.adj().array() += (is_ub_inf).select( + forward_as(arena_ub).adj().array() += (is_ub_inf).select( 0, ret.adj().array() * inv_logit_x + (1.0 / diff) * lp_adj); } }); @@ -480,22 +498,27 @@ inline auto lub_constrain(const T& x, const L& lb, const U& ub) { reverse_pass_callback([arena_x, arena_x_val, inv_logit_x, arena_ub, arena_lb, diff, ret, is_ub_inf, is_lb_inf, is_lb_ub_inf]() mutable { + using T_var = arena_t>; + using L_var = arena_t>; + using U_var = arena_t>; // The most likely case is neither of them are infinity const bool is_none_inf = !(is_lb_inf.any() || is_ub_inf.any()); if (is_none_inf) { if constexpr (is_autodiff_v) { - arena_x.adj().array() + forward_as(arena_x).adj().array() += ret.adj().array() * diff * inv_logit_x * (1.0 - inv_logit_x); } if constexpr (is_autodiff_v) { - arena_lb.adj().array() += ret.adj().array() * (1.0 - inv_logit_x); + forward_as(arena_lb).adj().array() + += ret.adj().array() * (1.0 - inv_logit_x); } if constexpr (is_autodiff_v) { - arena_ub.adj().array() += ret.adj().array() * inv_logit_x; + forward_as(arena_ub).adj().array() + += ret.adj().array() * inv_logit_x; } } else { if constexpr (is_autodiff_v) { - arena_x.adj().array() + forward_as(arena_x).adj().array() += (is_lb_ub_inf) .select( ret.adj().array(), @@ -507,12 +530,12 @@ inline auto lub_constrain(const T& x, const L& lb, const U& ub) { * (1.0 - inv_logit_x)))); } if constexpr (is_autodiff_v) { - arena_ub.adj().array() += (is_ub_inf).select( + forward_as(arena_ub).adj().array() += (is_ub_inf).select( 0, (is_lb_inf).select(ret.adj().array(), ret.adj().array() * inv_logit_x)); } if constexpr (is_autodiff_v) { - arena_lb.adj().array() += (is_lb_inf).select( + forward_as(arena_lb).adj().array() += (is_lb_inf).select( 0, (is_ub_inf).select(ret.adj().array(), ret.adj().array() * (1.0 - inv_logit_x))); } @@ -563,26 +586,29 @@ inline auto lub_constrain(const T& x, const L& lb, const U& ub, reverse_pass_callback([arena_x, arena_x_val, inv_logit_x, arena_ub, arena_lb, diff, ret, is_ub_inf, is_lb_inf, is_lb_ub_inf, lp]() mutable { + using T_var = arena_t>; + using L_var = arena_t>; + using U_var = arena_t>; const auto lp_adj = lp.adj(); // The most likely case is neither of them are infinity const bool is_none_inf = !(is_lb_inf.any() || is_ub_inf.any()); if (is_none_inf) { if constexpr (is_autodiff_v) { - arena_x.adj().array() + forward_as(arena_x).adj().array() += ret.adj().array() * diff * inv_logit_x * (1.0 - inv_logit_x) + lp.adj() * (1.0 - 2.0 * inv_logit_x); } if constexpr (is_autodiff_v) { - arena_lb.adj().array() + forward_as(arena_lb).adj().array() += ret.adj().array() * (1.0 - inv_logit_x) + -(1.0 / diff) * lp_adj; } if constexpr (is_autodiff_v) { - arena_ub.adj().array() + forward_as(arena_ub).adj().array() += ret.adj().array() * inv_logit_x + (1.0 / diff) * lp_adj; } } else { if constexpr (is_autodiff_v) { - arena_x.adj().array() + forward_as(arena_x).adj().array() += (is_lb_ub_inf) .select( ret.adj().array(), @@ -597,13 +623,13 @@ inline auto lub_constrain(const T& x, const L& lb, const U& ub, + lp.adj() * (1.0 - 2.0 * inv_logit_x)))); } if constexpr (is_autodiff_v) { - arena_lb.adj().array() += (is_lb_inf).select( + forward_as(arena_lb).adj().array() += (is_lb_inf).select( 0, (is_ub_inf).select(ret.adj().array(), ret.adj().array() * (1.0 - inv_logit_x) + -(1.0 / diff) * lp_adj)); } if constexpr (is_autodiff_v) { - arena_ub.adj().array() += (is_ub_inf).select( + forward_as(arena_ub).adj().array() += (is_ub_inf).select( 0, (is_lb_inf).select( ret.adj().array(), ret.adj().array() * inv_logit_x + (1.0 / diff) * lp_adj)); diff --git a/stan/math/rev/constraint/ordered_constrain.hpp b/stan/math/rev/constraint/ordered_constrain.hpp index fe8255e7c0d..f029e586e33 100644 --- a/stan/math/rev/constraint/ordered_constrain.hpp +++ b/stan/math/rev/constraint/ordered_constrain.hpp @@ -70,7 +70,7 @@ inline auto ordered_constrain(T&& x) { * @return Positive, increasing ordered vector. */ template * = nullptr> -inline auto ordered_constrain(VarVec&& x, scalar_type_t& lp) { +auto ordered_constrain(VarVec&& x, scalar_type_t& lp) { if (x.size() > 1) { lp += sum(x.tail(x.size() - 1)); } diff --git a/stan/math/rev/constraint/sum_to_zero_constrain.hpp b/stan/math/rev/constraint/sum_to_zero_constrain.hpp index c8004319ada..644dead5fe8 100644 --- a/stan/math/rev/constraint/sum_to_zero_constrain.hpp +++ b/stan/math/rev/constraint/sum_to_zero_constrain.hpp @@ -25,8 +25,7 @@ namespace internal { * @param z_adj The adjoint of the zero-sum vector (size N + 1) */ template -inline void sum_to_zero_vector_backprop(T&& y_adj, - const Eigen::VectorXd& z_adj) { +void sum_to_zero_vector_backprop(T&& y_adj, const Eigen::VectorXd& z_adj) { const auto N = y_adj.size(); double sum_u_adj = 0; diff --git a/stan/math/rev/core/build_vari_array.hpp b/stan/math/rev/core/build_vari_array.hpp index 8d627f0d192..f8c177dedd8 100644 --- a/stan/math/rev/core/build_vari_array.hpp +++ b/stan/math/rev/core/build_vari_array.hpp @@ -18,7 +18,7 @@ namespace math { * @return Flat array of vari pointers */ template -inline vari** build_vari_array(const Eigen::Matrix& x) { +vari** build_vari_array(const Eigen::Matrix& x) { vari** x_vi_ = ChainableStack::instance_->memalloc_.alloc_array(x.size()); for (int i = 0; i < x.size(); ++i) { diff --git a/stan/math/rev/core/callback_vari.hpp b/stan/math/rev/core/callback_vari.hpp index 04b29bf23c1..a270430145e 100644 --- a/stan/math/rev/core/callback_vari.hpp +++ b/stan/math/rev/core/callback_vari.hpp @@ -38,8 +38,8 @@ struct callback_vari : public vari_value { * @param functor functor or other callable to call in the reverse pass */ template -inline internal::callback_vari, F>* make_callback_vari( - T&& value, F&& functor) { +internal::callback_vari, F>* make_callback_vari(T&& value, + F&& functor) { return new internal::callback_vari, F>( std::move(value), std::forward(functor)); } @@ -58,7 +58,7 @@ inline internal::callback_vari, F>* make_callback_vari( * @param functor functor or other callable to call in the reverse pass */ template -inline var_value> make_callback_var(T&& value, F&& functor) { +var_value> make_callback_var(T&& value, F&& functor) { return var_value>( make_callback_vari(std::move(value), std::forward(functor))); } diff --git a/stan/math/rev/core/chainable_object.hpp b/stan/math/rev/core/chainable_object.hpp index c2726c9d494..d4e22bb966d 100644 --- a/stan/math/rev/core/chainable_object.hpp +++ b/stan/math/rev/core/chainable_object.hpp @@ -55,7 +55,7 @@ class chainable_object : public chainable_alloc { * @return pointer to object held in `chainable_object` */ template -inline auto make_chainable_ptr(T&& obj) { +auto make_chainable_ptr(T&& obj) { auto ptr = new chainable_object(std::forward(obj)); return &ptr->get(); } @@ -110,7 +110,7 @@ class unsafe_chainable_object : public chainable_alloc { * @return pointer to object held in `chainable_object` */ template -inline auto make_unsafe_chainable_ptr(T&& obj) { +auto make_unsafe_chainable_ptr(T&& obj) { auto ptr = new unsafe_chainable_object(std::forward(obj)); return &ptr->get(); } diff --git a/stan/math/rev/fun/diag_post_multiply.hpp b/stan/math/rev/fun/diag_post_multiply.hpp index 5d8affa18f6..fdcea382495 100644 --- a/stan/math/rev/fun/diag_post_multiply.hpp +++ b/stan/math/rev/fun/diag_post_multiply.hpp @@ -24,7 +24,7 @@ namespace math { template * = nullptr, require_vector_t* = nullptr, require_any_st_var* = nullptr> -inline auto diag_post_multiply(const T1& m1, const T2& m2) { +auto diag_post_multiply(const T1& m1, const T2& m2) { check_size_match("diag_post_multiply", "m2.size()", m2.size(), "m1.cols()", m1.cols()); using inner_ret_type = decltype(value_of(m1) * value_of(m2).asDiagonal()); diff --git a/stan/math/rev/fun/diag_pre_multiply.hpp b/stan/math/rev/fun/diag_pre_multiply.hpp index 1636c5e7918..80f8eb44100 100644 --- a/stan/math/rev/fun/diag_pre_multiply.hpp +++ b/stan/math/rev/fun/diag_pre_multiply.hpp @@ -24,7 +24,7 @@ namespace math { template * = nullptr, require_matrix_t* = nullptr, require_any_st_var* = nullptr> -inline auto diag_pre_multiply(const T1& m1, const T2& m2) { +auto diag_pre_multiply(const T1& m1, const T2& m2) { check_size_match("diag_pre_multiply", "m1.size()", m1.size(), "m2.rows()", m2.rows()); using inner_ret_type = decltype(value_of(m1).asDiagonal() * value_of(m2)); diff --git a/stan/math/rev/fun/elt_divide.hpp b/stan/math/rev/fun/elt_divide.hpp index fe3b2e0ce65..a3f2a58b971 100644 --- a/stan/math/rev/fun/elt_divide.hpp +++ b/stan/math/rev/fun/elt_divide.hpp @@ -25,7 +25,7 @@ namespace math { template * = nullptr, require_any_rev_matrix_t* = nullptr> -inline auto elt_divide(const Mat1& m1, const Mat2& m2) { +auto elt_divide(const Mat1& m1, const Mat2& m2) { check_matching_dims("elt_divide", "m1", m1, "m2", m2); using inner_ret_type = decltype((value_of(m1).array() / value_of(m2).array()).matrix()); @@ -78,13 +78,13 @@ inline auto elt_divide(const Mat1& m1, const Mat2& m2) { */ template * = nullptr, require_var_matrix_t* = nullptr> -inline auto elt_divide(Scal s, const Mat& m) { +auto elt_divide(Scal s, const Mat& m) { plain_type_t res = value_of(s) / m.val().array(); reverse_pass_callback([m, s, res]() mutable { m.adj().array() -= res.val().array() * res.adj().array() / m.val().array(); if constexpr (is_autodiff_v) - s.adj() += (res.adj().array() / m.val().array()).sum(); + forward_as(s).adj() += (res.adj().array() / m.val().array()).sum(); }); return res; diff --git a/stan/math/rev/fun/elt_multiply.hpp b/stan/math/rev/fun/elt_multiply.hpp index d2e52f19159..a706efbc4bc 100644 --- a/stan/math/rev/fun/elt_multiply.hpp +++ b/stan/math/rev/fun/elt_multiply.hpp @@ -26,7 +26,7 @@ namespace math { template * = nullptr, require_any_rev_matrix_t* = nullptr> -inline auto elt_multiply(const Mat1& m1, const Mat2& m2) { +auto elt_multiply(const Mat1& m1, const Mat2& m2) { check_matching_dims("elt_multiply", "m1", m1, "m2", m2); using inner_ret_type = decltype(value_of(m1).cwiseProduct(value_of(m2))); using ret_type = return_var_matrix_t; diff --git a/stan/math/rev/fun/fma.hpp b/stan/math/rev/fun/fma.hpp index 517eb3481d6..3a84bda941c 100644 --- a/stan/math/rev/fun/fma.hpp +++ b/stan/math/rev/fun/fma.hpp @@ -195,14 +195,19 @@ template * = nullptr> inline auto fma_reverse_pass(T1& arena_x, T2& arena_y, T3& arena_z, T4& ret) { return [arena_x, arena_y, arena_z, ret]() mutable { + using T1_var = arena_t>>; + using T2_var = arena_t>>; + using T3_var = arena_t>>; if constexpr (is_autodiff_v) { - arena_x.adj().array() += ret.adj().array() * value_of(arena_y).array(); + forward_as(arena_x).adj().array() + += ret.adj().array() * value_of(arena_y).array(); } if constexpr (is_autodiff_v) { - arena_y.adj().array() += ret.adj().array() * value_of(arena_x).array(); + forward_as(arena_y).adj().array() + += ret.adj().array() * value_of(arena_x).array(); } if constexpr (is_autodiff_v) { - arena_z.adj().array() += ret.adj().array(); + forward_as(arena_z).adj().array() += ret.adj().array(); } }; } @@ -215,14 +220,19 @@ template * = nullptr> inline auto fma_reverse_pass(T1& arena_x, T2& arena_y, T3& arena_z, T4& ret) { return [arena_x, arena_y, arena_z, ret]() mutable { + using T1_var = arena_t>; + using T2_var = arena_t>; + using T3_var = arena_t>; if constexpr (is_autodiff_v) { - arena_x.adj() += (ret.adj().array() * value_of(arena_y).array()).sum(); + forward_as(arena_x).adj() + += (ret.adj().array() * value_of(arena_y).array()).sum(); } if constexpr (is_autodiff_v) { - arena_y.adj().array() += ret.adj().array() * value_of(arena_x); + forward_as(arena_y).adj().array() + += ret.adj().array() * value_of(arena_x); } if constexpr (is_autodiff_v) { - arena_z.adj().array() += ret.adj().array(); + forward_as(arena_z).adj().array() += ret.adj().array(); } }; } @@ -235,14 +245,19 @@ template * = nullptr> inline auto fma_reverse_pass(T1& arena_x, T2& arena_y, T3& arena_z, T4& ret) { return [arena_x, arena_y, arena_z, ret]() mutable { + using T1_var = arena_t>; + using T2_var = arena_t>; + using T3_var = arena_t>; if constexpr (is_autodiff_v) { - arena_x.adj().array() += ret.adj().array() * value_of(arena_y); + forward_as(arena_x).adj().array() + += ret.adj().array() * value_of(arena_y); } if constexpr (is_autodiff_v) { - arena_y.adj() += (ret.adj().array() * value_of(arena_x).array()).sum(); + forward_as(arena_y).adj() + += (ret.adj().array() * value_of(arena_x).array()).sum(); } if constexpr (is_autodiff_v) { - arena_z.adj().array() += ret.adj().array(); + forward_as(arena_z).adj().array() += ret.adj().array(); } }; } @@ -255,14 +270,19 @@ template * = nullptr> inline auto fma_reverse_pass(T1& arena_x, T2& arena_y, T3& arena_z, T4& ret) { return [arena_x, arena_y, arena_z, ret]() mutable { + using T1_var = arena_t>; + using T2_var = arena_t>; + using T3_var = arena_t>; if constexpr (is_autodiff_v) { - arena_x.adj() += (ret.adj().array() * value_of(arena_y)).sum(); + forward_as(arena_x).adj() + += (ret.adj().array() * value_of(arena_y)).sum(); } if constexpr (is_autodiff_v) { - arena_y.adj() += (ret.adj().array() * value_of(arena_x)).sum(); + forward_as(arena_y).adj() + += (ret.adj().array() * value_of(arena_x)).sum(); } if constexpr (is_autodiff_v) { - arena_z.adj().array() += ret.adj().array(); + forward_as(arena_z).adj().array() += ret.adj().array(); } }; } @@ -275,14 +295,19 @@ template * = nullptr> inline auto fma_reverse_pass(T1& arena_x, T2& arena_y, T3& arena_z, T4& ret) { return [arena_x, arena_y, arena_z, ret]() mutable { + using T1_var = arena_t>; + using T2_var = arena_t>; + using T3_var = arena_t>; if constexpr (is_autodiff_v) { - arena_x.adj().array() += ret.adj().array() * value_of(arena_y).array(); + forward_as(arena_x).adj().array() + += ret.adj().array() * value_of(arena_y).array(); } if constexpr (is_autodiff_v) { - arena_y.adj().array() += ret.adj().array() * value_of(arena_x).array(); + forward_as(arena_y).adj().array() + += ret.adj().array() * value_of(arena_x).array(); } if constexpr (is_autodiff_v) { - arena_z.adj() += ret.adj().sum(); + forward_as(arena_z).adj() += ret.adj().sum(); } }; } @@ -295,14 +320,19 @@ template * = nullptr> inline auto fma_reverse_pass(T1& arena_x, T2& arena_y, T3& arena_z, T4& ret) { return [arena_x, arena_y, arena_z, ret]() mutable { + using T1_var = arena_t>; + using T2_var = arena_t>; + using T3_var = arena_t>; if constexpr (is_autodiff_v) { - arena_x.adj() += (ret.adj().array() * value_of(arena_y).array()).sum(); + forward_as(arena_x).adj() + += (ret.adj().array() * value_of(arena_y).array()).sum(); } if constexpr (is_autodiff_v) { - arena_y.adj().array() += ret.adj().array() * value_of(arena_x); + forward_as(arena_y).adj().array() + += ret.adj().array() * value_of(arena_x); } if constexpr (is_autodiff_v) { - arena_z.adj() += ret.adj().sum(); + forward_as(arena_z).adj() += ret.adj().sum(); } }; } @@ -315,14 +345,19 @@ template * = nullptr> inline auto fma_reverse_pass(T1& arena_x, T2& arena_y, T3& arena_z, T4& ret) { return [arena_x, arena_y, arena_z, ret]() mutable { + using T1_var = arena_t>; + using T2_var = arena_t>; + using T3_var = arena_t>; if constexpr (is_autodiff_v) { - arena_x.adj().array() += ret.adj().array() * value_of(arena_y); + forward_as(arena_x).adj().array() + += ret.adj().array() * value_of(arena_y); } if constexpr (is_autodiff_v) { - arena_y.adj() += (ret.adj().array() * value_of(arena_x).array()).sum(); + forward_as(arena_y).adj() + += (ret.adj().array() * value_of(arena_x).array()).sum(); } if constexpr (is_autodiff_v) { - arena_z.adj() += ret.adj().sum(); + forward_as(arena_z).adj() += ret.adj().sum(); } }; } diff --git a/stan/math/rev/fun/from_var_value.hpp b/stan/math/rev/fun/from_var_value.hpp index 9f7b5483c79..c222ea2d4b1 100644 --- a/stan/math/rev/fun/from_var_value.hpp +++ b/stan/math/rev/fun/from_var_value.hpp @@ -17,8 +17,8 @@ namespace math { * @param a matrix to convert */ template * = nullptr> -inline Eigen::Matrix -from_var_value(const T& a) { +Eigen::Matrix from_var_value( + const T& a) { arena_matrix> res(a.val()); reverse_pass_callback([res, a]() mutable { a.vi_->adj_ += res.adj(); }); @@ -37,7 +37,7 @@ template < conjunction, is_var>>, std::is_same, var>, bool_constant, var>::value>>* = nullptr> -inline T from_var_value(T&& a) { +T from_var_value(T&& a) { return std::forward(a); } @@ -49,7 +49,7 @@ inline T from_var_value(T&& a) { * @param a std::vector of elements to convert */ template -inline auto from_var_value(const std::vector& a) { +auto from_var_value(const std::vector& a) { std::vector()))> out; out.reserve(a.size()); for (size_t i = 0; i < a.size(); ++i) { diff --git a/stan/math/rev/fun/hypergeometric_1F0.hpp b/stan/math/rev/fun/hypergeometric_1F0.hpp index aa5267271f1..b591b7eb739 100644 --- a/stan/math/rev/fun/hypergeometric_1F0.hpp +++ b/stan/math/rev/fun/hypergeometric_1F0.hpp @@ -31,16 +31,16 @@ namespace math { template * = nullptr, require_any_var_t* = nullptr> -inline var hypergeometric_1F0(const Ta& a, const Tz& z) { +var hypergeometric_1F0(const Ta& a, const Tz& z) { double a_val = value_of(a); double z_val = value_of(z); double rtn = hypergeometric_1F0(a_val, z_val); return make_callback_var(rtn, [rtn, a, z, a_val, z_val](auto& vi) mutable { if constexpr (is_autodiff_v) { - a.adj() += vi.adj() * -rtn * log1m(z_val); + forward_as(a).adj() += vi.adj() * -rtn * log1m(z_val); } if constexpr (is_autodiff_v) { - z.adj() += vi.adj() * rtn * a_val * inv(1 - z_val); + forward_as(z).adj() += vi.adj() * rtn * a_val * inv(1 - z_val); } }); } diff --git a/stan/math/rev/fun/hypergeometric_2F1.hpp b/stan/math/rev/fun/hypergeometric_2F1.hpp index 8ee195765e2..74785fbcc25 100644 --- a/stan/math/rev/fun/hypergeometric_2F1.hpp +++ b/stan/math/rev/fun/hypergeometric_2F1.hpp @@ -38,23 +38,24 @@ inline return_type_t hypergeometric_2F1(const Ta1& a1, double b_dbl = value_of(b); double z_dbl = value_of(z); - return make_callback_var(hypergeometric_2F1(a1_dbl, a2_dbl, b_dbl, z_dbl), - [a1, a2, b, z](auto& vi) mutable { - auto grad_tuple = grad_2F1(a1, a2, b, z); + return make_callback_var( + hypergeometric_2F1(a1_dbl, a2_dbl, b_dbl, z_dbl), + [a1, a2, b, z](auto& vi) mutable { + auto grad_tuple = grad_2F1(a1, a2, b, z); - if constexpr (is_autodiff_v) { - a1.adj() += vi.adj() * std::get<0>(grad_tuple); - } - if constexpr (is_autodiff_v) { - a2.adj() += vi.adj() * std::get<1>(grad_tuple); - } - if constexpr (is_autodiff_v) { - b.adj() += vi.adj() * std::get<2>(grad_tuple); - } - if constexpr (is_autodiff_v) { - z.adj() += vi.adj() * std::get<3>(grad_tuple); - } - }); + if constexpr (is_autodiff_v) { + forward_as(a1).adj() += vi.adj() * std::get<0>(grad_tuple); + } + if constexpr (is_autodiff_v) { + forward_as(a2).adj() += vi.adj() * std::get<1>(grad_tuple); + } + if constexpr (is_autodiff_v) { + forward_as(b).adj() += vi.adj() * std::get<2>(grad_tuple); + } + if constexpr (is_autodiff_v) { + forward_as(z).adj() += vi.adj() * std::get<3>(grad_tuple); + } + }); } } // namespace math } // namespace stan diff --git a/stan/math/rev/fun/inv_inc_beta.hpp b/stan/math/rev/fun/inv_inc_beta.hpp index 64f6b75e75f..782ac8f2871 100644 --- a/stan/math/rev/fun/inv_inc_beta.hpp +++ b/stan/math/rev/fun/inv_inc_beta.hpp @@ -82,7 +82,7 @@ inline var inv_inc_beta(const T1& a, const T2& b, const T3& p) { double da3 = inc_beta(a_val, b_val, w) * exp(lbeta_ab) * (log_w - digamma(a_val) + digamma_apb); - a.adj() += vi.adj() * da1 * (exp(da2) - da3); + forward_as(a).adj() += vi.adj() * da1 * (exp(da2) - da3); } if constexpr (is_autodiff_v) { @@ -95,11 +95,12 @@ inline var inv_inc_beta(const T1& a, const T2& b, const T3& p) { double db3 = inc_beta(b_val, a_val, one_m_w) * exp(lbeta_ab) * (log1m_w - digamma(b_val) + digamma_apb); - b.adj() += vi.adj() * db1 * (exp(db2) - db3); + forward_as(b).adj() += vi.adj() * db1 * (exp(db2) - db3); } if constexpr (is_autodiff_v) { - p.adj() += vi.adj() * exp(one_m_b * log1m_w + one_m_a * log_w + lbeta_ab); + forward_as(p).adj() + += vi.adj() * exp(one_m_b * log1m_w + one_m_a * log_w + lbeta_ab); } }); } diff --git a/stan/math/rev/fun/log_determinant_ldlt.hpp b/stan/math/rev/fun/log_determinant_ldlt.hpp index 71e4d43a685..aea6ad030b5 100644 --- a/stan/math/rev/fun/log_determinant_ldlt.hpp +++ b/stan/math/rev/fun/log_determinant_ldlt.hpp @@ -19,7 +19,7 @@ namespace math { * @return ln(det(A)) */ template * = nullptr> -inline var log_determinant_ldlt(LDLT_factor& A) { +var log_determinant_ldlt(LDLT_factor& A) { if (A.matrix().size() == 0) { return 0; } diff --git a/stan/math/rev/fun/log_softmax.hpp b/stan/math/rev/fun/log_softmax.hpp index 92650558b65..9fddcbf8545 100644 --- a/stan/math/rev/fun/log_softmax.hpp +++ b/stan/math/rev/fun/log_softmax.hpp @@ -54,7 +54,7 @@ class log_softmax_elt_vari : public vari { * @throw std::domain_error if the input size is 0 */ template * = nullptr> -inline auto log_softmax(const T& x) { +auto log_softmax(const T& x) { const int a_size = x.size(); check_nonzero_size("log_softmax", "x", x); diff --git a/stan/math/rev/fun/pow.hpp b/stan/math/rev/fun/pow.hpp index 42ad34cb926..0f2ac96b056 100644 --- a/stan/math/rev/fun/pow.hpp +++ b/stan/math/rev/fun/pow.hpp @@ -93,21 +93,23 @@ inline auto pow(const Scal1& base, const Scal2& exponent) { return inv_sqrt(base); } } - return make_callback_var( - std::pow(value_of(base), value_of(exponent)), - [base, exponent](auto&& vi) mutable { - if (value_of(base) == 0.0) { - return; // partials zero, avoids 0 & log(0) - } - const double vi_mul = vi.adj() * vi.val(); + return make_callback_var(std::pow(value_of(base), value_of(exponent)), + [base, exponent](auto&& vi) mutable { + if (value_of(base) == 0.0) { + return; // partials zero, avoids 0 & log(0) + } + const double vi_mul = vi.adj() * vi.val(); - if constexpr (is_autodiff_v) { - base.adj() += vi_mul * value_of(exponent) / value_of(base); - } - if constexpr (is_autodiff_v) { - exponent.adj() += vi_mul * std::log(value_of(base)); - } - }); + if constexpr (is_autodiff_v) { + forward_as(base).adj() + += vi_mul * value_of(exponent) + / value_of(base); + } + if constexpr (is_autodiff_v) { + forward_as(exponent).adj() + += vi_mul * std::log(value_of(base)); + } + }); } } @@ -151,13 +153,16 @@ inline auto pow(const Mat1& base, const Mat2& exponent) { const auto& are_vals_zero = to_ref(value_of(arena_base) != 0.0); const auto& ret_mul = to_ref(ret.adj().array() * ret.val().array()); if constexpr (is_autodiff_v) { - arena_base.adj() += (are_vals_zero) - .select(ret_mul * value_of(arena_exponent) - / value_of(arena_base), - 0); + using base_var_arena_t = arena_t>; + forward_as(arena_base).adj() + += (are_vals_zero) + .select( + ret_mul * value_of(arena_exponent) / value_of(arena_base), + 0); } if constexpr (is_autodiff_v) { - arena_exponent.adj() + using exp_var_arena_t = arena_t>; + forward_as(arena_exponent).adj() += (are_vals_zero).select(ret_mul * value_of(arena_base).log(), 0); } }); @@ -206,14 +211,14 @@ inline auto pow(const Mat1& base, const Scal1& exponent) { const auto& are_vals_zero = to_ref(value_of(arena_base).array() != 0.0); const auto& ret_mul = to_ref(ret.adj().array() * ret.val().array()); if constexpr (is_autodiff_v) { - arena_base.adj().array() + forward_as(arena_base).adj().array() += (are_vals_zero) .select(ret_mul * value_of(exponent) / value_of(arena_base).array(), 0); } if constexpr (is_autodiff_v) { - exponent.adj() + forward_as(exponent).adj() += (are_vals_zero) .select(ret_mul * value_of(arena_base).array().log(), 0) .sum(); @@ -256,12 +261,13 @@ inline auto pow(Scal1 base, const Mat1& exponent) { } const auto& ret_mul = to_ref(ret.adj().array() * ret.val().array()); if constexpr (is_autodiff_v) { - base.adj() + forward_as(base).adj() += (ret_mul * value_of(arena_exponent).array() / value_of(base)) .sum(); } if constexpr (is_autodiff_v) { - arena_exponent.adj().array() += ret_mul * std::log(value_of(base)); + forward_as(arena_exponent).adj().array() + += ret_mul * std::log(value_of(base)); } }); return ret_type(ret); diff --git a/stan/math/rev/fun/read_corr_L.hpp b/stan/math/rev/fun/read_corr_L.hpp index d8e8e329730..3512f4d0692 100644 --- a/stan/math/rev/fun/read_corr_L.hpp +++ b/stan/math/rev/fun/read_corr_L.hpp @@ -33,7 +33,7 @@ namespace math { * canonical partial correlations. */ template * = nullptr> -inline auto read_corr_L(const T& CPCs, size_t K) { // on (-1, 1) +auto read_corr_L(const T& CPCs, size_t K) { // on (-1, 1) using ret_type = var_value; if (K == 0) { @@ -132,7 +132,7 @@ inline auto read_corr_L(const T& CPCs, size_t K) { // on (-1, 1) */ template * = nullptr, require_stan_scalar_t* = nullptr> -inline auto read_corr_L(const T1& CPCs, size_t K, T2& log_prob) { +auto read_corr_L(const T1& CPCs, size_t K, T2& log_prob) { using ret_val_type = Eigen::MatrixXd; using ret_type = var_value; diff --git a/stan/math/rev/fun/read_cov_matrix.hpp b/stan/math/rev/fun/read_cov_matrix.hpp index 5a57b65cb87..46609964bc2 100644 --- a/stan/math/rev/fun/read_cov_matrix.hpp +++ b/stan/math/rev/fun/read_cov_matrix.hpp @@ -27,8 +27,8 @@ namespace math { */ template * = nullptr> -inline var_value read_cov_matrix( - const T_CPCs& CPCs, const T_sds& sds, scalar_type_t& log_prob) { +var_value read_cov_matrix(const T_CPCs& CPCs, const T_sds& sds, + scalar_type_t& log_prob) { return multiply_lower_tri_self_transpose(read_cov_L(CPCs, sds, log_prob)); } diff --git a/stan/math/rev/fun/rep_row_vector.hpp b/stan/math/rev/fun/rep_row_vector.hpp index ea424cda2e8..272f75034c7 100644 --- a/stan/math/rev/fun/rep_row_vector.hpp +++ b/stan/math/rev/fun/rep_row_vector.hpp @@ -21,7 +21,7 @@ template * = nullptr, require_eigen_row_vector_t>* = nullptr> inline auto rep_row_vector(var x, int n) { return make_callback_var(rep_row_vector(x.val(), n), [x](auto& vi) mutable { - x.adj() += vi.adj().sum(); + forward_as(x).adj() += vi.adj().sum(); }); } diff --git a/stan/math/rev/fun/rep_vector.hpp b/stan/math/rev/fun/rep_vector.hpp index 3227a4453de..f653d5b3e0f 100644 --- a/stan/math/rev/fun/rep_vector.hpp +++ b/stan/math/rev/fun/rep_vector.hpp @@ -21,7 +21,7 @@ template * = nullptr, require_eigen_col_vector_t>* = nullptr> inline auto rep_vector(var x, int n) { return make_callback_var(rep_vector(x.val(), n), [x](auto& vi) mutable { - x.adj() += vi.adj().sum(); + forward_as(x).adj() += vi.adj().sum(); }); } diff --git a/stan/math/rev/fun/sd.hpp b/stan/math/rev/fun/sd.hpp index 25c27cad876..b5be0261467 100644 --- a/stan/math/rev/fun/sd.hpp +++ b/stan/math/rev/fun/sd.hpp @@ -25,7 +25,7 @@ namespace math { * @throw domain error size is not greater than zero. */ template * = nullptr> -inline var sd(const T& x) { +var sd(const T& x) { using std::sqrt; using T_vi = promote_scalar_t; using T_d = promote_scalar_t; @@ -68,7 +68,7 @@ inline var sd(const T& x) { * @throw domain error size is not greater than zero. */ template * = nullptr> -inline var sd(const T& x) { +var sd(const T& x) { check_nonzero_size("sd", "x", x); if (x.size() == 1) { @@ -94,7 +94,7 @@ inline var sd(const T& x) { * @throw domain error size is not greater than zero. */ template * = nullptr> -inline auto sd(T&& m) { +auto sd(T&& m) { return apply_vector_unary::reduce(std::forward(m), [](auto&& x) { return sd(std::forward(x)); }); diff --git a/stan/math/rev/fun/variance.hpp b/stan/math/rev/fun/variance.hpp index 57892c27234..f10356af71e 100644 --- a/stan/math/rev/fun/variance.hpp +++ b/stan/math/rev/fun/variance.hpp @@ -59,7 +59,7 @@ inline var variance(const std::vector& v) { * @return sample variance of specified matrix */ template * = nullptr> -inline var variance(const EigMat& m) { +var variance(const EigMat& m) { const auto& mat = to_ref(m); check_nonzero_size("variance", "m", mat); if (mat.size() == 1) { diff --git a/stan/math/rev/functor/algebra_solver_fp.hpp b/stan/math/rev/functor/algebra_solver_fp.hpp index 922eff29f82..871f5f1b09e 100644 --- a/stan/math/rev/functor/algebra_solver_fp.hpp +++ b/stan/math/rev/functor/algebra_solver_fp.hpp @@ -362,7 +362,7 @@ struct FixedPointSolver, fp_jac_type> { * std::runtime_error) if solver exceeds max_num_steps. */ template -inline Eigen::Matrix algebra_solver_fp( +Eigen::Matrix algebra_solver_fp( const F& f, const Eigen::Matrix& x, const Eigen::Matrix& y, const std::vector& x_r, const std::vector& x_i, const std::vector& u_scale, diff --git a/stan/math/rev/functor/algebra_system.hpp b/stan/math/rev/functor/algebra_system.hpp index 988e6d1e8a8..76b32ffe77f 100644 --- a/stan/math/rev/functor/algebra_system.hpp +++ b/stan/math/rev/functor/algebra_system.hpp @@ -98,12 +98,12 @@ struct hybrj_functor_solver : nlo_functor { // TODO(jgaeb): Remove this when the chain method of the fixed point solver is // updated. template -inline void algebra_solver_check( - const Eigen::Matrix& x, - const Eigen::Matrix y, - const std::vector& dat, const std::vector& dat_int, - double function_tolerance, - long int max_num_steps) { // NOLINT(runtime/int) +void algebra_solver_check(const Eigen::Matrix& x, + const Eigen::Matrix y, + const std::vector& dat, + const std::vector& dat_int, + double function_tolerance, + long int max_num_steps) { // NOLINT(runtime/int) check_nonzero_size("algebra_solver", "initial guess", x); check_finite("algebra_solver", "initial guess", x); check_finite("algebra_solver", "parameter vector", y); diff --git a/stan/math/rev/functor/cvodes_integrator_adjoint.hpp b/stan/math/rev/functor/cvodes_integrator_adjoint.hpp index d8e030355ee..78e0eaee8e7 100644 --- a/stan/math/rev/functor/cvodes_integrator_adjoint.hpp +++ b/stan/math/rev/functor/cvodes_integrator_adjoint.hpp @@ -526,7 +526,8 @@ class cvodes_integrator_adjoint_vari : public vari_base { // These are the dlog_density / d(initial_conditions[s]) adjoints if constexpr (is_var_y0_t0_) { - solver_->y0_.adj() += solver_->state_backward_; + forward_as>(solver_->y0_).adj() + += solver_->state_backward_; } // These are the dlog_density / d(parameters[s]) adjoints diff --git a/stan/math/rev/functor/dae.hpp b/stan/math/rev/functor/dae.hpp index a7432307301..ce5022ef13f 100644 --- a/stan/math/rev/functor/dae.hpp +++ b/stan/math/rev/functor/dae.hpp @@ -49,8 +49,7 @@ namespace math { */ template * = nullptr> -inline std::vector< - Eigen::Matrix, -1, 1>> +std::vector, -1, 1>> dae_tol_impl(const char* func, const F& f, const T_yy& yy0, const T_yp& yp0, double t0, const std::vector& ts, double rtol, double atol, int64_t max_num_steps, std::ostream* msgs, const T_Args&... args) { @@ -122,8 +121,7 @@ dae_tol_impl(const char* func, const F& f, const T_yy& yy0, const T_yp& yp0, */ template * = nullptr> -inline std::vector< - Eigen::Matrix, -1, 1>> +std::vector, -1, 1>> dae_tol(const F& f, const T_yy& yy0, const T_yp& yp0, double t0, const std::vector& ts, double rtol, double atol, int64_t max_num_steps, std::ostream* msgs, const T_Args&... args) { @@ -165,8 +163,7 @@ dae_tol(const F& f, const T_yy& yy0, const T_yp& yp0, double t0, */ template * = nullptr> -inline std::vector< - Eigen::Matrix, -1, 1>> +std::vector, -1, 1>> dae(const F& f, const T_yy& yy0, const T_yp& yp0, double t0, const std::vector& ts, std::ostream* msgs, const T_Args&... args) { return dae_tol_impl("dae", f, yy0, yp0, t0, ts, 1.e-10, 1.e-10, 1e8, msgs, diff --git a/stan/math/rev/functor/finite_diff_hessian_auto.hpp b/stan/math/rev/functor/finite_diff_hessian_auto.hpp index fad9fc0659d..6e63c6f9a9d 100644 --- a/stan/math/rev/functor/finite_diff_hessian_auto.hpp +++ b/stan/math/rev/functor/finite_diff_hessian_auto.hpp @@ -40,9 +40,9 @@ namespace internal { * @param[out] hess_fx Hessian of function at argument */ template -inline void finite_diff_hessian_auto(const F& f, const Eigen::VectorXd& x, - double& fx, Eigen::VectorXd& grad_fx, - Eigen::MatrixXd& hess_fx) { +void finite_diff_hessian_auto(const F& f, const Eigen::VectorXd& x, double& fx, + Eigen::VectorXd& grad_fx, + Eigen::MatrixXd& hess_fx) { int d = x.size(); Eigen::VectorXd x_temp(x); diff --git a/stan/math/rev/functor/finite_diff_hessian_times_vector_auto.hpp b/stan/math/rev/functor/finite_diff_hessian_times_vector_auto.hpp index eed1ff4d882..b86c7c8a6af 100644 --- a/stan/math/rev/functor/finite_diff_hessian_times_vector_auto.hpp +++ b/stan/math/rev/functor/finite_diff_hessian_times_vector_auto.hpp @@ -41,11 +41,9 @@ namespace internal { * @param[out] hvp Product of Hessian and vector at argument */ template -inline void finite_diff_hessian_times_vector_auto(const F& f, - const Eigen::VectorXd& x, - const Eigen::VectorXd& v, - double& fx, - Eigen::VectorXd& hvp) { +void finite_diff_hessian_times_vector_auto(const F& f, const Eigen::VectorXd& x, + const Eigen::VectorXd& v, double& fx, + Eigen::VectorXd& hvp) { fx = f(x); double epsilon = std::sqrt(EPSILON) * (1 + x.norm()) / v.norm(); diff --git a/stan/math/rev/functor/gradient.hpp b/stan/math/rev/functor/gradient.hpp index 0d35456f9e7..984facf177b 100644 --- a/stan/math/rev/functor/gradient.hpp +++ b/stan/math/rev/functor/gradient.hpp @@ -43,10 +43,8 @@ namespace math { * @param[out] grad_fx Gradient of function at argument */ template -inline void gradient(const F& f, - const Eigen::Matrix& x, - double& fx, - Eigen::Matrix& grad_fx) { +void gradient(const F& f, const Eigen::Matrix& x, + double& fx, Eigen::Matrix& grad_fx) { nested_rev_autodiff nested; Eigen::Matrix x_var(x); @@ -101,8 +99,8 @@ inline void gradient(const F& f, */ template * = nullptr> -inline void gradient(const F& f, const EigVec& x, double& fx, - InputIt first_grad_fx, InputIt last_grad_fx) { +void gradient(const F& f, const EigVec& x, double& fx, InputIt first_grad_fx, + InputIt last_grad_fx) { nested_rev_autodiff nested; if (last_grad_fx - first_grad_fx != x.size()) { diff --git a/stan/math/rev/functor/jacobian.hpp b/stan/math/rev/functor/jacobian.hpp index 48351511833..75692b06911 100644 --- a/stan/math/rev/functor/jacobian.hpp +++ b/stan/math/rev/functor/jacobian.hpp @@ -11,10 +11,9 @@ namespace stan { namespace math { template -inline void jacobian(const F& f, - const Eigen::Matrix& x, - Eigen::Matrix& fx, - Eigen::Matrix& J) { +void jacobian(const F& f, const Eigen::Matrix& x, + Eigen::Matrix& fx, + Eigen::Matrix& J) { using Eigen::Dynamic; using Eigen::Matrix; // Run nested autodiff in this scope diff --git a/stan/math/rev/functor/kinsol_solve.hpp b/stan/math/rev/functor/kinsol_solve.hpp index 51b4fef4d57..08e21e73822 100644 --- a/stan/math/rev/functor/kinsol_solve.hpp +++ b/stan/math/rev/functor/kinsol_solve.hpp @@ -58,15 +58,14 @@ namespace math { * negative flag that is not due to hitting max_num_steps. */ template -inline Eigen::VectorXd kinsol_solve( - const F1& f, const Eigen::VectorXd& x, - const double scaling_step_tol, // = 1e-3 - const double function_tolerance, // = 1e-6 - const int64_t max_num_steps, // = 200 - const bool custom_jacobian, // = 1 - const int steps_eval_jacobian, // = 10 - const int global_line_search, // = KIN_LINESEARCH - std::ostream* const msgs, const Args&... args) { +Eigen::VectorXd kinsol_solve(const F1& f, const Eigen::VectorXd& x, + const double scaling_step_tol, // = 1e-3 + const double function_tolerance, // = 1e-6 + const int64_t max_num_steps, // = 200 + const bool custom_jacobian, // = 1 + const int steps_eval_jacobian, // = 10 + const int global_line_search, // = KIN_LINESEARCH + std::ostream* const msgs, const Args&... args) { int N = x.size(); typedef kinsol_system_data system_data; system_data kinsol_data(f, x, msgs, args...); diff --git a/stan/math/rev/functor/map_rect_concurrent.hpp b/stan/math/rev/functor/map_rect_concurrent.hpp index 878261056fb..7b7bf42a643 100644 --- a/stan/math/rev/functor/map_rect_concurrent.hpp +++ b/stan/math/rev/functor/map_rect_concurrent.hpp @@ -20,8 +20,7 @@ namespace internal { template *> -inline Eigen::Matrix, Eigen::Dynamic, - 1> +Eigen::Matrix, Eigen::Dynamic, 1> map_rect_concurrent( const T_shared_param& shared_params, const std::vector>& diff --git a/stan/math/rev/functor/ode_adams.hpp b/stan/math/rev/functor/ode_adams.hpp index 15cd9813c25..500cd2e4c92 100644 --- a/stan/math/rev/functor/ode_adams.hpp +++ b/stan/math/rev/functor/ode_adams.hpp @@ -47,8 +47,8 @@ namespace math { */ template * = nullptr> -inline std::vector, Eigen::Dynamic, 1>> +std::vector, + Eigen::Dynamic, 1>> ode_adams_tol_impl(const char* function_name, const F& f, const T_y0& y0, const T_t0& t0, const std::vector& ts, double relative_tolerance, double absolute_tolerance, @@ -101,8 +101,8 @@ ode_adams_tol_impl(const char* function_name, const F& f, const T_y0& y0, */ template * = nullptr> -inline std::vector, Eigen::Dynamic, 1>> +std::vector, + Eigen::Dynamic, 1>> ode_adams_tol(const F& f, const T_y0& y0, const T_t0& t0, const std::vector& ts, double relative_tolerance, double absolute_tolerance, @@ -144,8 +144,8 @@ ode_adams_tol(const F& f, const T_y0& y0, const T_t0& t0, */ template * = nullptr> -inline std::vector, Eigen::Dynamic, 1>> +std::vector, + Eigen::Dynamic, 1>> ode_adams(const F& f, const T_y0& y0, const T_t0& t0, const std::vector& ts, std::ostream* msgs, const T_Args&... args) { diff --git a/stan/math/rev/functor/ode_adjoint.hpp b/stan/math/rev/functor/ode_adjoint.hpp index 147a3e4b1d7..261788285b0 100644 --- a/stan/math/rev/functor/ode_adjoint.hpp +++ b/stan/math/rev/functor/ode_adjoint.hpp @@ -68,7 +68,7 @@ template * = nullptr, require_any_not_st_arithmetic* = nullptr> -inline auto ode_adjoint_impl( +auto ode_adjoint_impl( const char* function_name, F&& f, const T_y0& y0, const T_t0& t0, const std::vector& ts, double relative_tolerance_forward, const T_abs_tol_fwd& absolute_tolerance_forward, @@ -152,7 +152,7 @@ template * = nullptr, require_all_st_arithmetic* = nullptr> -inline std::vector ode_adjoint_impl( +std::vector ode_adjoint_impl( const char* function_name, F&& f, const T_y0& y0, const T_t0& t0, const std::vector& ts, double relative_tolerance_forward, const T_abs_tol_fwd& absolute_tolerance_forward, @@ -240,7 +240,7 @@ template * = nullptr> -inline auto ode_adjoint_tol_ctl( +auto ode_adjoint_tol_ctl( F&& f, const T_y0& y0, const T_t0& t0, const std::vector& ts, double relative_tolerance_forward, const T_abs_tol_fwd& absolute_tolerance_forward, diff --git a/stan/math/rev/functor/ode_bdf.hpp b/stan/math/rev/functor/ode_bdf.hpp index 98df8616873..009bfe75c00 100644 --- a/stan/math/rev/functor/ode_bdf.hpp +++ b/stan/math/rev/functor/ode_bdf.hpp @@ -48,8 +48,8 @@ namespace math { */ template * = nullptr> -inline std::vector, Eigen::Dynamic, 1>> +std::vector, + Eigen::Dynamic, 1>> ode_bdf_tol_impl(const char* function_name, const F& f, const T_y0& y0, const T_t0& t0, const std::vector& ts, double relative_tolerance, double absolute_tolerance, @@ -102,8 +102,8 @@ ode_bdf_tol_impl(const char* function_name, const F& f, const T_y0& y0, */ template * = nullptr> -inline std::vector, Eigen::Dynamic, 1>> +std::vector, + Eigen::Dynamic, 1>> ode_bdf_tol(const F& f, const T_y0& y0, const T_t0& t0, const std::vector& ts, double relative_tolerance, double absolute_tolerance, @@ -145,8 +145,8 @@ ode_bdf_tol(const F& f, const T_y0& y0, const T_t0& t0, */ template * = nullptr> -inline std::vector, Eigen::Dynamic, 1>> +std::vector, + Eigen::Dynamic, 1>> ode_bdf(const F& f, const T_y0& y0, const T_t0& t0, const std::vector& ts, std::ostream* msgs, const T_Args&... args) { double relative_tolerance = 1e-10; diff --git a/stan/math/rev/functor/ode_store_sensitivities.hpp b/stan/math/rev/functor/ode_store_sensitivities.hpp index f8c9ce942d7..915ed898136 100644 --- a/stan/math/rev/functor/ode_store_sensitivities.hpp +++ b/stan/math/rev/functor/ode_store_sensitivities.hpp @@ -33,7 +33,7 @@ template ...>* = nullptr> -inline Eigen::Matrix ode_store_sensitivities( +Eigen::Matrix ode_store_sensitivities( const F& f, const std::vector& coupled_state, const Eigen::Matrix& y0, const T_t0& t0, const T_t& t, std::ostream* msgs, const Args&... args) { diff --git a/stan/math/rev/functor/solve_newton.hpp b/stan/math/rev/functor/solve_newton.hpp index af7be472323..33a31da6281 100644 --- a/stan/math/rev/functor/solve_newton.hpp +++ b/stan/math/rev/functor/solve_newton.hpp @@ -56,12 +56,12 @@ namespace math { template * = nullptr, require_all_st_arithmetic* = nullptr> -inline Eigen::VectorXd solve_newton_tol(const F& f, const T& x, - const double scaling_step_size, - const double function_tolerance, - const int64_t max_num_steps, - std::ostream* const msgs, - const Args&... args) { +Eigen::VectorXd solve_newton_tol(const F& f, const T& x, + const double scaling_step_size, + const double function_tolerance, + const int64_t max_num_steps, + std::ostream* const msgs, + const Args&... args) { const auto& x_ref = to_ref(value_of(x)); check_nonzero_size("solve_newton", "initial guess", x_ref); @@ -135,7 +135,7 @@ inline Eigen::VectorXd solve_newton_tol(const F& f, const T& x, template * = nullptr, require_any_st_var* = nullptr> -inline Eigen::Matrix solve_newton_tol( +Eigen::Matrix solve_newton_tol( const F& f, const T& x, const double scaling_step_size, const double function_tolerance, const int64_t max_num_steps, std::ostream* const msgs, const T_Args&... args) { @@ -236,9 +236,8 @@ inline Eigen::Matrix solve_newton_tol( */ template * = nullptr> -inline Eigen::Matrix, Eigen::Dynamic, 1> -solve_newton(const F& f, const T& x, std::ostream* const msgs, - const T_Args&... args) { +Eigen::Matrix, Eigen::Dynamic, 1> solve_newton( + const F& f, const T& x, std::ostream* const msgs, const T_Args&... args) { double scaling_step_size = 1e-3; double function_tolerance = 1e-6; int64_t max_num_steps = 200; @@ -293,15 +292,12 @@ solve_newton(const F& f, const T& x, std::ostream* const msgs, */ template * = nullptr> -inline Eigen::Matrix, Eigen::Dynamic, 1> -algebra_solver_newton(const F& f, const T1& x, const T2& y, - const std::vector& dat, - const std::vector& dat_int, - std::ostream* const msgs = nullptr, - const double scaling_step_size = 1e-3, - const double function_tolerance = 1e-6, - const int64_t max_num_steps - = 200) { // NOLINT(runtime/int) +Eigen::Matrix, Eigen::Dynamic, 1> algebra_solver_newton( + const F& f, const T1& x, const T2& y, const std::vector& dat, + const std::vector& dat_int, std::ostream* const msgs = nullptr, + const double scaling_step_size = 1e-3, + const double function_tolerance = 1e-6, + const long int max_num_steps = 200) { // NOLINT(runtime/int) return solve_newton_tol(algebra_solver_adapter(f), x, scaling_step_size, function_tolerance, max_num_steps, msgs, y, dat, dat_int); diff --git a/stan/math/rev/functor/solve_powell.hpp b/stan/math/rev/functor/solve_powell.hpp index 2696ff1d69d..587875c2445 100644 --- a/stan/math/rev/functor/solve_powell.hpp +++ b/stan/math/rev/functor/solve_powell.hpp @@ -45,11 +45,10 @@ namespace math { */ template * = nullptr> -inline T& solve_powell_call_solver(const F& f, T& x, std::ostream* const msgs, - const double relative_tolerance, - const double function_tolerance, - const int64_t max_num_steps, - const Args&... args) { +T& solve_powell_call_solver(const F& f, T& x, std::ostream* const msgs, + const double relative_tolerance, + const double function_tolerance, + const int64_t max_num_steps, const Args&... args) { // Construct the solver hybrj_functor_solver hfs(f); Eigen::HybridNonLinearSolver> solver(hfs); @@ -126,12 +125,12 @@ inline T& solve_powell_call_solver(const F& f, T& x, std::ostream* const msgs, template * = nullptr, require_all_st_arithmetic* = nullptr> -inline Eigen::VectorXd solve_powell_tol(const F& f, const T& x, - const double relative_tolerance, - const double function_tolerance, - const int64_t max_num_steps, - std::ostream* const msgs, - const Args&... args) { +Eigen::VectorXd solve_powell_tol(const F& f, const T& x, + const double relative_tolerance, + const double function_tolerance, + const int64_t max_num_steps, + std::ostream* const msgs, + const Args&... args) { auto x_ref = eval(value_of(x)); auto args_vals_tuple = std::make_tuple(to_ref(args)...); @@ -186,9 +185,8 @@ inline Eigen::VectorXd solve_powell_tol(const F& f, const T& x, */ template * = nullptr> -inline Eigen::Matrix, Eigen::Dynamic, 1> -solve_powell(const F& f, const T& x, std::ostream* const msgs, - const T_Args&... args) { +Eigen::Matrix, Eigen::Dynamic, 1> solve_powell( + const F& f, const T& x, std::ostream* const msgs, const T_Args&... args) { double relative_tolerance = 1e-10; double function_tolerance = 1e-6; int64_t max_num_steps = 200; @@ -250,7 +248,7 @@ solve_powell(const F& f, const T& x, std::ostream* const msgs, */ template * = nullptr> -inline Eigen::Matrix, Eigen::Dynamic, 1> algebra_solver( +Eigen::Matrix, Eigen::Dynamic, 1> algebra_solver( const F& f, const T1& x, const T2& y, const std::vector& dat, const std::vector& dat_int, std::ostream* msgs = nullptr, const double relative_tolerance = 1e-10, @@ -324,7 +322,7 @@ inline Eigen::Matrix, Eigen::Dynamic, 1> algebra_solver( template * = nullptr, require_any_st_var* = nullptr> -inline Eigen::Matrix solve_powell_tol( +Eigen::Matrix solve_powell_tol( const F& f, const T& x, const double relative_tolerance, const double function_tolerance, const int64_t max_num_steps, std::ostream* const msgs, const T_Args&... args) { diff --git a/test/expressions/expression_test_helpers.hpp b/test/expressions/expression_test_helpers.hpp index 96a09540a9d..43551bfdfbb 100644 --- a/test/expressions/expression_test_helpers.hpp +++ b/test/expressions/expression_test_helpers.hpp @@ -113,42 +113,42 @@ T make_pos_definite_matrix(double value = 0.4, int size = 1) { } template * = nullptr> -inline void expect_eq(T a, T b, const char* msg) { +void expect_eq(T a, T b, const char* msg) { EXPECT_EQ(a, b) << msg; } -inline void expect_eq(math::var a, math::var b, const char* msg) { +void expect_eq(math::var a, math::var b, const char* msg) { EXPECT_EQ(a.val(), b.val()) << msg; } template * = nullptr> -inline void expect_eq(math::fvar a, math::fvar b, const char* msg) { +void expect_eq(math::fvar a, math::fvar b, const char* msg) { expect_eq(a.val(), b.val(), msg); expect_eq(a.d(), b.d(), msg); } template * = nullptr> -inline void expect_eq(std::complex a, std::complex b, const char* msg) { +void expect_eq(std::complex a, std::complex b, const char* msg) { expect_eq(a.real(), b.real(), msg); expect_eq(a.imag(), b.imag(), msg); } -inline void expect_eq(std::complex a, std::complex b, - const char* msg) { +void expect_eq(std::complex a, std::complex b, + const char* msg) { expect_eq(a.real(), b.real(), msg); expect_eq(a.imag(), b.imag(), msg); } template * = nullptr> -inline void expect_eq(std::complex> a, - std::complex> b, const char* msg) { +void expect_eq(std::complex> a, std::complex> b, + const char* msg) { expect_eq(a.real(), b.real(), msg); expect_eq(a.imag(), b.imag(), msg); } template * = nullptr, require_vt_same* = nullptr> -inline void expect_eq(const T1& a, const T2& b, const char* msg) { +void expect_eq(const T1& a, const T2& b, const char* msg) { EXPECT_EQ(a.rows(), b.rows()) << msg; EXPECT_EQ(a.cols(), b.cols()) << msg; const auto& a_ref = math::to_ref(a); @@ -161,8 +161,8 @@ inline void expect_eq(const T1& a, const T2& b, const char* msg) { } template -inline void expect_eq(const std::vector& a, const std::vector& b, - const char* msg) { +void expect_eq(const std::vector& a, const std::vector& b, + const char* msg) { EXPECT_EQ(a.size(), b.size()); for (int i = 0; i < a.size(); i++) { expect_eq(a[i], b[i], msg); @@ -170,24 +170,21 @@ inline void expect_eq(const std::vector& a, const std::vector& b, } template * = nullptr> -inline void expect_eq(const T& t1, const T& t2, const char* msg) { +void expect_eq(const T& t1, const T& t2, const char* msg) { stan::math::for_each( [&msg](auto&& elt1, auto&& elt2) { expect_eq(elt1, elt2, msg); }, t1, t2); } template * = nullptr> -inline void expect_adj_eq(const T& a, const T& b, - const char* msg = "expect_ad_eq") {} +void expect_adj_eq(const T& a, const T& b, const char* msg = "expect_ad_eq") {} -inline void expect_adj_eq(math::var a, math::var b, - const char* msg = "expect_ad_eq") { +void expect_adj_eq(math::var a, math::var b, const char* msg = "expect_ad_eq") { EXPECT_EQ(a.adj(), b.adj()) << msg; } template * = nullptr, require_vt_same* = nullptr> -inline void expect_adj_eq(const T1& a, const T2& b, - const char* msg = "expect_ad_eq") { +void expect_adj_eq(const T1& a, const T2& b, const char* msg = "expect_ad_eq") { EXPECT_EQ(a.rows(), b.rows()) << msg; EXPECT_EQ(a.cols(), b.cols()) << msg; const auto& a_ref = math::to_ref(a); @@ -200,16 +197,16 @@ inline void expect_adj_eq(const T1& a, const T2& b, } template -inline void expect_adj_eq(const std::vector& a, const std::vector& b, - const char* msg = "expect_ad_eq") { +void expect_adj_eq(const std::vector& a, const std::vector& b, + const char* msg = "expect_ad_eq") { EXPECT_EQ(a.size(), b.size()) << msg; for (int i = 0; i < a.size(); i++) { expect_adj_eq(a[i], b[i], msg); } } -inline void grad(stan::math::var& a) { a.grad(); } -inline void grad(std::complex& a) { +void grad(stan::math::var& a) { a.grad(); } +void grad(std::complex& a) { a.real().grad(); a.imag().grad(); } @@ -228,7 +225,7 @@ scalar_type_t sum_if_number(const T& a) { return recursive_sum(a); } template * = nullptr> -inline double sum_if_number(const T& a) { +double sum_if_number(const T& a) { return 0; } diff --git a/test/prob/generate_tests.cpp b/test/prob/generate_tests.cpp index d54f377721d..f9563f839ae 100644 --- a/test/prob/generate_tests.cpp +++ b/test/prob/generate_tests.cpp @@ -22,7 +22,7 @@ int ROW_VECTORS = 1; int ROW_VECTORS = 0; #endif -inline void push_args(vector& args, const string& type) { +void push_args(vector& args, const string& type) { if (type.compare("varmat") == 0) { args.push_back("var"); args.push_back("std::vector"); @@ -40,7 +40,7 @@ inline void push_args(vector& args, const string& type) { } } -inline vector lookup_argument(const string& argument, const int& ind) { +vector lookup_argument(const string& argument, const int& ind) { using boost::iequals; vector args; if (iequals(argument, "int")) { @@ -83,7 +83,7 @@ std::ostream& operator<<(std::ostream& o, vector& vec) { return o; } -inline void write_includes(vector& outs, const string& include) { +void write_includes(vector& outs, const string& include) { for (size_t n = 0; n < outs.size(); n++) { std::ostream* out = outs[n]; *out << "#include " << endl; @@ -97,7 +97,7 @@ inline void write_includes(vector& outs, const string& include) { } } -inline vector tokenize_arguments(const string& arguments) { +vector tokenize_arguments(const string& arguments) { vector tokens; string delimiters = ", "; string args_only_string = arguments.substr(arguments.find(":") + 1); @@ -117,7 +117,7 @@ size_t size(const vector >& sequences) { return N; } -inline bool is_argument_list(const string& line) { +bool is_argument_list(const string& line) { size_t comment = line.find("// "); if (comment == string::npos) return false; @@ -180,8 +180,8 @@ pair read_test_name_from_file(const string& file) { return name; } -inline vector > build_argument_sequence(const string& arguments, - const int& ind) { +vector > build_argument_sequence(const string& arguments, + const int& ind) { vector argument_list = tokenize_arguments(arguments); vector > argument_sequence; for (size_t n = 0; n < argument_list.size(); n++) @@ -244,11 +244,10 @@ int num_ints(string arguments) { return num; } -inline void write_types_typedef(vector& outs, string base, - size_t& N, - vector > argument_sequence, - const size_t depth, const int& index, - const int& N_TESTS) { +void write_types_typedef(vector& outs, string base, size_t& N, + vector > argument_sequence, + const size_t depth, const int& index, + const int& N_TESTS) { vector args = argument_sequence.front(); argument_sequence.erase(argument_sequence.begin()); if (argument_sequence.size() > 0) { @@ -301,9 +300,9 @@ size_t write_types(vector& outs, return N; } -inline void write_test(vector& outs, const string& test_name, - const string& fixture_name, const size_t N, - const int& index, const int& N_TESTS) { +void write_test(vector& outs, const string& test_name, + const string& fixture_name, const size_t N, const int& index, + const int& N_TESTS) { for (size_t n = 0; n < N; n++) { std::ostream* out = outs[int(n / N_TESTS)]; if (index == 1) @@ -360,9 +359,9 @@ inline void write_test(vector& outs, const string& test_name, } } -inline void write_test_cases(vector& outs, const string& file, - const vector >& argument_sequence, - const int& index, const int& N_TESTS) { +void write_test_cases(vector& outs, const string& file, + const vector >& argument_sequence, + const int& index, const int& N_TESTS) { pair name = read_test_name_from_file(file); string test_name = name.first; string fixture_name = name.second; diff --git a/test/prob/utility.hpp b/test/prob/utility.hpp index 0a6a7ee0857..757a035be5c 100644 --- a/test/prob/utility.hpp +++ b/test/prob/utility.hpp @@ -56,7 +56,7 @@ std::ostream& operator<<(std::ostream& os, const vector& param) { // ------------------------------------------------------------ template -inline T get_param(const vector& params, const size_t n) { +T get_param(const vector& params, const size_t n) { T param = 0; if (n < params.size()) param = params[n]; @@ -69,8 +69,8 @@ empty get_param(const vector& /*params*/, const size_t /*n*/) { } template <> -inline fvar get_param>(const vector& params, - const size_t n) { +fvar get_param>(const vector& params, + const size_t n) { fvar param = 0; if (n < params.size()) { param = params[n]; @@ -79,8 +79,7 @@ inline fvar get_param>(const vector& params, return param; } template <> -inline fvar get_param>(const vector& params, - const size_t n) { +fvar get_param>(const vector& params, const size_t n) { fvar param = 0; if (n < params.size()) { param = params[n]; @@ -89,8 +88,8 @@ inline fvar get_param>(const vector& params, return param; } template <> -inline fvar> get_param>>( - const vector& params, const size_t n) { +fvar> get_param>>(const vector& params, + const size_t n) { fvar> param = 0; if (n < params.size()) { param = params[n]; @@ -99,8 +98,8 @@ inline fvar> get_param>>( return param; } template <> -inline fvar> get_param>>(const vector& params, - const size_t n) { +fvar> get_param>>(const vector& params, + const size_t n) { fvar> param = 0; if (n < params.size()) { param = params[n]; @@ -113,7 +112,7 @@ inline fvar> get_param>>(const vector& params, // default template handles Eigen::Matrix template * = nullptr> -inline T get_params(const vector>& parameters, const size_t p) { +T get_params(const vector>& parameters, const size_t p) { T param(parameters.size()); for (size_t n = 0; n < parameters.size(); n++) if (p < parameters[0].size()) @@ -123,7 +122,7 @@ inline T get_params(const vector>& parameters, const size_t p) { // handle `var_value` where T is an Eigen type template * = nullptr> -inline T get_params(const vector>& parameters, const size_t p) { +T get_params(const vector>& parameters, const size_t p) { typename T::value_type param(parameters.size()); for (size_t n = 0; n < parameters.size(); n++) if (p < parameters[0].size()) @@ -139,24 +138,23 @@ empty get_params(const vector>& /*parameters*/, } // handle scalars template <> -inline double get_params(const vector>& parameters, - const size_t p) { +double get_params(const vector>& parameters, + const size_t p) { double param(0); if (p < parameters[0].size()) param = parameters[0][p]; return param; } template <> -inline var get_params(const vector>& parameters, - const size_t p) { +var get_params(const vector>& parameters, const size_t p) { var param(0); if (p < parameters[0].size()) param = parameters[0][p]; return param; } template <> -inline fvar get_params>( - const vector>& parameters, const size_t p) { +fvar get_params>(const vector>& parameters, + const size_t p) { fvar param(0); if (p < parameters[0].size()) { param = parameters[0][p]; @@ -165,8 +163,8 @@ inline fvar get_params>( return param; } template <> -inline fvar get_params>(const vector>& parameters, - const size_t p) { +fvar get_params>(const vector>& parameters, + const size_t p) { fvar param(0); if (p < parameters[0].size()) { param = parameters[0][p]; @@ -203,8 +201,8 @@ int get_params(const vector>& parameters, const size_t p) { } // handle vectors template <> -inline vector get_params>( - const vector>& parameters, const size_t p) { +vector get_params>(const vector>& parameters, + const size_t p) { vector param(parameters.size()); for (size_t n = 0; n < parameters.size(); n++) if (p < parameters[0].size()) @@ -221,8 +219,8 @@ vector get_params>( return param; } template <> -inline vector get_params>( - const vector>& parameters, const size_t p) { +vector get_params>(const vector>& parameters, + const size_t p) { vector param(parameters.size()); for (size_t n = 0; n < parameters.size(); n++) if (p < parameters[0].size()) @@ -278,8 +276,8 @@ vector>> get_params>>>( // default template handles Eigen::Matrix template * = nullptr> -inline T get_params(const vector>& parameters, - const size_t /*n*/, const size_t p) { +T get_params(const vector>& parameters, const size_t /*n*/, + const size_t p) { T param(parameters.size()); for (size_t i = 0; i < parameters.size(); i++) if (p < parameters[0].size()) @@ -289,8 +287,8 @@ inline T get_params(const vector>& parameters, // handle `var_value` where T is an Eigen type template * = nullptr> -inline T get_params(const vector>& parameters, - const size_t /*n*/, const size_t p) { +T get_params(const vector>& parameters, const size_t /*n*/, + const size_t p) { typename T::value_type param(parameters.size()); for (size_t i = 0; i < parameters.size(); i++) if (p < parameters[0].size()) @@ -306,24 +304,24 @@ empty get_params(const vector>& /*parameters*/, } // handle scalars template <> -inline double get_params(const vector>& parameters, - const size_t n, const size_t p) { +double get_params(const vector>& parameters, + const size_t n, const size_t p) { double param(0); if (p < parameters[0].size()) param = parameters[n][p]; return param; } template <> -inline var get_params(const vector>& parameters, - const size_t n, const size_t p) { +var get_params(const vector>& parameters, const size_t n, + const size_t p) { var param(0); if (p < parameters[0].size()) param = parameters[n][p]; return param; } template <> -inline fvar get_params>( - const vector>& parameters, const size_t n, const size_t p) { +fvar get_params>(const vector>& parameters, + const size_t n, const size_t p) { fvar param(0); if (p < parameters[0].size()) { param = parameters[n][p]; @@ -332,8 +330,8 @@ inline fvar get_params>( return param; } template <> -inline fvar get_params>(const vector>& parameters, - const size_t n, const size_t p) { +fvar get_params>(const vector>& parameters, + const size_t n, const size_t p) { fvar param(0); if (p < parameters[0].size()) { param = parameters[n][p]; @@ -371,9 +369,8 @@ int get_params(const vector>& parameters, const size_t n, } // handle vectors template <> -inline vector get_params>( - const vector>& parameters, const size_t /*n*/, - const size_t p) { +vector get_params>(const vector>& parameters, + const size_t /*n*/, const size_t p) { vector param(parameters.size()); for (size_t i = 0; i < parameters.size(); i++) if (p < parameters[0].size()) @@ -391,9 +388,8 @@ vector get_params>( return param; } template <> -inline vector get_params>( - const vector>& parameters, const size_t /*n*/, - const size_t p) { +vector get_params>(const vector>& parameters, + const size_t /*n*/, const size_t p) { vector param(parameters.size()); for (size_t i = 0; i < parameters.size(); i++) if (p < parameters[0].size()) @@ -452,8 +448,8 @@ vector>> get_params>>>( // ------------------------------------------------------------ // default template handles Eigen::Matrix template * = nullptr> -inline T get_repeated_params(const vector& parameters, const size_t p, - const size_t N_REPEAT) { +T get_repeated_params(const vector& parameters, const size_t p, + const size_t N_REPEAT) { T params(N_REPEAT); stan::value_type_t param; @@ -471,8 +467,8 @@ inline T get_repeated_params(const vector& parameters, const size_t p, // handle `var_value` where T is an Eigen type template * = nullptr> -inline T get_repeated_params(const vector& parameters, const size_t p, - const size_t N_REPEAT) { +T get_repeated_params(const vector& parameters, const size_t p, + const size_t N_REPEAT) { typename T::value_type params(N_REPEAT); double param; @@ -490,8 +486,8 @@ inline T get_repeated_params(const vector& parameters, const size_t p, // handle `std::vector` template * = nullptr> -inline T get_repeated_params(const vector& parameters, const size_t p, - const size_t N_REPEAT) { +T get_repeated_params(const vector& parameters, const size_t p, + const size_t N_REPEAT) { T params(N_REPEAT); stan::value_type_t param; @@ -510,15 +506,14 @@ inline T get_repeated_params(const vector& parameters, const size_t p, // handle empty template ::value>* = nullptr> -inline T get_repeated_params(const vector&, const size_t, - const size_t) { +T get_repeated_params(const vector&, const size_t, const size_t) { return T(); } // handle scalars template * = nullptr> -inline T get_repeated_params(const vector& parameters, const size_t p, - const size_t /*N_REPEAT*/) { +T get_repeated_params(const vector& parameters, const size_t p, + const size_t /*N_REPEAT*/) { if (p < parameters.size()) return get_param(parameters, p); else @@ -598,88 +593,86 @@ struct any_vector { // ------------------------------------------------------------ template * = nullptr> -inline void add_adjoints(vector& /*x*/, T& /*p*/) {} +void add_adjoints(vector& /*x*/, T& /*p*/) {} template <> -inline void add_adjoints(vector& x, var& p) { +void add_adjoints(vector& x, var& p) { x.push_back(p.adj()); } template * = nullptr> -inline void add_adjoints(vector& x, T& p) { +void add_adjoints(vector& x, T& p) { for (size_type n = 0; n < p.size(); n++) { x.push_back(p.adj().coeff(n)); } } template <> -inline void add_adjoints>(vector& x, vector& p) { +void add_adjoints>(vector& x, vector& p) { for (size_type n = 0; n < p.size(); n++) x.push_back(p[n].adj()); } template <> -inline void add_adjoints>( +void add_adjoints>( vector& x, Eigen::Matrix& p) { for (size_type n = 0; n < p.size(); n++) x.push_back(p(n).adj()); } template <> -inline void add_adjoints>( +void add_adjoints>( vector& x, Eigen::Matrix& p) { for (size_type n = 0; n < p.size(); n++) x.push_back(p(n).adj()); } template <> -inline void add_adjoints>(vector& x, fvar& p) { +void add_adjoints>(vector& x, fvar& p) { x.push_back(p.val_.adj()); } template <> -inline void add_adjoints>>(vector& x, - vector>& p) { +void add_adjoints>>(vector& x, vector>& p) { for (size_t n = 0; n < p.size(); n++) x.push_back(p[n].val_.adj()); } template <> -inline void add_adjoints, 1, Eigen::Dynamic>>( +void add_adjoints, 1, Eigen::Dynamic>>( vector& x, Eigen::Matrix, 1, Eigen::Dynamic>& p) { for (size_type n = 0; n < p.size(); n++) x.push_back(p(n).val_.adj()); } template <> -inline void add_adjoints, Eigen::Dynamic, 1>>( +void add_adjoints, Eigen::Dynamic, 1>>( vector& x, Eigen::Matrix, Eigen::Dynamic, 1>& p) { for (size_type n = 0; n < p.size(); n++) x.push_back(p(n).val_.adj()); } template <> -inline void add_adjoints>>(vector& x, - fvar>& p) { +void add_adjoints>>(vector& x, fvar>& p) { x.push_back(p.val_.val_.adj()); } template <> -inline void add_adjoints>>>(vector& x, - vector>>& p) { +void add_adjoints>>>(vector& x, + vector>>& p) { for (size_t n = 0; n < p.size(); n++) x.push_back(p[n].val_.val_.adj()); } template <> -inline void add_adjoints>, 1, Eigen::Dynamic>>( +void add_adjoints>, 1, Eigen::Dynamic>>( vector& x, Eigen::Matrix>, 1, Eigen::Dynamic>& p) { for (size_type n = 0; n < p.size(); n++) x.push_back(p(n).val_.val_.adj()); } template <> -inline void add_adjoints>, Eigen::Dynamic, 1>>( +void add_adjoints>, Eigen::Dynamic, 1>>( vector& x, Eigen::Matrix>, Eigen::Dynamic, 1>& p) { for (size_type n = 0; n < p.size(); n++) x.push_back(p(n).val_.val_.adj()); @@ -687,8 +680,8 @@ inline void add_adjoints>, Eigen::Dynamic, 1>>( template -inline void add_adjoints(vector& x, T0& p0, T1& p1, T2& p2, T3& p3, - T4& p4, T5& p5) { +void add_adjoints(vector& x, T0& p0, T1& p1, T2& p2, T3& p3, T4& p4, + T5& p5) { if (!is_constant_all::value) add_adjoints(x, p0); if (!is_constant_all::value) diff --git a/test/prob/yule_simon/yule_simon_ccdf_log_test.hpp b/test/prob/yule_simon/yule_simon_ccdf_log_test.hpp deleted file mode 100644 index d5dbe5521b3..00000000000 --- a/test/prob/yule_simon/yule_simon_ccdf_log_test.hpp +++ /dev/null @@ -1,65 +0,0 @@ -// Arguments: Ints, Doubles -#include -#include - -using std::numeric_limits; -using std::vector; - -class AgradCcdfLogYuleSimon : public AgradCcdfLogTest { - public: - void valid_values(vector>& parameters, - vector& cdf_log) { - vector param(2); - - param[0] = 5; // n - param[1] = 20.0; // alpha - parameters.push_back(param); - cdf_log.push_back(std::log(1.0 - 0.9999811782420478)); // expected ccdf_log - - param[0] = 10; // n - param[1] = 5.5; // alpha - parameters.push_back(param); - cdf_log.push_back(std::log(1.0 - 0.9997987132162779)); // expected ccdf_log - } - - void invalid_values(vector& index, vector& value) { - // n - - // alpha - index.push_back(1U); - value.push_back(0.0); - - index.push_back(1U); - value.push_back(-1.0); - - index.push_back(1U); - value.push_back(std::numeric_limits::infinity()); - } - - // BOUND INCLUDED IN ORDER FOR TEST TO PASS WITH CURRENT FRAMEWORK - bool has_lower_bound() { return false; } - - bool has_upper_bound() { return false; } - - template - stan::return_type_t ccdf_log(const T_n& n, const T_alpha& alpha, - const T2&, const T3&, const T4&, - const T5&) { - return stan::math::yule_simon_lccdf(n, alpha); - } - - template - stan::return_type_t ccdf_log_function(const T_n& n, - const T_alpha& alpha, - const T2&, const T3&, - const T4&, const T5&) { - using stan::math::lgamma; - - auto log_ccdf - = lgamma(alpha + 1.0) + lgamma(n + 1.0) - lgamma(n + alpha + 1.0); - - return log_ccdf; - } -}; diff --git a/test/unit/math/expect_near_rel.hpp b/test/unit/math/expect_near_rel.hpp index b755ed53d8d..7d05c91850a 100644 --- a/test/unit/math/expect_near_rel.hpp +++ b/test/unit/math/expect_near_rel.hpp @@ -26,12 +26,10 @@ namespace internal { * @param tol relative tolerance */ template ...> -inline void expect_near_rel_finite(const std::string& msg, const T1& x1, - const T2& x2, - const relative_tolerance tol - = relative_tolerance(), - const char* x1_name = "x1", - const char* x2_name = "x2") { +void expect_near_rel_finite(const std::string& msg, const T1& x1, const T2& x2, + const relative_tolerance tol = relative_tolerance(), + const char* x1_name = "x1", + const char* x2_name = "x2") { double tol_val = tol.inexact(x1, x2); EXPECT_NEAR(x1, x2, tol_val) << "expect_near_rel_finite in: " << msg << " for " << x1_name << " vs " @@ -40,10 +38,9 @@ inline void expect_near_rel_finite(const std::string& msg, const T1& x1, template ...> -inline void expect_near_rel_finite(const std::string& msg, const EigMat1& x1, - const EigMat2& x2, - const char* x1_name = "x1", - const char* x2_name = "x2") { +void expect_near_rel_finite(const std::string& msg, const EigMat1& x1, + const EigMat2& x2, const char* x1_name = "x1", + const char* x2_name = "x2") { EXPECT_EQ(x1.rows(), x2.rows()); EXPECT_EQ(x1.cols(), x2.cols()); auto x1_eval = x1.eval(); @@ -54,11 +51,10 @@ inline void expect_near_rel_finite(const std::string& msg, const EigMat1& x1, } template -inline void expect_near_rel_finite(const std::string& msg, - const std::vector& x1, - const std::vector& x2, - const char* x1_name = "x1", - const char* x2_name = "x2") { +void expect_near_rel_finite(const std::string& msg, const std::vector& x1, + const std::vector& x2, + const char* x1_name = "x1", + const char* x2_name = "x2") { EXPECT_EQ(x1.size(), x2.size()); for (size_t i = 0; i < x1.size(); ++i) { expect_near_rel_finite(x1[i], x2[i], x1_name, x2_name); @@ -82,10 +78,9 @@ inline void expect_near_rel_finite(const std::string& msg, * @param tol relative tolerance */ template ...> -inline void expect_near_rel(const std::string& msg, const T1& x1, const T2& x2, - relative_tolerance tol = relative_tolerance(), - const char* x1_name = "x1", - const char* x2_name = "x2") { +void expect_near_rel(const std::string& msg, const T1& x1, const T2& x2, + relative_tolerance tol = relative_tolerance(), + const char* x1_name = "x1", const char* x2_name = "x2") { if (stan::math::is_nan(x1) || stan::math::is_nan(x2)) { EXPECT_TRUE(stan::math::is_nan(x1) && stan::math::is_nan(x2)) << "expect_near_rel(" << x1 << ", " << x2 << ")" << std::endl @@ -117,10 +112,9 @@ inline void expect_near_rel(const std::string& msg, const T1& x1, const T2& x2, */ template ...> -inline void expect_near_rel(const std::string& msg, EigMat1&& x1, EigMat2&& x2, - relative_tolerance tol = relative_tolerance(), - const char* x1_name = "x1", - const char* x2_name = "x2") { +void expect_near_rel(const std::string& msg, EigMat1&& x1, EigMat2&& x2, + relative_tolerance tol = relative_tolerance(), + const char* x1_name = "x1", const char* x2_name = "x2") { EXPECT_EQ(x1.rows(), x2.rows()) << "expect_near_rel (Eigen::Matrix)" << " rows must be same size." << x1_name << ".rows() = " << x1.rows() @@ -138,7 +132,7 @@ inline void expect_near_rel(const std::string& msg, EigMat1&& x1, EigMat2&& x2, for (int j = 0; j < x1.cols(); ++j) { for (int i = 0; i < x1.rows(); ++i) { std::string msg2 = std::string("expect_near_rel; require items x1("); - if constexpr (stan::is_vector::value) { + if (stan::is_vector::value) { msg2 += std::to_string(sentinal_val) + ") = x2(" + std::to_string(sentinal_val) + "): " + msg; } else { @@ -173,11 +167,10 @@ inline void expect_near_rel(const std::string& msg, EigMat1&& x1, EigMat2&& x2, * @param[in] tol relative tolerance */ template -inline void expect_near_rel(const std::string& msg, const std::vector& x1, - const std::vector& x2, - relative_tolerance tol = relative_tolerance(), - const char* x1_name = "x1", - const char* x2_name = "x2") { +void expect_near_rel(const std::string& msg, const std::vector& x1, + const std::vector& x2, + relative_tolerance tol = relative_tolerance(), + const char* x1_name = "x1", const char* x2_name = "x2") { EXPECT_EQ(x1.size(), x2.size()) << "expect_near_rel (std::vector):" << " vectors must be same size. " << x1_name << ".size() = " << x1.size() @@ -202,11 +195,10 @@ inline void expect_near_rel(const std::string& msg, const std::vector& x1, * @param tol[in] tolerance for comparison */ template -inline void expect_near_rel(const std::string& msg, const std::complex& z1, - const std::complex& z2, - relative_tolerance tol = relative_tolerance(), - const char* x1_name = "x1", - const char* x2_name = "x2") { +void expect_near_rel(const std::string& msg, const std::complex& z1, + const std::complex& z2, + relative_tolerance tol = relative_tolerance(), + const char* x1_name = "x1", const char* x2_name = "x2") { expect_near_rel(msg, z1.real(), z2.real(), tol, x1_name, x2_name); expect_near_rel(msg, z1.imag(), z2.imag(), tol, x1_name, x2_name); } @@ -225,11 +217,10 @@ inline void expect_near_rel(const std::string& msg, const std::complex& z1, * @param tol[in] tolerance for comparison */ template -inline void expect_near_rel(const std::string& msg, const T1& x1, - const std::complex& z2, - relative_tolerance tol = relative_tolerance(), - const char* x1_name = "x1", - const char* x2_name = "x2") { +void expect_near_rel(const std::string& msg, const T1& x1, + const std::complex& z2, + relative_tolerance tol = relative_tolerance(), + const char* x1_name = "x1", const char* x2_name = "x2") { expect_near_rel(msg, x1, z2.real(), tol, x1_name, x2_name); expect_near_rel(msg, 0, z2.imag(), tol, x1_name, x2_name); } @@ -248,11 +239,10 @@ inline void expect_near_rel(const std::string& msg, const T1& x1, * @param tol[in] tolerance for comparison */ template -inline void expect_near_rel(const std::string& msg, const std::complex& z1, - const T2& x2, - relative_tolerance tol = relative_tolerance(), - const char* x1_name = "x1", - const char* x2_name = "x2") { +void expect_near_rel(const std::string& msg, const std::complex& z1, + const T2& x2, + relative_tolerance tol = relative_tolerance(), + const char* x1_name = "x1", const char* x2_name = "x2") { expect_near_rel(msg, z1.real(), x2, tol, x1_name, x2_name); expect_near_rel(msg, z1.imag(), 0, tol, x1_name, x2_name); } diff --git a/test/unit/math/fwd/core/std_iterator_traits_test.cpp b/test/unit/math/fwd/core/std_iterator_traits_test.cpp index 1dc75e69364..6a4d2edb352 100644 --- a/test/unit/math/fwd/core/std_iterator_traits_test.cpp +++ b/test/unit/math/fwd/core/std_iterator_traits_test.cpp @@ -2,7 +2,7 @@ #include template -inline void expect_iterator_traits() { +void expect_iterator_traits() { using traits = std::iterator_traits; T a; T b; diff --git a/test/unit/math/fwd/fun/accumulator_test.cpp b/test/unit/math/fwd/fun/accumulator_test.cpp index 3d0f6657298..70e217d56d3 100644 --- a/test/unit/math/fwd/fun/accumulator_test.cpp +++ b/test/unit/math/fwd/fun/accumulator_test.cpp @@ -4,7 +4,7 @@ // test sum of first n numbers for sum of a template -inline void test_sum(stan::math::accumulator& a, int n) { +void test_sum(stan::math::accumulator& a, int n) { EXPECT_TRUE((n * (n + 1)) / 2 == a.sum()); } diff --git a/test/unit/math/fwd/fun/rank_test.cpp b/test/unit/math/fwd/fun/rank_test.cpp index a0b4c2ca2f0..3d62240c411 100644 --- a/test/unit/math/fwd/fun/rank_test.cpp +++ b/test/unit/math/fwd/fun/rank_test.cpp @@ -4,7 +4,7 @@ #include template -inline void test_rank() { +void test_rank() { using stan::math::rank; T c(1); @@ -38,7 +38,7 @@ inline void test_rank() { } template -inline void test_rank_int() { +void test_rank_int() { using stan::math::rank; T c(1); diff --git a/test/unit/math/fwd/fun/sort_indices_test.cpp b/test/unit/math/fwd/fun/sort_indices_test.cpp index 7a72ae516e5..43a9431f824 100644 --- a/test/unit/math/fwd/fun/sort_indices_test.cpp +++ b/test/unit/math/fwd/fun/sort_indices_test.cpp @@ -2,7 +2,7 @@ #include #include -inline void test_sort_indices_asc(std::vector val) { +void test_sort_indices_asc(std::vector val) { using stan::math::fvar; using stan::math::sort_indices_asc; using stan::math::sort_indices_desc; @@ -24,7 +24,7 @@ inline void test_sort_indices_asc(std::vector val) { EXPECT_FALSE(x_sorted[i] == x[j]); } -inline void test_sort_indices_asc3(std::vector val) { +void test_sort_indices_asc3(std::vector val) { using stan::math::fvar; using stan::math::sort_indices_asc; using stan::math::sort_indices_desc; @@ -46,7 +46,7 @@ inline void test_sort_indices_asc3(std::vector val) { EXPECT_FALSE(x_sorted[i] == x[j]); } -inline void test_sort_indices_desc(std::vector val) { +void test_sort_indices_desc(std::vector val) { using stan::math::fvar; using stan::math::sort_indices_asc; using stan::math::sort_indices_desc; @@ -68,7 +68,7 @@ inline void test_sort_indices_desc(std::vector val) { EXPECT_FALSE(x_sorted[i] == x[j]); } -inline void test_sort_indices_desc3(std::vector val) { +void test_sort_indices_desc3(std::vector val) { using stan::math::fvar; using stan::math::sort_indices_asc; using stan::math::sort_indices_desc; @@ -91,7 +91,7 @@ inline void test_sort_indices_desc3(std::vector val) { } template -inline void test_sort_indices_asc(Eigen::Matrix val) { +void test_sort_indices_asc(Eigen::Matrix val) { using stan::math::fvar; using stan::math::sort_indices_asc; using stan::math::sort_indices_desc; @@ -117,7 +117,7 @@ inline void test_sort_indices_asc(Eigen::Matrix val) { } template -inline void test_sort_indices_asc3(Eigen::Matrix val) { +void test_sort_indices_asc3(Eigen::Matrix val) { using stan::math::fvar; using stan::math::sort_indices_asc; using stan::math::sort_indices_desc; @@ -143,7 +143,7 @@ inline void test_sort_indices_asc3(Eigen::Matrix val) { } template -inline void test_sort_indices_desc(Eigen::Matrix val) { +void test_sort_indices_desc(Eigen::Matrix val) { using stan::math::fvar; using stan::math::sort_indices_asc; using stan::math::sort_indices_desc; @@ -169,7 +169,7 @@ inline void test_sort_indices_desc(Eigen::Matrix val) { } template -inline void test_sort_indices_desc3(Eigen::Matrix val) { +void test_sort_indices_desc3(Eigen::Matrix val) { using stan::math::fvar; using stan::math::sort_indices_asc; using stan::math::sort_indices_desc; diff --git a/test/unit/math/fwd/meta/is_constant_all_test.cpp b/test/unit/math/fwd/meta/is_constant_all_test.cpp index 43a0c456482..7a4fbd85f2b 100644 --- a/test/unit/math/fwd/meta/is_constant_all_test.cpp +++ b/test/unit/math/fwd/meta/is_constant_all_test.cpp @@ -2,7 +2,7 @@ #include template -inline void expect_not_const() { +void expect_not_const() { using stan::is_constant_all; bool temp = is_constant_all::value; EXPECT_FALSE(temp); diff --git a/test/unit/math/laplace/laplace_utility.hpp b/test/unit/math/laplace/laplace_utility.hpp index 8e5734ffe61..b60494c345d 100644 --- a/test/unit/math/laplace/laplace_utility.hpp +++ b/test/unit/math/laplace/laplace_utility.hpp @@ -182,7 +182,7 @@ struct diagonal_kernel_functor { }; template -inline void run_solver_grid(F&& body, ThetaVec&& theta_0) { +void run_solver_grid(F&& body, ThetaVec&& theta_0) { constexpr std::array solver_nums{1, 2, 3}; // [1, 3] constexpr std::array hessian_block_sizes{1, 2, 3}; // [1, 2] constexpr std::array max_steps_line_searches{0, 10}; // 0, 10 diff --git a/test/unit/math/mix/constraint/cholesky_corr_constrain_test.cpp b/test/unit/math/mix/constraint/cholesky_corr_constrain_test.cpp index 89e1ebb7e39..788848c8c2c 100644 --- a/test/unit/math/mix/constraint/cholesky_corr_constrain_test.cpp +++ b/test/unit/math/mix/constraint/cholesky_corr_constrain_test.cpp @@ -32,7 +32,7 @@ auto g3(const T& x) { } template -inline void expect_cholesky_corr_transform(const T& x) { +void expect_cholesky_corr_transform(const T& x) { stan::test::ad_tolerances tols; tols.hessian_hessian_ = 1e-2; tols.hessian_fvar_hessian_ = 1e-2; diff --git a/test/unit/math/mix/constraint/corr_matrix_constrain_test.cpp b/test/unit/math/mix/constraint/corr_matrix_constrain_test.cpp index 2b766dd7660..3dba44cd792 100644 --- a/test/unit/math/mix/constraint/corr_matrix_constrain_test.cpp +++ b/test/unit/math/mix/constraint/corr_matrix_constrain_test.cpp @@ -32,7 +32,7 @@ auto g3(const T& x) { } template -inline void expect_corr_matrix_transform(const T& x) { +void expect_corr_matrix_transform(const T& x) { stan::test::ad_tolerances tols; tols.hessian_hessian_ = 1e-2; tols.hessian_fvar_hessian_ = 1e-2; diff --git a/test/unit/math/mix/constraint/cov_matrix_constrain_test.cpp b/test/unit/math/mix/constraint/cov_matrix_constrain_test.cpp index ba9d959d57d..7352c9f45b2 100644 --- a/test/unit/math/mix/constraint/cov_matrix_constrain_test.cpp +++ b/test/unit/math/mix/constraint/cov_matrix_constrain_test.cpp @@ -32,7 +32,7 @@ auto g3(const T& x) { } template -inline void expect_cov_matrix_transform(const T& x) { +void expect_cov_matrix_transform(const T& x) { using stan::test::relative_tolerance; stan::test::ad_tolerances tols; tols.hessian_hessian_ = relative_tolerance(1e-3, 1e-3); diff --git a/test/unit/math/mix/constraint/identity_constrain_test.cpp b/test/unit/math/mix/constraint/identity_constrain_test.cpp index 750da07ad1e..2b01211f0f1 100644 --- a/test/unit/math/mix/constraint/identity_constrain_test.cpp +++ b/test/unit/math/mix/constraint/identity_constrain_test.cpp @@ -3,23 +3,23 @@ namespace identity_constrain_test { template -inline T g1(const T& x) { +T g1(const T& x) { return stan::math::identity_constrain(x); } template -inline T g2(const T& x) { +T g2(const T& x) { T lp = 0; return stan::math::identity_constrain(x, lp); } template -inline T g3(const T& x) { +T g3(const T& x) { T lp = 0; stan::math::identity_constrain(x, lp); return lp; } } // namespace identity_constrain_test -inline void expect_identity_constrain(double x) { +void expect_identity_constrain(double x) { auto f1 = [](const auto& x) { return identity_constrain_test::g1(x); }; auto f2 = [](const auto& x) { return identity_constrain_test::g2(x); }; auto f3 = [](const auto& x) { return identity_constrain_test::g3(x); }; diff --git a/test/unit/math/mix/constraint/lb_constrain_matvar_test.cpp b/test/unit/math/mix/constraint/lb_constrain_matvar_test.cpp index 4b2cb37f018..61ba6939963 100644 --- a/test/unit/math/mix/constraint/lb_constrain_matvar_test.cpp +++ b/test/unit/math/mix/constraint/lb_constrain_matvar_test.cpp @@ -3,7 +3,7 @@ namespace lb_constrain_test { template -inline void expect_matvar(const T1& x, const T2& lb) { +void expect_matvar(const T1& x, const T2& lb) { auto f1 = [](const auto& x, const auto& lb) { stan::return_type_t lp = 0; return stan::math::lb_constrain(x, lb, lp); @@ -30,7 +30,7 @@ inline void expect_matvar(const T1& x, const T2& lb) { } template -inline void expect_vec_matvar(const T1& x, const T2& lb) { +void expect_vec_matvar(const T1& x, const T2& lb) { auto f1 = [](const auto& x, const auto& lb) { stan::return_type_t lp = 0; return stan::math::lb_constrain(x, lb, lp); diff --git a/test/unit/math/mix/constraint/lb_constrain_test.cpp b/test/unit/math/mix/constraint/lb_constrain_test.cpp index 377507d4acd..cb0f99cd5ec 100644 --- a/test/unit/math/mix/constraint/lb_constrain_test.cpp +++ b/test/unit/math/mix/constraint/lb_constrain_test.cpp @@ -3,7 +3,7 @@ namespace lb_constrain_test { template -inline void expect(const T1& x, const T2& lb) { +void expect(const T1& x, const T2& lb) { auto f1 = [](const auto& x, const auto& lb) { stan::return_type_t lp = 0; return stan::math::lb_constrain(x, lb, lp); @@ -30,7 +30,7 @@ inline void expect(const T1& x, const T2& lb) { } template -inline void expect_vec(const T1& x, const T2& lb) { +void expect_vec(const T1& x, const T2& lb) { auto f1 = [](const auto& x, const auto& lb) { stan::return_type_t lp = 0; return stan::math::lb_constrain(x, lb, lp); diff --git a/test/unit/math/mix/constraint/lub_constrain_helpers.hpp b/test/unit/math/mix/constraint/lub_constrain_helpers.hpp index 83e5be961c9..2d600df51f1 100644 --- a/test/unit/math/mix/constraint/lub_constrain_helpers.hpp +++ b/test/unit/math/mix/constraint/lub_constrain_helpers.hpp @@ -3,7 +3,7 @@ namespace lub_constrain_tests { template -inline void expect(const T1& x, const T2& lb, const T3& ub) { +void expect(const T1& x, const T2& lb, const T3& ub) { auto f1 = [](const auto& x, const auto& lb, const auto& ub) { stan::return_type_t lp = 0; return stan::math::lub_constrain(x, lb, ub, lp); @@ -39,7 +39,7 @@ inline void expect(const T1& x, const T2& lb, const T3& ub) { stan::test::expect_ad(f6, x, lb, ub); } template -inline void expect_vec(const T1& x, const T2& lb, const T3& ub) { +void expect_vec(const T1& x, const T2& lb, const T3& ub) { auto f1 = [](const auto& x, const auto& lb, const auto& ub) { stan::return_type_t lp = 0; return stan::math::lub_constrain(x, lb, ub, lp); diff --git a/test/unit/math/mix/constraint/lub_constrain_matvar_test.cpp b/test/unit/math/mix/constraint/lub_constrain_matvar_test.cpp index ab15f2d8a89..f202e4af27b 100644 --- a/test/unit/math/mix/constraint/lub_constrain_matvar_test.cpp +++ b/test/unit/math/mix/constraint/lub_constrain_matvar_test.cpp @@ -2,7 +2,7 @@ namespace lub_constrain_tests { template -inline void expect_matvar(const T1& x, const T2& lb, const T3& ub) { +void expect_matvar(const T1& x, const T2& lb, const T3& ub) { auto f1 = [](const auto& x, const auto& lb, const auto& ub) { stan::return_type_t lp = 0; return stan::math::lub_constrain(x, lb, ub, lp); diff --git a/test/unit/math/mix/constraint/offset_multiplier_constrain_helpers.hpp b/test/unit/math/mix/constraint/offset_multiplier_constrain_helpers.hpp index c04df3c75ca..92f063e207c 100644 --- a/test/unit/math/mix/constraint/offset_multiplier_constrain_helpers.hpp +++ b/test/unit/math/mix/constraint/offset_multiplier_constrain_helpers.hpp @@ -3,7 +3,7 @@ namespace offset_multiplier_constrain_tests { template -inline void expect(const T1& x, const T2& mu, const T3& sigma) { +void expect(const T1& x, const T2& mu, const T3& sigma) { auto f1 = [](const auto& x, const auto& mu, const auto& sigma) { stan::return_type_t lp = 0; return stan::math::offset_multiplier_constrain(x, mu, sigma, lp); @@ -31,7 +31,7 @@ inline void expect(const T1& x, const T2& mu, const T3& sigma) { stan::test::expect_ad(f4, x, mu, sigma); } template -inline void expect_vec(const T1& x, const T2& mu, const T3& sigma) { +void expect_vec(const T1& x, const T2& mu, const T3& sigma) { auto f1 = [](const auto& x, const auto& mu, const auto& sigma) { stan::return_type_t lp = 0; return stan::math::offset_multiplier_constrain(x, mu, sigma, lp); diff --git a/test/unit/math/mix/constraint/offset_multiplier_constrain_matvar_helpers.hpp b/test/unit/math/mix/constraint/offset_multiplier_constrain_matvar_helpers.hpp index b51d5ca26fe..fc299d5dfb5 100644 --- a/test/unit/math/mix/constraint/offset_multiplier_constrain_matvar_helpers.hpp +++ b/test/unit/math/mix/constraint/offset_multiplier_constrain_matvar_helpers.hpp @@ -3,7 +3,7 @@ namespace offset_multiplier_constrain_tests { template -inline void expect_matvar(const T1& x, const T2& mu, const T3& sigma) { +void expect_matvar(const T1& x, const T2& mu, const T3& sigma) { auto f1 = [](const auto& x, const auto& mu, const auto& sigma) { stan::return_type_t lp = 0; return stan::math::offset_multiplier_constrain(x, mu, sigma, lp); @@ -31,7 +31,7 @@ inline void expect_matvar(const T1& x, const T2& mu, const T3& sigma) { stan::test::expect_ad_matvar(f4, x, mu, sigma); } template -inline void expect_vec_matvar(const T1& x, const T2& mu, const T3& sigma) { +void expect_vec_matvar(const T1& x, const T2& mu, const T3& sigma) { auto f1 = [](const auto& x, const auto& mu, const auto& sigma) { stan::return_type_t lp = 0; return stan::math::offset_multiplier_constrain(x, mu, sigma, lp); diff --git a/test/unit/math/mix/constraint/ordered_constrain_test.cpp b/test/unit/math/mix/constraint/ordered_constrain_test.cpp index 7e80967504b..4615d197867 100644 --- a/test/unit/math/mix/constraint/ordered_constrain_test.cpp +++ b/test/unit/math/mix/constraint/ordered_constrain_test.cpp @@ -2,24 +2,24 @@ namespace ordered_constrain_test { template -inline T g1(const T& x) { +T g1(const T& x) { stan::scalar_type_t lp = 0; return stan::math::ordered_constrain(x, lp); } template -inline T g2(const T& x) { +T g2(const T& x) { stan::scalar_type_t lp = 0; return stan::math::ordered_constrain(x, lp); } template -inline stan::scalar_type_t g3(const T& x) { +stan::scalar_type_t g3(const T& x) { stan::scalar_type_t lp = 0; stan::math::ordered_constrain(x, lp); return lp; } template -inline void expect_ordered_transform(const T& x) { +void expect_ordered_transform(const T& x) { auto f1 = [](const auto& x) { return g1(x); }; auto f2 = [](const auto& x) { return g2(x); }; auto f3 = [](const auto& x) { return g3(x); }; diff --git a/test/unit/math/mix/constraint/positive_ordered_constrain_test.cpp b/test/unit/math/mix/constraint/positive_ordered_constrain_test.cpp index e98be4ac24e..137226f8524 100644 --- a/test/unit/math/mix/constraint/positive_ordered_constrain_test.cpp +++ b/test/unit/math/mix/constraint/positive_ordered_constrain_test.cpp @@ -2,24 +2,24 @@ namespace positive_ordered_constrain_test { template -inline T g1(const T& x) { +T g1(const T& x) { stan::scalar_type_t lp = 0; return stan::math::positive_ordered_constrain(x, lp); } template -inline T g2(const T& x) { +T g2(const T& x) { stan::scalar_type_t lp = 0; return stan::math::positive_ordered_constrain(x, lp); } template -inline stan::scalar_type_t g3(const T& x) { +stan::scalar_type_t g3(const T& x) { typename stan::scalar_type::type lp = 0; stan::math::positive_ordered_constrain(x, lp); return lp; } template -inline void expect_positive_ordered_transform(const T& x) { +void expect_positive_ordered_transform(const T& x) { auto f1 = [](const auto& x) { return g1(x); }; auto f2 = [](const auto& x) { return g2(x); }; auto f3 = [](const auto& x) { return g3(x); }; diff --git a/test/unit/math/mix/constraint/simplex_constrain_test.cpp b/test/unit/math/mix/constraint/simplex_constrain_test.cpp index 68d820210b3..04c538fe0e7 100644 --- a/test/unit/math/mix/constraint/simplex_constrain_test.cpp +++ b/test/unit/math/mix/constraint/simplex_constrain_test.cpp @@ -2,12 +2,12 @@ namespace simplex_constrain_test { template -inline T g1(const T& x) { +T g1(const T& x) { stan::scalar_type_t lp = 0; return stan::math::simplex_constrain(x, lp); } template -inline T g2(const T& x) { +T g2(const T& x) { stan::scalar_type_t lp = 0; return stan::math::simplex_constrain(x, lp); } @@ -19,7 +19,7 @@ typename stan::scalar_type::type g3(const T& x) { } template -inline void expect_simplex_transform(const T& x) { +void expect_simplex_transform(const T& x) { auto f1 = [](const auto& x) { return g1(x); }; auto f2 = [](const auto& x) { return g2(x); }; auto f3 = [](const auto& x) { return g3(x); }; diff --git a/test/unit/math/mix/constraint/stochastic_column_constrain_test.cpp b/test/unit/math/mix/constraint/stochastic_column_constrain_test.cpp index 8171fb13f0e..995db3d1e7a 100644 --- a/test/unit/math/mix/constraint/stochastic_column_constrain_test.cpp +++ b/test/unit/math/mix/constraint/stochastic_column_constrain_test.cpp @@ -2,12 +2,12 @@ namespace stochastic_column_constrain_test { template -inline T g1(const T& x) { +T g1(const T& x) { stan::scalar_type_t lp = 0; return stan::math::stochastic_column_constrain(x, lp); } template -inline T g2(const T& x) { +T g2(const T& x) { stan::scalar_type_t lp = 0; return stan::math::stochastic_column_constrain(x, lp); } @@ -19,7 +19,7 @@ typename stan::scalar_type::type g3(const T& x) { } template -inline void expect_simplex_transform(const T& x) { +void expect_simplex_transform(const T& x) { auto f1 = [](const auto& x) { return g1(x); }; auto f2 = [](const auto& x) { return g2(x); }; auto f3 = [](const auto& x) { return g3(x); }; diff --git a/test/unit/math/mix/constraint/stochastic_row_constrain_test.cpp b/test/unit/math/mix/constraint/stochastic_row_constrain_test.cpp index 071fc7849a7..d40921d3032 100644 --- a/test/unit/math/mix/constraint/stochastic_row_constrain_test.cpp +++ b/test/unit/math/mix/constraint/stochastic_row_constrain_test.cpp @@ -2,12 +2,12 @@ namespace stochastic_row_constrain_test { template -inline T g1(const T& x) { +T g1(const T& x) { stan::scalar_type_t lp = 0; return stan::math::stochastic_row_constrain(x, lp); } template -inline T g2(const T& x) { +T g2(const T& x) { stan::scalar_type_t lp = 0; return stan::math::stochastic_row_constrain(x, lp); } @@ -19,7 +19,7 @@ typename stan::scalar_type::type g3(const T& x) { } template -inline void expect_simplex_transform(const T& x) { +void expect_simplex_transform(const T& x) { auto f1 = [](const auto& x) { return g1(x); }; auto f2 = [](const auto& x) { return g2(x); }; auto f3 = [](const auto& x) { return g3(x); }; diff --git a/test/unit/math/mix/constraint/sum_to_zero_constrain_test.cpp b/test/unit/math/mix/constraint/sum_to_zero_constrain_test.cpp index dbfd9ae5289..cb18967bb03 100644 --- a/test/unit/math/mix/constraint/sum_to_zero_constrain_test.cpp +++ b/test/unit/math/mix/constraint/sum_to_zero_constrain_test.cpp @@ -2,12 +2,12 @@ namespace sum_to_zero_constrain_test { template -inline T g1(const T& x) { +T g1(const T& x) { stan::scalar_type_t lp = 0; return stan::math::sum_to_zero_constrain(x, lp); } template -inline T g2(const T& x) { +T g2(const T& x) { stan::scalar_type_t lp = 0; return stan::math::sum_to_zero_constrain(x, lp); } @@ -19,7 +19,7 @@ typename stan::scalar_type::type g3(const T& x) { } template -inline void expect_sum_to_zero_transform(const T& x) { +void expect_sum_to_zero_transform(const T& x) { auto f1 = [](const auto& x) { return g1(x); }; auto f2 = [](const auto& x) { return g2(x); }; auto f3 = [](const auto& x) { return g3(x); }; diff --git a/test/unit/math/mix/constraint/unit_vector_constrain_test.cpp b/test/unit/math/mix/constraint/unit_vector_constrain_test.cpp index e113f4f2dfa..cd26807db3a 100644 --- a/test/unit/math/mix/constraint/unit_vector_constrain_test.cpp +++ b/test/unit/math/mix/constraint/unit_vector_constrain_test.cpp @@ -21,7 +21,7 @@ auto g3(const T& x) { } template -inline void expect_unit_vector_constrain(const T& x) { +void expect_unit_vector_constrain(const T& x) { stan::test::ad_tolerances tols; tols.gradient_fvar_grad_ = 1e0; tols.hessian_grad_ = 1e0; diff --git a/test/unit/math/mix/core/operator_logical_and_test.cpp b/test/unit/math/mix/core/operator_logical_and_test.cpp index 24ab3098b37..5e68e08b014 100644 --- a/test/unit/math/mix/core/operator_logical_and_test.cpp +++ b/test/unit/math/mix/core/operator_logical_and_test.cpp @@ -3,7 +3,7 @@ #include #include -inline void test_logical_and(double x, double y) { +void test_logical_and(double x, double y) { using stan::math::fvar; using stan::math::var; diff --git a/test/unit/math/mix/core/operator_logical_or_test.cpp b/test/unit/math/mix/core/operator_logical_or_test.cpp index 42cea8233d0..3e53c865dd8 100644 --- a/test/unit/math/mix/core/operator_logical_or_test.cpp +++ b/test/unit/math/mix/core/operator_logical_or_test.cpp @@ -3,7 +3,7 @@ #include #include -inline void test_logical_or(double x, double y) { +void test_logical_or(double x, double y) { using stan::math::fvar; using stan::math::var; diff --git a/test/unit/math/mix/core/operator_unary_not_test.cpp b/test/unit/math/mix/core/operator_unary_not_test.cpp index a0d4e86827e..b6fb1762280 100644 --- a/test/unit/math/mix/core/operator_unary_not_test.cpp +++ b/test/unit/math/mix/core/operator_unary_not_test.cpp @@ -2,7 +2,7 @@ #include #include -inline void test_unary_not(double x) { +void test_unary_not(double x) { using stan::math::fvar; using stan::math::var; diff --git a/test/unit/math/mix/core/std_complex_test.cpp b/test/unit/math/mix/core/std_complex_test.cpp index dbcd83e208d..23f253b348d 100644 --- a/test/unit/math/mix/core/std_complex_test.cpp +++ b/test/unit/math/mix/core/std_complex_test.cpp @@ -3,7 +3,7 @@ #include template -inline void test_constructor_init_type() { +void test_constructor_init_type() { S a = 2; std::complex z(a); EXPECT_EQ(a, z.real()); @@ -11,7 +11,7 @@ inline void test_constructor_init_type() { } template -inline void test_binary_constructor(const T1& x, const T2& y) { +void test_binary_constructor(const T1& x, const T2& y) { using stan::math::value_of_rec; std::complex z(x, y); EXPECT_EQ(1.1, value_of_rec(z.real())); @@ -19,7 +19,7 @@ inline void test_binary_constructor(const T1& x, const T2& y) { } template -inline void test_set_real_imag() { +void test_set_real_imag() { std::complex z; z.real(3.2); EXPECT_TRUE(z.real() == 3.2); @@ -28,7 +28,7 @@ inline void test_set_real_imag() { } template -inline void test_std_complex_constructor() { +void test_std_complex_constructor() { using stan::math::value_of_rec; using c_t = std::complex; @@ -77,12 +77,12 @@ TEST(mathMixCore, stdComplexConstructor) { // convenience for type inference of T template -inline std::complex to_std_complex(const T& x) { +std::complex to_std_complex(const T& x) { return {x}; } template -inline void expect_common_complex(const F& f) { +void expect_common_complex(const F& f) { // cover all quadrants and projections for (double re : std::vector{-1.4, -1e-3, 0, 2e-3, 2.3}) { for (double im : std::vector{-0.5, -3e-3, 0, 4e-3, 1.5}) { @@ -92,7 +92,7 @@ inline void expect_common_complex(const F& f) { } template -inline void expect_common_for_complex(const F& f) { +void expect_common_for_complex(const F& f) { for (double re : std::vector{-3.9, -1e-3, 0, 2e-3, 4.1}) { stan::test::expect_ad(f, re); } diff --git a/test/unit/math/mix/fun/accumulator_test.cpp b/test/unit/math/mix/fun/accumulator_test.cpp index da2efc19164..855b92330e2 100644 --- a/test/unit/math/mix/fun/accumulator_test.cpp +++ b/test/unit/math/mix/fun/accumulator_test.cpp @@ -4,7 +4,7 @@ // test sum of first n numbers for sum of a template -inline void test_sum(stan::math::accumulator& a, int n) { +void test_sum(stan::math::accumulator& a, int n) { EXPECT_TRUE((n * (n + 1)) / 2 == a.sum()); } diff --git a/test/unit/math/mix/fun/append_array_test.cpp b/test/unit/math/mix/fun/append_array_test.cpp index d570e4f4d6f..0cf6dd04288 100644 --- a/test/unit/math/mix/fun/append_array_test.cpp +++ b/test/unit/math/mix/fun/append_array_test.cpp @@ -47,7 +47,7 @@ typedef Eigen::Matrix Mffv; * @param z Output variable */ template -inline void build(int n1, int n0, T1& z) { +void build(int n1, int n0, T1& z) { std::random_device rd; std::mt19937 mt(rd()); z = T1(rd()); @@ -68,7 +68,7 @@ inline void build(int n1, int n0, T1& z) { * @param z Output variable */ template -inline void build(int n1, int n0, Eigen::Matrix& z) { +void build(int n1, int n0, Eigen::Matrix& z) { z = Eigen::Matrix(R == 1 ? 1 : n1, C == 1 ? 1 : n0); for (int i = 0; i < z.rows(); i++) { @@ -89,7 +89,7 @@ inline void build(int n1, int n0, Eigen::Matrix& z) { * @param z Output variable */ template -inline void build(int n2, int n1, int n0, std::vector& z) { +void build(int n2, int n1, int n0, std::vector& z) { z.resize(n2); for (int i = 0; i < n2; i++) { build(n1, n0, z[i]); @@ -108,7 +108,7 @@ inline void build(int n2, int n1, int n0, std::vector& z) { * @param z Output variable */ template -inline void build(int n3, int n2, int n1, int n0, std::vector& z) { +void build(int n3, int n2, int n1, int n0, std::vector& z) { z.resize(n3); for (int i = 0; i < n3; i++) { build(n2, n1, n0, z[i]); @@ -120,42 +120,42 @@ inline void build(int n3, int n2, int n1, int n0, std::vector& z) { * * @param z1 Argument */ -inline double get_value(const double& z1) { return z1; } +double get_value(const double& z1) { return z1; } /** * Get value of var. * * @param z1 Argument */ -inline double get_value(const var& z1) { return z1.val(); } +double get_value(const var& z1) { return z1.val(); } /** * Get value of fd * * @param z1 Argument */ -inline double get_value(const fd& z1) { return z1.val(); } +double get_value(const fd& z1) { return z1.val(); } /** * Get value of fvar * * @param z1 Argument */ -inline double get_value(const fv& z1) { return z1.val().val(); } +double get_value(const fv& z1) { return z1.val().val(); } /** * Get value of fvar > * * @param z1 Argument */ -inline double get_value(const ffd& z1) { return z1.val().val(); } +double get_value(const ffd& z1) { return z1.val().val(); } /** * Get value of fvar > * * @param z1 Argument */ -inline double get_value(const ffv& z1) { return z1.val().val().val(); } +double get_value(const ffv& z1) { return z1.val().val().val(); } /** * Check if variables are equal via floating point macro @@ -166,7 +166,7 @@ inline double get_value(const ffv& z1) { return z1.val().val().val(); } * @param z2 Second argument */ template -inline void check_eq(const T1& z1, const T2& z2) { +void check_eq(const T1& z1, const T2& z2) { EXPECT_FLOAT_EQ(get_value(z1), get_value(z2)); } @@ -177,7 +177,7 @@ inline void check_eq(const T1& z1, const T2& z2) { * @param z2 Second integer */ template <> -inline void check_eq(const int& z1, const int& z2) { +void check_eq(const int& z1, const int& z2) { EXPECT_EQ(z1, z2); } @@ -190,8 +190,8 @@ inline void check_eq(const int& z1, const int& z2) { * @param z2 Second matrix */ template -inline void check_eq(const Eigen::Matrix& z1, - const Eigen::Matrix& z2) { +void check_eq(const Eigen::Matrix& z1, + const Eigen::Matrix& z2) { EXPECT_EQ(z1.rows(), z2.rows()); EXPECT_EQ(z1.cols(), z2.cols()); @@ -209,7 +209,7 @@ inline void check_eq(const Eigen::Matrix& z1, * @param z2 Second std::vector */ template -inline void check_eq(const std::vector& z1, const std::vector& z2) { +void check_eq(const std::vector& z1, const std::vector& z2) { EXPECT_EQ(z1.size(), z2.size()); for (size_t i = 0; i < z1.size(); i++) check_eq(z1[i], z2[i]); @@ -225,7 +225,7 @@ inline void check_eq(const std::vector& z1, const std::vector& z2) { * @tparam T3 Element type of return std::vector */ template -inline void checkv() { +void checkv() { std::vector x; std::vector y; std::vector result; @@ -255,7 +255,7 @@ inline void checkv() { * @tparam T3 Element type of return std::vector */ template -inline void checkvv() { +void checkvv() { std::vector > x; std::vector > y; std::vector > result; @@ -284,7 +284,7 @@ inline void checkvv() { * @tparam T3 Element type of third container */ template -inline void check() { +void check() { // repeat the checks a few times since they're random for (int i = 0; i < 3; i++) { checkv(); diff --git a/test/unit/math/mix/fun/cholesky_decompose_test.cpp b/test/unit/math/mix/fun/cholesky_decompose_test.cpp index 940c53ad3de..3413c3e8d74 100644 --- a/test/unit/math/mix/fun/cholesky_decompose_test.cpp +++ b/test/unit/math/mix/fun/cholesky_decompose_test.cpp @@ -23,7 +23,7 @@ auto f(int dof) { auto f_matvar = [](const auto& x) { return stan::math::cholesky_decompose(x); }; -inline void expect_cholesky(const Eigen::MatrixXd& Sigma) { +void expect_cholesky(const Eigen::MatrixXd& Sigma) { Eigen::VectorXd yy = stan::math::cov_matrix_free(Sigma); // lazy, solving for x in x = (N * (N + 1)) / 2 int dof = .5 * (std::sqrt(8 * yy.size() + 1) - 1); diff --git a/test/unit/math/mix/fun/complex_schur_decompose_test.cpp b/test/unit/math/mix/fun/complex_schur_decompose_test.cpp index e1d2b89afc1..8c55eb42d85 100644 --- a/test/unit/math/mix/fun/complex_schur_decompose_test.cpp +++ b/test/unit/math/mix/fun/complex_schur_decompose_test.cpp @@ -50,7 +50,7 @@ TEST(mathMixFun, complexSchurDecompose) { } template -inline void test_complex_schur_decompose(const Eigen::MatrixXd& x) { +void test_complex_schur_decompose(const Eigen::MatrixXd& x) { using stan::math::complex_schur_decompose; using stan::math::complex_schur_decompose_t; using stan::math::complex_schur_decompose_u; @@ -70,7 +70,7 @@ inline void test_complex_schur_decompose(const Eigen::MatrixXd& x) { } template -inline void test_complex_schur_decompose_complex(const Eigen::MatrixXd& x) { +void test_complex_schur_decompose_complex(const Eigen::MatrixXd& x) { using stan::math::complex_schur_decompose; using stan::math::complex_schur_decompose_t; using stan::math::complex_schur_decompose_u; diff --git a/test/unit/math/mix/fun/conj_test.cpp b/test/unit/math/mix/fun/conj_test.cpp index 8fa0a949a66..359e1b0437a 100644 --- a/test/unit/math/mix/fun/conj_test.cpp +++ b/test/unit/math/mix/fun/conj_test.cpp @@ -10,7 +10,7 @@ TEST(mathMixMatFun, conj) { } template -inline void test_vectorized_conj() { +void test_vectorized_conj() { using stan::math::value_of_rec; using complex_t = std::complex; using complex_matrix = Eigen::Matrix; diff --git a/test/unit/math/mix/fun/copysign_test.cpp b/test/unit/math/mix/fun/copysign_test.cpp index ff268b9822f..e7b111c994f 100644 --- a/test/unit/math/mix/fun/copysign_test.cpp +++ b/test/unit/math/mix/fun/copysign_test.cpp @@ -6,14 +6,14 @@ #include template -inline void expect_eq_signbit(const U& u, const V& v) { +void expect_eq_signbit(const U& u, const V& v) { using stan::math::signbit; using std::signbit; EXPECT_EQ(signbit(u), signbit(v)); } template -inline void expect_copysign() { +void expect_copysign() { using stan::math::copysign; using stan::math::copysign_non_zero; using stan::math::is_nan; diff --git a/test/unit/math/mix/fun/cumulative_sum_test.cpp b/test/unit/math/mix/fun/cumulative_sum_test.cpp index 2ee291be6bb..e049cf17cf8 100644 --- a/test/unit/math/mix/fun/cumulative_sum_test.cpp +++ b/test/unit/math/mix/fun/cumulative_sum_test.cpp @@ -1,7 +1,7 @@ #include #include -inline void expect_cumulative_sum(std::vector& x) { +void expect_cumulative_sum(std::vector& x) { auto f = [](const auto& y) { return stan::math::cumulative_sum(y); }; Eigen::VectorXd v = Eigen::Map(x.data(), x.size()); Eigen::RowVectorXd rv = Eigen::Map(x.data(), x.size()); diff --git a/test/unit/math/mix/fun/diag_post_multiply_test.cpp b/test/unit/math/mix/fun/diag_post_multiply_test.cpp index 4c2dffe94d6..011ea2fef2e 100644 --- a/test/unit/math/mix/fun/diag_post_multiply_test.cpp +++ b/test/unit/math/mix/fun/diag_post_multiply_test.cpp @@ -1,7 +1,7 @@ #include -inline void expect_diag_post_multiply(const Eigen::MatrixXd& a, - const Eigen::VectorXd& v) { +void expect_diag_post_multiply(const Eigen::MatrixXd& a, + const Eigen::VectorXd& v) { auto f = [](const auto& x, const auto& y) { return stan::math::diag_post_multiply(x, y); }; diff --git a/test/unit/math/mix/fun/diag_pre_multiply_test.cpp b/test/unit/math/mix/fun/diag_pre_multiply_test.cpp index b874607edce..fa9d96f6cdb 100644 --- a/test/unit/math/mix/fun/diag_pre_multiply_test.cpp +++ b/test/unit/math/mix/fun/diag_pre_multiply_test.cpp @@ -1,8 +1,8 @@ #include #include -inline void expect_diag_pre_multiply(const Eigen::VectorXd& v, - const Eigen::MatrixXd& a) { +void expect_diag_pre_multiply(const Eigen::VectorXd& v, + const Eigen::MatrixXd& a) { auto f = [](const auto& x, const auto& y) { return stan::math::diag_pre_multiply(x, y); }; diff --git a/test/unit/math/mix/fun/eigen_comparisons_test.cpp b/test/unit/math/mix/fun/eigen_comparisons_test.cpp index 84fa44b6bee..b0bfd6e5682 100644 --- a/test/unit/math/mix/fun/eigen_comparisons_test.cpp +++ b/test/unit/math/mix/fun/eigen_comparisons_test.cpp @@ -4,9 +4,8 @@ template -inline void test_comparison(Op operation, - const Container1Plain& container1_plain, - const Container2Plain& container2_plain) { +void test_comparison(Op operation, const Container1Plain& container1_plain, + const Container2Plain& container2_plain) { EXPECT_MATRIX_EQ( operation(container1_plain, container2_plain), operation(ContainerT1(container1_plain), ContainerT2(container2_plain))); @@ -18,9 +17,9 @@ inline void test_comparison(Op operation, template -inline void test_comparison_combinations( - Op operation, const ContainerPlain& container1_plain, - const ContainerPlain& container2_plain) { +void test_comparison_combinations(Op operation, + const ContainerPlain& container1_plain, + const ContainerPlain& container2_plain) { test_comparison(operation, container1_plain, container2_plain); test_comparison( @@ -30,7 +29,7 @@ inline void test_comparison_combinations( } template -inline void test_comparison_all_shapes(Op operation) { +void test_comparison_all_shapes(Op operation) { Eigen::ArrayXXd m1(3, 2); m1 << -1, 2, 0.0, 0.5, 1, 1.5; Eigen::ArrayXXd m2(3, 2); @@ -55,7 +54,7 @@ inline void test_comparison_all_shapes(Op operation) { } template -inline void test_all_comparisons() { +void test_all_comparisons() { test_comparison_all_shapes( [](const auto& a, const auto& b) { return a < b; }); test_comparison_all_shapes( 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 33857d1632c..65be4d32153 100644 --- a/test/unit/math/mix/fun/eigendecompose_identity_complex_test.cpp +++ b/test/unit/math/mix/fun/eigendecompose_identity_complex_test.cpp @@ -1,7 +1,7 @@ #include template -inline void expect_identity_matrix_complex(const T& x) { +void expect_identity_matrix_complex(const T& x) { EXPECT_EQ(x.rows(), x.cols()); for (int j = 0; j < x.cols(); ++j) { for (int i = 0; i < x.rows(); ++i) { @@ -12,7 +12,7 @@ inline void expect_identity_matrix_complex(const T& x) { } template -inline void expectComplexEigenvectorsId() { +void expectComplexEigenvectorsId() { Eigen::Matrix, -1, -1> c22(2, 2); c22 << stan::math::to_complex(T(0), T(-1)), stan::math::to_complex(T(0), T(0)), stan::math::to_complex(T(2), T(0)), diff --git a/test/unit/math/mix/fun/eigendecompose_identity_test.cpp b/test/unit/math/mix/fun/eigendecompose_identity_test.cpp index 9e9e385e216..8a2f99ddc3f 100644 --- a/test/unit/math/mix/fun/eigendecompose_identity_test.cpp +++ b/test/unit/math/mix/fun/eigendecompose_identity_test.cpp @@ -1,7 +1,7 @@ #include template -inline void expect_identity_matrix(const T& x) { +void expect_identity_matrix(const T& x) { EXPECT_EQ(x.rows(), x.cols()); for (int j = 0; j < x.cols(); ++j) { for (int i = 0; i < x.rows(); ++i) { @@ -11,7 +11,7 @@ inline void expect_identity_matrix(const T& x) { } template -inline void expectEigenvectorsId() { +void expectEigenvectorsId() { for (const auto& m_d : stan::test::square_test_matrices(1, 2)) { Eigen::Matrix m(m_d); auto vecs = stan::math::eigenvectors(m).eval(); diff --git a/test/unit/math/mix/fun/fft_test.cpp b/test/unit/math/mix/fun/fft_test.cpp index df7dc105d82..62edc1684df 100644 --- a/test/unit/math/mix/fun/fft_test.cpp +++ b/test/unit/math/mix/fun/fft_test.cpp @@ -1,6 +1,6 @@ #include -inline void expect_fft(const Eigen::VectorXcd& x) { +void expect_fft(const Eigen::VectorXcd& x) { for (int m = 0; m < x.rows(); ++m) { auto g = [m](const auto& x) { using stan::math::fft; @@ -39,7 +39,7 @@ TEST(mathMixFun, fft) { expect_fft(x4); } -inline void expect_inv_fft(const Eigen::VectorXcd& x) { +void expect_inv_fft(const Eigen::VectorXcd& x) { for (int m = 0; m < x.rows(); ++m) { auto g = [m](const auto& x) { using stan::math::inv_fft; @@ -78,7 +78,7 @@ TEST(mathMixFun, invFft) { expect_inv_fft(x4); } -inline void expect_fft2(const Eigen::MatrixXcd& x) { +void expect_fft2(const Eigen::MatrixXcd& x) { for (int n = 0; n < x.cols(); ++n) { for (int m = 0; m < x.rows(); ++m) { auto g = [m, n](const auto& x) { @@ -125,7 +125,7 @@ TEST(mathMixFun, fft2) { expect_fft2(x33); } -inline void expect_inv_fft2(const Eigen::MatrixXcd& x) { +void expect_inv_fft2(const Eigen::MatrixXcd& x) { for (int n = 0; n < x.cols(); ++n) { for (int m = 0; m < x.rows(); ++m) { auto g = [m, n](const auto& x) { diff --git a/test/unit/math/mix/fun/get_imag_test.cpp b/test/unit/math/mix/fun/get_imag_test.cpp index d54d3987c1a..f60f6760e2b 100644 --- a/test/unit/math/mix/fun/get_imag_test.cpp +++ b/test/unit/math/mix/fun/get_imag_test.cpp @@ -7,7 +7,7 @@ TEST(mathMixMatFun, get_imag) { } template -inline void test_vectorized_get_imag() { +void test_vectorized_get_imag() { using complex_t = std::complex; using matrix_t = Eigen::Matrix; using complex_matrix = Eigen::Matrix; diff --git a/test/unit/math/mix/fun/get_real_test.cpp b/test/unit/math/mix/fun/get_real_test.cpp index 5cac21bc97f..48a3ea2bb4c 100644 --- a/test/unit/math/mix/fun/get_real_test.cpp +++ b/test/unit/math/mix/fun/get_real_test.cpp @@ -7,7 +7,7 @@ TEST(mathMixMatFun, get_real) { } template -inline void test_vectorized_get_real() { +void test_vectorized_get_real() { using complex_t = std::complex; using matrix_t = Eigen::Matrix; using complex_matrix = Eigen::Matrix; diff --git a/test/unit/math/mix/fun/head_test.cpp b/test/unit/math/mix/fun/head_test.cpp index 44e817e20de..46671852af3 100644 --- a/test/unit/math/mix/fun/head_test.cpp +++ b/test/unit/math/mix/fun/head_test.cpp @@ -2,7 +2,7 @@ #include template -inline void expect_head(const T& x, int n) { +void expect_head(const T& x, int n) { auto f = [](int i) { return [=](const auto& y) { return stan::math::head(y, i); }; }; diff --git a/test/unit/math/mix/fun/isfinite_test.cpp b/test/unit/math/mix/fun/isfinite_test.cpp index 3b172b28657..ef1f8dc8bd4 100644 --- a/test/unit/math/mix/fun/isfinite_test.cpp +++ b/test/unit/math/mix/fun/isfinite_test.cpp @@ -3,7 +3,7 @@ #include template -inline void expect_isfinite() { +void expect_isfinite() { using stan::math::isfinite; using std::isfinite; using std::numeric_limits; diff --git a/test/unit/math/mix/fun/isinf_test.cpp b/test/unit/math/mix/fun/isinf_test.cpp index d4ac41fafc1..86d9f5a4d55 100644 --- a/test/unit/math/mix/fun/isinf_test.cpp +++ b/test/unit/math/mix/fun/isinf_test.cpp @@ -2,7 +2,7 @@ #include template -inline void expect_isinf() { +void expect_isinf() { // C++ idiom for clients of the math lib // std::isnan explicit using; stan::math::nan by ADL using std::isinf; diff --git a/test/unit/math/mix/fun/isnan_test.cpp b/test/unit/math/mix/fun/isnan_test.cpp index 9a7efe47ab9..6470dce1a3c 100644 --- a/test/unit/math/mix/fun/isnan_test.cpp +++ b/test/unit/math/mix/fun/isnan_test.cpp @@ -2,7 +2,7 @@ #include template -inline void expect_isnan() { +void expect_isnan() { // C++ idiom for clients of the math library // std::isnan explicit using; stan::math::nan by ADL using std::isnan; diff --git a/test/unit/math/mix/fun/isnormal_test.cpp b/test/unit/math/mix/fun/isnormal_test.cpp index 8cdb8a1c6fa..e345e45042a 100644 --- a/test/unit/math/mix/fun/isnormal_test.cpp +++ b/test/unit/math/mix/fun/isnormal_test.cpp @@ -3,7 +3,7 @@ #include template -inline void expect_isnormal() { +void expect_isnormal() { using stan::math::isnormal; using std::isnormal; using std::numeric_limits; diff --git a/test/unit/math/mix/fun/log_mix_part2_test.cpp b/test/unit/math/mix/fun/log_mix_part2_test.cpp index f23883d360f..ac6643dc1d7 100644 --- a/test/unit/math/mix/fun/log_mix_part2_test.cpp +++ b/test/unit/math/mix/fun/log_mix_part2_test.cpp @@ -2,8 +2,8 @@ #include #include -inline void expect_log_mix(const std::vector& p, - const std::vector& d) { +void expect_log_mix(const std::vector& p, + const std::vector& d) { auto f = [](const auto& x, const auto& y) { return stan::math::log_mix(x, y); }; stan::test::ad_tolerances tols; @@ -26,14 +26,14 @@ inline void expect_log_mix(const std::vector& p, stan::test::expect_ad(tols, f, p_rv, d_rv); } -inline std::vector to_vectors( +std::vector to_vectors( const std::vector>& xs) { std::vector ys; for (const auto& x : xs) ys.push_back(stan::test::to_vector(x)); return ys; } -inline std::vector to_row_vectors( +std::vector to_row_vectors( const std::vector>& xs) { std::vector ys; for (const auto& x : xs) @@ -41,8 +41,8 @@ inline std::vector to_row_vectors( return ys; } -inline void expect_log_mix(const std::vector& p, - const std::vector>& ds) { +void expect_log_mix(const std::vector& p, + const std::vector>& ds) { auto f = [](const auto& x, const auto& y) { return stan::math::log_mix(x, y); }; stan::test::ad_tolerances tols; diff --git a/test/unit/math/mix/fun/logb_test.cpp b/test/unit/math/mix/fun/logb_test.cpp index 96bb72d5d35..840ee6f3d47 100644 --- a/test/unit/math/mix/fun/logb_test.cpp +++ b/test/unit/math/mix/fun/logb_test.cpp @@ -4,13 +4,13 @@ #include template -inline void expect_logb(double x) { +void expect_logb(double x) { using std::logb; T xt(x); stan::test::expect_near_rel("logb", logb(x), logb(xt)); } -inline void expect_all_logb(double x) { +void expect_all_logb(double x) { using stan::math::fvar; using stan::math::var; expect_logb(x); diff --git a/test/unit/math/mix/fun/matrix_exp_multiply_test.cpp b/test/unit/math/mix/fun/matrix_exp_multiply_test.cpp index cea51aae5da..2babb51e35c 100644 --- a/test/unit/math/mix/fun/matrix_exp_multiply_test.cpp +++ b/test/unit/math/mix/fun/matrix_exp_multiply_test.cpp @@ -6,7 +6,7 @@ auto f_idx(int i, int j) { }; } -inline void expect_matrix_exp_multiply(int m, int n) { +void expect_matrix_exp_multiply(int m, int n) { auto f = [](const auto& x, auto& y) { return stan::math::matrix_exp_multiply(x, y); }; diff --git a/test/unit/math/mix/fun/max_test.cpp b/test/unit/math/mix/fun/max_test.cpp index fe60483fa67..f450e8be8b7 100644 --- a/test/unit/math/mix/fun/max_test.cpp +++ b/test/unit/math/mix/fun/max_test.cpp @@ -2,7 +2,7 @@ #include template -inline void expect_max(const T& m) { +void expect_max(const T& m) { auto f = [](const auto& x) { return stan::math::max(x); }; Eigen::VectorXd v(m.size()); Eigen::RowVectorXd rv(m.size()); diff --git a/test/unit/math/mix/fun/mean_test.cpp b/test/unit/math/mix/fun/mean_test.cpp index f3d95164c1b..a770fb1245a 100644 --- a/test/unit/math/mix/fun/mean_test.cpp +++ b/test/unit/math/mix/fun/mean_test.cpp @@ -1,7 +1,7 @@ #include template -inline void expect_mean(const T& m) { +void expect_mean(const T& m) { auto f = [](const auto& x) { return stan::math::mean(x); }; Eigen::VectorXd v(m.size()); Eigen::RowVectorXd rv(m.size()); diff --git a/test/unit/math/mix/fun/min_test.cpp b/test/unit/math/mix/fun/min_test.cpp index a0fedec9743..e7e024ea204 100644 --- a/test/unit/math/mix/fun/min_test.cpp +++ b/test/unit/math/mix/fun/min_test.cpp @@ -2,7 +2,7 @@ #include template -inline void expect_min(const T& m) { +void expect_min(const T& m) { auto f = [](const auto& x) { return stan::math::min(x); }; Eigen::VectorXd v(m.size()); Eigen::RowVectorXd rv(m.size()); diff --git a/test/unit/math/mix/fun/multiply_util.hpp b/test/unit/math/mix/fun/multiply_util.hpp index 70e1e52557a..cda507842c6 100644 --- a/test/unit/math/mix/fun/multiply_util.hpp +++ b/test/unit/math/mix/fun/multiply_util.hpp @@ -3,7 +3,7 @@ #include template -inline void instantiate_multiply() { +void instantiate_multiply() { using stan::math::multiply; T v_scalar = 1.0; double d_scalar = 1.0; diff --git a/test/unit/math/mix/fun/pow_part1_test.cpp b/test/unit/math/mix/fun/pow_part1_test.cpp index 2f100b24458..72100764562 100644 --- a/test/unit/math/mix/fun/pow_part1_test.cpp +++ b/test/unit/math/mix/fun/pow_part1_test.cpp @@ -4,7 +4,7 @@ #include template -inline void expect_arith_instantiate() { +void expect_arith_instantiate() { auto a1 = stan::math::pow(T(1.0), 1); auto b1 = stan::math::pow(T(1.0), 1.0); auto c1 = stan::math::pow(1, T(1.0)); diff --git a/test/unit/math/mix/fun/prod_test.cpp b/test/unit/math/mix/fun/prod_test.cpp index a9ac41c9c5b..4326e18ceff 100644 --- a/test/unit/math/mix/fun/prod_test.cpp +++ b/test/unit/math/mix/fun/prod_test.cpp @@ -2,7 +2,7 @@ #include template -inline void expect_prod(const T& m) { +void expect_prod(const T& m) { auto f = [](const auto& x) { return stan::math::prod(x); }; Eigen::VectorXd v(m.size()); for (int i = 0; i < m.size(); ++i) { diff --git a/test/unit/math/mix/fun/promote_scalar_test.cpp b/test/unit/math/mix/fun/promote_scalar_test.cpp index 84bb8101e75..f49637881ea 100644 --- a/test/unit/math/mix/fun/promote_scalar_test.cpp +++ b/test/unit/math/mix/fun/promote_scalar_test.cpp @@ -8,22 +8,22 @@ namespace stan { namespace math { namespace test { template * = nullptr> -inline void expect_same_value_of_rec(T&& a, S&& b) { +void expect_same_value_of_rec(T&& a, S&& b) { using stan::math::value_of_rec; EXPECT_EQ(value_of_rec(a), value_of_rec(b)); } template * = nullptr> -inline void expect_same_value_of_rec(T&& a, S&& b) { +void expect_same_value_of_rec(T&& a, S&& b) { using stan::math::value_of_rec; EXPECT_MATRIX_EQ(value_of_rec(a), value_of_rec(b)); } template * = nullptr> -inline void expect_same_value_of_rec(T&& a, S&& b); +void expect_same_value_of_rec(T&& a, S&& b); template * = nullptr> -inline void expect_same_value_of_rec(T&& a, S&& b) { +void expect_same_value_of_rec(T&& a, S&& b) { using stan::math::value_of_rec; for (size_t i = 0; i < a.size(); ++i) { expect_same_value_of_rec(a[i], b[i]); @@ -31,7 +31,7 @@ inline void expect_same_value_of_rec(T&& a, S&& b) { } template *> -inline void expect_same_value_of_rec(T&& a, S&& b) { +void expect_same_value_of_rec(T&& a, S&& b) { stan::math::for_each( [](auto&& test, auto&& result) { stan::math::test::expect_same_value_of_rec(test, result); @@ -44,7 +44,7 @@ inline void expect_same_value_of_rec(T&& a, S&& b) { } // namespace stan template -inline void test_promote_scalar() { +void test_promote_scalar() { using eig_mat = Eigen::Matrix; auto tester_gen = []() { return std::make_tuple(UnPromotedType(1.0), eig_mat::Random(2, 2).eval(), @@ -86,7 +86,7 @@ TEST(mixFun, promote_scalar_tuple) { } template -inline void test_promote_scalar_basic() { +void test_promote_scalar_basic() { std::tuple x{UnPromotedType(3.5), UnPromotedType(4.5)}; std::tuple, UnPromotedType> z diff --git a/test/unit/math/mix/fun/pseudo_eigenvectors_test.cpp b/test/unit/math/mix/fun/pseudo_eigenvectors_test.cpp index fc0bb475a8a..f8695e2dd8a 100644 --- a/test/unit/math/mix/fun/pseudo_eigenvectors_test.cpp +++ b/test/unit/math/mix/fun/pseudo_eigenvectors_test.cpp @@ -16,7 +16,7 @@ TEST(mathMixFun, pseudoEigenvectors) { } template -inline void expect_zero_matrix(const T& m) { +void expect_zero_matrix(const T& m) { for (int j = 0; j < m.cols(); ++j) { for (int i = 0; i < m.rows(); ++i) { EXPECT_NEAR(0.0, stan::math::value_of_rec(m(i, j)), 1e-6); @@ -25,7 +25,7 @@ inline void expect_zero_matrix(const T& m) { } template -inline void test_pseudo_eigendecomposition() { +void test_pseudo_eigendecomposition() { using stan::math::pseudo_eigenvalues; using stan::math::pseudo_eigenvectors; for (const auto& x : stan::test::square_test_matrices(1, 3)) { diff --git a/test/unit/math/mix/fun/rank_test.cpp b/test/unit/math/mix/fun/rank_test.cpp index 16497887f6c..9d15638b47b 100644 --- a/test/unit/math/mix/fun/rank_test.cpp +++ b/test/unit/math/mix/fun/rank_test.cpp @@ -4,7 +4,7 @@ #include template -inline void test_rank() { +void test_rank() { using stan::math::rank; T c(1); @@ -38,7 +38,7 @@ inline void test_rank() { } template -inline void test_rank_int() { +void test_rank_int() { using stan::math::rank; T c(1); diff --git a/test/unit/math/mix/fun/rep_matrix_test.cpp b/test/unit/math/mix/fun/rep_matrix_test.cpp index 32d031a0367..293330b793f 100644 --- a/test/unit/math/mix/fun/rep_matrix_test.cpp +++ b/test/unit/math/mix/fun/rep_matrix_test.cpp @@ -4,14 +4,14 @@ TEST(MathMixMatFun, repMatrix) { // y is scalar auto f = [](int m, int n) { return [=](const auto& y) { - return stan::math::rep_matrix>(y, m, n); + return stan::math::rep_matrix(y, m, n); }; }; // y is row vector or column vector auto g = [](int k) { return [=](const auto& y) { - return stan::math::rep_matrix>(y, k); + return stan::math::rep_matrix(y, k); }; }; diff --git a/test/unit/math/mix/fun/scalbn_test.cpp b/test/unit/math/mix/fun/scalbn_test.cpp index a564cbc71da..e02da4c82a4 100644 --- a/test/unit/math/mix/fun/scalbn_test.cpp +++ b/test/unit/math/mix/fun/scalbn_test.cpp @@ -4,7 +4,7 @@ #include template -inline void expect_scalbn(double x) { +void expect_scalbn(double x) { using std::scalbn; T xt(x); for (int n = 2; n < 5; ++n) { @@ -12,7 +12,7 @@ inline void expect_scalbn(double x) { } } -inline void expect_all_scalbn(double x) { +void expect_all_scalbn(double x) { using stan::math::fvar; using stan::math::var; expect_scalbn(x); diff --git a/test/unit/math/mix/fun/sd_test.cpp b/test/unit/math/mix/fun/sd_test.cpp index 7160953b6d4..2ef3b6c5aa3 100644 --- a/test/unit/math/mix/fun/sd_test.cpp +++ b/test/unit/math/mix/fun/sd_test.cpp @@ -1,8 +1,8 @@ #include template -inline void expect_sd(const T& m, const stan::test::ad_tolerances& tols - = stan::test::ad_tolerances()) { +void expect_sd(const T& m, const stan::test::ad_tolerances& tols + = stan::test::ad_tolerances()) { auto f = [](const auto& x) { return stan::math::sd(x); }; Eigen::VectorXd v(m.size()); Eigen::RowVectorXd rv(m.size()); diff --git a/test/unit/math/mix/fun/signbit_test.cpp b/test/unit/math/mix/fun/signbit_test.cpp index 419c4cca304..357c9d72121 100644 --- a/test/unit/math/mix/fun/signbit_test.cpp +++ b/test/unit/math/mix/fun/signbit_test.cpp @@ -3,7 +3,7 @@ #include template -inline void expect_signbit() { +void expect_signbit() { using stan::math::signbit; using std::numeric_limits; using std::signbit; diff --git a/test/unit/math/mix/fun/sort_indices_test.cpp b/test/unit/math/mix/fun/sort_indices_test.cpp index f337cc2845e..a3ce18d88c8 100644 --- a/test/unit/math/mix/fun/sort_indices_test.cpp +++ b/test/unit/math/mix/fun/sort_indices_test.cpp @@ -2,7 +2,7 @@ #include #include -inline void test_sort_indices_asc2(std::vector val) { +void test_sort_indices_asc2(std::vector val) { using stan::math::fvar; using stan::math::sort_indices_asc; using stan::math::var; @@ -24,7 +24,7 @@ inline void test_sort_indices_asc2(std::vector val) { EXPECT_FALSE(x_sorted[i] == x[j]); } -inline void test_sort_indices_asc4(std::vector val) { +void test_sort_indices_asc4(std::vector val) { using stan::math::fvar; using stan::math::sort_indices_asc; using stan::math::var; @@ -46,7 +46,7 @@ inline void test_sort_indices_asc4(std::vector val) { EXPECT_FALSE(x_sorted[i] == x[j]); } -inline void test_sort_indices_desc2(std::vector val) { +void test_sort_indices_desc2(std::vector val) { using stan::math::fvar; using stan::math::sort_indices_desc; using stan::math::var; @@ -68,7 +68,7 @@ inline void test_sort_indices_desc2(std::vector val) { EXPECT_FALSE(x_sorted[i] == x[j]); } -inline void test_sort_indices_desc4(std::vector val) { +void test_sort_indices_desc4(std::vector val) { using stan::math::fvar; using stan::math::sort_indices_desc; using stan::math::var; @@ -91,7 +91,7 @@ inline void test_sort_indices_desc4(std::vector val) { } template -inline void test_sort_indices_asc2(Eigen::Matrix val) { +void test_sort_indices_asc2(Eigen::Matrix val) { using stan::math::fvar; using stan::math::sort_indices_asc; using stan::math::var; @@ -117,7 +117,7 @@ inline void test_sort_indices_asc2(Eigen::Matrix val) { } template -inline void test_sort_indices_asc4(Eigen::Matrix val) { +void test_sort_indices_asc4(Eigen::Matrix val) { using stan::math::fvar; using stan::math::sort_indices_asc; using stan::math::var; @@ -143,7 +143,7 @@ inline void test_sort_indices_asc4(Eigen::Matrix val) { } template -inline void test_sort_indices_desc2(Eigen::Matrix val) { +void test_sort_indices_desc2(Eigen::Matrix val) { using stan::math::fvar; using stan::math::sort_indices_desc; using stan::math::var; @@ -169,7 +169,7 @@ inline void test_sort_indices_desc2(Eigen::Matrix val) { } template -inline void test_sort_indices_desc4(Eigen::Matrix val) { +void test_sort_indices_desc4(Eigen::Matrix val) { using stan::math::fvar; using stan::math::sort_indices_desc; using stan::math::var; diff --git a/test/unit/math/mix/fun/sort_test.cpp b/test/unit/math/mix/fun/sort_test.cpp index dcea470c9cf..ad786a567e3 100644 --- a/test/unit/math/mix/fun/sort_test.cpp +++ b/test/unit/math/mix/fun/sort_test.cpp @@ -2,9 +2,9 @@ #include #include -inline void expect_sort(const std::vector& sv, - const stan::test::ad_tolerances& tols - = stan::test::ad_tolerances()) { +void expect_sort(const std::vector& sv, + const stan::test::ad_tolerances& tols + = stan::test::ad_tolerances()) { auto f_asc = [](const auto& x) { return stan::math::sort_asc(x); }; auto f_desc = [](const auto& x) { return stan::math::sort_desc(x); }; diff --git a/test/unit/math/mix/fun/squared_distance_test.cpp b/test/unit/math/mix/fun/squared_distance_test.cpp index 956c795ecbc..29822f54c0b 100644 --- a/test/unit/math/mix/fun/squared_distance_test.cpp +++ b/test/unit/math/mix/fun/squared_distance_test.cpp @@ -16,10 +16,10 @@ TEST(mathMixScalFun, squaredDistance) { stan::test::expect_ad(f, nan, 1.0); stan::test::expect_ad(f, nan, nan); } -inline void expect_squared_distance(const std::vector& sv1, - const std::vector& sv2, - const stan::test::ad_tolerances& tols - = stan::test::ad_tolerances()) { +void expect_squared_distance(const std::vector& sv1, + const std::vector& sv2, + const stan::test::ad_tolerances& tols + = stan::test::ad_tolerances()) { auto f = [](const auto& x, const auto& y) { return stan::math::squared_distance(x, y); }; diff --git a/test/unit/math/mix/fun/sum_test.cpp b/test/unit/math/mix/fun/sum_test.cpp index cce57b4d9f7..7bbeb075346 100644 --- a/test/unit/math/mix/fun/sum_test.cpp +++ b/test/unit/math/mix/fun/sum_test.cpp @@ -2,7 +2,7 @@ #include template -inline void expect_sum(const T& m) { +void expect_sum(const T& m) { using stan::test::expect_ad_matvar; auto f = [](const auto& x) { return stan::math::sum(x); }; Eigen::VectorXd v = stan::math::to_vector(m); diff --git a/test/unit/math/mix/fun/tail_test.cpp b/test/unit/math/mix/fun/tail_test.cpp index c79284061b2..ccb7febd42e 100644 --- a/test/unit/math/mix/fun/tail_test.cpp +++ b/test/unit/math/mix/fun/tail_test.cpp @@ -2,7 +2,7 @@ #include template -inline void expect_tail(const T& x, int n) { +void expect_tail(const T& x, int n) { auto f = [](int i) { return [=](const auto& y) { return stan::math::tail(y, i); }; }; diff --git a/test/unit/math/mix/fun/transpose_test.cpp b/test/unit/math/mix/fun/transpose_test.cpp index db7e67a8ffe..25d0069969c 100644 --- a/test/unit/math/mix/fun/transpose_test.cpp +++ b/test/unit/math/mix/fun/transpose_test.cpp @@ -1,6 +1,6 @@ #include -inline void expect_transpose(const Eigen::MatrixXd& m) { +void expect_transpose(const Eigen::MatrixXd& m) { auto f = [](const auto& x) { return stan::math::transpose(x); }; Eigen::VectorXd v = stan::test::to_vector(m); Eigen::RowVectorXd rv = stan::test::to_row_vector(m); diff --git a/test/unit/math/mix/fun/ub_constrain_matvar_test.cpp b/test/unit/math/mix/fun/ub_constrain_matvar_test.cpp index a739e72c91a..5efcfbe6cda 100644 --- a/test/unit/math/mix/fun/ub_constrain_matvar_test.cpp +++ b/test/unit/math/mix/fun/ub_constrain_matvar_test.cpp @@ -3,7 +3,7 @@ namespace ub_constrain_test { template -inline void expect_matvar(const T1& x, const T2& ub) { +void expect_matvar(const T1& x, const T2& ub) { auto f1 = [](const auto& x, const auto& ub) { stan::return_type_t lp = 0; return stan::math::ub_constrain(x, ub, lp); @@ -30,7 +30,7 @@ inline void expect_matvar(const T1& x, const T2& ub) { } template -inline void expect_vec_matvar(const T1& x, const T2& ub) { +void expect_vec_matvar(const T1& x, const T2& ub) { auto f1 = [](const auto& x, const auto& ub) { stan::return_type_t lp = 0; return stan::math::ub_constrain(x, ub, lp); diff --git a/test/unit/math/mix/fun/ub_constrain_test.cpp b/test/unit/math/mix/fun/ub_constrain_test.cpp index e1c79d55ddc..90ec887fcd2 100644 --- a/test/unit/math/mix/fun/ub_constrain_test.cpp +++ b/test/unit/math/mix/fun/ub_constrain_test.cpp @@ -3,7 +3,7 @@ namespace ub_constrain_test { template -inline void expect(const T1& x, const T2& ub) { +void expect(const T1& x, const T2& ub) { auto f1 = [](const auto& x, const auto& ub) { stan::return_type_t lp = 0; return stan::math::ub_constrain(x, ub, lp); @@ -30,7 +30,7 @@ inline void expect(const T1& x, const T2& ub) { } template -inline void expect_vec(const T1& x, const T2& ub) { +void expect_vec(const T1& x, const T2& ub) { auto f1 = [](const auto& x, const auto& ub) { stan::return_type_t lp = 0; return stan::math::ub_constrain(x, ub, lp); diff --git a/test/unit/math/mix/fun/value_of_test.cpp b/test/unit/math/mix/fun/value_of_test.cpp index 393cc431bd1..d095d5afa25 100644 --- a/test/unit/math/mix/fun/value_of_test.cpp +++ b/test/unit/math/mix/fun/value_of_test.cpp @@ -145,6 +145,9 @@ TEST(AgradMix, tuple_value_of) { // tuple(vector, array[tuple(vec, vec, vec, array[], tuple(mat, mat, mat, // array[]))]) auto a_b_tuple_vec_tuple_ad = std::make_tuple(v_a, a_b_tuple_vec_ad, ffv_b); + using ffv = fvar>; + using fv = fvar; + using v = var; stan::math::test::recursive_for_each( [](auto&& x_ad, auto&& x_dbl) { EXPECT_FLOAT_EQ(stan::math::test::get_val(x_ad), x_dbl); diff --git a/test/unit/math/mix/fun/variance_test.cpp b/test/unit/math/mix/fun/variance_test.cpp index 5b6d77a324a..f4f26364eb0 100644 --- a/test/unit/math/mix/fun/variance_test.cpp +++ b/test/unit/math/mix/fun/variance_test.cpp @@ -1,7 +1,7 @@ #include #include -inline void expect_variance(const Eigen::MatrixXd& m) { +void expect_variance(const Eigen::MatrixXd& m) { auto f = [](const auto& x) { return stan::math::variance(x); }; Eigen::VectorXd v = stan::test::to_vector(m); Eigen::RowVectorXd rv = stan::math::to_row_vector(m); diff --git a/test/unit/math/mix/functor/finite_diff_grad_hessian_auto_test.cpp b/test/unit/math/mix/functor/finite_diff_grad_hessian_auto_test.cpp index d5946aac4f5..cecc05b8e7a 100644 --- a/test/unit/math/mix/functor/finite_diff_grad_hessian_auto_test.cpp +++ b/test/unit/math/mix/functor/finite_diff_grad_hessian_auto_test.cpp @@ -5,8 +5,8 @@ #include template -inline void test_grad_hessian_finite_diff(const std::string& msg, const F& f, - Eigen::VectorXd& x) { +void test_grad_hessian_finite_diff(const std::string& msg, const F& f, + Eigen::VectorXd& x) { double fx; Eigen::VectorXd grad_fx; Eigen::MatrixXd hess_fx; diff --git a/test/unit/math/mix/functor/finite_diff_gradient_auto_test.cpp b/test/unit/math/mix/functor/finite_diff_gradient_auto_test.cpp index eeae792742a..e288331aae0 100644 --- a/test/unit/math/mix/functor/finite_diff_gradient_auto_test.cpp +++ b/test/unit/math/mix/functor/finite_diff_gradient_auto_test.cpp @@ -4,7 +4,7 @@ #include template -inline void expect_match_autodiff(const F& f, Eigen::VectorXd x) { +void expect_match_autodiff(const F& f, Eigen::VectorXd x) { double fx_fd; Eigen::VectorXd grad_fx_fd; stan::math::finite_diff_gradient_auto(f, x, fx_fd, grad_fx_fd); diff --git a/test/unit/math/mix/functor/reduce_sum_util.hpp b/test/unit/math/mix/functor/reduce_sum_util.hpp index 6666d7eea2f..9d70fe1054c 100644 --- a/test/unit/math/mix/functor/reduce_sum_util.hpp +++ b/test/unit/math/mix/functor/reduce_sum_util.hpp @@ -15,7 +15,7 @@ namespace math { namespace test { template -inline void expect_ad_reduce_sum_lpdf(T1&& data, T2&& arg) { +void expect_ad_reduce_sum_lpdf(T1&& data, T2&& arg) { using stan::math::test::reduce_sum_int_sum_lpdf; using stan::math::test::reduce_sum_static_int_sum_lpdf; using stan::math::test::reduce_sum_static_sum_lpdf; diff --git a/test/unit/math/mix/meta/base_type_test.cpp b/test/unit/math/mix/meta/base_type_test.cpp index e71c0bc851f..f1454afbefc 100644 --- a/test/unit/math/mix/meta/base_type_test.cpp +++ b/test/unit/math/mix/meta/base_type_test.cpp @@ -5,7 +5,7 @@ #include template -inline void expect_base() { +void expect_base() { EXPECT_SAME_TYPE(R, typename stan::base_type::type); EXPECT_SAME_TYPE(R, stan::base_type_t); EXPECT_SAME_TYPE(R, typename stan::base_type::type); @@ -17,7 +17,7 @@ inline void expect_base() { } template -inline void test_base() { +void test_base() { // scalar types expect_base(); diff --git a/test/unit/math/mix/meta/eigen_utils.hpp b/test/unit/math/mix/meta/eigen_utils.hpp index 09f9fb7ebb8..b44df145390 100644 --- a/test/unit/math/mix/meta/eigen_utils.hpp +++ b/test/unit/math/mix/meta/eigen_utils.hpp @@ -26,7 +26,7 @@ namespace test { */ template class Checker> -inline void test_eigen_sparse_matrix() { +void test_eigen_sparse_matrix() { using Eigen::EigenBase; using Eigen::SparseCompressedBase; using Eigen::SparseMapBase; @@ -70,7 +70,7 @@ inline void test_eigen_sparse_matrix() { */ template class Checker, typename EigenType> -inline void test_eigen_dense_hierarchy() { +void test_eigen_dense_hierarchy() { using Eigen::ArrayBase; using Eigen::DenseBase; using Eigen::EigenBase; @@ -117,7 +117,7 @@ inline void test_eigen_dense_hierarchy() { */ template class Checker, typename EigenType> -inline void test_eigen_dense_exprs() { +void test_eigen_dense_exprs() { std::remove_reference_t A; std::remove_reference_t B; @@ -155,7 +155,7 @@ inline void test_eigen_dense_exprs() { */ template class Checker> -inline void test_eigen_dense_decomp_matrix() { +void test_eigen_dense_decomp_matrix() { using Eigen::DenseBase; using Eigen::EigenBase; using Eigen::MapBase; @@ -176,7 +176,7 @@ inline void test_eigen_dense_decomp_matrix() { */ template class Checker> -inline void test_eigen_dense_decomp_array() { +void test_eigen_dense_decomp_array() { using Eigen::DenseBase; using Eigen::EigenBase; using Eigen::MapBase; @@ -211,7 +211,7 @@ inline void test_eigen_dense_decomp_array() { template class Checker, template class EigenType, int... EigenDims> -inline void all_eigen_dense() { +void all_eigen_dense() { using stan::math::fvar; using stan::math::var; @@ -250,7 +250,7 @@ inline void all_eigen_dense() { template class Checker, template class EigenType, int... EigenDims> -inline void all_eigen_dense_exprs() { +void all_eigen_dense_exprs() { using stan::math::fvar; using stan::math::var; test_eigen_dense_exprs class Checker> -inline void all_eigen_dense_decomp() { +void all_eigen_dense_decomp() { using stan::math::fvar; using stan::math::var; @@ -307,7 +307,7 @@ inline void all_eigen_dense_decomp() { */ template class Checker> -inline void all_eigen_sparse() { +void all_eigen_sparse() { using stan::math::fvar; using stan::math::var; diff --git a/test/unit/math/mix/meta/is_complex_test.cpp b/test/unit/math/mix/meta/is_complex_test.cpp index 9d2dda8c90c..61969d80578 100644 --- a/test/unit/math/mix/meta/is_complex_test.cpp +++ b/test/unit/math/mix/meta/is_complex_test.cpp @@ -5,12 +5,12 @@ #include template -inline void expect_is_complex() { +void expect_is_complex() { EXPECT_EQ(expected, stan::is_complex::value); } template -inline void test_is_complex() { +void test_is_complex() { expect_is_complex>(); expect_is_complex>(); expect_is_complex&>(); @@ -37,12 +37,12 @@ TEST(stanMathMix, isComplex) { } template -inline void expect_is_vt_complex() { +void expect_is_vt_complex() { EXPECT_EQ(expected, stan::is_vt_complex::value); } template -inline void test_is_vt_complex() { +void test_is_vt_complex() { using complex_std_vec = std::vector>; using complex_eigen_vec = Eigen::Matrix, -1, 1>; expect_is_vt_complex(); @@ -78,12 +78,12 @@ TEST(stanMathMix, is_vt_Complex) { } template -inline void expect_is_vt_not_complex() { +void expect_is_vt_not_complex() { EXPECT_EQ(expected, stan::is_vt_not_complex::value); } template -inline void test_is_vt_not_complex() { +void test_is_vt_not_complex() { using complex_std_vec = std::vector>; using complex_eigen_vec = Eigen::Matrix, -1, 1>; expect_is_vt_not_complex(); diff --git a/test/unit/math/mix/meta/is_constant_all_test.cpp b/test/unit/math/mix/meta/is_constant_all_test.cpp index e4e48782f45..ad52f661747 100644 --- a/test/unit/math/mix/meta/is_constant_all_test.cpp +++ b/test/unit/math/mix/meta/is_constant_all_test.cpp @@ -2,7 +2,7 @@ #include template -inline void expect_not_const() { +void expect_not_const() { using stan::is_constant_all; bool temp = is_constant_all::value; EXPECT_FALSE(temp); diff --git a/test/unit/math/mix/meta/return_type_test.cpp b/test/unit/math/mix/meta/return_type_test.cpp index ae284528055..64bce0a1ae4 100644 --- a/test/unit/math/mix/meta/return_type_test.cpp +++ b/test/unit/math/mix/meta/return_type_test.cpp @@ -5,13 +5,13 @@ #include template -inline void expect_return() { +void expect_return() { EXPECT_SAME_TYPE(R, typename stan::return_type::type); EXPECT_SAME_TYPE(R, stan::return_type_t); } template -inline void test_return() { +void test_return() { // scalar types expect_return(); expect_return(); diff --git a/test/unit/math/mix/meta/scalar_type_test.cpp b/test/unit/math/mix/meta/scalar_type_test.cpp index 6f9450aad9d..96f54517078 100644 --- a/test/unit/math/mix/meta/scalar_type_test.cpp +++ b/test/unit/math/mix/meta/scalar_type_test.cpp @@ -4,7 +4,7 @@ #include template -inline void expect_scalar_type() { +void expect_scalar_type() { using stan::scalar_type_t; static_assert(std::is_same>::value, "NOT SAME"); static_assert(std::is_same>::value, "NOT SAME"); @@ -19,7 +19,7 @@ inline void expect_scalar_type() { } template -inline void test_scalar_type() { +void test_scalar_type() { using Eigen::Matrix; using std::complex; using std::vector; diff --git a/test/unit/math/mix/prob/dirichlet_test.cpp b/test/unit/math/mix/prob/dirichlet_test.cpp index 0b1ea61dae0..419dd83dccd 100644 --- a/test/unit/math/mix/prob/dirichlet_test.cpp +++ b/test/unit/math/mix/prob/dirichlet_test.cpp @@ -2,7 +2,7 @@ namespace dirichlet_test { template -inline std::vector vectorize_softmax(const std::vector& y) { +std::vector vectorize_softmax(const std::vector& y) { std::vector y_simplex; for (size_t i = 0; i < y.size(); ++i) { y_simplex.push_back(stan::math::softmax(y[i])); @@ -11,7 +11,7 @@ inline std::vector vectorize_softmax(const std::vector& y) { } template * = nullptr> -inline T vectorize_softmax(const T& y) { +T vectorize_softmax(const T& y) { return stan::math::softmax(y); } } // namespace dirichlet_test diff --git a/test/unit/math/mix/prob/higher_order_utils.hpp b/test/unit/math/mix/prob/higher_order_utils.hpp index 7285c6bf15d..369b7d3f2b8 100644 --- a/test/unit/math/mix/prob/higher_order_utils.hpp +++ b/test/unit/math/mix/prob/higher_order_utils.hpp @@ -4,17 +4,16 @@ #include #include -inline void test_hess_eq(Eigen::Matrix hess_1, - Eigen::Matrix hess_2) { +void test_hess_eq(Eigen::Matrix hess_1, + Eigen::Matrix hess_2) { for (int i = 0; i < hess_1.size(); ++i) { double tolerance = 1e-6 * fmax(fabs(hess_1(i)), fabs(hess_2(i))) + 1e-10; EXPECT_NEAR(hess_1(i), hess_2(i), tolerance); } } -inline void test_grad_hess_eq( - std::vector > g_hess_1, - std::vector > g_hess_2) { +void test_grad_hess_eq(std::vector > g_hess_1, + std::vector > g_hess_2) { for (size_t m = 0; m < g_hess_1.size(); ++m) for (int i = 0; i < g_hess_1[m].size(); ++i) { double tolerance diff --git a/test/unit/math/mix/prob/util.hpp b/test/unit/math/mix/prob/util.hpp index 5b1dea8ad59..e3536ca986c 100644 --- a/test/unit/math/mix/prob/util.hpp +++ b/test/unit/math/mix/prob/util.hpp @@ -45,4 +45,21 @@ class Wiener5MixArgs : public ::testing::Test { 0.2, 0.02, 9.0, 0.01, 0.2, 4, 0.2, 1e14}}; }; +class Wiener4MixArgs : public ::testing::Test { + public: + const char* function = "function"; + void SetUp() {} + + Eigen::VectorXd y{{1.0, 0.05, 3.0, 1.0, 1.0, 2.0, 1.0, 1e-14, 1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 100.0, 1e10}}; + Eigen::VectorXd a{{2.5, 2.5, 2.5, 0.2, 15.0, 1e-13, 2.5e10, 2.5, 2.5, 2.5, + 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5}}; + Eigen::VectorXd t0{{2.2, 0.01, 2.2, 0.2, 0.2, 1.99, 1e-13, 0.0, 0.2, 0.2, 0.2, + 0.2, 0.2, 0.2, 0.2, 0.2, 1e13, 0.2, 0.2}}; + Eigen::VectorXd w{{0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 1e-13, 0.999999999999, + 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5}}; + Eigen::VectorXd v{{2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 1e-12, 0.0, 2.0, 0.0, -5.0, + 8.0, 2.0, 2.0, 2.0, 2.0, 2.0, 4e10, -4e10}}; +}; + #endif diff --git a/test/unit/math/mix/prob/wiener4_lccdf_0_test.cpp b/test/unit/math/mix/prob/wiener4_lccdf_0_test.cpp new file mode 100644 index 00000000000..d32b38c7fa6 --- /dev/null +++ b/test/unit/math/mix/prob/wiener4_lccdf_0_test.cpp @@ -0,0 +1,33 @@ +#include +#include + +TEST(mathMixDouble, wiener4_lccdf) { + double y = 1.0; + double a = 2.5; + double t0 = 0.2; + double w = 0.5; + double v = 1.5; + stan::math::wiener_lccdf(y, a, t0, w, v, 1e-4); +} + +TEST(mathMixVar, wiener4_lccdf) { + using stan::math::var; + var y = 1.0; + var a = 2.5; + var t0 = 0.2; + var w = 0.5; + var v = 1.5; + stan::math::wiener_lccdf(y, a, t0, w, v, 1e-4); +} + +TEST(mathMixFVar, wiener4_lccdf) { + using stan::math::fvar; + using stan::math::var; + fvar y = 1.0; + fvar a = 2.5; + fvar t0 = 0.2; + fvar w = 0.5; + fvar v = 1.5; + double error = 1e-4; + stan::math::wiener_lccdf(y, a, t0, w, v, error); +} diff --git a/test/unit/math/mix/prob/wiener4_lccdf_1_test.cpp b/test/unit/math/mix/prob/wiener4_lccdf_1_test.cpp new file mode 100644 index 00000000000..26425508337 --- /dev/null +++ b/test/unit/math/mix/prob/wiener4_lccdf_1_test.cpp @@ -0,0 +1,48 @@ +#include +#include +#include + +TEST_F(Wiener4MixArgs, wiener_lccdf_y_a_t0) { + auto f_y_a_t0 = [](const auto& w, const auto& v) { + return [&w, &v](const auto& y, const auto& a, const auto& t0) { + return stan::math::wiener_lccdf(y, a, t0, w, v, 1e-4); + }; + }; + stan::test::expect_ad(f_y_a_t0(w, v), y, a, t0); +} + +TEST_F(Wiener4MixArgs, wiener_lccdf_y_a_w) { + auto f_y_a_w = [](const auto& t0, const auto& v) { + return [&t0, &v](const auto& y, const auto& a, const auto& w) { + return stan::math::wiener_lccdf(y, a, t0, w, v, 1e-4); + }; + }; + stan::test::expect_ad(f_y_a_w(t0, v), y, a, w); +} + +TEST_F(Wiener4MixArgs, wiener_lccdf_y_a_v) { + auto f_y_a_v = [](const auto& t0, const auto& w) { + return [&t0, &w](const auto& y, const auto& a, const auto& v) { + return stan::math::wiener_lccdf(y, a, t0, w, v, 1e-4); + }; + }; + stan::test::expect_ad(f_y_a_v(t0, w), y, a, v); +} + +TEST_F(Wiener4MixArgs, wiener_lccdf_y_t0_w) { + auto f_y_t0_w = [](const auto& a, const auto& v) { + return [&a, &v](const auto& y, const auto& t0, const auto& w) { + return stan::math::wiener_lccdf(y, a, t0, w, v, 1e-4); + }; + }; + stan::test::expect_ad(f_y_t0_w(a, v), y, t0, w); +} + +TEST_F(Wiener4MixArgs, wiener_lccdf_y_t0_v) { + auto f_y_t0_v = [](const auto& a, const auto& w) { + return [&a, &w](const auto& y, const auto& t0, const auto& v) { + return stan::math::wiener_lccdf(y, a, t0, w, v, 1e-4); + }; + }; + stan::test::expect_ad(f_y_t0_v(a, w), y, t0, v); +} diff --git a/test/unit/math/mix/prob/wiener4_lccdf_2_test.cpp b/test/unit/math/mix/prob/wiener4_lccdf_2_test.cpp new file mode 100644 index 00000000000..579bf94189a --- /dev/null +++ b/test/unit/math/mix/prob/wiener4_lccdf_2_test.cpp @@ -0,0 +1,48 @@ +#include +#include +#include + +TEST_F(Wiener4MixArgs, wiener_lccdf_y_w_v) { + auto f_y_w_v = [](const auto& a, const auto& t0) { + return [&a, &t0](const auto& y, const auto& w, const auto& v) { + return stan::math::wiener_lccdf(y, a, t0, w, v, 1e-4); + }; + }; + stan::test::expect_ad(f_y_w_v(a, t0), y, w, v); +} + +TEST_F(Wiener4MixArgs, wiener_lccdf_a_t0_w) { + auto f_a_t0_w = [](const auto& y, const auto& v) { + return [&y, &v](const auto& a, const auto& t0, const auto& w) { + return stan::math::wiener_lccdf(y, a, t0, w, v, 1e-4); + }; + }; + stan::test::expect_ad(f_a_t0_w(y, v), a, t0, w); +} + +TEST_F(Wiener4MixArgs, wiener_lccdf_a_t0_v) { + auto f_a_t0_v = [](const auto& y, const auto& w) { + return [&y, &w](const auto& a, const auto& t0, const auto& v) { + return stan::math::wiener_lccdf(y, a, t0, w, v, 1e-4); + }; + }; + stan::test::expect_ad(f_a_t0_v(y, w), a, t0, v); +} + +TEST_F(Wiener4MixArgs, wiener_lccdf_a_w_v) { + auto f_a_w_v = [](const auto& y, const auto& t0) { + return [&y, &t0](const auto& a, const auto& w, const auto& v) { + return stan::math::wiener_lccdf(y, a, t0, w, v, 1e-4); + }; + }; + stan::test::expect_ad(f_a_w_v(y, t0), a, w, v); +} + +TEST_F(Wiener4MixArgs, wiener_lccdf_t0_w_v) { + auto f_t0_w_v = [](const auto& y, const auto& a) { + return [&y, &a](const auto& t0, const auto& w, const auto& v) { + return stan::math::wiener_lccdf(y, a, t0, w, v, 1e-4); + }; + }; + stan::test::expect_ad(f_t0_w_v(y, a), t0, w, v); +} diff --git a/test/unit/math/mix/prob/wiener4_lcdf_0_test.cpp b/test/unit/math/mix/prob/wiener4_lcdf_0_test.cpp new file mode 100644 index 00000000000..23a7d5d3ae1 --- /dev/null +++ b/test/unit/math/mix/prob/wiener4_lcdf_0_test.cpp @@ -0,0 +1,33 @@ +#include +#include + +TEST(mathMixDouble, wiener4_lcdf) { + double y = 1.0; + double a = 2.5; + double t0 = 0.2; + double w = 0.5; + double v = 1.5; + stan::math::wiener_lcdf(y, a, t0, w, v, 1e-4); +} + +TEST(mathMixVar, wiener4_lcdf) { + using stan::math::var; + var y = 1.0; + var a = 2.5; + var t0 = 0.2; + var w = 0.5; + var v = 1.5; + stan::math::wiener_lcdf(y, a, t0, w, v, 1e-4); +} + +TEST(mathMixFVar, wiener4_lcdf) { + using stan::math::fvar; + using stan::math::var; + fvar y = 1.0; + fvar a = 2.5; + fvar t0 = 0.2; + fvar w = 0.5; + fvar v = 1.5; + double error = 1e-4; + stan::math::wiener_lcdf(y, a, t0, w, v, error); +} diff --git a/test/unit/math/mix/prob/wiener4_lcdf_1_test.cpp b/test/unit/math/mix/prob/wiener4_lcdf_1_test.cpp new file mode 100644 index 00000000000..2cda5b5899c --- /dev/null +++ b/test/unit/math/mix/prob/wiener4_lcdf_1_test.cpp @@ -0,0 +1,48 @@ +#include +#include +#include + +TEST_F(Wiener4MixArgs, wiener_lcdf_y_a_t0) { + auto f_y_a_t0 = [](const auto& w, const auto& v) { + return [&w, &v](const auto& y, const auto& a, const auto& t0) { + return stan::math::wiener_lcdf(y, a, t0, w, v, 1e-4); + }; + }; + stan::test::expect_ad(f_y_a_t0(w, v), y, a, t0); +} + +TEST_F(Wiener4MixArgs, wiener_lcdf_y_a_w) { + auto f_y_a_w = [](const auto& t0, const auto& v) { + return [&t0, &v](const auto& y, const auto& a, const auto& w) { + return stan::math::wiener_lcdf(y, a, t0, w, v, 1e-4); + }; + }; + stan::test::expect_ad(f_y_a_w(t0, v), y, a, w); +} + +TEST_F(Wiener4MixArgs, wiener_lcdf_y_a_v) { + auto f_y_a_v = [](const auto& t0, const auto& w) { + return [&t0, &w](const auto& y, const auto& a, const auto& v) { + return stan::math::wiener_lcdf(y, a, t0, w, v, 1e-4); + }; + }; + stan::test::expect_ad(f_y_a_v(t0, w), y, a, v); +} + +TEST_F(Wiener4MixArgs, wiener_lcdf_y_t0_w) { + auto f_y_t0_w = [](const auto& a, const auto& v) { + return [&a, &v](const auto& y, const auto& t0, const auto& w) { + return stan::math::wiener_lcdf(y, a, t0, w, v, 1e-4); + }; + }; + stan::test::expect_ad(f_y_t0_w(a, v), y, t0, w); +} + +TEST_F(Wiener4MixArgs, wiener_lcdf_y_t0_v) { + auto f_y_t0_v = [](const auto& a, const auto& w) { + return [&a, &w](const auto& y, const auto& t0, const auto& v) { + return stan::math::wiener_lcdf(y, a, t0, w, v, 1e-4); + }; + }; + stan::test::expect_ad(f_y_t0_v(a, w), y, t0, v); +} diff --git a/test/unit/math/mix/prob/wiener4_lcdf_2_test.cpp b/test/unit/math/mix/prob/wiener4_lcdf_2_test.cpp new file mode 100644 index 00000000000..2677da3b92b --- /dev/null +++ b/test/unit/math/mix/prob/wiener4_lcdf_2_test.cpp @@ -0,0 +1,48 @@ +#include +#include +#include + +TEST_F(Wiener4MixArgs, wiener_lcdf_y_w_v) { + auto f_y_w_v = [](const auto& a, const auto& t0) { + return [&a, &t0](const auto& y, const auto& w, const auto& v) { + return stan::math::wiener_lcdf(y, a, t0, w, v, 1e-4); + }; + }; + stan::test::expect_ad(f_y_w_v(a, t0), y, w, v); +} + +TEST_F(Wiener4MixArgs, wiener_lcdf_a_t0_w) { + auto f_a_t0_w = [](const auto& y, const auto& v) { + return [&y, &v](const auto& a, const auto& t0, const auto& w) { + return stan::math::wiener_lcdf(y, a, t0, w, v, 1e-4); + }; + }; + stan::test::expect_ad(f_a_t0_w(y, v), a, t0, w); +} + +TEST_F(Wiener4MixArgs, wiener_lcdf_a_t0_v) { + auto f_a_t0_v = [](const auto& y, const auto& w) { + return [&y, &w](const auto& a, const auto& t0, const auto& v) { + return stan::math::wiener_lcdf(y, a, t0, w, v, 1e-4); + }; + }; + stan::test::expect_ad(f_a_t0_v(y, w), a, t0, v); +} + +TEST_F(Wiener4MixArgs, wiener_lcdf_a_w_v) { + auto f_a_w_v = [](const auto& y, const auto& t0) { + return [&y, &t0](const auto& a, const auto& w, const auto& v) { + return stan::math::wiener_lcdf(y, a, t0, w, v, 1e-4); + }; + }; + stan::test::expect_ad(f_a_w_v(y, t0), a, w, v); +} + +TEST_F(Wiener4MixArgs, wiener_lcdf_t0_w_v) { + auto f_t0_w_v = [](const auto& y, const auto& a) { + return [&y, &a](const auto& t0, const auto& w, const auto& v) { + return stan::math::wiener_lcdf(y, a, t0, w, v, 1e-4); + }; + }; + stan::test::expect_ad(f_t0_w_v(y, a), t0, w, v); +} diff --git a/test/unit/math/mix/prob/wiener5_lpdf_0_test.cpp b/test/unit/math/mix/prob/wiener5_lpdf_0_test.cpp index 24901ac760b..4cc6ba01367 100644 --- a/test/unit/math/mix/prob/wiener5_lpdf_0_test.cpp +++ b/test/unit/math/mix/prob/wiener5_lpdf_0_test.cpp @@ -3,7 +3,7 @@ TEST(mathMixDouble5, wiener_lpdf) { double y = 1.0; - double a = 2.0; + double a = 2.5; double t0 = 0.2; double w = 0.5; double v = 1.5; @@ -14,7 +14,7 @@ TEST(mathMixDouble5, wiener_lpdf) { TEST(mathMixVar5, wiener_lpdf) { using stan::math::var; var y = 1.0; - var a = 2.0; + var a = 2.5; var t0 = 0.2; var w = 0.5; var v = 1.5; @@ -26,7 +26,7 @@ TEST(mathMixFVar5, wiener_lpdf) { using stan::math::fvar; using stan::math::var; fvar y = 1.0; - fvar a = 2.0; + fvar a = 2.5; fvar t0 = 0.2; fvar w = 0.5; fvar v = 1.5; diff --git a/test/unit/math/mix/prob/wiener_full_lccdf_0_test.cpp b/test/unit/math/mix/prob/wiener_full_lccdf_0_test.cpp new file mode 100644 index 00000000000..569c677d043 --- /dev/null +++ b/test/unit/math/mix/prob/wiener_full_lccdf_0_test.cpp @@ -0,0 +1,53 @@ +#include +#include +#include + +TEST(mathMixDouble, wiener_lccdf) { + double y = 1.0; + double a = 2.0; + double t0 = 0.2; + double w = 0.5; + double v = 1.5; + double sv = 0.2; + double sw = 0.2; + double st0 = 0.2; + stan::math::wiener_lccdf(y, a, t0, w, v, sv, sw, st0, 1e-4); +} + +TEST(mathMixVar, wiener_lccdf) { + using stan::math::var; + var y = 1.0; + var a = 2.0; + var t0 = 0.2; + var w = 0.5; + var v = 1.5; + var sv = 0.2; + var sw = 0; + var st0 = 0.2; + stan::math::wiener_lccdf(y, a, t0, w, v, sv, sw, st0); +} + +TEST(mathMixFVar, wiener_lccdf) { + using stan::math::fvar; + using stan::math::var; + fvar y = 1.0; + fvar a = 2.0; + fvar t0 = 0.2; + fvar w = 0.5; + fvar v = 1.5; + fvar sv = 0.2; + fvar sw = 0; + fvar st0 = 0.2; + stan::math::wiener_lccdf(y, a, t0, w, v, sv, sw, st0); +} + +TEST_F(Wiener7MixArgs, wiener_lccdf_y_a_t0) { + auto f_y_a_t0 = [](const auto& w, const auto& v, const auto& sv, + const auto& sw, const auto& st0) { + return + [&w, &v, &sv, &sw, &st0](const auto& y, const auto& a, const auto& t0) { + return stan::math::wiener_lccdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_y_a_t0(w, v, sv, sw, st0), y, a, t0); +} diff --git a/test/unit/math/mix/prob/wiener_full_lccdf_10_test.cpp b/test/unit/math/mix/prob/wiener_full_lccdf_10_test.cpp new file mode 100644 index 00000000000..e7eca727b91 --- /dev/null +++ b/test/unit/math/mix/prob/wiener_full_lccdf_10_test.cpp @@ -0,0 +1,58 @@ +#include +#include +#include + +TEST_F(Wiener7MixArgs, wiener_lccdf_w_v_sv) { + auto f_w_v_sv = [](const auto& y, const auto& a, const auto& t0, + const auto& sw, const auto& st0) { + return + [&y, &a, &t0, &sw, &st0](const auto& w, const auto& v, const auto& sv) { + return stan::math::wiener_lccdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_w_v_sv(y, a, t0, sw, st0), w, v, sv); +} + +TEST_F(Wiener7MixArgs, wiener_lccdf_w_v_sw) { + auto f_w_v_sw = [](const auto& y, const auto& a, const auto& t0, + const auto& sv, const auto& st0) { + return + [&y, &a, &t0, &sv, &st0](const auto& w, const auto& v, const auto& sw) { + return stan::math::wiener_lccdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_w_v_sw(y, a, t0, sv, st0), w, v, sw); +} + +TEST_F(Wiener7MixArgs, wiener_lccdf_w_v_st0) { + auto f_w_v_st0 = [](const auto& y, const auto& a, const auto& t0, + const auto& sv, const auto& sw) { + return + [&y, &a, &t0, &sv, &sw](const auto& w, const auto& v, const auto& st0) { + return stan::math::wiener_lccdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_w_v_st0(y, a, t0, sv, sw), w, v, st0); +} + +TEST_F(Wiener7MixArgs, wiener_lccdf_w_sv_sw) { + auto f_w_sv_sw = [](const auto& y, const auto& a, const auto& t0, + const auto& v, const auto& st0) { + return + [&y, &a, &t0, &v, &st0](const auto& w, const auto& sv, const auto& sw) { + return stan::math::wiener_lccdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_w_sv_sw(y, a, t0, v, st0), w, sv, sw); +} + +TEST_F(Wiener7MixArgs, wiener_lccdf_w_sv_st0) { + auto f_w_sv_st0 = [](const auto& y, const auto& a, const auto& t0, + const auto& v, const auto& sw) { + return + [&y, &a, &t0, &v, &sw](const auto& w, const auto& sv, const auto& st0) { + return stan::math::wiener_lccdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_w_sv_st0(y, a, t0, v, sw), w, sv, st0); +} diff --git a/test/unit/math/mix/prob/wiener_full_lccdf_11_test.cpp b/test/unit/math/mix/prob/wiener_full_lccdf_11_test.cpp new file mode 100644 index 00000000000..11d7d7c5c27 --- /dev/null +++ b/test/unit/math/mix/prob/wiener_full_lccdf_11_test.cpp @@ -0,0 +1,58 @@ +#include +#include +#include + +TEST_F(Wiener7MixArgs, wiener_lccdf_w_sw_st0) { + auto f_w_sw_st0 = [](const auto& y, const auto& a, const auto& t0, + const auto& v, const auto& sv) { + return + [&y, &a, &t0, &v, &sv](const auto& w, const auto& sw, const auto& st0) { + return stan::math::wiener_lccdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_w_sw_st0(y, a, t0, v, sv), w, sw, st0); +} + +TEST_F(Wiener7MixArgs, wiener_lccdf_v_sv_sw) { + auto f_v_sv_sw = [](const auto& y, const auto& a, const auto& t0, + const auto& w, const auto& st0) { + return + [&y, &a, &t0, &w, &st0](const auto& v, const auto& sv, const auto& sw) { + return stan::math::wiener_lccdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_v_sv_sw(y, a, t0, w, st0), v, sv, sw); +} + +TEST_F(Wiener7MixArgs, wiener_lccdf_v_sv_st0) { + auto f_v_sv_st0 = [](const auto& y, const auto& a, const auto& t0, + const auto& w, const auto& sw) { + return + [&y, &a, &t0, &w, &sw](const auto& v, const auto& sv, const auto& st0) { + return stan::math::wiener_lccdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_v_sv_st0(y, a, t0, w, sw), v, sv, st0); +} + +TEST_F(Wiener7MixArgs, wiener_lccdf_v_sw_st0) { + auto f_v_sw_st0 = [](const auto& y, const auto& a, const auto& t0, + const auto& w, const auto& sv) { + return + [&y, &a, &t0, &w, &sv](const auto& v, const auto& sw, const auto& st0) { + return stan::math::wiener_lccdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_v_sw_st0(y, a, t0, w, sv), v, sw, st0); +} + +TEST_F(Wiener7MixArgs, wiener_lccdf_sv_sw_st0) { + auto f_sv_sw_st0 = [](const auto& y, const auto& a, const auto& t0, + const auto& w, const auto& v) { + return + [&y, &a, &t0, &w, &v](const auto& sv, const auto& sw, const auto& st0) { + return stan::math::wiener_lccdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_sv_sw_st0(y, a, t0, w, v), sv, sw, st0); +} diff --git a/test/unit/math/mix/prob/wiener_full_lccdf_1_test.cpp b/test/unit/math/mix/prob/wiener_full_lccdf_1_test.cpp new file mode 100644 index 00000000000..771e20d4c57 --- /dev/null +++ b/test/unit/math/mix/prob/wiener_full_lccdf_1_test.cpp @@ -0,0 +1,58 @@ +#include +#include +#include + +TEST_F(Wiener7MixArgs, wiener_lccdf_y_a_w) { + auto f_y_a_w = [](const auto& t0, const auto& v, const auto& sv, + const auto& sw, const auto& st0) { + return + [&t0, &v, &sv, &sw, &st0](const auto& y, const auto& a, const auto& w) { + return stan::math::wiener_lccdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_y_a_w(t0, v, sv, sw, st0), y, a, w); +} + +TEST_F(Wiener7MixArgs, wiener_lccdf_y_a_v) { + auto f_y_a_v = [](const auto& t0, const auto& w, const auto& sv, + const auto& sw, const auto& st0) { + return + [&t0, &w, &sv, &sw, &st0](const auto& y, const auto& a, const auto& v) { + return stan::math::wiener_lccdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_y_a_v(t0, w, sv, sw, st0), y, a, v); +} + +TEST_F(Wiener7MixArgs, wiener_lccdf_y_a_sv) { + auto f_y_a_sv = [](const auto& t0, const auto& w, const auto& v, + const auto& sw, const auto& st0) { + return + [&t0, &w, &v, &sw, &st0](const auto& y, const auto& a, const auto& sv) { + return stan::math::wiener_lccdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_y_a_sv(t0, w, v, sw, st0), y, a, sv); +} + +TEST_F(Wiener7MixArgs, wiener_lccdf_y_a_sw) { + auto f_y_a_sw = [](const auto& t0, const auto& w, const auto& v, + const auto& sv, const auto& st0) { + return + [&t0, &w, &v, &sv, &st0](const auto& y, const auto& a, const auto& sw) { + return stan::math::wiener_lccdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_y_a_sw(t0, w, v, sv, st0), y, a, sw); +} + +TEST_F(Wiener7MixArgs, wiener_lccdf_y_a_st0) { + auto f_y_a_st0 = [](const auto& t0, const auto& w, const auto& v, + const auto& sv, const auto& sw) { + return + [&t0, &w, &v, &sv, &sw](const auto& y, const auto& a, const auto& st0) { + return stan::math::wiener_lccdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_y_a_st0(t0, w, v, sv, sw), y, a, st0); +} diff --git a/test/unit/math/mix/prob/wiener_full_lccdf_2_test.cpp b/test/unit/math/mix/prob/wiener_full_lccdf_2_test.cpp new file mode 100644 index 00000000000..76aabef0e32 --- /dev/null +++ b/test/unit/math/mix/prob/wiener_full_lccdf_2_test.cpp @@ -0,0 +1,58 @@ +#include +#include +#include + +TEST_F(Wiener7MixArgs, wiener_lccdf_y_t0_w) { + auto f_y_t0_w = [](const auto& a, const auto& v, const auto& sv, + const auto& sw, const auto& st0) { + return + [&a, &v, &sv, &sw, &st0](const auto& y, const auto& t0, const auto& w) { + return stan::math::wiener_lccdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_y_t0_w(a, v, sv, sw, st0), y, t0, w); +} + +TEST_F(Wiener7MixArgs, wiener_lccdf_y_t0_v) { + auto f_y_t0_v = [](const auto& a, const auto& w, const auto& sv, + const auto& sw, const auto& st0) { + return + [&a, &w, &sv, &sw, &st0](const auto& y, const auto& t0, const auto& v) { + return stan::math::wiener_lccdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_y_t0_v(a, w, sv, sw, st0), y, t0, v); +} + +TEST_F(Wiener7MixArgs, wiener_lccdf_y_t0_sv) { + auto f_y_t0_sv = [](const auto& a, const auto& w, const auto& v, + const auto& sw, const auto& st0) { + return + [&a, &w, &v, &sw, &st0](const auto& y, const auto& t0, const auto& sv) { + return stan::math::wiener_lccdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_y_t0_sv(a, w, v, sw, st0), y, t0, sv); +} + +TEST_F(Wiener7MixArgs, wiener_lccdf_y_t0_sw) { + auto f_y_t0_sw = [](const auto& a, const auto& w, const auto& v, + const auto& sv, const auto& st0) { + return + [&a, &w, &v, &sv, &st0](const auto& y, const auto& t0, const auto& sw) { + return stan::math::wiener_lccdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_y_t0_sw(a, w, v, sv, st0), y, t0, sw); +} + +TEST_F(Wiener7MixArgs, wiener_lccdf_y_t0_st0) { + auto f_y_t0_st0 = [](const auto& a, const auto& w, const auto& v, + const auto& sv, const auto& sw) { + return + [&a, &w, &v, &sv, &sw](const auto& y, const auto& t0, const auto& st0) { + return stan::math::wiener_lccdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_y_t0_st0(a, w, v, sv, sw), y, t0, st0); +} diff --git a/test/unit/math/mix/prob/wiener_full_lccdf_3_test.cpp b/test/unit/math/mix/prob/wiener_full_lccdf_3_test.cpp new file mode 100644 index 00000000000..870d294bfc0 --- /dev/null +++ b/test/unit/math/mix/prob/wiener_full_lccdf_3_test.cpp @@ -0,0 +1,58 @@ +#include +#include +#include + +TEST_F(Wiener7MixArgs, wiener_lccdf_y_w_v) { + auto f_y_w_v = [](const auto& a, const auto& t0, const auto& sv, + const auto& sw, const auto& st0) { + return + [&a, &t0, &sv, &sw, &st0](const auto& y, const auto& w, const auto& v) { + return stan::math::wiener_lccdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_y_w_v(a, t0, sv, sw, st0), y, w, v); +} + +TEST_F(Wiener7MixArgs, wiener_lccdf_y_w_sv) { + auto f_y_w_sv = [](const auto& a, const auto& t0, const auto& v, + const auto& sw, const auto& st0) { + return + [&a, &t0, &v, &sw, &st0](const auto& y, const auto& w, const auto& sv) { + return stan::math::wiener_lccdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_y_w_sv(a, t0, v, sw, st0), y, w, sv); +} + +TEST_F(Wiener7MixArgs, wiener_lccdf_y_w_sw) { + auto f_y_w_sw = [](const auto& a, const auto& t0, const auto& v, + const auto& sv, const auto& st0) { + return + [&a, &t0, &v, &sv, &st0](const auto& y, const auto& w, const auto& sw) { + return stan::math::wiener_lccdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_y_w_sw(a, t0, v, sv, st0), y, w, sw); +} + +TEST_F(Wiener7MixArgs, wiener_lccdf_y_w_st0) { + auto f_y_w_st0 = [](const auto& a, const auto& t0, const auto& v, + const auto& sv, const auto& sw) { + return + [&a, &t0, &v, &sv, &sw](const auto& y, const auto& w, const auto& st0) { + return stan::math::wiener_lccdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_y_w_st0(a, t0, v, sv, sw), y, w, st0); +} + +TEST_F(Wiener7MixArgs, wiener_lccdf_y_v_sv) { + auto f_y_v_sv = [](const auto& a, const auto& t0, const auto& w, + const auto& sw, const auto& st0) { + return + [&a, &t0, &w, &sw, &st0](const auto& y, const auto& v, const auto& sv) { + return stan::math::wiener_lccdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_y_v_sv(a, t0, w, sw, st0), y, v, sv); +} diff --git a/test/unit/math/mix/prob/wiener_full_lccdf_4_test.cpp b/test/unit/math/mix/prob/wiener_full_lccdf_4_test.cpp new file mode 100644 index 00000000000..8277f69f45b --- /dev/null +++ b/test/unit/math/mix/prob/wiener_full_lccdf_4_test.cpp @@ -0,0 +1,58 @@ +#include +#include +#include + +TEST_F(Wiener7MixArgs, wiener_lccdf_y_v_sw) { + auto f_y_v_sw = [](const auto& a, const auto& t0, const auto& w, + const auto& sv, const auto& st0) { + return + [&a, &t0, &w, &sv, &st0](const auto& y, const auto& v, const auto& sw) { + return stan::math::wiener_lccdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_y_v_sw(a, t0, w, sv, st0), y, v, sw); +} + +TEST_F(Wiener7MixArgs, wiener_lccdf_y_v_st0) { + auto f_y_v_st0 = [](const auto& a, const auto& t0, const auto& w, + const auto& sv, const auto& sw) { + return + [&a, &t0, &w, &sv, &sw](const auto& y, const auto& v, const auto& st0) { + return stan::math::wiener_lccdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_y_v_st0(a, t0, w, sv, sw), y, v, st0); +} + +TEST_F(Wiener7MixArgs, wiener_lccdf_y_sv_sw) { + auto f_y_sv_sw = [](const auto& a, const auto& t0, const auto& w, + const auto& v, const auto& st0) { + return + [&a, &t0, &w, &v, &st0](const auto& y, const auto& sv, const auto& sw) { + return stan::math::wiener_lccdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_y_sv_sw(a, t0, w, v, st0), y, sv, sw); +} + +TEST_F(Wiener7MixArgs, wiener_lccdf_y_sv_st0) { + auto f_y_sv_st0 = [](const auto& a, const auto& t0, const auto& w, + const auto& v, const auto& sw) { + return + [&a, &t0, &w, &v, &sw](const auto& y, const auto& sv, const auto& st0) { + return stan::math::wiener_lccdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_y_sv_st0(a, t0, w, v, sw), y, sv, st0); +} + +TEST_F(Wiener7MixArgs, wiener_lccdf_y_sw_st0) { + auto f_y_sw_st0 = [](const auto& a, const auto& t0, const auto& w, + const auto& v, const auto& sv) { + return + [&a, &t0, &w, &v, &sv](const auto& y, const auto& sw, const auto& st0) { + return stan::math::wiener_lccdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_y_sw_st0(a, t0, w, v, sv), y, sw, st0); +} diff --git a/test/unit/math/mix/prob/wiener_full_lccdf_5_test.cpp b/test/unit/math/mix/prob/wiener_full_lccdf_5_test.cpp new file mode 100644 index 00000000000..f24cef06a49 --- /dev/null +++ b/test/unit/math/mix/prob/wiener_full_lccdf_5_test.cpp @@ -0,0 +1,58 @@ +#include +#include +#include + +TEST_F(Wiener7MixArgs, wiener_lccdf_a_t0_w) { + auto f_a_t0_w = [](const auto& y, const auto& v, const auto& sv, + const auto& sw, const auto& st0) { + return + [&y, &v, &sv, &sw, &st0](const auto& a, const auto& t0, const auto& w) { + return stan::math::wiener_lccdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_a_t0_w(y, v, sv, sw, st0), a, t0, w); +} + +TEST_F(Wiener7MixArgs, wiener_lccdf_a_t0_v) { + auto f_a_t0_v = [](const auto& y, const auto& w, const auto& sv, + const auto& sw, const auto& st0) { + return + [&y, &w, &sv, &sw, &st0](const auto& a, const auto& t0, const auto& v) { + return stan::math::wiener_lccdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_a_t0_v(y, w, sv, sw, st0), a, t0, v); +} + +TEST_F(Wiener7MixArgs, wiener_lccdf_a_t0_sv) { + auto f_a_t0_sv = [](const auto& y, const auto& w, const auto& v, + const auto& sw, const auto& st0) { + return + [&y, &w, &v, &sw, &st0](const auto& a, const auto& t0, const auto& sv) { + return stan::math::wiener_lccdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_a_t0_sv(y, w, v, sw, st0), a, t0, sv); +} + +TEST_F(Wiener7MixArgs, wiener_lccdf_a_t0_sw) { + auto f_a_t0_sw = [](const auto& y, const auto& w, const auto& v, + const auto& sv, const auto& st0) { + return + [&y, &w, &v, &sv, &st0](const auto& a, const auto& t0, const auto& sw) { + return stan::math::wiener_lccdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_a_t0_sw(y, w, v, sv, st0), a, t0, sw); +} + +TEST_F(Wiener7MixArgs, wiener_lccdf_a_t0_st0) { + auto f_a_t0_st0 = [](const auto& y, const auto& w, const auto& v, + const auto& sv, const auto& sw) { + return + [&y, &w, &v, &sv, &sw](const auto& a, const auto& t0, const auto& st0) { + return stan::math::wiener_lccdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_a_t0_st0(y, w, v, sv, sw), a, t0, st0); +} diff --git a/test/unit/math/mix/prob/wiener_full_lccdf_6_test.cpp b/test/unit/math/mix/prob/wiener_full_lccdf_6_test.cpp new file mode 100644 index 00000000000..f98faacfa6c --- /dev/null +++ b/test/unit/math/mix/prob/wiener_full_lccdf_6_test.cpp @@ -0,0 +1,58 @@ +#include +#include +#include + +TEST_F(Wiener7MixArgs, wiener_lccdf_a_w_v) { + auto f_a_w_v = [](const auto& y, const auto& t0, const auto& sv, + const auto& sw, const auto& st0) { + return + [&y, &t0, &sv, &sw, &st0](const auto& a, const auto& w, const auto& v) { + return stan::math::wiener_lccdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_a_w_v(y, t0, sv, sw, st0), a, w, v); +} + +TEST_F(Wiener7MixArgs, wiener_lccdf_a_w_sv) { + auto f_a_w_sv = [](const auto& y, const auto& t0, const auto& v, + const auto& sw, const auto& st0) { + return + [&y, &t0, &v, &sw, &st0](const auto& a, const auto& w, const auto& sv) { + return stan::math::wiener_lccdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_a_w_sv(y, t0, v, sw, st0), a, w, sv); +} + +TEST_F(Wiener7MixArgs, wiener_lccdf_a_w_sw) { + auto f_a_w_sw = [](const auto& y, const auto& t0, const auto& v, + const auto& sv, const auto& st0) { + return + [&y, &t0, &v, &sv, &st0](const auto& a, const auto& w, const auto& sw) { + return stan::math::wiener_lccdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_a_w_sw(y, t0, v, sv, st0), a, w, sw); +} + +TEST_F(Wiener7MixArgs, wiener_lccdf_a_w_st0) { + auto f_a_w_st0 = [](const auto& y, const auto& t0, const auto& v, + const auto& sv, const auto& sw) { + return + [&y, &t0, &v, &sv, &sw](const auto& a, const auto& w, const auto& st0) { + return stan::math::wiener_lccdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_a_w_st0(y, t0, v, sv, sw), a, w, st0); +} + +TEST_F(Wiener7MixArgs, wiener_lccdf_a_v_sv) { + auto f_a_v_sv = [](const auto& y, const auto& t0, const auto& w, + const auto& sw, const auto& st0) { + return + [&y, &t0, &w, &sw, &st0](const auto& a, const auto& v, const auto& sv) { + return stan::math::wiener_lccdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_a_v_sv(y, t0, w, sw, st0), a, v, sv); +} diff --git a/test/unit/math/mix/prob/wiener_full_lccdf_7_test.cpp b/test/unit/math/mix/prob/wiener_full_lccdf_7_test.cpp new file mode 100644 index 00000000000..f7e38df10b1 --- /dev/null +++ b/test/unit/math/mix/prob/wiener_full_lccdf_7_test.cpp @@ -0,0 +1,58 @@ +#include +#include +#include + +TEST_F(Wiener7MixArgs, wiener_lccdf_a_v_sw) { + auto f_a_v_sw = [](const auto& y, const auto& t0, const auto& w, + const auto& sv, const auto& st0) { + return + [&y, &t0, &w, &sv, &st0](const auto& a, const auto& v, const auto& sw) { + return stan::math::wiener_lccdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_a_v_sw(y, t0, w, sv, st0), a, v, sw); +} + +TEST_F(Wiener7MixArgs, wiener_lccdf_a_v_st0) { + auto f_a_v_st0 = [](const auto& y, const auto& t0, const auto& w, + const auto& sv, const auto& sw) { + return + [&y, &t0, &w, &sv, &sw](const auto& a, const auto& v, const auto& st0) { + return stan::math::wiener_lccdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_a_v_st0(y, t0, w, sv, sw), a, v, st0); +} + +TEST_F(Wiener7MixArgs, wiener_lccdf_a_sv_sw) { + auto f_a_sv_sw = [](const auto& y, const auto& t0, const auto& w, + const auto& v, const auto& st0) { + return + [&y, &t0, &w, &v, &st0](const auto& a, const auto& sv, const auto& sw) { + return stan::math::wiener_lccdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_a_sv_sw(y, t0, w, v, st0), a, sv, sw); +} + +TEST_F(Wiener7MixArgs, wiener_lccdf_a_sv_st0) { + auto f_a_sv_st0 = [](const auto& y, const auto& t0, const auto& w, + const auto& v, const auto& sw) { + return + [&y, &t0, &w, &v, &sw](const auto& a, const auto& sv, const auto& st0) { + return stan::math::wiener_lccdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_a_sv_st0(y, t0, w, v, sw), a, sv, st0); +} + +TEST_F(Wiener7MixArgs, wiener_lccdf_a_sw_st0) { + auto f_a_sw_st0 = [](const auto& y, const auto& t0, const auto& w, + const auto& v, const auto& sv) { + return + [&y, &t0, &w, &v, &sv](const auto& a, const auto& sw, const auto& st0) { + return stan::math::wiener_lccdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_a_sw_st0(y, t0, w, v, sv), a, sw, st0); +} diff --git a/test/unit/math/mix/prob/wiener_full_lccdf_8_test.cpp b/test/unit/math/mix/prob/wiener_full_lccdf_8_test.cpp new file mode 100644 index 00000000000..39128239a62 --- /dev/null +++ b/test/unit/math/mix/prob/wiener_full_lccdf_8_test.cpp @@ -0,0 +1,58 @@ +#include +#include +#include + +TEST_F(Wiener7MixArgs, wiener_lccdf_t0_w_v) { + auto f_t0_w_v = [](const auto& y, const auto& a, const auto& sv, + const auto& sw, const auto& st0) { + return + [&y, &a, &sv, &sw, &st0](const auto& t0, const auto& w, const auto& v) { + return stan::math::wiener_lccdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_t0_w_v(y, a, sv, sw, st0), t0, w, v); +} + +TEST_F(Wiener7MixArgs, wiener_lccdf_t0_w_sv) { + auto f_t0_w_sv = [](const auto& y, const auto& a, const auto& v, + const auto& sw, const auto& st0) { + return + [&y, &a, &v, &sw, &st0](const auto& t0, const auto& w, const auto& sv) { + return stan::math::wiener_lccdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_t0_w_sv(y, a, v, sw, st0), t0, w, sv); +} + +TEST_F(Wiener7MixArgs, wiener_lccdf_t0_w_sw) { + auto f_t0_w_sw = [](const auto& y, const auto& a, const auto& v, + const auto& sv, const auto& st0) { + return + [&y, &a, &v, &sv, &st0](const auto& t0, const auto& w, const auto& sw) { + return stan::math::wiener_lccdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_t0_w_sw(y, a, v, sv, st0), t0, w, sw); +} + +TEST_F(Wiener7MixArgs, wiener_lccdf_t0_w_st0) { + auto f_t0_w_st0 = [](const auto& y, const auto& a, const auto& v, + const auto& sv, const auto& sw) { + return + [&y, &a, &v, &sv, &sw](const auto& t0, const auto& w, const auto& st0) { + return stan::math::wiener_lccdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_t0_w_st0(y, a, v, sv, sw), t0, w, st0); +} + +TEST_F(Wiener7MixArgs, wiener_lccdf_t0_v_sv) { + auto f_t0_v_sv = [](const auto& y, const auto& a, const auto& w, + const auto& sw, const auto& st0) { + return + [&y, &a, &w, &sw, &st0](const auto& t0, const auto& v, const auto& sv) { + return stan::math::wiener_lccdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_t0_v_sv(y, a, w, sw, st0), t0, v, sv); +} diff --git a/test/unit/math/mix/prob/wiener_full_lccdf_9_test.cpp b/test/unit/math/mix/prob/wiener_full_lccdf_9_test.cpp new file mode 100644 index 00000000000..2a8382f3693 --- /dev/null +++ b/test/unit/math/mix/prob/wiener_full_lccdf_9_test.cpp @@ -0,0 +1,58 @@ +#include +#include +#include + +TEST_F(Wiener7MixArgs, wiener_lccdf_t0_v_sw) { + auto f_t0_v_sw = [](const auto& y, const auto& a, const auto& w, + const auto& sv, const auto& st0) { + return + [&y, &a, &w, &sv, &st0](const auto& t0, const auto& v, const auto& sw) { + return stan::math::wiener_lccdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_t0_v_sw(y, a, w, sv, st0), t0, v, sw); +} + +TEST_F(Wiener7MixArgs, wiener_lccdf_t0_v_st0) { + auto f_t0_v_st0 = [](const auto& y, const auto& a, const auto& w, + const auto& sv, const auto& sw) { + return + [&y, &a, &w, &sv, &sw](const auto& t0, const auto& v, const auto& st0) { + return stan::math::wiener_lccdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_t0_v_st0(y, a, w, sv, sw), t0, v, st0); +} + +TEST_F(Wiener7MixArgs, wiener_lccdf_t0_sv_sw) { + auto f_t0_sv_sw = [](const auto& y, const auto& a, const auto& w, + const auto& v, const auto& st0) { + return + [&y, &a, &w, &v, &st0](const auto& t0, const auto& sv, const auto& sw) { + return stan::math::wiener_lccdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_t0_sv_sw(y, a, w, v, st0), t0, sv, sw); +} + +TEST_F(Wiener7MixArgs, wiener_lccdf_t0_sv_st0) { + auto f_t0_sv_st0 = [](const auto& y, const auto& a, const auto& w, + const auto& v, const auto& sw) { + return + [&y, &a, &w, &v, &sw](const auto& t0, const auto& sv, const auto& st0) { + return stan::math::wiener_lccdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_t0_sv_st0(y, a, w, v, sw), t0, sv, st0); +} + +TEST_F(Wiener7MixArgs, wiener_lccdf_t0_sw_st0) { + auto f_t0_sw_st0 = [](const auto& y, const auto& a, const auto& w, + const auto& v, const auto& sv) { + return + [&y, &a, &w, &v, &sv](const auto& t0, const auto& sw, const auto& st0) { + return stan::math::wiener_lccdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_t0_sw_st0(y, a, w, v, sv), t0, sw, st0); +} diff --git a/test/unit/math/mix/prob/wiener_full_lcdf_0_test.cpp b/test/unit/math/mix/prob/wiener_full_lcdf_0_test.cpp new file mode 100644 index 00000000000..0dd7b4306f2 --- /dev/null +++ b/test/unit/math/mix/prob/wiener_full_lcdf_0_test.cpp @@ -0,0 +1,53 @@ +#include +#include +#include + +TEST(mathMixDouble, wiener_lcdf) { + double y = 1.0; + double a = 2.0; + double t0 = 0.2; + double w = 0.5; + double v = 1.5; + double sv = 0.2; + double sw = 0.2; + double st0 = 0.2; + stan::math::wiener_lcdf(y, a, t0, w, v, sv, sw, st0, 1e-4); +} + +TEST(mathMixVar, wiener_lcdf) { + using stan::math::var; + var y = 1.0; + var a = 2.0; + var t0 = 0.2; + var w = 0.5; + var v = 1.5; + var sv = 0.2; + var sw = 0; + var st0 = 0.2; + stan::math::wiener_lcdf(y, a, t0, w, v, sv, sw, st0); +} + +TEST(mathMixFVar, wiener_lcdf) { + using stan::math::fvar; + using stan::math::var; + fvar y = 1.0; + fvar a = 2.0; + fvar t0 = 0.2; + fvar w = 0.5; + fvar v = 1.5; + fvar sv = 0.2; + fvar sw = 0; + fvar st0 = 0.2; + stan::math::wiener_lcdf(y, a, t0, w, v, sv, sw, st0); +} + +TEST_F(Wiener7MixArgs, wiener_lcdf_y_a_t0) { + auto f_y_a_t0 = [](const auto& w, const auto& v, const auto& sv, + const auto& sw, const auto& st0) { + return + [&w, &v, &sv, &sw, &st0](const auto& y, const auto& a, const auto& t0) { + return stan::math::wiener_lcdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_y_a_t0(w, v, sv, sw, st0), y, a, t0); +} diff --git a/test/unit/math/mix/prob/wiener_full_lcdf_10_test.cpp b/test/unit/math/mix/prob/wiener_full_lcdf_10_test.cpp new file mode 100644 index 00000000000..5aa2c43df18 --- /dev/null +++ b/test/unit/math/mix/prob/wiener_full_lcdf_10_test.cpp @@ -0,0 +1,58 @@ +#include +#include +#include + +TEST_F(Wiener7MixArgs, wiener_lcdf_w_v_sv) { + auto f_w_v_sv = [](const auto& y, const auto& a, const auto& t0, + const auto& sw, const auto& st0) { + return + [&y, &a, &t0, &sw, &st0](const auto& w, const auto& v, const auto& sv) { + return stan::math::wiener_lcdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_w_v_sv(y, a, t0, sw, st0), w, v, sv); +} + +TEST_F(Wiener7MixArgs, wiener_lcdf_w_v_sw) { + auto f_w_v_sw = [](const auto& y, const auto& a, const auto& t0, + const auto& sv, const auto& st0) { + return + [&y, &a, &t0, &sv, &st0](const auto& w, const auto& v, const auto& sw) { + return stan::math::wiener_lcdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_w_v_sw(y, a, t0, sv, st0), w, v, sw); +} + +TEST_F(Wiener7MixArgs, wiener_lcdf_w_v_st0) { + auto f_w_v_st0 = [](const auto& y, const auto& a, const auto& t0, + const auto& sv, const auto& sw) { + return + [&y, &a, &t0, &sv, &sw](const auto& w, const auto& v, const auto& st0) { + return stan::math::wiener_lcdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_w_v_st0(y, a, t0, sv, sw), w, v, st0); +} + +TEST_F(Wiener7MixArgs, wiener_lcdf_w_sv_sw) { + auto f_w_sv_sw = [](const auto& y, const auto& a, const auto& t0, + const auto& v, const auto& st0) { + return + [&y, &a, &t0, &v, &st0](const auto& w, const auto& sv, const auto& sw) { + return stan::math::wiener_lcdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_w_sv_sw(y, a, t0, v, st0), w, sv, sw); +} + +TEST_F(Wiener7MixArgs, wiener_lcdf_w_sv_st0) { + auto f_w_sv_st0 = [](const auto& y, const auto& a, const auto& t0, + const auto& v, const auto& sw) { + return + [&y, &a, &t0, &v, &sw](const auto& w, const auto& sv, const auto& st0) { + return stan::math::wiener_lcdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_w_sv_st0(y, a, t0, v, sw), w, sv, st0); +} diff --git a/test/unit/math/mix/prob/wiener_full_lcdf_11_test.cpp b/test/unit/math/mix/prob/wiener_full_lcdf_11_test.cpp new file mode 100644 index 00000000000..765f21df6dd --- /dev/null +++ b/test/unit/math/mix/prob/wiener_full_lcdf_11_test.cpp @@ -0,0 +1,58 @@ +#include +#include +#include + +TEST_F(Wiener7MixArgs, wiener_lcdf_w_sw_st0) { + auto f_w_sw_st0 = [](const auto& y, const auto& a, const auto& t0, + const auto& v, const auto& sv) { + return + [&y, &a, &t0, &v, &sv](const auto& w, const auto& sw, const auto& st0) { + return stan::math::wiener_lcdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_w_sw_st0(y, a, t0, v, sv), w, sw, st0); +} + +TEST_F(Wiener7MixArgs, wiener_lcdf_v_sv_sw) { + auto f_v_sv_sw = [](const auto& y, const auto& a, const auto& t0, + const auto& w, const auto& st0) { + return + [&y, &a, &t0, &w, &st0](const auto& v, const auto& sv, const auto& sw) { + return stan::math::wiener_lcdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_v_sv_sw(y, a, t0, w, st0), v, sv, sw); +} + +TEST_F(Wiener7MixArgs, wiener_lcdf_v_sv_st0) { + auto f_v_sv_st0 = [](const auto& y, const auto& a, const auto& t0, + const auto& w, const auto& sw) { + return + [&y, &a, &t0, &w, &sw](const auto& v, const auto& sv, const auto& st0) { + return stan::math::wiener_lcdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_v_sv_st0(y, a, t0, w, sw), v, sv, st0); +} + +TEST_F(Wiener7MixArgs, wiener_lcdf_v_sw_st0) { + auto f_v_sw_st0 = [](const auto& y, const auto& a, const auto& t0, + const auto& w, const auto& sv) { + return + [&y, &a, &t0, &w, &sv](const auto& v, const auto& sw, const auto& st0) { + return stan::math::wiener_lcdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_v_sw_st0(y, a, t0, w, sv), v, sw, st0); +} + +TEST_F(Wiener7MixArgs, wiener_lcdf_sv_sw_st0) { + auto f_sv_sw_st0 = [](const auto& y, const auto& a, const auto& t0, + const auto& w, const auto& v) { + return + [&y, &a, &t0, &w, &v](const auto& sv, const auto& sw, const auto& st0) { + return stan::math::wiener_lcdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_sv_sw_st0(y, a, t0, w, v), sv, sw, st0); +} diff --git a/test/unit/math/mix/prob/wiener_full_lcdf_1_test.cpp b/test/unit/math/mix/prob/wiener_full_lcdf_1_test.cpp new file mode 100644 index 00000000000..27e7c7b7cf3 --- /dev/null +++ b/test/unit/math/mix/prob/wiener_full_lcdf_1_test.cpp @@ -0,0 +1,58 @@ +#include +#include +#include + +TEST_F(Wiener7MixArgs, wiener_lcdf_y_a_w) { + auto f_y_a_w = [](const auto& t0, const auto& v, const auto& sv, + const auto& sw, const auto& st0) { + return + [&t0, &v, &sv, &sw, &st0](const auto& y, const auto& a, const auto& w) { + return stan::math::wiener_lcdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_y_a_w(t0, v, sv, sw, st0), y, a, w); +} + +TEST_F(Wiener7MixArgs, wiener_lcdf_y_a_v) { + auto f_y_a_v = [](const auto& t0, const auto& w, const auto& sv, + const auto& sw, const auto& st0) { + return + [&t0, &w, &sv, &sw, &st0](const auto& y, const auto& a, const auto& v) { + return stan::math::wiener_lcdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_y_a_v(t0, w, sv, sw, st0), y, a, v); +} + +TEST_F(Wiener7MixArgs, wiener_lcdf_y_a_sv) { + auto f_y_a_sv = [](const auto& t0, const auto& w, const auto& v, + const auto& sw, const auto& st0) { + return + [&t0, &w, &v, &sw, &st0](const auto& y, const auto& a, const auto& sv) { + return stan::math::wiener_lcdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_y_a_sv(t0, w, v, sw, st0), y, a, sv); +} + +TEST_F(Wiener7MixArgs, wiener_lcdf_y_a_sw) { + auto f_y_a_sw = [](const auto& t0, const auto& w, const auto& v, + const auto& sv, const auto& st0) { + return + [&t0, &w, &v, &sv, &st0](const auto& y, const auto& a, const auto& sw) { + return stan::math::wiener_lcdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_y_a_sw(t0, w, v, sv, st0), y, a, sw); +} + +TEST_F(Wiener7MixArgs, wiener_lcdf_y_a_st0) { + auto f_y_a_st0 = [](const auto& t0, const auto& w, const auto& v, + const auto& sv, const auto& sw) { + return + [&t0, &w, &v, &sv, &sw](const auto& y, const auto& a, const auto& st0) { + return stan::math::wiener_lcdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_y_a_st0(t0, w, v, sv, sw), y, a, st0); +} diff --git a/test/unit/math/mix/prob/wiener_full_lcdf_2_test.cpp b/test/unit/math/mix/prob/wiener_full_lcdf_2_test.cpp new file mode 100644 index 00000000000..a628fa7da98 --- /dev/null +++ b/test/unit/math/mix/prob/wiener_full_lcdf_2_test.cpp @@ -0,0 +1,58 @@ +#include +#include +#include + +TEST_F(Wiener7MixArgs, wiener_lcdf_y_t0_w) { + auto f_y_t0_w = [](const auto& a, const auto& v, const auto& sv, + const auto& sw, const auto& st0) { + return + [&a, &v, &sv, &sw, &st0](const auto& y, const auto& t0, const auto& w) { + return stan::math::wiener_lcdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_y_t0_w(a, v, sv, sw, st0), y, t0, w); +} + +TEST_F(Wiener7MixArgs, wiener_lcdf_y_t0_v) { + auto f_y_t0_v = [](const auto& a, const auto& w, const auto& sv, + const auto& sw, const auto& st0) { + return + [&a, &w, &sv, &sw, &st0](const auto& y, const auto& t0, const auto& v) { + return stan::math::wiener_lcdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_y_t0_v(a, w, sv, sw, st0), y, t0, v); +} + +TEST_F(Wiener7MixArgs, wiener_lcdf_y_t0_sv) { + auto f_y_t0_sv = [](const auto& a, const auto& w, const auto& v, + const auto& sw, const auto& st0) { + return + [&a, &w, &v, &sw, &st0](const auto& y, const auto& t0, const auto& sv) { + return stan::math::wiener_lcdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_y_t0_sv(a, w, v, sw, st0), y, t0, sv); +} + +TEST_F(Wiener7MixArgs, wiener_lcdf_y_t0_sw) { + auto f_y_t0_sw = [](const auto& a, const auto& w, const auto& v, + const auto& sv, const auto& st0) { + return + [&a, &w, &v, &sv, &st0](const auto& y, const auto& t0, const auto& sw) { + return stan::math::wiener_lcdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_y_t0_sw(a, w, v, sv, st0), y, t0, sw); +} + +TEST_F(Wiener7MixArgs, wiener_lcdf_y_t0_st0) { + auto f_y_t0_st0 = [](const auto& a, const auto& w, const auto& v, + const auto& sv, const auto& sw) { + return + [&a, &w, &v, &sv, &sw](const auto& y, const auto& t0, const auto& st0) { + return stan::math::wiener_lcdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_y_t0_st0(a, w, v, sv, sw), y, t0, st0); +} diff --git a/test/unit/math/mix/prob/wiener_full_lcdf_3_test.cpp b/test/unit/math/mix/prob/wiener_full_lcdf_3_test.cpp new file mode 100644 index 00000000000..936ea3be317 --- /dev/null +++ b/test/unit/math/mix/prob/wiener_full_lcdf_3_test.cpp @@ -0,0 +1,58 @@ +#include +#include +#include + +TEST_F(Wiener7MixArgs, wiener_lcdf_y_w_v) { + auto f_y_w_v = [](const auto& a, const auto& t0, const auto& sv, + const auto& sw, const auto& st0) { + return + [&a, &t0, &sv, &sw, &st0](const auto& y, const auto& w, const auto& v) { + return stan::math::wiener_lcdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_y_w_v(a, t0, sv, sw, st0), y, w, v); +} + +TEST_F(Wiener7MixArgs, wiener_lcdf_y_w_sv) { + auto f_y_w_sv = [](const auto& a, const auto& t0, const auto& v, + const auto& sw, const auto& st0) { + return + [&a, &t0, &v, &sw, &st0](const auto& y, const auto& w, const auto& sv) { + return stan::math::wiener_lcdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_y_w_sv(a, t0, v, sw, st0), y, w, sv); +} + +TEST_F(Wiener7MixArgs, wiener_lcdf_y_w_sw) { + auto f_y_w_sw = [](const auto& a, const auto& t0, const auto& v, + const auto& sv, const auto& st0) { + return + [&a, &t0, &v, &sv, &st0](const auto& y, const auto& w, const auto& sw) { + return stan::math::wiener_lcdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_y_w_sw(a, t0, v, sv, st0), y, w, sw); +} + +TEST_F(Wiener7MixArgs, wiener_lcdf_y_w_st0) { + auto f_y_w_st0 = [](const auto& a, const auto& t0, const auto& v, + const auto& sv, const auto& sw) { + return + [&a, &t0, &v, &sv, &sw](const auto& y, const auto& w, const auto& st0) { + return stan::math::wiener_lcdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_y_w_st0(a, t0, v, sv, sw), y, w, st0); +} + +TEST_F(Wiener7MixArgs, wiener_lcdf_y_v_sv) { + auto f_y_v_sv = [](const auto& a, const auto& t0, const auto& w, + const auto& sw, const auto& st0) { + return + [&a, &t0, &w, &sw, &st0](const auto& y, const auto& v, const auto& sv) { + return stan::math::wiener_lcdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_y_v_sv(a, t0, w, sw, st0), y, v, sv); +} diff --git a/test/unit/math/mix/prob/wiener_full_lcdf_4_test.cpp b/test/unit/math/mix/prob/wiener_full_lcdf_4_test.cpp new file mode 100644 index 00000000000..b7e0699eb47 --- /dev/null +++ b/test/unit/math/mix/prob/wiener_full_lcdf_4_test.cpp @@ -0,0 +1,58 @@ +#include +#include +#include + +TEST_F(Wiener7MixArgs, wiener_lcdf_y_v_sw) { + auto f_y_v_sw = [](const auto& a, const auto& t0, const auto& w, + const auto& sv, const auto& st0) { + return + [&a, &t0, &w, &sv, &st0](const auto& y, const auto& v, const auto& sw) { + return stan::math::wiener_lcdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_y_v_sw(a, t0, w, sv, st0), y, v, sw); +} + +TEST_F(Wiener7MixArgs, wiener_lcdf_y_v_st0) { + auto f_y_v_st0 = [](const auto& a, const auto& t0, const auto& w, + const auto& sv, const auto& sw) { + return + [&a, &t0, &w, &sv, &sw](const auto& y, const auto& v, const auto& st0) { + return stan::math::wiener_lcdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_y_v_st0(a, t0, w, sv, sw), y, v, st0); +} + +TEST_F(Wiener7MixArgs, wiener_lcdf_y_sv_sw) { + auto f_y_sv_sw = [](const auto& a, const auto& t0, const auto& w, + const auto& v, const auto& st0) { + return + [&a, &t0, &w, &v, &st0](const auto& y, const auto& sv, const auto& sw) { + return stan::math::wiener_lcdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_y_sv_sw(a, t0, w, v, st0), y, sv, sw); +} + +TEST_F(Wiener7MixArgs, wiener_lcdf_y_sv_st0) { + auto f_y_sv_st0 = [](const auto& a, const auto& t0, const auto& w, + const auto& v, const auto& sw) { + return + [&a, &t0, &w, &v, &sw](const auto& y, const auto& sv, const auto& st0) { + return stan::math::wiener_lcdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_y_sv_st0(a, t0, w, v, sw), y, sv, st0); +} + +TEST_F(Wiener7MixArgs, wiener_lcdf_y_sw_st0) { + auto f_y_sw_st0 = [](const auto& a, const auto& t0, const auto& w, + const auto& v, const auto& sv) { + return + [&a, &t0, &w, &v, &sv](const auto& y, const auto& sw, const auto& st0) { + return stan::math::wiener_lcdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_y_sw_st0(a, t0, w, v, sv), y, sw, st0); +} diff --git a/test/unit/math/mix/prob/wiener_full_lcdf_5_test.cpp b/test/unit/math/mix/prob/wiener_full_lcdf_5_test.cpp new file mode 100644 index 00000000000..10adf45a2bc --- /dev/null +++ b/test/unit/math/mix/prob/wiener_full_lcdf_5_test.cpp @@ -0,0 +1,58 @@ +#include +#include +#include + +TEST_F(Wiener7MixArgs, wiener_lcdf_a_t0_w) { + auto f_a_t0_w = [](const auto& y, const auto& v, const auto& sv, + const auto& sw, const auto& st0) { + return + [&y, &v, &sv, &sw, &st0](const auto& a, const auto& t0, const auto& w) { + return stan::math::wiener_lcdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_a_t0_w(y, v, sv, sw, st0), a, t0, w); +} + +TEST_F(Wiener7MixArgs, wiener_lcdf_a_t0_v) { + auto f_a_t0_v = [](const auto& y, const auto& w, const auto& sv, + const auto& sw, const auto& st0) { + return + [&y, &w, &sv, &sw, &st0](const auto& a, const auto& t0, const auto& v) { + return stan::math::wiener_lcdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_a_t0_v(y, w, sv, sw, st0), a, t0, v); +} + +TEST_F(Wiener7MixArgs, wiener_lcdf_a_t0_sv) { + auto f_a_t0_sv = [](const auto& y, const auto& w, const auto& v, + const auto& sw, const auto& st0) { + return + [&y, &w, &v, &sw, &st0](const auto& a, const auto& t0, const auto& sv) { + return stan::math::wiener_lcdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_a_t0_sv(y, w, v, sw, st0), a, t0, sv); +} + +TEST_F(Wiener7MixArgs, wiener_lcdf_a_t0_sw) { + auto f_a_t0_sw = [](const auto& y, const auto& w, const auto& v, + const auto& sv, const auto& st0) { + return + [&y, &w, &v, &sv, &st0](const auto& a, const auto& t0, const auto& sw) { + return stan::math::wiener_lcdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_a_t0_sw(y, w, v, sv, st0), a, t0, sw); +} + +TEST_F(Wiener7MixArgs, wiener_lcdf_a_t0_st0) { + auto f_a_t0_st0 = [](const auto& y, const auto& w, const auto& v, + const auto& sv, const auto& sw) { + return + [&y, &w, &v, &sv, &sw](const auto& a, const auto& t0, const auto& st0) { + return stan::math::wiener_lcdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_a_t0_st0(y, w, v, sv, sw), a, t0, st0); +} diff --git a/test/unit/math/mix/prob/wiener_full_lcdf_6_test.cpp b/test/unit/math/mix/prob/wiener_full_lcdf_6_test.cpp new file mode 100644 index 00000000000..c9f8833d902 --- /dev/null +++ b/test/unit/math/mix/prob/wiener_full_lcdf_6_test.cpp @@ -0,0 +1,58 @@ +#include +#include +#include + +TEST_F(Wiener7MixArgs, wiener_lcdf_a_w_v) { + auto f_a_w_v = [](const auto& y, const auto& t0, const auto& sv, + const auto& sw, const auto& st0) { + return + [&y, &t0, &sv, &sw, &st0](const auto& a, const auto& w, const auto& v) { + return stan::math::wiener_lcdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_a_w_v(y, t0, sv, sw, st0), a, w, v); +} + +TEST_F(Wiener7MixArgs, wiener_lcdf_a_w_sv) { + auto f_a_w_sv = [](const auto& y, const auto& t0, const auto& v, + const auto& sw, const auto& st0) { + return + [&y, &t0, &v, &sw, &st0](const auto& a, const auto& w, const auto& sv) { + return stan::math::wiener_lcdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_a_w_sv(y, t0, v, sw, st0), a, w, sv); +} + +TEST_F(Wiener7MixArgs, wiener_lcdf_a_w_sw) { + auto f_a_w_sw = [](const auto& y, const auto& t0, const auto& v, + const auto& sv, const auto& st0) { + return + [&y, &t0, &v, &sv, &st0](const auto& a, const auto& w, const auto& sw) { + return stan::math::wiener_lcdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_a_w_sw(y, t0, v, sv, st0), a, w, sw); +} + +TEST_F(Wiener7MixArgs, wiener_lcdf_a_w_st0) { + auto f_a_w_st0 = [](const auto& y, const auto& t0, const auto& v, + const auto& sv, const auto& sw) { + return + [&y, &t0, &v, &sv, &sw](const auto& a, const auto& w, const auto& st0) { + return stan::math::wiener_lcdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_a_w_st0(y, t0, v, sv, sw), a, w, st0); +} + +TEST_F(Wiener7MixArgs, wiener_lcdf_a_v_sv) { + auto f_a_v_sv = [](const auto& y, const auto& t0, const auto& w, + const auto& sw, const auto& st0) { + return + [&y, &t0, &w, &sw, &st0](const auto& a, const auto& v, const auto& sv) { + return stan::math::wiener_lcdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_a_v_sv(y, t0, w, sw, st0), a, v, sv); +} diff --git a/test/unit/math/mix/prob/wiener_full_lcdf_7_test.cpp b/test/unit/math/mix/prob/wiener_full_lcdf_7_test.cpp new file mode 100644 index 00000000000..fe6d6061037 --- /dev/null +++ b/test/unit/math/mix/prob/wiener_full_lcdf_7_test.cpp @@ -0,0 +1,58 @@ +#include +#include +#include + +TEST_F(Wiener7MixArgs, wiener_lcdf_a_v_sw) { + auto f_a_v_sw = [](const auto& y, const auto& t0, const auto& w, + const auto& sv, const auto& st0) { + return + [&y, &t0, &w, &sv, &st0](const auto& a, const auto& v, const auto& sw) { + return stan::math::wiener_lcdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_a_v_sw(y, t0, w, sv, st0), a, v, sw); +} + +TEST_F(Wiener7MixArgs, wiener_lcdf_a_v_st0) { + auto f_a_v_st0 = [](const auto& y, const auto& t0, const auto& w, + const auto& sv, const auto& sw) { + return + [&y, &t0, &w, &sv, &sw](const auto& a, const auto& v, const auto& st0) { + return stan::math::wiener_lcdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_a_v_st0(y, t0, w, sv, sw), a, v, st0); +} + +TEST_F(Wiener7MixArgs, wiener_lcdf_a_sv_sw) { + auto f_a_sv_sw = [](const auto& y, const auto& t0, const auto& w, + const auto& v, const auto& st0) { + return + [&y, &t0, &w, &v, &st0](const auto& a, const auto& sv, const auto& sw) { + return stan::math::wiener_lcdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_a_sv_sw(y, t0, w, v, st0), a, sv, sw); +} + +TEST_F(Wiener7MixArgs, wiener_lcdf_a_sv_st0) { + auto f_a_sv_st0 = [](const auto& y, const auto& t0, const auto& w, + const auto& v, const auto& sw) { + return + [&y, &t0, &w, &v, &sw](const auto& a, const auto& sv, const auto& st0) { + return stan::math::wiener_lcdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_a_sv_st0(y, t0, w, v, sw), a, sv, st0); +} + +TEST_F(Wiener7MixArgs, wiener_lcdf_a_sw_st0) { + auto f_a_sw_st0 = [](const auto& y, const auto& t0, const auto& w, + const auto& v, const auto& sv) { + return + [&y, &t0, &w, &v, &sv](const auto& a, const auto& sw, const auto& st0) { + return stan::math::wiener_lcdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_a_sw_st0(y, t0, w, v, sv), a, sw, st0); +} diff --git a/test/unit/math/mix/prob/wiener_full_lcdf_8_test.cpp b/test/unit/math/mix/prob/wiener_full_lcdf_8_test.cpp new file mode 100644 index 00000000000..54350c2dc46 --- /dev/null +++ b/test/unit/math/mix/prob/wiener_full_lcdf_8_test.cpp @@ -0,0 +1,58 @@ +#include +#include +#include + +TEST_F(Wiener7MixArgs, wiener_lcdf_t0_w_v) { + auto f_t0_w_v = [](const auto& y, const auto& a, const auto& sv, + const auto& sw, const auto& st0) { + return + [&y, &a, &sv, &sw, &st0](const auto& t0, const auto& w, const auto& v) { + return stan::math::wiener_lcdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_t0_w_v(y, a, sv, sw, st0), t0, w, v); +} + +TEST_F(Wiener7MixArgs, wiener_lcdf_t0_w_sv) { + auto f_t0_w_sv = [](const auto& y, const auto& a, const auto& v, + const auto& sw, const auto& st0) { + return + [&y, &a, &v, &sw, &st0](const auto& t0, const auto& w, const auto& sv) { + return stan::math::wiener_lcdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_t0_w_sv(y, a, v, sw, st0), t0, w, sv); +} + +TEST_F(Wiener7MixArgs, wiener_lcdf_t0_w_sw) { + auto f_t0_w_sw = [](const auto& y, const auto& a, const auto& v, + const auto& sv, const auto& st0) { + return + [&y, &a, &v, &sv, &st0](const auto& t0, const auto& w, const auto& sw) { + return stan::math::wiener_lcdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_t0_w_sw(y, a, v, sv, st0), t0, w, sw); +} + +TEST_F(Wiener7MixArgs, wiener_lcdf_t0_w_st0) { + auto f_t0_w_st0 = [](const auto& y, const auto& a, const auto& v, + const auto& sv, const auto& sw) { + return + [&y, &a, &v, &sv, &sw](const auto& t0, const auto& w, const auto& st0) { + return stan::math::wiener_lcdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_t0_w_st0(y, a, v, sv, sw), t0, w, st0); +} + +TEST_F(Wiener7MixArgs, wiener_lcdf_t0_v_sv) { + auto f_t0_v_sv = [](const auto& y, const auto& a, const auto& w, + const auto& sw, const auto& st0) { + return + [&y, &a, &w, &sw, &st0](const auto& t0, const auto& v, const auto& sv) { + return stan::math::wiener_lcdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_t0_v_sv(y, a, w, sw, st0), t0, v, sv); +} diff --git a/test/unit/math/mix/prob/wiener_full_lcdf_9_test.cpp b/test/unit/math/mix/prob/wiener_full_lcdf_9_test.cpp new file mode 100644 index 00000000000..566b5ff4c83 --- /dev/null +++ b/test/unit/math/mix/prob/wiener_full_lcdf_9_test.cpp @@ -0,0 +1,58 @@ +#include +#include +#include + +TEST_F(Wiener7MixArgs, wiener_lcdf_t0_v_sw) { + auto f_t0_v_sw = [](const auto& y, const auto& a, const auto& w, + const auto& sv, const auto& st0) { + return + [&y, &a, &w, &sv, &st0](const auto& t0, const auto& v, const auto& sw) { + return stan::math::wiener_lcdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_t0_v_sw(y, a, w, sv, st0), t0, v, sw); +} + +TEST_F(Wiener7MixArgs, wiener_lcdf_t0_v_st0) { + auto f_t0_v_st0 = [](const auto& y, const auto& a, const auto& w, + const auto& sv, const auto& sw) { + return + [&y, &a, &w, &sv, &sw](const auto& t0, const auto& v, const auto& st0) { + return stan::math::wiener_lcdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_t0_v_st0(y, a, w, sv, sw), t0, v, st0); +} + +TEST_F(Wiener7MixArgs, wiener_lcdf_t0_sv_sw) { + auto f_t0_sv_sw = [](const auto& y, const auto& a, const auto& w, + const auto& v, const auto& st0) { + return + [&y, &a, &w, &v, &st0](const auto& t0, const auto& sv, const auto& sw) { + return stan::math::wiener_lcdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_t0_sv_sw(y, a, w, v, st0), t0, sv, sw); +} + +TEST_F(Wiener7MixArgs, wiener_lcdf_t0_sv_st0) { + auto f_t0_sv_st0 = [](const auto& y, const auto& a, const auto& w, + const auto& v, const auto& sw) { + return + [&y, &a, &w, &v, &sw](const auto& t0, const auto& sv, const auto& st0) { + return stan::math::wiener_lcdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_t0_sv_st0(y, a, w, v, sw), t0, sv, st0); +} + +TEST_F(Wiener7MixArgs, wiener_lcdf_t0_sw_st0) { + auto f_t0_sw_st0 = [](const auto& y, const auto& a, const auto& w, + const auto& v, const auto& sv) { + return + [&y, &a, &w, &v, &sv](const auto& t0, const auto& sw, const auto& st0) { + return stan::math::wiener_lcdf(y, a, t0, w, v, sv, sw, st0); + }; + }; + stan::test::expect_ad(f_t0_sw_st0(y, a, w, v, sv), t0, sw, st0); +} diff --git a/test/unit/math/opencl/cholesky_decompose_test.cpp b/test/unit/math/opencl/cholesky_decompose_test.cpp index c056bc91b61..8ed13db61ac 100644 --- a/test/unit/math/opencl/cholesky_decompose_test.cpp +++ b/test/unit/math/opencl/cholesky_decompose_test.cpp @@ -30,7 +30,7 @@ TEST(MathMatrixOpenCL, cholesky_decompose_cpu_vs_cl_small) { } namespace { -inline void cholesky_decompose_test(int size) { +void cholesky_decompose_test(int size) { stan::math::matrix_d m1 = stan::math::matrix_d::Random(size, size); stan::math::matrix_d m1_pos_def = m1 * m1.transpose() + size * Eigen::MatrixXd::Identity(size, size); diff --git a/test/unit/math/opencl/kernel_generator/elt_function_cl_test.cpp b/test/unit/math/opencl/kernel_generator/elt_function_cl_test.cpp index b97b945172f..10562ffb173 100644 --- a/test/unit/math/opencl/kernel_generator/elt_function_cl_test.cpp +++ b/test/unit/math/opencl/kernel_generator/elt_function_cl_test.cpp @@ -19,7 +19,7 @@ using stan::math::matrix_cl; namespace stan { namespace math { -inline MatrixXd rsqrt(const MatrixXd& a) { return stan::math::inv_sqrt(a); } +MatrixXd rsqrt(const MatrixXd& a) { return stan::math::inv_sqrt(a); } } // namespace math } // namespace stan diff --git a/test/unit/math/opencl/kernel_generator/reference_kernel.hpp b/test/unit/math/opencl/kernel_generator/reference_kernel.hpp index 54b5fc6c2f7..f50a82a3b16 100644 --- a/test/unit/math/opencl/kernel_generator/reference_kernel.hpp +++ b/test/unit/math/opencl/kernel_generator/reference_kernel.hpp @@ -14,7 +14,7 @@ namespace test { * @param filename Name of the file * @return file content */ -inline std::string load_reference_kernel(const std::string& filename) { +std::string load_reference_kernel(const std::string& filename) { std::string path = "test/unit/math/opencl/kernel_generator/reference_kernels/" + filename; std::ifstream input(path); @@ -31,8 +31,8 @@ inline std::string load_reference_kernel(const std::string& filename) { * @param kernel content to write in the file * @throw ios_base::failure File could not be opened or written. */ -inline void store_reference_kernel_if_needed(const std::string& filename, - const std::string& kernel) { +void store_reference_kernel_if_needed(const std::string& filename, + const std::string& kernel) { #ifdef STAN_TEST_KERNEL_GENERATOR_STORE_REFERENCE_KERNELS std::string path = "test/unit/math/opencl/kernel_generator/reference_kernels/" + filename; diff --git a/test/unit/math/opencl/prim/crossprod_test.cpp b/test/unit/math/opencl/prim/crossprod_test.cpp index 4172bb70c32..32965619e81 100644 --- a/test/unit/math/opencl/prim/crossprod_test.cpp +++ b/test/unit/math/opencl/prim/crossprod_test.cpp @@ -3,7 +3,7 @@ #include #include -inline void test_crossprod(const stan::math::matrix_d& x) { +void test_crossprod(const stan::math::matrix_d& x) { using stan::math::crossprod; stan::math::matrix_cl x_cl(x); stan::math::matrix_d y_cl = from_matrix_cl(crossprod(x_cl)); diff --git a/test/unit/math/opencl/prim/mdivide_left_tri_low_test.cpp b/test/unit/math/opencl/prim/mdivide_left_tri_low_test.cpp index c0151631ed1..89e66e4f1c0 100644 --- a/test/unit/math/opencl/prim/mdivide_left_tri_low_test.cpp +++ b/test/unit/math/opencl/prim/mdivide_left_tri_low_test.cpp @@ -28,7 +28,7 @@ TEST(MathMatrixCL, mdivide_left_tri_low_cl_exception) { EXPECT_THROW(stan::math::mdivide_left_tri_low(m5, m5), std::invalid_argument); } -inline void mdivide_left_tri_low_Ab_test(int size) { +void mdivide_left_tri_low_Ab_test(int size) { boost::random::mt19937 rng; auto m1 = stan::math::matrix_d(size, size); for (int i = 0; i < size; i++) { @@ -56,7 +56,7 @@ inline void mdivide_left_tri_low_Ab_test(int size) { } } -inline void mdivide_left_tri_low_A_test(int size) { +void mdivide_left_tri_low_A_test(int size) { boost::random::mt19937 rng; auto m1 = stan::math::matrix_d(size, size); for (int i = 0; i < size; i++) { diff --git a/test/unit/math/opencl/prim/mdivide_right_tri_low_test.cpp b/test/unit/math/opencl/prim/mdivide_right_tri_low_test.cpp index a339cfbb107..9c4cc3ceb91 100644 --- a/test/unit/math/opencl/prim/mdivide_right_tri_low_test.cpp +++ b/test/unit/math/opencl/prim/mdivide_right_tri_low_test.cpp @@ -28,7 +28,7 @@ TEST(MathMatrixCL, mdivide_right_tri_low_cl_exception) { std::invalid_argument); } -inline void mdivide_right_tri_low_Ab_test(int size) { +void mdivide_right_tri_low_Ab_test(int size) { boost::random::mt19937 rng; auto m1 = stan::math::matrix_d(size, size); for (int i = 0; i < size; i++) { diff --git a/test/unit/math/opencl/prim/tcrossprod_test.cpp b/test/unit/math/opencl/prim/tcrossprod_test.cpp index 31eaad2962a..5059db1580e 100644 --- a/test/unit/math/opencl/prim/tcrossprod_test.cpp +++ b/test/unit/math/opencl/prim/tcrossprod_test.cpp @@ -3,7 +3,7 @@ #include #include -inline void test_tcrossprod(const stan::math::matrix_d& x) { +void test_tcrossprod(const stan::math::matrix_d& x) { using stan::math::tcrossprod; stan::math::matrix_cl x_cl(x); stan::math::matrix_d y_cl = from_matrix_cl(tcrossprod(x_cl)); diff --git a/test/unit/math/opencl/rev/constraint/lb_constrain_test.cpp b/test/unit/math/opencl/rev/constraint/lb_constrain_test.cpp index 2d5763e28ec..29cff620c89 100644 --- a/test/unit/math/opencl/rev/constraint/lb_constrain_test.cpp +++ b/test/unit/math/opencl/rev/constraint/lb_constrain_test.cpp @@ -10,7 +10,7 @@ auto lb_constrain_functor = [](const auto& a, const auto& b) { auto lb_constrain_functor2 = [](const auto& a, const auto& b) { using T_lp = stan::return_type_t; T_lp lp(4); - if constexpr (!stan::is_constant::value) { + if (!stan::is_constant::value) { stan::math::adjoint_of(lp) += 9; } return stan::math::lb_constrain(a, b, lp); diff --git a/test/unit/math/opencl/rev/constraint/lub_constrain_test.cpp b/test/unit/math/opencl/rev/constraint/lub_constrain_test.cpp index 121faaf1e81..6e25d57798a 100644 --- a/test/unit/math/opencl/rev/constraint/lub_constrain_test.cpp +++ b/test/unit/math/opencl/rev/constraint/lub_constrain_test.cpp @@ -10,7 +10,7 @@ auto lub_constrain_functor = [](const auto& a, const auto& b, const auto& c) { auto lub_constrain_functor2 = [](const auto& a, const auto& b, const auto& c) { using T_lp = stan::return_type_t; T_lp lp(4); - if constexpr (!stan::is_constant::value) { + if (!stan::is_constant::value) { stan::math::adjoint_of(lp) += 9; } return stan::math::lub_constrain(a, b, c, lp); diff --git a/test/unit/math/opencl/rev/constraint/offset_multiplier_constrain_test.cpp b/test/unit/math/opencl/rev/constraint/offset_multiplier_constrain_test.cpp index 96564fbd6f5..50b0bfd0b41 100644 --- a/test/unit/math/opencl/rev/constraint/offset_multiplier_constrain_test.cpp +++ b/test/unit/math/opencl/rev/constraint/offset_multiplier_constrain_test.cpp @@ -12,7 +12,7 @@ auto offset_multiplier_constrain_functor2 = [](const auto& a, const auto& b, const auto& c) { using T_lp = stan::return_type_t; T_lp lp(4); - if constexpr (!stan::is_constant::value) { + if (!stan::is_constant::value) { stan::math::adjoint_of(lp) += 9; } return stan::math::offset_multiplier_constrain(a, b, c, lp); diff --git a/test/unit/math/opencl/rev/constraint/ub_constrain_test.cpp b/test/unit/math/opencl/rev/constraint/ub_constrain_test.cpp index f681740a100..3a887e460dc 100644 --- a/test/unit/math/opencl/rev/constraint/ub_constrain_test.cpp +++ b/test/unit/math/opencl/rev/constraint/ub_constrain_test.cpp @@ -10,7 +10,7 @@ auto ub_constrain_functor = [](const auto& a, const auto& b) { auto ub_constrain_functor2 = [](const auto& a, const auto& b) { using T_lp = stan::return_type_t; T_lp lp(4); - if constexpr (!stan::is_constant::value) { + if (!stan::is_constant::value) { stan::math::adjoint_of(lp) += 9; } return stan::math::ub_constrain(a, b, lp); diff --git a/test/unit/math/opencl/rev/constraint/unit_vector_constrain_test.cpp b/test/unit/math/opencl/rev/constraint/unit_vector_constrain_test.cpp index 3ed0152e783..a8c3077e65d 100644 --- a/test/unit/math/opencl/rev/constraint/unit_vector_constrain_test.cpp +++ b/test/unit/math/opencl/rev/constraint/unit_vector_constrain_test.cpp @@ -9,7 +9,7 @@ auto unit_vector_constrain_functor auto unit_vector_constrain_functor2 = [](const auto& a) { using T_lp = stan::return_type_t; T_lp lp(4); - if constexpr (!stan::is_constant::value) { + if (!stan::is_constant::value) { stan::math::adjoint_of(lp) += 9; } return stan::math::unit_vector_constrain(a, lp); diff --git a/test/unit/math/opencl/tri_inverse_test.cpp b/test/unit/math/opencl/tri_inverse_test.cpp index 98c36794892..9eda4495e94 100644 --- a/test/unit/math/opencl/tri_inverse_test.cpp +++ b/test/unit/math/opencl/tri_inverse_test.cpp @@ -24,7 +24,7 @@ TEST(MathMatrixCL, inverse_cl_exception) { EXPECT_THROW(m3 = tri_inverse(m5), std::invalid_argument); } -inline void lower_inverse_test(int size) { +void lower_inverse_test(int size) { boost::random::mt19937 rng; auto m1 = stan::math::matrix_d(size, size); for (int i = 0; i < size; i++) { @@ -55,7 +55,7 @@ inline void lower_inverse_test(int size) { EXPECT_LT(max_error, 1e-8); } -inline void upper_inverse_test(int size) { +void upper_inverse_test(int size) { boost::random::mt19937 rng; auto m1 = stan::math::matrix_d(size, size); for (int i = 0; i < size; i++) { diff --git a/test/unit/math/opencl/util.hpp b/test/unit/math/opencl/util.hpp index de712ee6279..9170a8d848c 100644 --- a/test/unit/math/opencl/util.hpp +++ b/test/unit/math/opencl/util.hpp @@ -17,7 +17,7 @@ namespace test { namespace internal { template * = nullptr> -inline T opencl_argument(const T& x) { +T opencl_argument(const T& x) { return x; } template * = nullptr> @@ -26,7 +26,7 @@ auto opencl_argument(const T& x) { } template >>* = nullptr> -inline T var_argument(const T& x) { +T var_argument(const T& x) { return x; } template * = nullptr> -inline void expect_eq(T a, T b, const char* msg) { +void expect_eq(T a, T b, const char* msg) { stan::test::expect_near_rel(msg, a, b); } -inline void expect_eq(math::var a, math::var b, const char* msg) { +void expect_eq(math::var a, math::var b, const char* msg) { stan::test::expect_near_rel(msg, a.val(), b.val()); } template * = nullptr, require_all_not_st_var* = nullptr> -inline void expect_eq(const T1& a, const T2& b, const char* msg) { +void expect_eq(const T1& a, const T2& b, const char* msg) { EXPECT_EQ(a.rows(), b.rows()) << msg; EXPECT_EQ(a.cols(), b.cols()) << msg; const auto& a_ref = math::to_ref(a); @@ -68,12 +68,12 @@ inline void expect_eq(const T1& a, const T2& b, const char* msg) { } } template * = nullptr> -inline void expect_eq(const T1& a, const T2& b, const char* msg) { +void expect_eq(const T1& a, const T2& b, const char* msg) { expect_eq(a.val(), b.val(), msg); } template -inline void expect_eq(const std::vector& a, const std::vector& b, - const char* msg) { +void expect_eq(const std::vector& a, const std::vector& b, + const char* msg) { EXPECT_EQ(a.size(), b.size()); for (int i = 0; i < a.size(); i++) { expect_eq(a[i], b[i], msg); @@ -81,12 +81,12 @@ inline void expect_eq(const std::vector& a, const std::vector& b, } template * = nullptr> -inline void expect_eq(const T1& a, const T2& b, const char* msg) { +void expect_eq(const T1& a, const T2& b, const char* msg) { expect_eq(from_matrix_cl>(a), b, msg); } template * = nullptr> -inline void expect_eq(const T1& a, const T2& b, const char* msg) { +void expect_eq(const T1& a, const T2& b, const char* msg) { expect_eq(a, from_matrix_cl>(b), msg); } @@ -104,13 +104,13 @@ auto recursive_sum(const std::vector& a) { } template * = nullptr> -inline void expect_adj_near(const T& a, const T& b, const char* msg) {} -inline void expect_adj_near(var a, var b, const char* msg) { +void expect_adj_near(const T& a, const T& b, const char* msg) {} +void expect_adj_near(var a, var b, const char* msg) { stan::test::expect_near_rel(msg, a.adj(), b.adj()); } template * = nullptr, require_vt_same* = nullptr> -inline void expect_adj_near(const T1& a, const T2& b, const char* msg) { +void expect_adj_near(const T1& a, const T2& b, const char* msg) { EXPECT_EQ(a.rows(), b.rows()) << msg; EXPECT_EQ(a.cols(), b.cols()) << msg; const auto& a_ref = math::to_ref(a); @@ -118,8 +118,8 @@ inline void expect_adj_near(const T1& a, const T2& b, const char* msg) { stan::test::expect_near_rel(msg, a_ref.adj(), b_ref.adj()); } template -inline void expect_adj_near(const std::vector& a, const std::vector& b, - const char* msg) { +void expect_adj_near(const std::vector& a, const std::vector& b, + const char* msg) { EXPECT_EQ(a.size(), b.size()) << msg; for (int i = 0; i < a.size(); i++) { expect_adj_near(a[i], b[i], msg); @@ -127,12 +127,12 @@ inline void expect_adj_near(const std::vector& a, const std::vector& b, } template -inline void prim_rev_argument_combinations(Functor f) { +void prim_rev_argument_combinations(Functor f) { f(std::make_tuple(), std::make_tuple()); } template -inline void prim_rev_argument_combinations(const Functor& f, const Arg0& arg0, - const Args&... args) { +void prim_rev_argument_combinations(const Functor& f, const Arg0& arg0, + const Args&... args) { prim_rev_argument_combinations( [&f, &arg0](const auto& args1, const auto& args2) { constexpr size_t Size @@ -156,9 +156,9 @@ inline void prim_rev_argument_combinations(const Functor& f, const Arg0& arg0, } template -inline void compare_cpu_opencl_prim_rev_impl(const Functor& functor, - std::index_sequence, - const Args&... args) { +void compare_cpu_opencl_prim_rev_impl(const Functor& functor, + std::index_sequence, + const Args&... args) { prim_rev_argument_combinations( [&functor](const auto& args_for_cpu, const auto& args_for_opencl) { std::string signature = type_name().data(); @@ -192,10 +192,10 @@ inline void compare_cpu_opencl_prim_rev_impl(const Functor& functor, template -inline void compare_cpu_opencl_prim_rev_impl(const FunctorCPU& functorCPU, - const FunctorCL& functorCL, - std::index_sequence, - const Args&... args) { +void compare_cpu_opencl_prim_rev_impl(const FunctorCPU& functorCPU, + const FunctorCL& functorCL, + std::index_sequence, + const Args&... args) { prim_rev_argument_combinations( [&functorCPU, &functorCL](const auto& args_for_cpu, const auto& args_for_opencl) { @@ -227,7 +227,7 @@ auto to_vector_if(const T& x, std::size_t N) { return Eigen::Matrix::Constant(N, x); } template * = nullptr> -inline T to_vector_if(const T& x, std::size_t N) { +T to_vector_if(const T& x, std::size_t N) { return x; } @@ -242,9 +242,9 @@ int64_t rows(const T& x) { } template -inline void test_opencl_broadcasting_prim_rev_impl(const Functor& functor, - std::index_sequence, - const Args&... args) { +void test_opencl_broadcasting_prim_rev_impl(const Functor& functor, + std::index_sequence, + const Args&... args) { prim_rev_argument_combinations( [&functor, N = std::max({rows(args)...})](const auto& args_broadcast, const auto& args_vector) { @@ -304,8 +304,7 @@ inline void test_opencl_broadcasting_prim_rev_impl(const Functor& functor, * in CPU memory (no vars, no arguments on the OpenCL device). */ template -inline void compare_cpu_opencl_prim(const Functor& functor, - const Args&... args) { +void compare_cpu_opencl_prim(const Functor& functor, const Args&... args) { auto res_cpu = eval(functor(args...)); auto res_opencl = eval(functor(internal::opencl_argument(args)...)); internal::expect_eq(res_cpu, res_opencl, @@ -329,8 +328,7 @@ inline void compare_cpu_opencl_prim(const Functor& functor, * in CPU memory (no vars, no arguments on the OpenCL device). */ template -inline void compare_cpu_opencl_prim_rev(const Functor& functor, - const Args&... args) { +void compare_cpu_opencl_prim_rev(const Functor& functor, const Args&... args) { internal::compare_cpu_opencl_prim_rev_impl( functor, std::make_index_sequence{}, args...); recover_memory(); @@ -354,9 +352,9 @@ inline void compare_cpu_opencl_prim_rev(const Functor& functor, * in CPU memory (no vars, no arguments on the OpenCL device). */ template -inline void compare_cpu_opencl_prim_rev_separate(const FunctorCPU& functorCPU, - const FunctorCL& fucntorCL, - const Args&... args) { +void compare_cpu_opencl_prim_rev_separate(const FunctorCPU& functorCPU, + const FunctorCL& fucntorCL, + const Args&... args) { internal::compare_cpu_opencl_prim_rev_impl( functorCPU, fucntorCL, std::make_index_sequence{}, args...); @@ -386,8 +384,8 @@ template * = nullptr, require_stan_scalar_t< std::tuple_element_t>>* = nullptr> -inline void test_opencl_broadcasting_prim_rev(const Functor& functor, - const Args&... args) { +void test_opencl_broadcasting_prim_rev(const Functor& functor, + const Args&... args) { internal::test_opencl_broadcasting_prim_rev_impl( functor, std::make_index_sequence{}, args...); recover_memory(); diff --git a/test/unit/math/prim/constraint/cholesky_corr_transform_test.cpp b/test/unit/math/prim/constraint/cholesky_corr_transform_test.cpp index 4f6deed1af4..712fc6616e4 100644 --- a/test/unit/math/prim/constraint/cholesky_corr_transform_test.cpp +++ b/test/unit/math/prim/constraint/cholesky_corr_transform_test.cpp @@ -25,7 +25,7 @@ TEST(ProbTransform, CholeskyCorrelation4) { EXPECT_FLOAT_EQ(L(m, n), x(m, n)); } -inline void test_cholesky_correlation_values( +void test_cholesky_correlation_values( const Eigen::Matrix& L) { using Eigen::Dynamic; using Eigen::Matrix; diff --git a/test/unit/math/prim/err/elementwise_check_test.cpp b/test/unit/math/prim/err/elementwise_check_test.cpp index 377e7cdb1bc..aa61fbadecd 100644 --- a/test/unit/math/prim/err/elementwise_check_test.cpp +++ b/test/unit/math/prim/err/elementwise_check_test.cpp @@ -9,24 +9,24 @@ namespace elementwise_check_test { auto p = [](const auto& x) { return !stan::math::is_nan(x); }; template -inline void do_check(const T& x) { +void do_check(const T& x) { stan::math::elementwise_check([](const auto& x) { return p(x); }, "elementwise_check_tests", "x", x, "not nan"); } template -inline bool do_is(const T& x) { +bool do_is(const T& x) { return stan::math::elementwise_is([](const auto& x) { return p(x); }, x); } template -inline void expect_good(const T& x) { +void expect_good(const T& x) { EXPECT_NO_THROW(do_check(x)); EXPECT_TRUE(do_is(x)); } template -inline void expect_bad(const T& x) { +void expect_bad(const T& x) { EXPECT_THROW(do_check(x), std::domain_error); EXPECT_FALSE(do_is(x)); } diff --git a/test/unit/math/prim/fun/accumulator_test.cpp b/test/unit/math/prim/fun/accumulator_test.cpp index a3eef3e2c16..7eca88dc798 100644 --- a/test/unit/math/prim/fun/accumulator_test.cpp +++ b/test/unit/math/prim/fun/accumulator_test.cpp @@ -4,7 +4,7 @@ // test sum of first n numbers for sum of a template -inline void test_sum(stan::math::accumulator& a, int n) { +void test_sum(stan::math::accumulator& a, int n) { EXPECT_FLOAT_EQ((n * (n + 1)) / 2, a.sum()); } diff --git a/test/unit/math/prim/fun/assign_test.cpp b/test/unit/math/prim/fun/assign_test.cpp index be85d0f4924..89c5422f7e8 100644 --- a/test/unit/math/prim/fun/assign_test.cpp +++ b/test/unit/math/prim/fun/assign_test.cpp @@ -7,7 +7,7 @@ #include template -inline void test_print_mat_size(const std::string& expected) { +void test_print_mat_size(const std::string& expected) { using stan::math::print_mat_size; std::stringstream ss; stan::math::print_mat_size(ss); diff --git a/test/unit/math/prim/fun/binary_scalar_tester.hpp b/test/unit/math/prim/fun/binary_scalar_tester.hpp index b08c3c53122..747b948f99f 100644 --- a/test/unit/math/prim/fun/binary_scalar_tester.hpp +++ b/test/unit/math/prim/fun/binary_scalar_tester.hpp @@ -20,7 +20,7 @@ namespace test { */ template * = nullptr> -inline void binary_scalar_tester_impl(const F& f, const T1& x, const T2& y) { +void binary_scalar_tester_impl(const F& f, const T1& x, const T2& y) { auto vec_vec = math::eval(f(x, y)); auto vec_scal = math::eval(f(x, y(0))); auto scal_vec = math::eval(f(x(0), y)); @@ -90,7 +90,7 @@ inline void binary_scalar_tester_impl(const F& f, const T1& x, const T2& y) { */ template * = nullptr> -inline void binary_scalar_tester_impl(const F& f, const T1& x, const T2& y) { +void binary_scalar_tester_impl(const F& f, const T1& x, const T2& y) { auto vec_vec = math::eval(f(x, y)); auto vec_scal = math::eval(f(x, y[0])); auto scal_vec = math::eval(f(x[0], y)); @@ -162,7 +162,7 @@ template , require_eigen_matrix_dynamic_t* = nullptr, require_std_vector_t* = nullptr> -inline void binary_scalar_tester_impl(const F& f, const T1& x, const T2& y) { +void binary_scalar_tester_impl(const F& f, const T1& x, const T2& y) { auto vec_vec = math::eval(f(x, y)); for (int r = 0; r < x.rows(); ++r) { for (int c = 0; c < x.cols(); ++c) { @@ -215,7 +215,7 @@ template , require_std_vector_t* = nullptr, require_eigen_matrix_dynamic_t* = nullptr> -inline void binary_scalar_tester_impl(const F& f, const T1& x, const T2& y) { +void binary_scalar_tester_impl(const F& f, const T1& x, const T2& y) { auto vec_vec = math::eval(f(x, y)); for (int r = 0; r < y.rows(); ++r) { for (int c = 0; c < y.cols(); ++c) { @@ -281,7 +281,7 @@ inline void binary_scalar_tester_impl(const F& f, const T1& x, const T2& y) { */ template * = nullptr> -inline void binary_scalar_tester(const F& f, const T1& x, const T2& y) { +void binary_scalar_tester(const F& f, const T1& x, const T2& y) { binary_scalar_tester_impl(f, x, y); binary_scalar_tester_impl(f, x.transpose().eval(), y.transpose().eval()); binary_scalar_tester_impl(f, x.replicate(1, x.size()).eval(), @@ -311,7 +311,7 @@ template * = nullptr, require_any_std_vector_st* = nullptr, require_any_eigen_matrix_dynamic_t* = nullptr> -inline void binary_scalar_tester(const F& f, const T1& x, const T2& y) { +void binary_scalar_tester(const F& f, const T1& x, const T2& y) { binary_scalar_tester_impl(f, x, y); } @@ -329,7 +329,7 @@ inline void binary_scalar_tester(const F& f, const T1& x, const T2& y) { */ template * = nullptr> -inline void binary_scalar_tester(const F& f, const T1& x, const T2& y) { +void binary_scalar_tester(const F& f, const T1& x, const T2& y) { binary_scalar_tester_impl(f, x, y); } @@ -350,7 +350,7 @@ inline void binary_scalar_tester(const F& f, const T1& x, const T2& y) { template * = nullptr, require_eigen_vector_t* = nullptr> -inline void binary_scalar_tester(const F& f, const T1& x, const T2& y) { +void binary_scalar_tester(const F& f, const T1& x, const T2& y) { binary_scalar_tester_impl(f, x, y); binary_scalar_tester_impl(f, x, y.transpose()); binary_scalar_tester_impl(f, x, y.array()); @@ -373,7 +373,7 @@ inline void binary_scalar_tester(const F& f, const T1& x, const T2& y) { template * = nullptr, require_std_vector_t* = nullptr> -inline void binary_scalar_tester(const F& f, const T1& x, const T2& y) { +void binary_scalar_tester(const F& f, const T1& x, const T2& y) { binary_scalar_tester_impl(f, x, y); binary_scalar_tester_impl(f, x.transpose(), y); binary_scalar_tester_impl(f, x.array(), y); diff --git a/test/unit/math/prim/fun/binomial_coefficient_log_test.cpp b/test/unit/math/prim/fun/binomial_coefficient_log_test.cpp index 7ab57f460b8..439eaf3a8c1 100644 --- a/test/unit/math/prim/fun/binomial_coefficient_log_test.cpp +++ b/test/unit/math/prim/fun/binomial_coefficient_log_test.cpp @@ -5,7 +5,7 @@ #include template -inline void test_binom_coefficient(const T_N& N, const T_n& n) { +void test_binom_coefficient(const T_N& N, const T_n& n) { using stan::math::binomial_coefficient_log; EXPECT_FLOAT_EQ(lgamma(N + 1) - lgamma(n + 1) - lgamma(N - n + 1), binomial_coefficient_log(N, n)) diff --git a/test/unit/math/prim/fun/choose_test.cpp b/test/unit/math/prim/fun/choose_test.cpp index 0630db85065..b5bc0f197c5 100644 --- a/test/unit/math/prim/fun/choose_test.cpp +++ b/test/unit/math/prim/fun/choose_test.cpp @@ -13,7 +13,7 @@ int finite_choose_test(int N, int n) { return round_to_int(exp(lgamma(N + 1) - lgamma(n + 1) - lgamma(N - n + 1))); } -inline void test_choose_finite(int N, int n) { +void test_choose_finite(int N, int n) { using stan::math::choose; if (n > N) EXPECT_EQ(0, choose(N, n)); diff --git a/test/unit/math/prim/fun/crossprod_test.cpp b/test/unit/math/prim/fun/crossprod_test.cpp index b81f59575cd..6bdb9b8682a 100644 --- a/test/unit/math/prim/fun/crossprod_test.cpp +++ b/test/unit/math/prim/fun/crossprod_test.cpp @@ -1,7 +1,7 @@ #include #include -inline void test_crossprod(const stan::math::matrix_d& x) { +void test_crossprod(const stan::math::matrix_d& x) { using stan::math::crossprod; stan::math::matrix_d y = crossprod(x); stan::math::matrix_d xtx = x.transpose() * x; diff --git a/test/unit/math/prim/fun/cumulative_sum_test.cpp b/test/unit/math/prim/fun/cumulative_sum_test.cpp index 34634c978f8..f1bf96fce04 100644 --- a/test/unit/math/prim/fun/cumulative_sum_test.cpp +++ b/test/unit/math/prim/fun/cumulative_sum_test.cpp @@ -3,7 +3,7 @@ #include template -inline void test_cumulative_sum() { +void test_cumulative_sum() { using stan::math::cumulative_sum; T c(1); diff --git a/test/unit/math/prim/fun/divide_test.cpp b/test/unit/math/prim/fun/divide_test.cpp index c1227f2a51d..0b5c0b1dd58 100644 --- a/test/unit/math/prim/fun/divide_test.cpp +++ b/test/unit/math/prim/fun/divide_test.cpp @@ -37,7 +37,7 @@ TEST(MathFunctions, divide) { EXPECT_EQ(-2, divide(-44, 17)); } -inline void test_divide_modulus(int a, int b) { +void test_divide_modulus(int a, int b) { using stan::math::divide; using stan::math::modulus; EXPECT_EQ(a, divide(a, b) * b + modulus(a, b)); diff --git a/test/unit/math/prim/fun/linspaced_row_vector_test.cpp b/test/unit/math/prim/fun/linspaced_row_vector_test.cpp index 4718a99363c..a5d08ba3305 100644 --- a/test/unit/math/prim/fun/linspaced_row_vector_test.cpp +++ b/test/unit/math/prim/fun/linspaced_row_vector_test.cpp @@ -3,8 +3,8 @@ #include #include -inline void expect_linspaced_row_vector(int K, double low, double high, - const Eigen::RowVectorXd& expected) { +void expect_linspaced_row_vector(int K, double low, double high, + const Eigen::RowVectorXd& expected) { Eigen::RowVectorXd found = stan::math::linspaced_row_vector(K, low, high); EXPECT_MATRIX_FLOAT_EQ(expected, found); } diff --git a/test/unit/math/prim/fun/linspaced_vector_test.cpp b/test/unit/math/prim/fun/linspaced_vector_test.cpp index f8ebc5bc9be..26ec8524347 100644 --- a/test/unit/math/prim/fun/linspaced_vector_test.cpp +++ b/test/unit/math/prim/fun/linspaced_vector_test.cpp @@ -3,8 +3,8 @@ #include #include -inline void expect_linspaced_vector(int K, double low, double high, - const Eigen::VectorXd& expected) { +void expect_linspaced_vector(int K, double low, double high, + const Eigen::VectorXd& expected) { Eigen::VectorXd found = stan::math::linspaced_vector(K, low, high); EXPECT_MATRIX_FLOAT_EQ(expected, found); } diff --git a/test/unit/math/prim/fun/log_diff_exp_test.cpp b/test/unit/math/prim/fun/log_diff_exp_test.cpp index 1ba173573ff..e1177030a2c 100644 --- a/test/unit/math/prim/fun/log_diff_exp_test.cpp +++ b/test/unit/math/prim/fun/log_diff_exp_test.cpp @@ -4,7 +4,7 @@ #include #include -inline void test_log_diff_exp(double a, double b) { +void test_log_diff_exp(double a, double b) { using stan::math::log_diff_exp; using std::exp; using std::log; diff --git a/test/unit/math/prim/fun/log_mix_test.cpp b/test/unit/math/prim/fun/log_mix_test.cpp index f28405a45dd..8ea8fb77d6a 100644 --- a/test/unit/math/prim/fun/log_mix_test.cpp +++ b/test/unit/math/prim/fun/log_mix_test.cpp @@ -17,7 +17,7 @@ TEST(MathFunctions, log_mix_exceptions) { EXPECT_THROW(log_mix(0.5, 10, std::numeric_limits::quiet_NaN()), std::domain_error); } -inline void test_log_mix(double theta, double lambda1, double lambda2) { +void test_log_mix(double theta, double lambda1, double lambda2) { using stan::math::log_mix; using stan::math::row_vector_d; using stan::math::vector_d; @@ -34,7 +34,7 @@ TEST(MathFunctions, log_mix_values) { } template -inline void log_mix_val_test(T_a a, T_b b) { +void log_mix_val_test(T_a a, T_b b) { using stan::math::log_mix; a[0] = 0.321; a[1] = 0.115; diff --git a/test/unit/math/prim/fun/log_softmax_test.cpp b/test/unit/math/prim/fun/log_softmax_test.cpp index 27f682a17ff..a75a50e281c 100644 --- a/test/unit/math/prim/fun/log_softmax_test.cpp +++ b/test/unit/math/prim/fun/log_softmax_test.cpp @@ -2,8 +2,7 @@ #include #include -inline void test_log_softmax( - const Eigen::Matrix& theta) { +void test_log_softmax(const Eigen::Matrix& theta) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::log_softmax; diff --git a/test/unit/math/prim/fun/log_sum_exp_test.cpp b/test/unit/math/prim/fun/log_sum_exp_test.cpp index b515e61ae77..6b13f9c4970 100644 --- a/test/unit/math/prim/fun/log_sum_exp_test.cpp +++ b/test/unit/math/prim/fun/log_sum_exp_test.cpp @@ -5,14 +5,14 @@ #include #include -inline void test_log_sum_exp(double a, double b) { +void test_log_sum_exp(double a, double b) { using stan::math::log_sum_exp; using std::exp; using std::log; EXPECT_FLOAT_EQ(log(exp(a) + exp(b)), log_sum_exp(a, b)); } -inline void test_log_sum_exp(const std::vector& as) { +void test_log_sum_exp(const std::vector& as) { using stan::math::log_sum_exp; using std::exp; using std::log; @@ -73,7 +73,7 @@ TEST(MathFunctions, log_sum_exp_nan) { } template -inline void test_log_sum_exp(const Eigen::Matrix& as) { +void test_log_sum_exp(const Eigen::Matrix& as) { using stan::math::log_sum_exp; using std::exp; using std::log; diff --git a/test/unit/math/prim/fun/multiply_lower_tri_self_transpose_test.cpp b/test/unit/math/prim/fun/multiply_lower_tri_self_transpose_test.cpp index da5231f2030..4d8332fefb2 100644 --- a/test/unit/math/prim/fun/multiply_lower_tri_self_transpose_test.cpp +++ b/test/unit/math/prim/fun/multiply_lower_tri_self_transpose_test.cpp @@ -1,7 +1,7 @@ #include #include -inline stan::math::matrix_d generate_large_L_tri_mat() { +stan::math::matrix_d generate_large_L_tri_mat() { stan::math::matrix_d x; double vals[10000]; @@ -15,8 +15,7 @@ inline stan::math::matrix_d generate_large_L_tri_mat() { return x; } -inline void test_multiply_lower_tri_self_transpose( - const stan::math::matrix_d& x) { +void test_multiply_lower_tri_self_transpose(const stan::math::matrix_d& x) { using stan::math::multiply_lower_tri_self_transpose; stan::math::matrix_d y = multiply_lower_tri_self_transpose(x); stan::math::matrix_d xp = x; diff --git a/test/unit/math/prim/fun/promote_type_test_util.hpp b/test/unit/math/prim/fun/promote_type_test_util.hpp index c7eaa64cdd0..950d95ef956 100644 --- a/test/unit/math/prim/fun/promote_type_test_util.hpp +++ b/test/unit/math/prim/fun/promote_type_test_util.hpp @@ -8,7 +8,7 @@ // E is expected value of promote_scalar_type::type template -inline void expect_promote_type() { +void expect_promote_type() { using stan::math::promote_scalar_type; using stan::math::test::type_name; using promoted_S = typename promote_scalar_type::type; diff --git a/test/unit/math/prim/fun/quantile_test.cpp b/test/unit/math/prim/fun/quantile_test.cpp index a939a1098ac..957a2a2974a 100644 --- a/test/unit/math/prim/fun/quantile_test.cpp +++ b/test/unit/math/prim/fun/quantile_test.cpp @@ -5,7 +5,7 @@ #include template -inline void test_quantile_double() { +void test_quantile_double() { using stan::math::index_type_t; using stan::math::quantile; @@ -87,7 +87,7 @@ TEST(MathFunctions, quantileStdVecInt) { } template * = nullptr> -inline void test_quantile_double() { +void test_quantile_double() { using stan::math::index_type_t; using stan::math::quantile; diff --git a/test/unit/math/prim/fun/rank_test.cpp b/test/unit/math/prim/fun/rank_test.cpp index 711fd755d73..6e71b59cd3a 100644 --- a/test/unit/math/prim/fun/rank_test.cpp +++ b/test/unit/math/prim/fun/rank_test.cpp @@ -3,7 +3,7 @@ #include template -inline void test_rank() { +void test_rank() { using stan::math::rank; T c(1); @@ -37,7 +37,7 @@ inline void test_rank() { } template -inline void test_rank_int() { +void test_rank_int() { using stan::math::rank; T c(1); diff --git a/test/unit/math/prim/fun/scalar_seq_view_test.cpp b/test/unit/math/prim/fun/scalar_seq_view_test.cpp index 8b887046e79..92f0052958b 100644 --- a/test/unit/math/prim/fun/scalar_seq_view_test.cpp +++ b/test/unit/math/prim/fun/scalar_seq_view_test.cpp @@ -58,7 +58,7 @@ TEST(MathMetaPrim, ScalarSeqViewArray) { } template -inline void expect_scalar_seq_view_values(C v) { +void expect_scalar_seq_view_values(C v) { using stan::scalar_seq_view; v << 1.1, 2.2, 3.3, 4.4; diff --git a/test/unit/math/prim/fun/sort_indices_test.cpp b/test/unit/math/prim/fun/sort_indices_test.cpp index 99e470bb4c3..44085083454 100644 --- a/test/unit/math/prim/fun/sort_indices_test.cpp +++ b/test/unit/math/prim/fun/sort_indices_test.cpp @@ -3,7 +3,7 @@ #include template -inline void test_sort_indices_asc() { +void test_sort_indices_asc() { using stan::math::sort_indices_asc; using idx_t = stan::math::index_type_t; @@ -47,7 +47,7 @@ TEST(MathMatrixPrimMat, sort_indices_asc) { } template -inline void test_sort_indices_desc() { +void test_sort_indices_desc() { using stan::math::sort_indices_desc; using idx_t = stan::math::index_type_t; diff --git a/test/unit/math/prim/fun/sort_test.cpp b/test/unit/math/prim/fun/sort_test.cpp index a2ca1f10c1e..55de6a3b0fd 100644 --- a/test/unit/math/prim/fun/sort_test.cpp +++ b/test/unit/math/prim/fun/sort_test.cpp @@ -6,7 +6,7 @@ #include template -inline void test_sort_asc() { +void test_sort_asc() { using stan::math::index_type_t; using stan::math::sort_asc; @@ -72,7 +72,7 @@ TEST(MathMatrixPrimMat, sort_asc) { } template -inline void test_sort_desc() { +void test_sort_desc() { using stan::math::index_type_t; using stan::math::sort_desc; diff --git a/test/unit/math/prim/fun/sort_test_util.hpp b/test/unit/math/prim/fun/sort_test_util.hpp index e36b80830f9..a6241cb6467 100644 --- a/test/unit/math/prim/fun/sort_test_util.hpp +++ b/test/unit/math/prim/fun/sort_test_util.hpp @@ -6,7 +6,7 @@ #include template -inline void test_sort_asc_throws() { +void test_sort_asc_throws() { using stan::math::sort_asc; C xs0; @@ -31,7 +31,7 @@ inline void test_sort_asc_throws() { } template -inline void test_sort_desc_throws() { +void test_sort_desc_throws() { using stan::math::sort_desc; C xs0; diff --git a/test/unit/math/prim/fun/tcrossprod_test.cpp b/test/unit/math/prim/fun/tcrossprod_test.cpp index b54d9702305..a19bfe37e29 100644 --- a/test/unit/math/prim/fun/tcrossprod_test.cpp +++ b/test/unit/math/prim/fun/tcrossprod_test.cpp @@ -1,7 +1,7 @@ #include #include -inline void test_tcrossprod(const stan::math::matrix_d& x) { +void test_tcrossprod(const stan::math::matrix_d& x) { using stan::math::tcrossprod; stan::math::matrix_d y = tcrossprod(x); stan::math::matrix_d xxt = x * x.transpose(); diff --git a/test/unit/math/prim/fun/ternary_scalar_tester.hpp b/test/unit/math/prim/fun/ternary_scalar_tester.hpp index 6d31ef6a3fe..a17b887669c 100644 --- a/test/unit/math/prim/fun/ternary_scalar_tester.hpp +++ b/test/unit/math/prim/fun/ternary_scalar_tester.hpp @@ -24,8 +24,8 @@ namespace test { */ template * = nullptr> -inline void ternary_scalar_tester_impl(const F& f, const T1& x, const T2& y, - const T3& z) { +void ternary_scalar_tester_impl(const F& f, const T1& x, const T2& y, + const T3& z) { auto mat_mat_mat = math::eval(f(x, y, z)); auto mat_mat_scal = math::eval(f(x, y, z(0))); auto mat_scal_scal = math::eval(f(x, y(0), z(0))); @@ -146,8 +146,8 @@ inline void ternary_scalar_tester_impl(const F& f, const T1& x, const T2& y, */ template * = nullptr> -inline void ternary_scalar_tester_impl(const F& f, const T1& x, const T2& y, - const T3& z) { +void ternary_scalar_tester_impl(const F& f, const T1& x, const T2& y, + const T3& z) { auto mat_mat_mat = math::eval(f(x, y, z)); auto mat_mat_scal = math::eval(f(x, y, z[0])); auto mat_scal_scal = math::eval(f(x, y[0], z[0])); @@ -266,8 +266,7 @@ inline void ternary_scalar_tester_impl(const F& f, const T1& x, const T2& y, */ template * = nullptr> -inline void ternary_scalar_tester(const F& f, const T1& x, const T2& y, - const T3& z) { +void ternary_scalar_tester(const F& f, const T1& x, const T2& y, const T3& z) { ternary_scalar_tester_impl(f, x, y, z); ternary_scalar_tester_impl(f, x.transpose().eval(), y.transpose().eval(), z.transpose().eval()); diff --git a/test/unit/math/prim/fun/to_complex_test.cpp b/test/unit/math/prim/fun/to_complex_test.cpp index 575dc6fa03a..7f4d0e340aa 100644 --- a/test/unit/math/prim/fun/to_complex_test.cpp +++ b/test/unit/math/prim/fun/to_complex_test.cpp @@ -3,7 +3,7 @@ #include template -inline void test_constructor(const T& re, const S& im) { +void test_constructor(const T& re, const S& im) { std::complex z1(re, im); std::complex z2 = stan::math::to_complex(re, im); EXPECT_EQ(z1, z2); diff --git a/test/unit/math/prim/fun/to_matrix_test.cpp b/test/unit/math/prim/fun/to_matrix_test.cpp index 936636d0a72..5776a5f7183 100644 --- a/test/unit/math/prim/fun/to_matrix_test.cpp +++ b/test/unit/math/prim/fun/to_matrix_test.cpp @@ -17,7 +17,7 @@ inline Eigen::Matrix row_major_to_column_major( } // [T] -> Matrix -inline void test_to_matrix_array_answers(int m, int n) { +void test_to_matrix_array_answers(int m, int n) { using stan::math::to_matrix; std::vector vec(m * n); std::vector vec_int(m * n); @@ -55,7 +55,7 @@ TEST(ToMatrixArray, exceptions) { } // Matrix -> Matrix -inline void test_to_matrix_matrix_answers(int m, int n) { +void test_to_matrix_matrix_answers(int m, int n) { using stan::math::to_matrix; Eigen::MatrixXd a(m, n); for (int i = 0; i < m * n; ++i) @@ -71,8 +71,7 @@ TEST(ToMatrixMatrix, answers) { } // Matrix -> Matrix (with reshape) -inline void test_to_matrix_matrix_reshape_answers(int m1, int n1, int m2, - int n2) { +void test_to_matrix_matrix_reshape_answers(int m1, int n1, int m2, int n2) { using stan::math::to_matrix; Eigen::MatrixXd a(m1, n1); Eigen::MatrixXd b(m2, n2); @@ -121,7 +120,7 @@ TEST(ToMatrixMatrixReshape, answers) { } // Vector -> Matrix -inline void test_to_vector_matrix_answers(int m, int m2, int n2) { +void test_to_vector_matrix_answers(int m, int m2, int n2) { using stan::math::to_matrix; Eigen::VectorXd a(m); Eigen::MatrixXd b(m2, n2); @@ -162,7 +161,7 @@ TEST(ToMatrixVector, answers) { } // RowVector -> Matrix -inline void test_to_row_vector_matrix_answers(int n, int m2, int n2) { +void test_to_row_vector_matrix_answers(int n, int m2, int n2) { using stan::math::to_matrix; Eigen::RowVectorXd a(n); Eigen::MatrixXd b(m2, n2); @@ -203,7 +202,7 @@ TEST(ToMatrixRowVector, answers) { } // [[T]] -> Matrix -inline void test_to_matrix_2darray_answers(int m, int n) { +void test_to_matrix_2darray_answers(int m, int n) { using stan::math::to_matrix; std::vector > vec(m, std::vector(n)); std::vector > vec_int(m, std::vector(n)); diff --git a/test/unit/math/prim/functor/hcubature_test.cpp b/test/unit/math/prim/functor/hcubature_test.cpp index 006decbbf75..79a3b917f05 100644 --- a/test/unit/math/prim/functor/hcubature_test.cpp +++ b/test/unit/math/prim/functor/hcubature_test.cpp @@ -101,10 +101,9 @@ inline auto f7(const T_x& x, double a) { template -inline void test_integration(const F& f, const ArgsTupleT& pars, int dim, - const T_a& a, const T_b& b, int maxEval, - double reqAbsError, const T_relerr& reqRelError, - double val) { +void test_integration(const F& f, const ArgsTupleT& pars, int dim, const T_a& a, + const T_b& b, int maxEval, double reqAbsError, + const T_relerr& reqRelError, double val) { using stan::math::hcubature; for (auto tolerance : reqRelError) { 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 50b94969a66..9d6c665800e 100644 --- a/test/unit/math/prim/functor/integrate_1d_impl_test.cpp +++ b/test/unit/math/prim/functor/integrate_1d_impl_test.cpp @@ -150,8 +150,8 @@ struct f16 { } }; -inline double lbaX_pdf(double X, double t, double A, double v, double s, - std::ostream *pstream__) { +double lbaX_pdf(double X, double t, double A, double v, double s, + std::ostream *pstream__) { double b_A_tv_ts; double b_tv_ts; double term_1; @@ -166,8 +166,8 @@ inline double lbaX_pdf(double X, double t, double A, double v, double s, return pdf; } -inline double lbaX_cdf(double X, double t, double A, double v, double s, - std::ostream *pstream__) { +double lbaX_cdf(double X, double t, double A, double v, double s, + std::ostream *pstream__) { double b_A_tv; double b_tv; double ts; @@ -192,11 +192,9 @@ inline double lbaX_cdf(double X, double t, double A, double v, double s, return cdf; } -inline double rank_density(double x, double xc, - const std::vector &theta, - const std::vector &x_r, - const std::vector &x_i, - std::ostream *pstream__) { +double rank_density(double x, double xc, const std::vector &theta, + const std::vector &x_r, const std::vector &x_i, + std::ostream *pstream__) { double t = theta[0]; double A = theta[1]; double v1 = theta[2]; @@ -216,8 +214,8 @@ struct rank_density_functor__ { } }; -inline double order(double down, double up, const std::vector &theta, - const std::vector &x_r, std::ostream *pstream__) { +double order(double down, double up, const std::vector &theta, + const std::vector &x_r, std::ostream *pstream__) { std::vector x_i; double v; @@ -254,8 +252,8 @@ inline double order(double down, double up, const std::vector &theta, * @param val correct value of integral */ template -inline void test_integration(const F &f, double a, double b, double val, - const Args &... args) { +void test_integration(const F &f, double a, double b, double val, + const Args &... args) { using stan::math::integrate_1d_impl; std::vector tolerances = {1e-4, 1e-6, 1e-8}; diff --git a/test/unit/math/prim/functor/integrate_1d_test.cpp b/test/unit/math/prim/functor/integrate_1d_test.cpp index 75d65d5916f..fca9c52e0de 100644 --- a/test/unit/math/prim/functor/integrate_1d_test.cpp +++ b/test/unit/math/prim/functor/integrate_1d_test.cpp @@ -214,8 +214,8 @@ struct f17 { } }; -inline double lbaX_pdf(double X, double t, double A, double v, double s, - std::ostream *pstream__) { +double lbaX_pdf(double X, double t, double A, double v, double s, + std::ostream *pstream__) { double b_A_tv_ts; double b_tv_ts; double term_1; @@ -230,8 +230,8 @@ inline double lbaX_pdf(double X, double t, double A, double v, double s, return pdf; } -inline double lbaX_cdf(double X, double t, double A, double v, double s, - std::ostream *pstream__) { +double lbaX_cdf(double X, double t, double A, double v, double s, + std::ostream *pstream__) { double b_A_tv; double b_tv; double ts; @@ -256,11 +256,9 @@ inline double lbaX_cdf(double X, double t, double A, double v, double s, return cdf; } -inline double rank_density(double x, double xc, - const std::vector &theta, - const std::vector &x_r, - const std::vector &x_i, - std::ostream *pstream__) { +double rank_density(double x, double xc, const std::vector &theta, + const std::vector &x_r, const std::vector &x_i, + std::ostream *pstream__) { double t = theta[0]; double A = theta[1]; double v1 = theta[2]; @@ -279,8 +277,8 @@ struct rank_density_functor__ { } }; -inline double order(double down, double up, const std::vector &theta, - const std::vector &x_r, std::ostream *pstream__) { +double order(double down, double up, const std::vector &theta, + const std::vector &x_r, std::ostream *pstream__) { std::vector x_i; double v; @@ -317,10 +315,10 @@ inline double order(double down, double up, const std::vector &theta, * @param val correct value of integral */ template -inline void test_integration(const F &f, double a, double b, - std::vector thetas, - const std::vector &x_r, - const std::vector &x_i, double val) { +void test_integration(const F &f, double a, double b, + std::vector thetas, + const std::vector &x_r, + const std::vector &x_i, double val) { using stan::math::integrate_1d; std::vector tolerances = {1e-4, 1e-6, 1e-8}; diff --git a/test/unit/math/prim/functor/reduce_sum_util.hpp b/test/unit/math/prim/functor/reduce_sum_util.hpp index 18172224e22..94025e06664 100644 --- a/test/unit/math/prim/functor/reduce_sum_util.hpp +++ b/test/unit/math/prim/functor/reduce_sum_util.hpp @@ -11,7 +11,7 @@ namespace stan { namespace math { namespace test { -inline std::ostream* get_new_msg() { +std::ostream* get_new_msg() { std::ostream* msgs = nullptr; return msgs; } @@ -147,7 +147,7 @@ struct grouped_count_lpdf { }; template -inline void test_slices(T1 result, T2&& vec_value, Args&&... args) { +void test_slices(T1 result, T2&& vec_value, Args&&... args) { using stan::math::test::get_new_msg; using stan::math::test::sum_lpdf; diff --git a/test/unit/math/prim/functor/utils_threads.hpp b/test/unit/math/prim/functor/utils_threads.hpp index 77de14ffeb2..45853058e2d 100644 --- a/test/unit/math/prim/functor/utils_threads.hpp +++ b/test/unit/math/prim/functor/utils_threads.hpp @@ -5,7 +5,7 @@ #include // utility to set number of threads to use -inline void set_n_threads(int num_threads) { +void set_n_threads(int num_threads) { static char env_string[256]; std::string num_threads_str = std::to_string(num_threads); snprintf(env_string, sizeof(env_string), "STAN_NUM_THREADS=%s", @@ -14,7 +14,7 @@ inline void set_n_threads(int num_threads) { } // Can't easily use std::string as putenv require non-const char* -inline void set_n_threads(const char* value) { +void set_n_threads(const char* value) { static char env_string[256]; snprintf(env_string, sizeof(env_string), "STAN_NUM_THREADS=%s", value); putenv(env_string); diff --git a/test/unit/math/prim/meta/apply_template_permutations.hpp b/test/unit/math/prim/meta/apply_template_permutations.hpp index 1680c0d3d56..46bc9dc1fc0 100644 --- a/test/unit/math/prim/meta/apply_template_permutations.hpp +++ b/test/unit/math/prim/meta/apply_template_permutations.hpp @@ -132,8 +132,7 @@ struct apply_template_permutations_helper -inline void apply_template_permutations(const T_functor& func, - const T_param& param) { +void apply_template_permutations(const T_functor& func, const T_param& param) { apply_template_permutations_helper::value - 1, diff --git a/test/unit/math/prim/meta/forward_as_test.cpp b/test/unit/math/prim/meta/forward_as_test.cpp new file mode 100644 index 00000000000..75cd3f0495f --- /dev/null +++ b/test/unit/math/prim/meta/forward_as_test.cpp @@ -0,0 +1,13 @@ +#include +#include +#include + +TEST(MathMetaPrim, ForwardAsScalar) { + using stan::math::forward_as; + + int a = 1; + + EXPECT_NO_THROW(forward_as(a) = 2); + EXPECT_EQ(a, 2); + EXPECT_FLOAT_EQ(forward_as(a), 2.0); +} diff --git a/test/unit/math/prim/meta/is_constant_all_test.cpp b/test/unit/math/prim/meta/is_constant_all_test.cpp index 3aae724cf86..f1458b71060 100644 --- a/test/unit/math/prim/meta/is_constant_all_test.cpp +++ b/test/unit/math/prim/meta/is_constant_all_test.cpp @@ -3,7 +3,7 @@ #include template -inline void expect_is_const() { +void expect_is_const() { using stan::is_constant_all; bool temp = is_constant_all::value; EXPECT_TRUE(temp); diff --git a/test/unit/math/prim/prob/VectorRNGTestRig.hpp b/test/unit/math/prim/prob/VectorRNGTestRig.hpp index 1de8889e4b1..e7d347f17cf 100644 --- a/test/unit/math/prim/prob/VectorRNGTestRig.hpp +++ b/test/unit/math/prim/prob/VectorRNGTestRig.hpp @@ -218,32 +218,32 @@ class VectorRNGTestRig { }; template <> -inline std::vector VectorRNGTestRig::get_good_p1() const { +std::vector VectorRNGTestRig::get_good_p1() const { return good_p1_int_; } template <> -inline std::vector VectorRNGTestRig::get_bad_p1() const { +std::vector VectorRNGTestRig::get_bad_p1() const { return bad_p1_int_; } template <> -inline std::vector VectorRNGTestRig::get_good_p2() const { +std::vector VectorRNGTestRig::get_good_p2() const { return good_p2_int_; } template <> -inline std::vector VectorRNGTestRig::get_bad_p2() const { +std::vector VectorRNGTestRig::get_bad_p2() const { return bad_p2_int_; } template <> -inline std::vector VectorRNGTestRig::get_good_p3() const { +std::vector VectorRNGTestRig::get_good_p3() const { return good_p3_int_; } template <> -inline std::vector VectorRNGTestRig::get_bad_p3() const { +std::vector VectorRNGTestRig::get_bad_p3() const { return bad_p3_int_; } diff --git a/test/unit/math/prim/prob/dirichlet_test.cpp b/test/unit/math/prim/prob/dirichlet_test.cpp index e2386ed08a7..777252a54e7 100644 --- a/test/unit/math/prim/prob/dirichlet_test.cpp +++ b/test/unit/math/prim/prob/dirichlet_test.cpp @@ -131,14 +131,14 @@ TEST(ProbDistributions, DirichletBounds) { << "size mismatch: theta is a 2-vector, alpha is a 4-vector"; } -inline double chi_square(std::vector bin, std::vector expect) { +double chi_square(std::vector bin, std::vector expect) { double chi = 0; for (size_t j = 0; j < bin.size(); j++) chi += ((bin[j] - expect[j]) * (bin[j] - expect[j]) / expect[j]); return chi; } -inline void test_dirichlet3_1(Eigen::VectorXd alpha) { +void test_dirichlet3_1(Eigen::VectorXd alpha) { boost::random::mt19937 rng; int N = 10000; int K = stan::math::round(2 * std::pow(N, 0.4)); @@ -164,7 +164,7 @@ inline void test_dirichlet3_1(Eigen::VectorXd alpha) { EXPECT_TRUE(chi_square(bin, expect) < quantile(complement(mydist, 1e-6))); } -inline void test_dirichlet3_2(Eigen::VectorXd alpha) { +void test_dirichlet3_2(Eigen::VectorXd alpha) { using Eigen::Dynamic; using Eigen::Matrix; using Eigen::VectorXd; diff --git a/test/unit/math/prim/prob/gamma_lccdf_test.cpp b/test/unit/math/prim/prob/gamma_lccdf_test.cpp deleted file mode 100644 index 2893f2f0166..00000000000 --- a/test/unit/math/prim/prob/gamma_lccdf_test.cpp +++ /dev/null @@ -1,245 +0,0 @@ -#include -#include -#include - -TEST(ProbGamma, lccdf_works) { - using stan::math::gamma_lccdf; - - double y = 0.8; - double alpha = 1.1; - double beta = 2.3; - - EXPECT_NO_THROW(gamma_lccdf(y, alpha, beta)); -} - -TEST(ProbGamma, lccdf_zero_y) { - using stan::math::gamma_lccdf; - - // When y = 0, LCCDF(0) = log(P(Y > 0)) = log(1) = 0 - // For continuous distribution, P(Y > 0) = 1 - double alpha = 1.5; - double beta = 2.0; - - double result = gamma_lccdf(0.0, alpha, beta); - EXPECT_EQ(result, 0.0); -} - -TEST(ProbGamma, lccdf_large_y) { - using stan::math::gamma_lccdf; - - // When y is very large, CDF approaches 1, so LCCDF = log(1-1) = log(0) = -inf - double alpha = 1.5; - double beta = 2.0; - double y = 1e10; - - double result = gamma_lccdf(y, alpha, beta); - - // Should be a very large negative number (approaching -infinity) - EXPECT_LT(result, -1000.0); -} - -TEST(ProbGamma, lccdf_infinity_y) { - using stan::math::gamma_lccdf; - using stan::math::negative_infinity; - - // When y = infinity, LCCDF = log(P(Y > ∞)) = log(0) = -∞ - double alpha = 1.5; - double beta = 2.0; - double y = std::numeric_limits::infinity(); - - double result = gamma_lccdf(y, alpha, beta); - EXPECT_EQ(result, negative_infinity()); -} - -TEST(ProbGamma, lccdf_small_alpha_small_y) { - using stan::math::gamma_lccdf; - - // Small alpha, small y - numerically challenging - double y = 0.001; - double alpha = 0.1; - double beta = 1.0; - - double result = gamma_lccdf(y, alpha, beta); - - // Should be finite and negative - EXPECT_TRUE(std::isfinite(result)); - EXPECT_LT(result, 0.0); -} - -TEST(ProbGamma, lccdf_large_alpha_large_y) { - using stan::math::gamma_lccdf; - - // Large alpha, large y - double y = 100.0; - double alpha = 50.0; - double beta = 0.5; - - double result = gamma_lccdf(y, alpha, beta); - - // Should be finite - EXPECT_TRUE(std::isfinite(result)); -} - -TEST(ProbGamma, lccdf_alpha_one) { - using stan::math::gamma_lccdf; - using std::exp; - using std::log; - - // When alpha = 1, gamma becomes exponential - // For exponential with rate beta: LCCDF(y) = log(1 - (1-exp(-beta*y))) = - // log(exp(-beta*y)) = -beta*y - double y = 2.0; - double alpha = 1.0; - double beta = 3.0; - - double result = gamma_lccdf(y, alpha, beta); - double expected = -beta * y; // = -6.0 - - EXPECT_NEAR(result, expected, 1e-10); -} - -TEST(ProbGamma, lccdf_various_values) { - using stan::math::gamma_lccdf; - - // Test a variety of parameter combinations - std::vector> test_cases = { - {0.5, 0.5, 1.0}, // Small y, small alpha - {1.0, 1.0, 1.0}, // All ones - {2.0, 3.0, 0.5}, // Moderate values - {10.0, 2.0, 0.1}, // Large y, small beta - {0.1, 10.0, 2.0}, // Small y, large alpha - {5.0, 5.0, 1.0}, // Equal alpha and y - {0.01, 0.5, 10.0}, // Small y, large beta - {100.0, 100.0, 1.0} // Large matched values - }; - - for (const auto& test_case : test_cases) { - double y = std::get<0>(test_case); - double alpha = std::get<1>(test_case); - double beta = std::get<2>(test_case); - - double result = gamma_lccdf(y, alpha, beta); - - // All results should be finite and <= 0 - EXPECT_TRUE(std::isfinite(result)) - << "Failed for y=" << y << ", alpha=" << alpha << ", beta=" << beta; - EXPECT_LE(result, 0.0) << "Failed for y=" << y << ", alpha=" << alpha - << ", beta=" << beta; - } -} - -TEST(ProbGamma, lccdf_extreme_small_values) { - using stan::math::gamma_lccdf; - - // Very small but non-zero values - double y = 1e-10; - double alpha = 1e-5; - double beta = 1.0; - - double result = gamma_lccdf(y, alpha, beta); - - EXPECT_TRUE(std::isfinite(result)); -} - -TEST(ProbGamma, lccdf_extreme_large_alpha) { - using stan::math::gamma_lccdf; - - // Very large alpha (approaches normal distribution) - double y = 1000.0; - double alpha = 1000.0; - double beta = 1.0; - - double result = gamma_lccdf(y, alpha, beta); - - EXPECT_TRUE(std::isfinite(result)); -} - -TEST(ProbGamma, lccdf_monotonic_in_y) { - using stan::math::gamma_lccdf; - - // LCCDF should be monotonically decreasing in y - double alpha = 2.0; - double beta = 1.5; - - double y1 = 1.0; - double y2 = 2.0; - double y3 = 3.0; - - double lccdf1 = gamma_lccdf(y1, alpha, beta); - double lccdf2 = gamma_lccdf(y2, alpha, beta); - double lccdf3 = gamma_lccdf(y3, alpha, beta); - - EXPECT_GT(lccdf1, lccdf2); - EXPECT_GT(lccdf2, lccdf3); -} - -TEST(ProbGamma, lccdf_consistency_with_cdf) { - using stan::math::gamma_cdf; - using stan::math::gamma_lccdf; - using std::log; - - // Test that lccdf(y) ≈ log(1 - cdf(y)) - double y = 1.5; - double alpha = 2.5; - double beta = 1.8; - - double lccdf_val = gamma_lccdf(y, alpha, beta); - double cdf_val = gamma_cdf(y, alpha, beta); - double expected = log(1.0 - cdf_val); - - EXPECT_NEAR(lccdf_val, expected, 1e-10); -} - -TEST(ProbGamma, lccdf_numerically_challenging) { - using stan::math::gamma_lccdf; - - // Test cases that might cause numerical issues - std::vector> challenging_cases = { - {1e-8, 1e-6, 1.0}, // Very small y and alpha - {1e-6, 100.0, 1e-3}, // Very small y, large alpha, small beta - {1000.0, 0.1, 1e-4}, // Large y, small alpha, very small beta - {50.0, 50.0, 1.0}, // Matched moderate values - {0.001, 0.001, 100.0}, // Small y and alpha, large beta - {1e6, 10.0, 1e-6}, // Very large y, moderate alpha, very small beta - }; - - for (const auto& test_case : challenging_cases) { - double y = std::get<0>(test_case); - double alpha = std::get<1>(test_case); - double beta = std::get<2>(test_case); - - double result = gamma_lccdf(y, alpha, beta); - - // Should not be NaN - EXPECT_FALSE(std::isnan(result)) - << "NaN for y=" << y << ", alpha=" << alpha << ", beta=" << beta; - - // Should be <= 0 (log of probability) - EXPECT_LE(result, 0.0) << "Positive value for y=" << y - << ", alpha=" << alpha << ", beta=" << beta; - } -} - -TEST(ProbGamma, lccdf_shape_zero_throws) { - using stan::math::gamma_lccdf; - - // alpha (shape) must be positive - EXPECT_THROW(gamma_lccdf(1.0, 0.0, 1.0), std::domain_error); - EXPECT_THROW(gamma_lccdf(1.0, -1.0, 1.0), std::domain_error); -} - -TEST(ProbGamma, lccdf_rate_zero_throws) { - using stan::math::gamma_lccdf; - - // beta (rate) must be positive - EXPECT_THROW(gamma_lccdf(1.0, 1.0, 0.0), std::domain_error); - EXPECT_THROW(gamma_lccdf(1.0, 1.0, -1.0), std::domain_error); -} - -TEST(ProbGamma, lccdf_negative_y_throws) { - using stan::math::gamma_lccdf; - - // y must be non-negative - EXPECT_THROW(gamma_lccdf(-1.0, 1.0, 1.0), std::domain_error); - EXPECT_THROW(gamma_lccdf(-0.001, 1.0, 1.0), std::domain_error); -} diff --git a/test/unit/math/prim/prob/hmm_util.hpp b/test/unit/math/prim/prob/hmm_util.hpp index fe114281107..9f4f3e011bb 100644 --- a/test/unit/math/prim/prob/hmm_util.hpp +++ b/test/unit/math/prim/prob/hmm_util.hpp @@ -49,7 +49,7 @@ inline stan::return_type_t hmm_marginal_test_wrapper( * 0: normal(mu, sigma) * 1: normal(-mu, sigma) */ -inline double state_lpdf(double y, double abs_mu, double sigma, int state) { +double state_lpdf(double y, double abs_mu, double sigma, int state) { int x = state == 0 ? 1 : -1; double chi = (y - x * abs_mu) / sigma; return -0.5 * chi * chi - 0.5 * std::log(2 * M_PI) - std::log(sigma); diff --git a/test/unit/math/prim/prob/loglogistic_test.cpp b/test/unit/math/prim/prob/loglogistic_test.cpp index 38422afd7ee..94a38ea4cc7 100644 --- a/test/unit/math/prim/prob/loglogistic_test.cpp +++ b/test/unit/math/prim/prob/loglogistic_test.cpp @@ -23,7 +23,7 @@ class LoglogisticTestRig : public VectorRNGTestRig { } }; -inline double icdf(double x, double alpha, double beta) { +double icdf(double x, double alpha, double beta) { return alpha * pow(x / (1 - x), 1 / beta); } diff --git a/test/unit/math/prim/prob/matrix_normal_prec_rng_test.cpp b/test/unit/math/prim/prob/matrix_normal_prec_rng_test.cpp index 18fad92196e..32a550ef72b 100644 --- a/test/unit/math/prim/prob/matrix_normal_prec_rng_test.cpp +++ b/test/unit/math/prim/prob/matrix_normal_prec_rng_test.cpp @@ -131,9 +131,9 @@ TEST(ProbDistributionsMatrixNormalPrecRng, ErrorSize) { * Assert that the samples come from the normal distribution with this * mean and variance. */ -inline void assert_matches_normal_distribution( - const double mean, const double variance, - const std::vector &samples) { +void assert_matches_normal_distribution(const double mean, + const double variance, + const std::vector &samples) { using Eigen::MatrixXd; using stan::math::matrix_normal_prec_rng; int N = samples.size(); @@ -146,9 +146,8 @@ inline void assert_matches_normal_distribution( assert_matches_quantiles(samples, quantiles, 1e-6); } -inline std::vector extract_entry( - const unsigned int r, const unsigned int c, - const std::vector &samples) { +std::vector extract_entry(const unsigned int r, const unsigned int c, + const std::vector &samples) { using Eigen::MatrixXd; using stan::math::matrix_normal_prec_rng; std::vector univariate_samples; @@ -157,7 +156,7 @@ inline std::vector extract_entry( return univariate_samples; } -inline std::vector extract_sum_of_entries( +std::vector extract_sum_of_entries( const unsigned int r1, const unsigned int c1, const unsigned int r2, const unsigned int c2, const std::vector &samples) { using Eigen::MatrixXd; diff --git a/test/unit/math/prim/prob/neg_binomial_test.cpp b/test/unit/math/prim/prob/neg_binomial_test.cpp index 7d1240ccd85..a3696eaa49a 100644 --- a/test/unit/math/prim/prob/neg_binomial_test.cpp +++ b/test/unit/math/prim/prob/neg_binomial_test.cpp @@ -71,8 +71,8 @@ TEST(ProbDistributionsNegBinomial, error_check) { } } -inline void expected_bin_sizes(double* expect, const int K, const int N, - const double alpha, const double beta) { +void expected_bin_sizes(double* expect, const int K, const int N, + const double alpha, const double beta) { long double p = 0; for (int i = 0; i < K; i++) { expect[i] = N * std::exp(stan::math::neg_binomial_lpmf(i, alpha, beta)); diff --git a/test/unit/math/prim/prob/ordered_logistic_test.cpp b/test/unit/math/prim/prob/ordered_logistic_test.cpp index 423d211ea6a..9f71fb8b253 100644 --- a/test/unit/math/prim/prob/ordered_logistic_test.cpp +++ b/test/unit/math/prim/prob/ordered_logistic_test.cpp @@ -5,8 +5,8 @@ #include #include -inline stan::math::vector_d get_simplex_inv_logit( - double lambda, const stan::math::vector_d& c) { +stan::math::vector_d get_simplex_inv_logit(double lambda, + const stan::math::vector_d& c) { using stan::math::inv_logit; int K = c.size() + 1; stan::math::vector_d theta(K); diff --git a/test/unit/math/prim/prob/ordered_probit_test.cpp b/test/unit/math/prim/prob/ordered_probit_test.cpp index c9c5094afcc..44ca2754e89 100644 --- a/test/unit/math/prim/prob/ordered_probit_test.cpp +++ b/test/unit/math/prim/prob/ordered_probit_test.cpp @@ -4,8 +4,8 @@ #include #include -inline stan::math::vector_d get_simplex_Phi(double lambda, - const stan::math::vector_d& c) { +stan::math::vector_d get_simplex_Phi(double lambda, + const stan::math::vector_d& c) { using stan::math::Phi; int K = c.size() + 1; stan::math::vector_d theta(K); diff --git a/test/unit/math/prim/prob/skew_double_exponential_test.cpp b/test/unit/math/prim/prob/skew_double_exponential_test.cpp index 9132a2f188c..3c9b27bc0a1 100644 --- a/test/unit/math/prim/prob/skew_double_exponential_test.cpp +++ b/test/unit/math/prim/prob/skew_double_exponential_test.cpp @@ -22,7 +22,7 @@ class SkewDoubleExponentialTestRig : public VectorRNGTestRig { } }; -inline double icdf(double z, double mu, double sigma, double tau) { +double icdf(double z, double mu, double sigma, double tau) { if (z < tau) { return log(z / tau) * sigma / (2.0 * (1.0 - tau)) + mu; } else { diff --git a/test/unit/math/prim/prob/util.hpp b/test/unit/math/prim/prob/util.hpp index 553d3749fe6..0089e0f584b 100644 --- a/test/unit/math/prim/prob/util.hpp +++ b/test/unit/math/prim/prob/util.hpp @@ -10,9 +10,8 @@ * Uses a chi-squared test to assert that a vector of observed counts * is consistent with a vector of expected counts. Useful for testing RNGs. */ -inline void assert_chi_squared(const std::vector& counts, - const std::vector& expected, - double tolerance) { +void assert_chi_squared(const std::vector& counts, + const std::vector& expected, double tolerance) { int bins = counts.size(); EXPECT_EQ(bins, expected.size()); @@ -34,10 +33,10 @@ inline void assert_chi_squared(const std::vector& counts, * upper bound bin_boundaries[i], using a chi-squared goodness of fit * test. bin_boundaries is assumed sorted in increasing order. **/ -inline void assert_matches_bins(const std::vector& samples, - const std::vector& bin_boundaries, - const std::vector& proportions, - double tolerance) { +void assert_matches_bins(const std::vector& samples, + const std::vector& bin_boundaries, + const std::vector& proportions, + double tolerance) { ASSERT_GT(samples.size(), 0); int N = samples.size(); std::vector mysamples = samples; @@ -72,9 +71,9 @@ inline void assert_matches_bins(const std::vector& samples, * distributed among the quantiles.size() equiprobable bins, who's * upper bounds are given in quantiles in increasing order. */ -inline void assert_matches_quantiles(const std::vector& samples, - const std::vector& quantiles, - double tolerance) { +void assert_matches_quantiles(const std::vector& samples, + const std::vector& quantiles, + double tolerance) { int K = quantiles.size(); std::vector proportions; for (int i = 0; i < K; ++i) diff --git a/test/unit/math/prim/prob/vector_rng_test_helper.hpp b/test/unit/math/prim/prob/vector_rng_test_helper.hpp index 717ae8a7ec0..8c49d65aa9b 100644 --- a/test/unit/math/prim/prob/vector_rng_test_helper.hpp +++ b/test/unit/math/prim/prob/vector_rng_test_helper.hpp @@ -17,7 +17,7 @@ namespace internal { template -inline void shuffle_container(C& x) { +void shuffle_container(C& x) { std::random_device rng; std::mt19937 twister(rng()); std::shuffle(x.begin(), x.end(), twister); @@ -39,8 +39,8 @@ using ArgumentTypes * @param params Values to copy into params */ template -inline void assign_parameter_values(T_param& params, - const std::vector& values) { +void assign_parameter_values(T_param& params, + const std::vector& values) { if (values.size() == 0) return; @@ -58,8 +58,8 @@ inline void assign_parameter_values(T_param& params, * @param params Parameter vector to write values to * @param params Values to copy into params */ -inline void assign_parameter_values(std::vector& params, - const std::vector& values) { +void assign_parameter_values(std::vector& params, + const std::vector& values) { if (values.size() == 0) return; @@ -77,8 +77,8 @@ inline void assign_parameter_values(std::vector& params, * @param params Parameter vector to write values to * @param params Values to copy into params */ -inline void assign_parameter_values(std::vector& params, - const std::vector& values) { +void assign_parameter_values(std::vector& params, + const std::vector& values) { if (values.size() == 0) return; @@ -93,8 +93,7 @@ inline void assign_parameter_values(std::vector& params, * @param param Output parameter to write value to * @param params Vector with value to copy into param */ -inline void assign_parameter_values(double& param, - const std::vector& values) { +void assign_parameter_values(double& param, const std::vector& values) { if (values.size() == 0) return; @@ -107,8 +106,7 @@ inline void assign_parameter_values(double& param, * @param param Output parameter to write value to * @param params Vector with value to copy into param */ -inline void assign_parameter_values(int& param, - const std::vector& values) { +void assign_parameter_values(int& param, const std::vector& values) { if (values.size() == 0) return; @@ -123,7 +121,7 @@ inline void assign_parameter_values(int& param, * @param N New size */ template -inline void resize_if_vector(T& v, int N) { +void resize_if_vector(T& v, int N) { v.resize(N); } @@ -131,13 +129,13 @@ inline void resize_if_vector(T& v, int N) { * For doubles, resize_if_vector does nothing */ template <> -inline void resize_if_vector(double& v, int N) {} +void resize_if_vector(double& v, int N) {} /* * For ints, resize_if_vector does nothing */ template <> -inline void resize_if_vector(int& v, int N) {} +void resize_if_vector(int& v, int N) {} /* * check_dist_throws feeds rig.generate_samples various @@ -297,7 +295,7 @@ struct check_dist_throws { * @param T_rig Test rig for random number generator */ template -inline void check_dist_throws_all_types(const T_rig& rig) { +void check_dist_throws_all_types(const T_rig& rig) { apply_template_permutations( check_dist_throws{}, rig); } @@ -312,7 +310,7 @@ inline void check_dist_throws_all_types(const T_rig& rig) { * @param T_rig Test rig for random number generator */ template -inline void check_dist_throws_int_first_argument(const T_rig& rig) { +void check_dist_throws_int_first_argument(const T_rig& rig) { apply_template_permutations>, ArgumentTypes, ArgumentTypes>(check_dist_throws{}, rig); } @@ -328,7 +326,7 @@ inline void check_dist_throws_int_first_argument(const T_rig& rig) { * @param T_rig Test rig for random number generator */ template -inline void check_dist_throws_real_first_argument(const T_rig& rig) { +void check_dist_throws_real_first_argument(const T_rig& rig) { apply_template_permutations>, ArgumentTypes, ArgumentTypes>(check_dist_throws{}, rig); @@ -342,7 +340,7 @@ inline void check_dist_throws_real_first_argument(const T_rig& rig) { * @return vector of length 1 with value v */ template -inline std::vector promote_to_vector(T v) { +std::vector promote_to_vector(T v) { return std::vector(1, v); } @@ -351,7 +349,7 @@ inline std::vector promote_to_vector(T v) { * just using std::move but cpplint complained about use of unapproved Rvalues. */ template -inline std::vector promote_to_vector(std::vector v) { +std::vector promote_to_vector(std::vector v) { return v; } @@ -432,7 +430,7 @@ struct check_quantiles { * @param T_rig Test rig for random number generator */ template -inline void check_quantiles_no_params(const T_rig& rig) { +void check_quantiles_no_params(const T_rig& rig) { apply_template_permutations, std::tuple, std::tuple>(check_quantiles{}, rig); } @@ -446,7 +444,7 @@ inline void check_quantiles_no_params(const T_rig& rig) { * @param T_rig Test rig for random number generator */ template -inline void check_quantiles_real(const T_rig& rig) { +void check_quantiles_real(const T_rig& rig) { apply_template_permutations, std::tuple>(check_quantiles{}, rig); } @@ -460,7 +458,7 @@ inline void check_quantiles_real(const T_rig& rig) { * @param T_rig Test rig for random number generator */ template -inline void check_quantiles_real_real(const T_rig& rig) { +void check_quantiles_real_real(const T_rig& rig) { apply_template_permutations>( check_quantiles{}, rig); } @@ -476,7 +474,7 @@ inline void check_quantiles_real_real(const T_rig& rig) { * @param T_rig Test rig for random number generator */ template -inline void check_quantiles_real_first_argument(const T_rig& rig) { +void check_quantiles_real_first_argument(const T_rig& rig) { apply_template_permutations>, ArgumentTypes, std::tuple>( check_quantiles{}, rig); @@ -491,7 +489,7 @@ inline void check_quantiles_real_first_argument(const T_rig& rig) { * @param T_rig Test rig for random number generator */ template -inline void check_quantiles_real_real_real(const T_rig& rig) { +void check_quantiles_real_real_real(const T_rig& rig) { apply_template_permutations( check_quantiles{}, rig); } @@ -638,7 +636,7 @@ struct check_counts { * @param T_rig Test rig for random number generator */ template -inline void check_counts_real(const T_rig& rig) { +void check_counts_real(const T_rig& rig) { apply_template_permutations, std::tuple>(check_counts{}, rig); } @@ -652,7 +650,7 @@ inline void check_counts_real(const T_rig& rig) { * @param T_rig Test rig for random number generator */ template -inline void check_counts_real_real(const T_rig& rig) { +void check_counts_real_real(const T_rig& rig) { apply_template_permutations>( check_counts{}, rig); } @@ -666,7 +664,7 @@ inline void check_counts_real_real(const T_rig& rig) { * @param T_rig Test rig for random number generator */ template -inline void check_counts_real_real_real(const T_rig& rig) { +void check_counts_real_real_real(const T_rig& rig) { apply_template_permutations( check_counts{}, rig); } @@ -681,7 +679,7 @@ inline void check_counts_real_real_real(const T_rig& rig) { * @param T_rig Test rig for random number generator */ template -inline void check_counts_int_real(const T_rig& rig) { +void check_counts_int_real(const T_rig& rig) { apply_template_permutations>, ArgumentTypes, std::tuple>(check_counts{}, rig); } @@ -696,7 +694,7 @@ inline void check_counts_int_real(const T_rig& rig) { * @param T_rig Test rig for random number generator */ template -inline void check_counts_int_real_real(const T_rig& rig) { +void check_counts_int_real_real(const T_rig& rig) { apply_template_permutations>, ArgumentTypes, ArgumentTypes>(check_counts{}, rig); } diff --git a/test/unit/math/prim/prob/wiener_full_lccdf_test.cpp b/test/unit/math/prim/prob/wiener_full_lccdf_test.cpp new file mode 100644 index 00000000000..c1fdf33505d --- /dev/null +++ b/test/unit/math/prim/prob/wiener_full_lccdf_test.cpp @@ -0,0 +1,414 @@ +#include +#include +#include +#include + +#include +#include + +TEST(mathPrimScalProbWienerFullLccdfScal, valid) { + using stan::math::INFTY; + using stan::math::wiener_lccdf; + double rt = 1, a = 1, v = -1, w = 0.5, t0 = 0.1, sv = 0.2, sw = 0.2, + st0 = 0.1; + EXPECT_NO_THROW(wiener_lccdf(rt, a, t0, w, v, sv, sw, st0)); + rt = 5; + a = 1; + v = 1; + w = 0.5; + t0 = 0.0; + sv = 0.0; + sw = 0.0; + st0 = 0.0; + EXPECT_NO_THROW(wiener_lccdf(rt, a, t0, w, v, sv, sw, st0)); +} + +// rt +TEST(mathPrimScalProbWienerFullLccdfScal, invalid_rt) { + using stan::math::INFTY; + using stan::math::wiener_lccdf; + double a = 1, v = -1, w = 0.5, t0 = 0.1, sv = 0.2, sw = 0.2, st0 = 0.1; + EXPECT_THROW(wiener_lccdf(0, a, t0, w, v, sv, sw, st0), std::domain_error); + EXPECT_THROW(wiener_lccdf(-1, a, t0, w, v, sv, sw, st0), std::domain_error); + EXPECT_THROW(wiener_lccdf(INFTY, a, t0, w, v, sv, sw, st0), + std::domain_error); + EXPECT_THROW(wiener_lccdf(-INFTY, a, t0, w, v, sv, sw, st0), + std::domain_error); + EXPECT_THROW(wiener_lccdf(NAN, a, t0, w, v, sv, sw, st0), std::domain_error); +} + +// a +TEST(mathPrimScalProbWienerFullLccdfScal, invalid_a) { + using stan::math::INFTY; + using stan::math::wiener_lccdf; + double rt = 1, v = -1, w = 0.5, t0 = 0.1, sv = 0.2, sw = 0.2, st0 = 0.1; + EXPECT_THROW(wiener_lccdf(rt, 0, t0, w, v, sv, sw, st0), std::domain_error); + EXPECT_THROW(wiener_lccdf(rt, -1, t0, w, v, sv, sw, st0), std::domain_error); + EXPECT_THROW(wiener_lccdf(rt, INFTY, t0, w, v, sv, sw, st0), + std::domain_error); + EXPECT_THROW(wiener_lccdf(rt, -INFTY, t0, w, v, sv, sw, st0), + std::domain_error); + EXPECT_THROW(wiener_lccdf(rt, NAN, t0, w, v, sv, sw, st0), std::domain_error); +} + +// v +TEST(mathPrimScalProbWienerFullLccdfScal, invalid_v) { + using stan::math::INFTY; + using stan::math::wiener_lccdf; + double rt = 1, a = 1, v = -1, w = 0.5, t0 = 0.1, sv = 0.2, sw = 0.2, + st0 = 0.1; + EXPECT_THROW(wiener_lccdf(rt, a, t0, w, INFTY, sv, sw, st0), + std::domain_error); + EXPECT_THROW(wiener_lccdf(rt, a, t0, w, -INFTY, sv, sw, st0), + std::domain_error); + EXPECT_THROW(wiener_lccdf(rt, a, t0, w, NAN, sv, sw, st0), std::domain_error); +} + +// w +TEST(mathPrimScalProbWienerFullLccdfScal, invalid_w) { + using stan::math::INFTY; + using stan::math::wiener_lccdf; + double rt = 1, a = 1, v = -1, t0 = 0.1, sv = 0.2, sw = 0.2, st0 = 0.1; + EXPECT_THROW(wiener_lccdf(rt, a, t0, -0.1, v, sv, sw, st0), + std::domain_error); + EXPECT_THROW(wiener_lccdf(rt, a, t0, 0, v, sv, sw, st0), std::domain_error); + EXPECT_THROW(wiener_lccdf(rt, a, t0, 1, v, sv, sw, st0), std::domain_error); + EXPECT_THROW(wiener_lccdf(rt, a, t0, 1.1, v, sv, sw, st0), std::domain_error); + EXPECT_THROW(wiener_lccdf(rt, a, t0, INFTY, v, sv, sw, st0), + std::domain_error); + EXPECT_THROW(wiener_lccdf(rt, a, t0, -INFTY, v, sv, sw, st0), + std::domain_error); + EXPECT_THROW(wiener_lccdf(rt, a, t0, NAN, v, sv, sw, st0), std::domain_error); +} + +// t0 +TEST(mathPrimScalProbWienerFullLccdfScal, invalid_t0) { + using stan::math::INFTY; + using stan::math::wiener_lccdf; + double rt = 1, a = 1, v = -1, w = 0.5, sv = 0.2, sw = 0.2, st0 = 0.1; + EXPECT_THROW(wiener_lccdf(rt, a, 2, w, v, sv, sw, st0), + std::domain_error); // rt must be greater than t0 + EXPECT_THROW(wiener_lccdf(rt, a, -1, w, v, sv, sw, st0), std::domain_error); + EXPECT_THROW(wiener_lccdf(rt, a, INFTY, w, v, sv, sw, st0), + std::domain_error); + EXPECT_THROW(wiener_lccdf(rt, a, -INFTY, w, v, sv, sw, st0), + std::domain_error); + EXPECT_THROW(wiener_lccdf(rt, a, NAN, w, v, sv, sw, st0), std::domain_error); +} + +// sv +TEST(mathPrimScalProbWienerFullLccdfScal, invalid_sv) { + using stan::math::INFTY; + using stan::math::wiener_lccdf; + double rt = 1, a = 1, v = -1, w = 0.5, t0 = 0.1, sw = 0.2, st0 = 0.1; + EXPECT_THROW(wiener_lccdf(rt, a, t0, w, v, -1, sw, st0), std::domain_error); + EXPECT_THROW(wiener_lccdf(rt, a, t0, w, v, INFTY, sw, st0), + std::domain_error); + EXPECT_THROW(wiener_lccdf(rt, a, t0, w, v, -INFTY, sw, st0), + std::domain_error); + EXPECT_THROW(wiener_lccdf(rt, a, t0, w, v, NAN, sw, st0), std::domain_error); +} + +// sw +TEST(mathPrimScalProbWienerFullLccdfScal, invalid_sw) { + using stan::math::INFTY; + using stan::math::wiener_lccdf; + double rt = 1, a = 1, v = -1, w = 0.5, t0 = 0.1, sv = 0.2, st0 = 0.1; + EXPECT_THROW(wiener_lccdf(rt, a, t0, w, v, sv, -1, st0), std::domain_error); + EXPECT_THROW(wiener_lccdf(rt, a, t0, 0.8, v, sv, 0.5, st0), + std::domain_error); // sw must be smaller than 2*(1-w) + EXPECT_THROW(wiener_lccdf(rt, a, t0, 0.3, v, sv, 0.7, st0), + std::domain_error); // sw must be smaller than 2*w + EXPECT_THROW(wiener_lccdf(rt, a, t0, w, v, sv, INFTY, st0), + std::domain_error); + EXPECT_THROW(wiener_lccdf(rt, a, t0, w, v, sv, -INFTY, st0), + std::domain_error); + EXPECT_THROW(wiener_lccdf(rt, a, t0, w, v, sv, NAN, st0), std::domain_error); +} + +// st0 +TEST(mathPrimScalProbWienerFullLccdfScal, invalid_st0) { + using stan::math::INFTY; + using stan::math::wiener_lccdf; + double rt = 1, a = 1, v = -1, w = 0.5, t0 = 0.1, sv = 0.2, sw = 0.2; + EXPECT_THROW(wiener_lccdf(rt, a, t0, w, v, sv, sw, -1), std::domain_error); + EXPECT_THROW(wiener_lccdf(rt, a, t0, w, v, sv, sw, INFTY), std::domain_error); + EXPECT_THROW(wiener_lccdf(rt, a, t0, w, v, sv, sw, -INFTY), + std::domain_error); + EXPECT_THROW(wiener_lccdf(rt, a, t0, w, v, sv, sw, NAN), std::domain_error); +} + +TEST(mathPrimScalProbWienerFullLccdfPrecScal, valid) { + using stan::math::INFTY; + using stan::math::wiener_lccdf; + double rt = 1, a = 1, v = -1, w = 0.5, t0 = 0.1, sv = 0.2, sw = 0.2, + st0 = 0.1; + EXPECT_NO_THROW(wiener_lccdf(rt, a, t0, w, v, sv, sw, st0, 1e-4)); + rt = 5; + a = 1; + v = 1; + w = 0.5; + t0 = 0.0; + sv = 0.0; + sw = 0.0; + st0 = 0.0; + EXPECT_NO_THROW(wiener_lccdf(rt, a, t0, w, v, sv, sw, st0, 1e-4)); +} + +// rt +TEST(mathPrimScalProbWienerFullLccdfPrecScal, invalid_rt) { + using stan::math::INFTY; + using stan::math::wiener_lccdf; + double a = 1, v = -1, w = 0.5, t0 = 0.1, sv = 0.2, sw = 0.2, st0 = 0.1; + EXPECT_THROW(wiener_lccdf(0, a, t0, w, v, sv, sw, st0, 1e-4), + std::domain_error); + EXPECT_THROW(wiener_lccdf(-1, a, t0, w, v, sv, sw, st0, 1e-4), + std::domain_error); + EXPECT_THROW(wiener_lccdf(INFTY, a, t0, w, v, sv, sw, st0, 1e-4), + std::domain_error); + EXPECT_THROW(wiener_lccdf(-INFTY, a, t0, w, v, sv, sw, st0, 1e-4), + std::domain_error); + EXPECT_THROW(wiener_lccdf(NAN, a, t0, w, v, sv, sw, st0, 1e-4), + std::domain_error); +} + +// a +TEST(mathPrimScalProbWienerFullLccdfPrecScal, invalid_a) { + using stan::math::INFTY; + using stan::math::wiener_lccdf; + double rt = 1, v = -1, w = 0.5, t0 = 0.1, sv = 0.2, sw = 0.2, st0 = 0.1; + EXPECT_THROW(wiener_lccdf(rt, 0, t0, w, v, sv, sw, st0, 1e-4), + std::domain_error); + EXPECT_THROW(wiener_lccdf(rt, -1, t0, w, v, sv, sw, st0, 1e-4), + std::domain_error); + EXPECT_THROW(wiener_lccdf(rt, INFTY, t0, w, v, sv, sw, st0, 1e-4), + std::domain_error); + EXPECT_THROW(wiener_lccdf(rt, -INFTY, t0, w, v, sv, sw, st0, 1e-4), + std::domain_error); + EXPECT_THROW(wiener_lccdf(rt, NAN, t0, w, v, sv, sw, st0, 1e-4), + std::domain_error); +} + +// v +TEST(mathPrimScalProbWienerFullLccdfPrecScal, invalid_v) { + using stan::math::INFTY; + using stan::math::wiener_lccdf; + double rt = 1, a = 1, v = -1, w = 0.5, t0 = 0.1, sv = 0.2, sw = 0.2, + st0 = 0.1; + EXPECT_THROW(wiener_lccdf(rt, a, t0, w, INFTY, sv, sw, st0, 1e-4), + std::domain_error); + EXPECT_THROW(wiener_lccdf(rt, a, t0, w, -INFTY, sv, sw, st0, 1e-4), + std::domain_error); + EXPECT_THROW(wiener_lccdf(rt, a, t0, w, NAN, sv, sw, st0, 1e-4), + std::domain_error); +} + +// w +TEST(mathPrimScalProbWienerFullLccdfPrecScal, invalid_w) { + using stan::math::INFTY; + using stan::math::wiener_lccdf; + double rt = 1, a = 1, v = -1, t0 = 0.1, sv = 0.2, sw = 0.2, st0 = 0.1; + EXPECT_THROW(wiener_lccdf(rt, a, t0, -0.1, v, sv, sw, st0, 1e-4), + std::domain_error); + EXPECT_THROW(wiener_lccdf(rt, a, t0, 0, v, sv, sw, st0, 1e-4), + std::domain_error); + EXPECT_THROW(wiener_lccdf(rt, a, t0, 1, v, sv, sw, st0, 1e-4), + std::domain_error); + EXPECT_THROW(wiener_lccdf(rt, a, t0, 1.1, v, sv, sw, st0, 1e-4), + std::domain_error); + EXPECT_THROW(wiener_lccdf(rt, a, t0, INFTY, v, sv, sw, st0, 1e-4), + std::domain_error); + EXPECT_THROW(wiener_lccdf(rt, a, t0, -INFTY, v, sv, sw, st0, 1e-4), + std::domain_error); + EXPECT_THROW(wiener_lccdf(rt, a, t0, NAN, v, sv, sw, st0, 1e-4), + std::domain_error); +} + +// t0 +TEST(mathPrimScalProbWienerFullLccdfPrecScal, invalid_t0) { + using stan::math::INFTY; + using stan::math::wiener_lccdf; + double rt = 1, a = 1, v = -1, w = 0.5, sv = 0.2, sw = 0.2, st0 = 0.1; + EXPECT_THROW(wiener_lccdf(rt, a, 2, w, v, sv, sw, st0, 1e-4), + std::domain_error); // rt must be greater than t0 + EXPECT_THROW(wiener_lccdf(rt, a, -1, w, v, sv, sw, st0, 1e-4), + std::domain_error); + EXPECT_THROW(wiener_lccdf(rt, a, INFTY, w, v, sv, sw, st0, 1e-4), + std::domain_error); + EXPECT_THROW(wiener_lccdf(rt, a, -INFTY, w, v, sv, sw, st0, 1e-4), + std::domain_error); + EXPECT_THROW(wiener_lccdf(rt, a, NAN, w, v, sv, sw, st0, 1e-4), + std::domain_error); +} + +// sv +TEST(mathPrimScalProbWienerFullLccdfPrecScal, invalid_sv) { + using stan::math::INFTY; + using stan::math::wiener_lccdf; + double rt = 1, a = 1, v = -1, w = 0.5, t0 = 0.1, sw = 0.2, st0 = 0.1; + EXPECT_THROW(wiener_lccdf(rt, a, t0, w, v, -1, sw, st0, 1e-4), + std::domain_error); + EXPECT_THROW(wiener_lccdf(rt, a, t0, w, v, INFTY, sw, st0, 1e-4), + std::domain_error); + EXPECT_THROW(wiener_lccdf(rt, a, t0, w, v, -INFTY, sw, st0, 1e-4), + std::domain_error); + EXPECT_THROW(wiener_lccdf(rt, a, t0, w, v, NAN, sw, st0, 1e-4), + std::domain_error); +} + +// sw +TEST(mathPrimScalProbWienerFullLccdfPrecScal, invalid_sw) { + using stan::math::INFTY; + using stan::math::wiener_lccdf; + double rt = 1, a = 1, v = -1, w = 0.5, t0 = 0.1, sv = 0.2, st0 = 0.1; + EXPECT_THROW(wiener_lccdf(rt, a, t0, w, v, sv, -1, st0, 1e-4), + std::domain_error); + EXPECT_THROW(wiener_lccdf(rt, a, t0, 0.8, v, sv, 0.5, st0, 1e-4), + std::domain_error); // sw must be smaller than 2*(1-w) + EXPECT_THROW(wiener_lccdf(rt, a, t0, 0.3, v, sv, 0.7, st0, 1e-4), + std::domain_error); // sw must be smaller than 2*w + EXPECT_THROW(wiener_lccdf(rt, a, t0, w, v, sv, INFTY, st0, 1e-4), + std::domain_error); + EXPECT_THROW(wiener_lccdf(rt, a, t0, w, v, sv, -INFTY, st0, 1e-4), + std::domain_error); + EXPECT_THROW(wiener_lccdf(rt, a, t0, w, v, sv, NAN, st0, 1e-4), + std::domain_error); +} + +// st0 +TEST(mathPrimScalProbWienerFullLccdfPrecScal, invalid_st0) { + using stan::math::INFTY; + using stan::math::wiener_lccdf; + double rt = 1, a = 1, v = -1, w = 0.5, t0 = 0.1, sv = 0.2, sw = 0.2; + EXPECT_THROW(wiener_lccdf(rt, a, t0, w, v, sv, sw, -1, 1e-4), + std::domain_error); + EXPECT_THROW(wiener_lccdf(rt, a, t0, w, v, sv, sw, INFTY, 1e-4), + std::domain_error); + EXPECT_THROW(wiener_lccdf(rt, a, t0, w, v, sv, sw, -INFTY, 1e-4), + std::domain_error); + EXPECT_THROW(wiener_lccdf(rt, a, t0, w, v, sv, sw, NAN, 1e-4), + std::domain_error); +} + +TEST(mathPrimCorrectValues, wiener_lccdf) { + /* Test concrete values. True values are computed in R using the R-package + * WienR and the function WienerCDF() with its partial derivatives: + * ccdf = cdf(big_value) - cdf + * lccdf = log(cdf(big_value) - cdf) + * lccdf' = ccdf'/ccdf = (cdf(big_value)'-cdf')/ccdf + */ + std::vector y_vec + = {.2, .3, 2.2, .1, 2, 1.7, 3, 2.5, 3.7, 1.8, .9, 1.5, 2}; + std::vector a_vec + = {3, 1.7, 2.4, 2, 1.2, 1.5, 4, 1.5, 1.7, 6, 1, 2.5, 2}; + std::vector t0_vec + = {0, 0, 0, 0, 0.2, 0.3, 0.1, 0.7, 1, 0.6, .1, .2, .2}; + std::vector w_vec + = {.7, .92, .9, .4, 0.5, 0.3, 0.45, 0.6, 0.8, 0.35, .4, .5, .6}; + std::vector v_vec + = {-1, -7.3, -4.9, 2.5, 1, 0.5, -0.7, 0.9, -1.4, 2, .8, -1, -.9}; + std::vector sv_vec = {0, 0, 0, 0, 0.5, 0, 0, 0.7, 0.8, 0, .4, .5, .2}; + std::vector sw_vec = {0, 0, 0, 0, 0, 0.1, 0, 0.2, 0, 0.3, .2, 0, .2}; + std::vector st0_vec + = {0, 0, 0, 0, 0, 0, 0.1, 0, 0.1, 0.1, .2, .3, .25}; + + std::vector true_lccdf + = {-1.92033254902358, -13.5626831740558, -33.8122958054115, + -0.0207304574971297, -7.08470781580343, -3.44486241813253, + -4.18311596420185, -4.95366166391584, -7.23109216780916, + -0.125273337362733, -3.79815495569855, -2.96111699037856, + -4.14929265642466}; + std::vector true_grad_y + = {-1.33001519743633, -31.1083518155787, -12.9346392526053, + -0.169566706752058, -3.7986585460178, -2.31784674820993, + -0.536530793068282, -2.48164917576694, -1.89222689054599, + -0.484444809563098, -5.31460285637481, -0.975151391419348, + -1.57127046017878}; + std::vector true_grad_a + = {-0.432928212420575, -0.0286062052702194, 0.308724832214765, + 0.05132866977503, 10.5080654585197, 4.37077488076664, + -0.193420148034756, 5.36345669388884, 5.14057131554871, + 0.11692460737807, 7.07166462218294, 0.365404340761721, + 1.53902298927608}; + std::vector true_grad_t0 = { + 1.33001519743633, 31.1083518155787, 12.9346392526053, 0.169566706752058, + 3.7986585460178, 2.31784674820993, 0.536530793068282, 2.48164917576694, + 1.89222689054599, 0.484444809563098, 5.31460285637481, 0.975151391419348, + 1.57127046017878}; + std::vector true_grad_w + = {4.61303457108487, 0.611152450869066, 1.93288590604027, + 0.139815038667115, -0.911757809733564, 1.54221437873658, + 3.63420918438666, -1.85952752467816, -3.65499582974638, + -1.12442042700282, 0.262989430764412, 1.3830938669116, + 0.518345884055846}; + std::vector true_grad_v + = {1.83079071623625, 2.56351255240926, 11.4026845637584, + 0.0274975992798594, -0.960807197217193, 0.132382852324283, + 5.47350811619098, -0.652456751242452, 1.57258003231325, + -0.207055671666776, -0.0823432112415456, 2.18370562291933, + 2.62134233757004}; + std::vector true_grad_sv = {0, + 0, + 0, + 0, + -0.209370036446517, + 0, + 0, + -0.430772737121245, + 1.14730002231356, + 0, + -0.293744554675593, + 1.73837609123659, + 0.997525744657476}; + std::vector true_grad_sw = {0, + 0, + 0, + 0, + 0, + -0.106375521997502, + 0, + -0.114806591325169, + 0, + -0.201319331904563, + -0.180444908443688, + 0, + -0.17718676934793}; + std::vector true_grad_st0 = {0, + 0, + 0, + 0, + 0, + 0, + 0.270517553006863, + 0, + 0.976409725660212, + 0.235042776747307, + 3.12081986216078, + 0.512275314141889, + 0.837649445725816}; + + using stan::math::var; + double err_tol_dens = 1e-6; + double err_tol = 1e-4; + for (int i = 0; i < y_vec.size(); i++) { + var y = y_vec[i]; + var a = a_vec[i]; + var t0 = t0_vec[i]; + var w = w_vec[i]; + var v = v_vec[i]; + var sv = sv_vec[i]; + var sw = sw_vec[i]; + var st0 = st0_vec[i]; + var lccdf = stan::math::wiener_lccdf(y, a, t0, w, v, sv, sw, st0); + lccdf.grad(); + EXPECT_NEAR(lccdf.val(), true_lccdf[i], err_tol_dens); + EXPECT_NEAR(y.adj(), true_grad_y[i], err_tol); + EXPECT_NEAR(a.adj(), true_grad_a[i], err_tol); + EXPECT_NEAR(t0.adj(), true_grad_t0[i], err_tol); + EXPECT_NEAR(w.adj(), true_grad_w[i], err_tol); + EXPECT_NEAR(v.adj(), true_grad_v[i], err_tol); + EXPECT_NEAR(sv.adj(), true_grad_sv[i], err_tol); + EXPECT_NEAR(sw.adj(), true_grad_sw[i], err_tol); + EXPECT_NEAR(st0.adj(), true_grad_st0[i], err_tol); + } +} diff --git a/test/unit/math/prim/prob/wiener_full_lcdf_test.cpp b/test/unit/math/prim/prob/wiener_full_lcdf_test.cpp new file mode 100644 index 00000000000..bf18ff38150 --- /dev/null +++ b/test/unit/math/prim/prob/wiener_full_lcdf_test.cpp @@ -0,0 +1,405 @@ +#include +#include +#include +#include + +#include +#include + +TEST(mathPrimScalProbWienerFullLcdfScal, valid) { + using stan::math::INFTY; + using stan::math::wiener_lcdf; + double rt = 1, a = 1, v = -1, w = 0.5, t0 = 0.1, sv = 0.2, sw = 0.2, + st0 = 0.1; + EXPECT_NO_THROW(wiener_lcdf(rt, a, t0, w, v, sv, sw, st0)); + rt = 5; + a = 1; + v = 1; + w = 0.5; + t0 = 0.0; + sv = 0.0; + sw = 0.0; + st0 = 0.0; + EXPECT_NO_THROW(wiener_lcdf(rt, a, t0, w, v, sv, sw, st0)); +} + +// rt +TEST(mathPrimScalProbWienerFullLcdfScal, invalid_rt) { + using stan::math::INFTY; + using stan::math::wiener_lcdf; + double a = 1, v = -1, w = 0.5, t0 = 0.1, sv = 0.2, sw = 0.2, st0 = 0.1; + EXPECT_THROW(wiener_lcdf(0, a, t0, w, v, sv, sw, st0), std::domain_error); + EXPECT_THROW(wiener_lcdf(-1, a, t0, w, v, sv, sw, st0), std::domain_error); + EXPECT_THROW(wiener_lcdf(INFTY, a, t0, w, v, sv, sw, st0), std::domain_error); + EXPECT_THROW(wiener_lcdf(-INFTY, a, t0, w, v, sv, sw, st0), + std::domain_error); + EXPECT_THROW(wiener_lcdf(NAN, a, t0, w, v, sv, sw, st0), std::domain_error); +} + +// a +TEST(mathPrimScalProbWienerFullLcdfScal, invalid_a) { + using stan::math::INFTY; + using stan::math::wiener_lcdf; + double rt = 1, v = -1, w = 0.5, t0 = 0.1, sv = 0.2, sw = 0.2, st0 = 0.1; + EXPECT_THROW(wiener_lcdf(rt, 0, t0, w, v, sv, sw, st0), std::domain_error); + EXPECT_THROW(wiener_lcdf(rt, -1, t0, w, v, sv, sw, st0), std::domain_error); + EXPECT_THROW(wiener_lcdf(rt, INFTY, t0, w, v, sv, sw, st0), + std::domain_error); + EXPECT_THROW(wiener_lcdf(rt, -INFTY, t0, w, v, sv, sw, st0), + std::domain_error); + EXPECT_THROW(wiener_lcdf(rt, NAN, t0, w, v, sv, sw, st0), std::domain_error); +} + +// v +TEST(mathPrimScalProbWienerFullLcdfScal, invalid_v) { + using stan::math::INFTY; + using stan::math::wiener_lcdf; + double rt = 1, a = 1, v = -1, w = 0.5, t0 = 0.1, sv = 0.2, sw = 0.2, + st0 = 0.1; + EXPECT_THROW(wiener_lcdf(rt, a, t0, w, INFTY, sv, sw, st0), + std::domain_error); + EXPECT_THROW(wiener_lcdf(rt, a, t0, w, -INFTY, sv, sw, st0), + std::domain_error); + EXPECT_THROW(wiener_lcdf(rt, a, t0, w, NAN, sv, sw, st0), std::domain_error); +} + +// w +TEST(mathPrimScalProbWienerFullLcdfScal, invalid_w) { + using stan::math::INFTY; + using stan::math::wiener_lcdf; + double rt = 1, a = 1, v = -1, t0 = 0.1, sv = 0.2, sw = 0.2, st0 = 0.1; + EXPECT_THROW(wiener_lcdf(rt, a, t0, -0.1, v, sv, sw, st0), std::domain_error); + EXPECT_THROW(wiener_lcdf(rt, a, t0, 0, v, sv, sw, st0), std::domain_error); + EXPECT_THROW(wiener_lcdf(rt, a, t0, 1, v, sv, sw, st0), std::domain_error); + EXPECT_THROW(wiener_lcdf(rt, a, t0, 1.1, v, sv, sw, st0), std::domain_error); + EXPECT_THROW(wiener_lcdf(rt, a, t0, INFTY, v, sv, sw, st0), + std::domain_error); + EXPECT_THROW(wiener_lcdf(rt, a, t0, -INFTY, v, sv, sw, st0), + std::domain_error); + EXPECT_THROW(wiener_lcdf(rt, a, t0, NAN, v, sv, sw, st0), std::domain_error); +} + +// t0 +TEST(mathPrimScalProbWienerFullLcdfScal, invalid_t0) { + using stan::math::INFTY; + using stan::math::wiener_lcdf; + double rt = 1, a = 1, v = -1, w = 0.5, sv = 0.2, sw = 0.2, st0 = 0.1; + EXPECT_THROW(wiener_lcdf(rt, a, 2, w, v, sv, sw, st0), + std::domain_error); // rt must be greater than t0 + EXPECT_THROW(wiener_lcdf(rt, a, -1, w, v, sv, sw, st0), std::domain_error); + EXPECT_THROW(wiener_lcdf(rt, a, INFTY, w, v, sv, sw, st0), std::domain_error); + EXPECT_THROW(wiener_lcdf(rt, a, -INFTY, w, v, sv, sw, st0), + std::domain_error); + EXPECT_THROW(wiener_lcdf(rt, a, NAN, w, v, sv, sw, st0), std::domain_error); +} + +// sv +TEST(mathPrimScalProbWienerFullLcdfScal, invalid_sv) { + using stan::math::INFTY; + using stan::math::wiener_lcdf; + double rt = 1, a = 1, v = -1, w = 0.5, t0 = 0.1, sw = 0.2, st0 = 0.1; + EXPECT_THROW(wiener_lcdf(rt, a, t0, w, v, -1, sw, st0), std::domain_error); + EXPECT_THROW(wiener_lcdf(rt, a, t0, w, v, INFTY, sw, st0), std::domain_error); + EXPECT_THROW(wiener_lcdf(rt, a, t0, w, v, -INFTY, sw, st0), + std::domain_error); + EXPECT_THROW(wiener_lcdf(rt, a, t0, w, v, NAN, sw, st0), std::domain_error); +} + +// sw +TEST(mathPrimScalProbWienerFullLcdfScal, invalid_sw) { + using stan::math::INFTY; + using stan::math::wiener_lcdf; + double rt = 1, a = 1, v = -1, w = 0.5, t0 = 0.1, sv = 0.2, st0 = 0.1; + EXPECT_THROW(wiener_lcdf(rt, a, t0, w, v, sv, -1, st0), std::domain_error); + EXPECT_THROW(wiener_lcdf(rt, a, t0, 0.8, v, sv, 0.5, st0), + std::domain_error); // sw must be smaller than 2*(1-w) + EXPECT_THROW(wiener_lcdf(rt, a, t0, 0.3, v, sv, 0.7, st0), + std::domain_error); // sw must be smaller than 2*w + EXPECT_THROW(wiener_lcdf(rt, a, t0, w, v, sv, INFTY, st0), std::domain_error); + EXPECT_THROW(wiener_lcdf(rt, a, t0, w, v, sv, -INFTY, st0), + std::domain_error); + EXPECT_THROW(wiener_lcdf(rt, a, t0, w, v, sv, NAN, st0), std::domain_error); +} + +// st0 +TEST(mathPrimScalProbWienerFullLcdfScal, invalid_st0) { + using stan::math::INFTY; + using stan::math::wiener_lcdf; + double rt = 1, a = 1, v = -1, w = 0.5, t0 = 0.1, sv = 0.2, sw = 0.2; + EXPECT_THROW(wiener_lcdf(rt, a, t0, w, v, sv, sw, -1), std::domain_error); + EXPECT_THROW(wiener_lcdf(rt, a, t0, w, v, sv, sw, INFTY), std::domain_error); + EXPECT_THROW(wiener_lcdf(rt, a, t0, w, v, sv, sw, -INFTY), std::domain_error); + EXPECT_THROW(wiener_lcdf(rt, a, t0, w, v, sv, sw, NAN), std::domain_error); +} + +TEST(mathPrimScalProbWienerFullLcdfPrecScal, valid) { + using stan::math::INFTY; + using stan::math::wiener_lcdf; + double rt = 1, a = 1, v = -1, w = 0.5, t0 = 0.1, sv = 0.2, sw = 0.2, + st0 = 0.1; + EXPECT_NO_THROW(wiener_lcdf(rt, a, t0, w, v, sv, sw, st0, 1e-4)); + rt = 5; + a = 1; + v = 1; + w = 0.5; + t0 = 0.0; + sv = 0.0; + sw = 0.0; + st0 = 0.0; + EXPECT_NO_THROW(wiener_lcdf(rt, a, t0, w, v, sv, sw, st0, 1e-4)); +} + +// rt +TEST(mathPrimScalProbWienerFullLcdfPrecScal, invalid_rt) { + using stan::math::INFTY; + using stan::math::wiener_lcdf; + double a = 1, v = -1, w = 0.5, t0 = 0.1, sv = 0.2, sw = 0.2, st0 = 0.1; + EXPECT_THROW(wiener_lcdf(0, a, t0, w, v, sv, sw, st0, 1e-4), + std::domain_error); + EXPECT_THROW(wiener_lcdf(-1, a, t0, w, v, sv, sw, st0, 1e-4), + std::domain_error); + EXPECT_THROW(wiener_lcdf(INFTY, a, t0, w, v, sv, sw, st0, 1e-4), + std::domain_error); + EXPECT_THROW(wiener_lcdf(-INFTY, a, t0, w, v, sv, sw, st0, 1e-4), + std::domain_error); + EXPECT_THROW(wiener_lcdf(NAN, a, t0, w, v, sv, sw, st0, 1e-4), + std::domain_error); +} + +// a +TEST(mathPrimScalProbWienerFullLcdfPrecScal, invalid_a) { + using stan::math::INFTY; + using stan::math::wiener_lcdf; + double rt = 1, v = -1, w = 0.5, t0 = 0.1, sv = 0.2, sw = 0.2, st0 = 0.1; + EXPECT_THROW(wiener_lcdf(rt, 0, t0, w, v, sv, sw, st0, 1e-4), + std::domain_error); + EXPECT_THROW(wiener_lcdf(rt, -1, t0, w, v, sv, sw, st0, 1e-4), + std::domain_error); + EXPECT_THROW(wiener_lcdf(rt, INFTY, t0, w, v, sv, sw, st0, 1e-4), + std::domain_error); + EXPECT_THROW(wiener_lcdf(rt, -INFTY, t0, w, v, sv, sw, st0, 1e-4), + std::domain_error); + EXPECT_THROW(wiener_lcdf(rt, NAN, t0, w, v, sv, sw, st0, 1e-4), + std::domain_error); +} + +// v +TEST(mathPrimScalProbWienerFullLcdfPrecScal, invalid_v) { + using stan::math::INFTY; + using stan::math::wiener_lcdf; + double rt = 1, a = 1, v = -1, w = 0.5, t0 = 0.1, sv = 0.2, sw = 0.2, + st0 = 0.1; + EXPECT_THROW(wiener_lcdf(rt, a, t0, w, INFTY, sv, sw, st0, 1e-4), + std::domain_error); + EXPECT_THROW(wiener_lcdf(rt, a, t0, w, -INFTY, sv, sw, st0, 1e-4), + std::domain_error); + EXPECT_THROW(wiener_lcdf(rt, a, t0, w, NAN, sv, sw, st0, 1e-4), + std::domain_error); +} + +// w +TEST(mathPrimScalProbWienerFullLcdfPrecScal, invalid_w) { + using stan::math::INFTY; + using stan::math::wiener_lcdf; + double rt = 1, a = 1, v = -1, t0 = 0.1, sv = 0.2, sw = 0.2, st0 = 0.1; + EXPECT_THROW(wiener_lcdf(rt, a, t0, -0.1, v, sv, sw, st0, 1e-4), + std::domain_error); + EXPECT_THROW(wiener_lcdf(rt, a, t0, 0, v, sv, sw, st0, 1e-4), + std::domain_error); + EXPECT_THROW(wiener_lcdf(rt, a, t0, 1, v, sv, sw, st0, 1e-4), + std::domain_error); + EXPECT_THROW(wiener_lcdf(rt, a, t0, 1.1, v, sv, sw, st0, 1e-4), + std::domain_error); + EXPECT_THROW(wiener_lcdf(rt, a, t0, INFTY, v, sv, sw, st0, 1e-4), + std::domain_error); + EXPECT_THROW(wiener_lcdf(rt, a, t0, -INFTY, v, sv, sw, st0, 1e-4), + std::domain_error); + EXPECT_THROW(wiener_lcdf(rt, a, t0, NAN, v, sv, sw, st0, 1e-4), + std::domain_error); +} + +// t0 +TEST(mathPrimScalProbWienerFullLcdfPrecScal, invalid_t0) { + using stan::math::INFTY; + using stan::math::wiener_lcdf; + double rt = 1, a = 1, v = -1, w = 0.5, sv = 0.2, sw = 0.2, st0 = 0.1; + EXPECT_THROW(wiener_lcdf(rt, a, 2, w, v, sv, sw, st0, 1e-4), + std::domain_error); // rt must be greater than t0 + EXPECT_THROW(wiener_lcdf(rt, a, -1, w, v, sv, sw, st0, 1e-4), + std::domain_error); + EXPECT_THROW(wiener_lcdf(rt, a, INFTY, w, v, sv, sw, st0, 1e-4), + std::domain_error); + EXPECT_THROW(wiener_lcdf(rt, a, -INFTY, w, v, sv, sw, st0, 1e-4), + std::domain_error); + EXPECT_THROW(wiener_lcdf(rt, a, NAN, w, v, sv, sw, st0, 1e-4), + std::domain_error); +} + +// sv +TEST(mathPrimScalProbWienerFullLcdfPrecScal, invalid_sv) { + using stan::math::INFTY; + using stan::math::wiener_lcdf; + double rt = 1, a = 1, v = -1, w = 0.5, t0 = 0.1, sw = 0.2, st0 = 0.1; + EXPECT_THROW(wiener_lcdf(rt, a, t0, w, v, -1, sw, st0, 1e-4), + std::domain_error); + EXPECT_THROW(wiener_lcdf(rt, a, t0, w, v, INFTY, sw, st0, 1e-4), + std::domain_error); + EXPECT_THROW(wiener_lcdf(rt, a, t0, w, v, -INFTY, sw, st0, 1e-4), + std::domain_error); + EXPECT_THROW(wiener_lcdf(rt, a, t0, w, v, NAN, sw, st0, 1e-4), + std::domain_error); +} + +// sw +TEST(mathPrimScalProbWienerFullLcdfPrecScal, invalid_sw) { + using stan::math::INFTY; + using stan::math::wiener_lcdf; + double rt = 1, a = 1, v = -1, w = 0.5, t0 = 0.1, sv = 0.2, st0 = 0.1; + EXPECT_THROW(wiener_lcdf(rt, a, t0, w, v, sv, -1, st0, 1e-4), + std::domain_error); + EXPECT_THROW(wiener_lcdf(rt, a, t0, 0.8, v, sv, 0.5, st0, 1e-4), + std::domain_error); // sw must be smaller than 2*(1-w) + EXPECT_THROW(wiener_lcdf(rt, a, t0, 0.3, v, sv, 0.7, st0, 1e-4), + std::domain_error); // sw must be smaller than 2*w + EXPECT_THROW(wiener_lcdf(rt, a, t0, w, v, sv, INFTY, st0, 1e-4), + std::domain_error); + EXPECT_THROW(wiener_lcdf(rt, a, t0, w, v, sv, -INFTY, st0, 1e-4), + std::domain_error); + EXPECT_THROW(wiener_lcdf(rt, a, t0, w, v, sv, NAN, st0, 1e-4), + std::domain_error); +} + +// st0 +TEST(mathPrimScalProbWienerFullLcdfPrecScal, invalid_st0) { + using stan::math::INFTY; + using stan::math::wiener_lcdf; + double rt = 1, a = 1, v = -1, w = 0.5, t0 = 0.1, sv = 0.2, sw = 0.2; + EXPECT_THROW(wiener_lcdf(rt, a, t0, w, v, sv, sw, -1, 1e-4), + std::domain_error); + EXPECT_THROW(wiener_lcdf(rt, a, t0, w, v, sv, sw, INFTY, 1e-4), + std::domain_error); + EXPECT_THROW(wiener_lcdf(rt, a, t0, w, v, sv, sw, -INFTY, 1e-4), + std::domain_error); + EXPECT_THROW(wiener_lcdf(rt, a, t0, w, v, sv, sw, NAN, 1e-4), + std::domain_error); +} + +TEST(mathPrimCorrectValues, wiener_lcdf) { + /* Test concrete values. True values are computed in R using the R-package + * WienR and the function WienerCDF() with its partial derivatives + */ + std::vector y_vec + = {.2, .3, 2.2, .1, 2, 1.7, 3, 2.5, 3.7, 1.8, .9, 1.5, 2}; + std::vector a_vec + = {3, 1.7, 2.4, 2, 1.2, 1.5, 4, 1.5, 1.7, 6, 1, 2.5, 2}; + std::vector t0_vec + = {0, 0, 0, 0, 0.2, 0.3, 0.1, 0.7, 1, 0.6, .1, .2, .2}; + std::vector w_vec + = {.7, .92, .9, .4, 0.5, 0.3, 0.45, 0.6, 0.8, 0.35, .4, .5, .6}; + std::vector v_vec + = {-1, -7.3, -4.9, 2.5, 1, 0.5, -0.7, 0.9, -1.4, 2, .8, -1, -.9}; + std::vector sv_vec = {0, 0, 0, 0, 0.5, 0, 0, 0.7, 0.8, 0, .4, .5, .2}; + std::vector sw_vec = {0, 0, 0, 0, 0, 0.1, 0, 0.2, 0, 0.3, .2, 0, .2}; + std::vector st0_vec + = {0, 0, 0, 0, 0, 0, 0.1, 0, 0.1, 0.1, .2, .3, .25}; + + std::vector true_lcdf + = {-4.09435375436108, -1.98560937871925, -2.35200000058001, + -6.09860875887167, -0.28490338793642, -0.835235451149805, + -3.60573984770431, -0.213132053911535, -0.887413009805869, + -2.14898785081967, -0.574404607969948, -2.67530409425456, + -1.55387294861195}; + std::vector true_grad_y + = {11.6955868009794, 0.000291754616022926, 2.81009792107004e-13, + 73.9485382296513, 0.00423167900126897, 0.170505395422671, + 0.301191971384078, 0.0216747718871863, 0.00332619998061515, + 3.66549265245825, 0.211550389634303, 0.732731869409894, + 0.117239643328064}; + std::vector true_grad_a + = {-1.90909592842206, -1.1680106846017, -0.979999994944343, + -6.17343628534049, 0.189129525101159, -0.0640548615428843, + -1.01571721473935, 0.0439926894045548, -0.405445995424302, + -0.875235676490553, 0.0169546689079121, -1.10780211022062, + -0.724594716693696}; + std::vector true_grad_t0 + = {-11.6955868009794, -0.000291754616022926, -2.81009792107004e-13, + -73.9485382296513, -0.00423167900126897, -0.170505395422671, + -0.301191971384078, -0.0216747718871863, -0.00332619998061515, + -3.66549265245825, -0.211550389634303, -0.732731869409894, + -0.117239643328064}; + std::vector true_grad_w = { + 19.0909592842206, 24.8202270495257, 23.5200000150767, 20.578120951136, + 1.03356005252668, 2.72745006368943, 7.46860413650941, 0.749294067331125, + 3.99584607466979, 8.74288037387998, 1.83454127550223, 5.60378493291068, + 4.16252427817267}; + std::vector true_grad_v + = {1.04905306487445, 0.27197850836347, 0.479999997523509, + 0.977134030099708, 0.27971915432389, 0.762665629738307, + 3.35189640059343, 0.25195637817767, 0.558439280243674, + 1.59504189896887, 0.392934480883027, 1.62283843578951, + 1.22498956343152}; + std::vector true_grad_sv = {0, + 0, + 0, + 0, + -0.075059359595863, + 0, + 0, + -0.118203610656295, + 0.137718761146619, + 0, + -0.0215064672196581, + 1.05496167316742, + 0.220567350697758}; + std::vector true_grad_sw = {0, + 0, + 0, + 0, + 0, + -0.0276727265109265, + 0, + -0.0201028131785313, + 0, + 1.43818889437335, + -0.0415094057459971, + 0, + 0.25713151312856}; + std::vector true_grad_st0 = {0, + 0, + 0, + 0, + 0, + 0, + -0.151860277428223, + 0, + -0.00171635548928614, + -1.7784225450937, + -0.12422577484349, + -0.384925306866848, + -0.0625008391233113}; + + using stan::math::var; + double err_tol_dens = 1e-6; + double err_tol = 1e-4; + for (int i = 0; i < y_vec.size(); i++) { + var y = y_vec[i]; + var a = a_vec[i]; + var t0 = t0_vec[i]; + var w = w_vec[i]; + var v = v_vec[i]; + var sv = sv_vec[i]; + var sw = sw_vec[i]; + var st0 = st0_vec[i]; + var lcdf = stan::math::wiener_lcdf(y, a, t0, w, v, sv, sw, st0); + lcdf.grad(); + EXPECT_NEAR(lcdf.val(), true_lcdf[i], err_tol_dens); + EXPECT_NEAR(y.adj(), true_grad_y[i], err_tol); + EXPECT_NEAR(a.adj(), true_grad_a[i], err_tol); + EXPECT_NEAR(t0.adj(), true_grad_t0[i], err_tol); + EXPECT_NEAR(w.adj(), true_grad_w[i], err_tol); + EXPECT_NEAR(v.adj(), true_grad_v[i], err_tol); + EXPECT_NEAR(sv.adj(), true_grad_sv[i], err_tol); + EXPECT_NEAR(sw.adj(), true_grad_sw[i], err_tol); + EXPECT_NEAR(st0.adj(), true_grad_st0[i], err_tol); + } +} diff --git a/test/unit/math/prim/util.hpp b/test/unit/math/prim/util.hpp index 735fc50f3b7..a7ec6321093 100644 --- a/test/unit/math/prim/util.hpp +++ b/test/unit/math/prim/util.hpp @@ -85,7 +85,7 @@ namespace unit { * * @param[in] a Matrix to test. */ -inline void expect_symmetric(const Eigen::MatrixXd& a) { +void expect_symmetric(const Eigen::MatrixXd& a) { for (int j = 1; j < a.cols(); ++j) for (int i = 0; i < j; ++i) EXPECT_EQ(a(i, j), a(j, i)) << "failed symmetry at " << i << ", " << j; diff --git a/test/unit/math/rev/core/accumulate_adjoints_test.cpp b/test/unit/math/rev/core/accumulate_adjoints_test.cpp index e8017993f73..ba9252809d7 100644 --- a/test/unit/math/rev/core/accumulate_adjoints_test.cpp +++ b/test/unit/math/rev/core/accumulate_adjoints_test.cpp @@ -1,10 +1,9 @@ #include #include #include -#include #include -TEST_F(AgradRev, Rev_accumulate_adjoints_zero_args) { +TEST(AgradRev_accumulate_adjoints, zero_args) { Eigen::VectorXd storage = Eigen::VectorXd::Zero(1000); double* ptr = stan::math::accumulate_adjoints(storage.data()); @@ -15,7 +14,7 @@ TEST_F(AgradRev, Rev_accumulate_adjoints_zero_args) { EXPECT_EQ(ptr, storage.data()); } -TEST_F(AgradRev, Rev_accumulate_adjoints_int_arg) { +TEST(AgradRev_accumulate_adjoints, int_arg) { int arg = 5; Eigen::VectorXd storage = Eigen::VectorXd::Zero(1000); @@ -28,7 +27,7 @@ TEST_F(AgradRev, Rev_accumulate_adjoints_int_arg) { EXPECT_EQ(ptr, storage.data()); } -TEST_F(AgradRev, Rev_accumulate_adjoints_double_arg) { +TEST(AgradRev_accumulate_adjoints, double_arg) { double arg = 5.0; Eigen::VectorXd storage = Eigen::VectorXd::Zero(1000); @@ -41,7 +40,7 @@ TEST_F(AgradRev, Rev_accumulate_adjoints_double_arg) { EXPECT_EQ(ptr, storage.data()); } -TEST_F(AgradRev, Rev_accumulate_adjoints_std_vector_int_arg) { +TEST(AgradRev_accumulate_adjoints, std_vector_int_arg) { std::vector arg(5, 10); Eigen::VectorXd storage = Eigen::VectorXd::Zero(1000); @@ -54,7 +53,7 @@ TEST_F(AgradRev, Rev_accumulate_adjoints_std_vector_int_arg) { EXPECT_EQ(ptr, storage.data()); } -TEST_F(AgradRev, Rev_accumulate_adjoints_std_vector_double_arg) { +TEST(AgradRev_accumulate_adjoints, std_vector_double_arg) { std::vector arg(5, 10.0); Eigen::VectorXd storage = Eigen::VectorXd::Zero(1000); @@ -67,7 +66,7 @@ TEST_F(AgradRev, Rev_accumulate_adjoints_std_vector_double_arg) { EXPECT_EQ(ptr, storage.data()); } -TEST_F(AgradRev, Rev_accumulate_adjoints_eigen_vector_arg) { +TEST(AgradRev_accumulate_adjoints, eigen_vector_arg) { Eigen::VectorXd arg = Eigen::VectorXd::Ones(5); Eigen::VectorXd storage = Eigen::VectorXd::Zero(1000); @@ -79,7 +78,7 @@ TEST_F(AgradRev, Rev_accumulate_adjoints_eigen_vector_arg) { EXPECT_EQ(ptr, storage.data()); } -TEST_F(AgradRev, Rev_accumulate_adjoints_eigen_row_vector_arg) { +TEST(AgradRev_accumulate_adjoints, eigen_row_vector_arg) { Eigen::RowVectorXd arg = Eigen::RowVectorXd::Ones(5); Eigen::VectorXd storage = Eigen::VectorXd::Zero(1000); @@ -92,7 +91,7 @@ TEST_F(AgradRev, Rev_accumulate_adjoints_eigen_row_vector_arg) { EXPECT_EQ(ptr, storage.data()); } -TEST_F(AgradRev, Rev_accumulate_adjoints_eigen_matrix_arg) { +TEST(AgradRev_accumulate_adjoints, eigen_matrix_arg) { Eigen::MatrixXd arg = Eigen::MatrixXd::Ones(5, 5); Eigen::VectorXd storage = Eigen::VectorXd::Zero(1000); @@ -105,7 +104,7 @@ TEST_F(AgradRev, Rev_accumulate_adjoints_eigen_matrix_arg) { EXPECT_EQ(ptr, storage.data()); } -TEST_F(AgradRev, Rev_accumulate_adjoints_std_vector_std_vector_double_arg) { +TEST(AgradRev_accumulate_adjoints, std_vector_std_vector_double_arg) { std::vector> arg(5, std::vector(5, 10.0)); Eigen::VectorXd storage = Eigen::VectorXd::Zero(1000); @@ -118,7 +117,7 @@ TEST_F(AgradRev, Rev_accumulate_adjoints_std_vector_std_vector_double_arg) { EXPECT_EQ(ptr, storage.data()); } -TEST_F(AgradRev, Rev_accumulate_adjoints_std_vector_eigen_vector_arg) { +TEST(AgradRev_accumulate_adjoints, std_vector_eigen_vector_arg) { std::vector arg(2, Eigen::VectorXd::Ones(5)); Eigen::VectorXd storage = Eigen::VectorXd::Zero(1000); @@ -131,7 +130,7 @@ TEST_F(AgradRev, Rev_accumulate_adjoints_std_vector_eigen_vector_arg) { EXPECT_EQ(ptr, storage.data()); } -TEST_F(AgradRev, Rev_accumulate_adjoints_std_vector_eigen_row_vector_arg) { +TEST(AgradRev_accumulate_adjoints, std_vector_eigen_row_vector_arg) { std::vector arg(2, Eigen::VectorXd::Ones(5)); Eigen::VectorXd storage = Eigen::VectorXd::Zero(1000); @@ -144,7 +143,7 @@ TEST_F(AgradRev, Rev_accumulate_adjoints_std_vector_eigen_row_vector_arg) { EXPECT_EQ(ptr, storage.data()); } -TEST_F(AgradRev, Rev_accumulate_adjoints_std_vector_eigen_matrix_arg) { +TEST(AgradRev_accumulate_adjoints, std_vector_eigen_matrix_arg) { std::vector arg(2, Eigen::MatrixXd::Ones(5, 3)); Eigen::VectorXd storage = Eigen::VectorXd::Zero(1000); @@ -157,7 +156,7 @@ TEST_F(AgradRev, Rev_accumulate_adjoints_std_vector_eigen_matrix_arg) { EXPECT_EQ(ptr, storage.data()); } -TEST_F(AgradRev, Rev_accumulate_adjoints_var_arg) { +TEST(AgradRev_accumulate_adjoints, var_arg) { using stan::math::var; using stan::math::vari; var arg(5.0); @@ -179,7 +178,7 @@ TEST_F(AgradRev, Rev_accumulate_adjoints_var_arg) { stan::math::recover_memory(); } -TEST_F(AgradRev, Rev_accumulate_adjoints_std_vector_var_arg) { +TEST(AgradRev_accumulate_adjoints, std_vector_var_arg) { using stan::math::var; using stan::math::vari; std::vector arg(5); @@ -204,7 +203,7 @@ TEST_F(AgradRev, Rev_accumulate_adjoints_std_vector_var_arg) { stan::math::recover_memory(); } -TEST_F(AgradRev, Rev_accumulate_adjoints_eigen_vector_var_arg) { +TEST(AgradRev_accumulate_adjoints, eigen_vector_var_arg) { using stan::math::var; using stan::math::vari; Eigen::Matrix arg(5); @@ -229,7 +228,7 @@ TEST_F(AgradRev, Rev_accumulate_adjoints_eigen_vector_var_arg) { stan::math::recover_memory(); } -TEST_F(AgradRev, Rev_accumulate_adjoints_eigen_row_vector_var_arg) { +TEST(AgradRev_accumulate_adjoints, eigen_row_vector_var_arg) { using stan::math::var; using stan::math::vari; Eigen::Matrix arg(5); @@ -254,7 +253,7 @@ TEST_F(AgradRev, Rev_accumulate_adjoints_eigen_row_vector_var_arg) { stan::math::recover_memory(); } -TEST_F(AgradRev, Rev_accumulate_adjoints_eigen_matrix_var_arg) { +TEST(AgradRev_accumulate_adjoints, eigen_matrix_var_arg) { using stan::math::var; using stan::math::vari; Eigen::Matrix arg(5, 5); @@ -279,7 +278,7 @@ TEST_F(AgradRev, Rev_accumulate_adjoints_eigen_matrix_var_arg) { stan::math::recover_memory(); } -TEST_F(AgradRev, Rev_accumulate_adjoints_std_vector_std_vector_var_arg) { +TEST(AgradRev_accumulate_adjoints, std_vector_std_vector_var_arg) { using stan::math::var; using stan::math::vari; std::vector arg_(5, var(5.0)); @@ -303,7 +302,7 @@ TEST_F(AgradRev, Rev_accumulate_adjoints_std_vector_std_vector_var_arg) { stan::math::recover_memory(); } -TEST_F(AgradRev, Rev_accumulate_adjoints_std_vector_eigen_vector_var_arg) { +TEST(AgradRev_accumulate_adjoints, std_vector_eigen_vector_var_arg) { using stan::math::var; using stan::math::vari; Eigen::Matrix arg_(5); @@ -329,7 +328,7 @@ TEST_F(AgradRev, Rev_accumulate_adjoints_std_vector_eigen_vector_var_arg) { stan::math::recover_memory(); } -TEST_F(AgradRev, Rev_accumulate_adjoints_std_vector_eigen_row_vector_var_arg) { +TEST(AgradRev_accumulate_adjoints, std_vector_eigen_row_vector_var_arg) { using stan::math::var; using stan::math::vari; Eigen::Matrix arg_(5); @@ -355,7 +354,7 @@ TEST_F(AgradRev, Rev_accumulate_adjoints_std_vector_eigen_row_vector_var_arg) { stan::math::recover_memory(); } -TEST_F(AgradRev, Rev_accumulate_adjoints_std_vector_eigen_matrix_var_arg) { +TEST(AgradRev_accumulate_adjoints, std_vector_eigen_matrix_var_arg) { using stan::math::var; using stan::math::vari; Eigen::Matrix arg_(5, 3); @@ -381,7 +380,7 @@ TEST_F(AgradRev, Rev_accumulate_adjoints_std_vector_eigen_matrix_var_arg) { stan::math::recover_memory(); } -TEST_F(AgradRev, Rev_accumulate_adjoints_sum) { +TEST(AgradRev_accumulate_adjoints, sum) { using stan::math::var; using stan::math::vari; int arg1 = 1; diff --git a/test/unit/math/rev/core/arena_allocator_test.cpp b/test/unit/math/rev/core/arena_allocator_test.cpp index 0103914f54c..0a6a30c7f0b 100644 --- a/test/unit/math/rev/core/arena_allocator_test.cpp +++ b/test/unit/math/rev/core/arena_allocator_test.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include @@ -10,7 +9,7 @@ #include #include -inline void arena_allocator_test() { +void arena_allocator_test() { std::vector> v; v.reserve(3); for (int i = 0; i < 5; i++) { @@ -139,6 +138,6 @@ inline void arena_allocator_test() { } } -TEST_F(AgradRev, RevArena_arena_allocator_test) { +TEST(AgradRevArena, arena_allocator_test) { EXPECT_NO_THROW(arena_allocator_test()); } diff --git a/test/unit/math/rev/core/arena_matrix_test.cpp b/test/unit/math/rev/core/arena_matrix_test.cpp index fe866decc52..f67650c1a84 100644 --- a/test/unit/math/rev/core/arena_matrix_test.cpp +++ b/test/unit/math/rev/core/arena_matrix_test.cpp @@ -241,7 +241,7 @@ TEST_F(AgradRev, arena_sparse_matrix_inplace_ops) { expect_sparse_dense_matrix_equal(A_m, C); } -TEST_F(AgradRev, RevArenaMat_arena_matrix_move_test) { +TEST(AgradRevArenaMat, arena_matrix_move_test) { using stan::math::arena_matrix; Eigen::VectorXd c = Eigen::VectorXd::Random(3); Eigen::VectorXd d = c; diff --git a/test/unit/math/rev/core/build_vari_array_test.cpp b/test/unit/math/rev/core/build_vari_array_test.cpp index aca515b367a..072ebf00530 100644 --- a/test/unit/math/rev/core/build_vari_array_test.cpp +++ b/test/unit/math/rev/core/build_vari_array_test.cpp @@ -1,9 +1,8 @@ #include -#include #include #include -TEST_F(AgradRev, RevBuild_build_vari_array) { +TEST(AgradRevBuild, build_vari_array) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::var; diff --git a/test/unit/math/rev/core/callback_vari_test.cpp b/test/unit/math/rev/core/callback_vari_test.cpp index eb9b4a7740a..3bfcad264e0 100644 --- a/test/unit/math/rev/core/callback_vari_test.cpp +++ b/test/unit/math/rev/core/callback_vari_test.cpp @@ -1,9 +1,8 @@ #include #include #include -#include -TEST_F(AgradRev, RevCBack_callback_vari_scalar_test) { +TEST(AgradRevCBack, callback_vari_scalar_test) { stan::math::var a = 1; stan::math::var b = 1; @@ -21,7 +20,7 @@ TEST_F(AgradRev, RevCBack_callback_vari_scalar_test) { EXPECT_EQ(b.adj(), 2); } -TEST_F(AgradRev, RevCBack_callback_vari_const_scalar_compile_test) { +TEST(AgradRevCBack, callback_vari_const_scalar_compile_test) { stan::math::var a = 1; const double& a_val = a.val(); @@ -31,7 +30,7 @@ TEST_F(AgradRev, RevCBack_callback_vari_const_scalar_compile_test) { EXPECT_FLOAT_EQ(a.val(), b.val()); } -TEST_F(AgradRev, RevCBack_callback_vari_eigen_test) { +TEST(AgradRevCBack, callback_vari_eigen_test) { Eigen::MatrixXd val(2, 3); val << 1, 2, 3, 4, 5, 6; stan::math::var_value a = val; @@ -45,7 +44,7 @@ TEST_F(AgradRev, RevCBack_callback_vari_eigen_test) { EXPECT_MATRIX_EQ(a.adj(), Eigen::MatrixXd::Constant(2, 3, 2)); } -TEST_F(AgradRev, RevCBack_make_callback_var_scalar_test) { +TEST(AgradRevCBack, make_callback_var_scalar_test) { stan::math::var a = 1; stan::math::var b = 1; @@ -64,7 +63,7 @@ TEST_F(AgradRev, RevCBack_make_callback_var_scalar_test) { EXPECT_EQ(b.adj(), 2); } -TEST_F(AgradRev, RevCBack_make_callback_var_eigen_test) { +TEST(AgradRevCBack, make_callback_var_eigen_test) { Eigen::MatrixXd val(2, 3); val << 1, 2, 3, 4, 5, 6; stan::math::var_value a = val; diff --git a/test/unit/math/rev/core/chainable_object_test.cpp b/test/unit/math/rev/core/chainable_object_test.cpp index a5ec06840bc..d668b330310 100644 --- a/test/unit/math/rev/core/chainable_object_test.cpp +++ b/test/unit/math/rev/core/chainable_object_test.cpp @@ -1,7 +1,6 @@ #include #include #include -#include class ChainableObjectTest { public: @@ -12,7 +11,7 @@ class ChainableObjectTest { int ChainableObjectTest::counter = 0; -TEST_F(AgradRev, RevChain_chainable_object_test) { +TEST(AgradRevChain, chainable_object_test) { { EXPECT_NO_THROW(new stan::math::chainable_object( ChainableObjectTest())); @@ -24,7 +23,7 @@ TEST_F(AgradRev, RevChain_chainable_object_test) { EXPECT_EQ((ChainableObjectTest::counter), 1); } -TEST_F(AgradRev, RevChain_chainable_object_nested_test) { +TEST(AgradRevChain, chainable_object_nested_test) { stan::math::start_nested(); { @@ -40,7 +39,7 @@ TEST_F(AgradRev, RevChain_chainable_object_nested_test) { EXPECT_EQ((ChainableObjectTest::counter), 1); } -TEST_F(AgradRev, RevChain_make_chainable_ptr_test) { +TEST(AgradRevChain, make_chainable_ptr_test) { { EXPECT_NO_THROW(stan::math::make_chainable_ptr(ChainableObjectTest())); ChainableObjectTest::counter = 0; @@ -51,7 +50,7 @@ TEST_F(AgradRev, RevChain_make_chainable_ptr_test) { EXPECT_EQ((ChainableObjectTest::counter), 1); } -TEST_F(AgradRev, RevChain_make_chainable_ptr_nested_test) { +TEST(AgradRevChain, make_chainable_ptr_nested_test) { stan::math::start_nested(); { @@ -75,7 +74,7 @@ class UnsafeChainableObjectTest { int UnsafeChainableObjectTest::counter = 0; -TEST_F(AgradRev, RevChain_unsafe_chainable_object_test) { +TEST(AgradRevChain, unsafe_chainable_object_test) { { EXPECT_NO_THROW( new stan::math::unsafe_chainable_object( @@ -88,7 +87,7 @@ TEST_F(AgradRev, RevChain_unsafe_chainable_object_test) { EXPECT_EQ((UnsafeChainableObjectTest::counter), 1); } -TEST_F(AgradRev, RevChain_unsafe_chainable_object_nested_test) { +TEST(AgradRevChain, unsafe_chainable_object_nested_test) { stan::math::start_nested(); { @@ -104,7 +103,7 @@ TEST_F(AgradRev, RevChain_unsafe_chainable_object_nested_test) { EXPECT_EQ((UnsafeChainableObjectTest::counter), 1); } -TEST_F(AgradRev, RevChain_make_unsafe_chainable_ptr_test) { +TEST(AgradRevChain, make_unsafe_chainable_ptr_test) { { EXPECT_NO_THROW( stan::math::make_unsafe_chainable_ptr(UnsafeChainableObjectTest())); @@ -116,7 +115,7 @@ TEST_F(AgradRev, RevChain_make_unsafe_chainable_ptr_test) { EXPECT_EQ((UnsafeChainableObjectTest::counter), 1); } -TEST_F(AgradRev, RevChain_make_unsafe_chainable_ptr_nested_test) { +TEST(AgradRevChain, make_unsafe_chainable_ptr_nested_test) { stan::math::start_nested(); { diff --git a/test/unit/math/rev/core/count_vars_test.cpp b/test/unit/math/rev/core/count_vars_test.cpp index 25157012714..ec9a6b96e38 100644 --- a/test/unit/math/rev/core/count_vars_test.cpp +++ b/test/unit/math/rev/core/count_vars_test.cpp @@ -1,140 +1,136 @@ #include #include #include -#include - #include using stan::math::var; -TEST_F(AgradRev, Rev_count_vars_int_arg) { +TEST(AgradRev_count_vars, int_arg) { int arg = 5; EXPECT_EQ(0, stan::math::count_vars(arg)); } -TEST_F(AgradRev, Rev_count_vars_double_arg) { +TEST(AgradRev_count_vars, double_arg) { double arg = 5.0; EXPECT_EQ(0, stan::math::count_vars(arg)); } -TEST_F(AgradRev, Rev_count_vars_std_vector_int_arg) { +TEST(AgradRev_count_vars, std_vector_int_arg) { std::vector arg(5, 10); EXPECT_EQ(0, stan::math::count_vars(arg)); } -TEST_F(AgradRev, Rev_count_vars_std_vector_double_arg) { +TEST(AgradRev_count_vars, std_vector_double_arg) { std::vector arg(5, 10.0); EXPECT_EQ(0, stan::math::count_vars(arg)); } -TEST_F(AgradRev, Rev_count_vars_eigen_vector_arg) { +TEST(AgradRev_count_vars, eigen_vector_arg) { Eigen::VectorXd arg = Eigen::VectorXd::Ones(5); EXPECT_EQ(0, stan::math::count_vars(arg)); } -TEST_F(AgradRev, Rev_count_vars_eigen_row_vector_arg) { +TEST(AgradRev_count_vars, eigen_row_vector_arg) { Eigen::RowVectorXd arg = Eigen::RowVectorXd::Ones(5); EXPECT_EQ(0, stan::math::count_vars(arg)); } -TEST_F(AgradRev, Rev_count_vars_eigen_matrix_arg) { +TEST(AgradRev_count_vars, eigen_matrix_arg) { Eigen::MatrixXd arg = Eigen::MatrixXd::Ones(5, 5); EXPECT_EQ(0, stan::math::count_vars(arg)); } -TEST_F(AgradRev, Rev_count_vars_std_vector_std_vector_double_arg) { +TEST(AgradRev_count_vars, std_vector_std_vector_double_arg) { std::vector> arg(5, std::vector(5, 10.0)); EXPECT_EQ(0, stan::math::count_vars(arg)); } -TEST_F(AgradRev, Rev_count_vars_std_vector_eigen_vector_arg) { +TEST(AgradRev_count_vars, std_vector_eigen_vector_arg) { std::vector arg(2, Eigen::VectorXd::Ones(5)); EXPECT_EQ(0, stan::math::count_vars(arg)); } -TEST_F(AgradRev, Rev_count_vars_std_vector_eigen_row_vector_arg) { +TEST(AgradRev_count_vars, std_vector_eigen_row_vector_arg) { std::vector arg(2, Eigen::VectorXd::Ones(5)); EXPECT_EQ(0, stan::math::count_vars(arg)); } -TEST_F(AgradRev, Rev_count_vars_std_vector_eigen_matrix_arg) { +TEST(AgradRev_count_vars, std_vector_eigen_matrix_arg) { std::vector arg(2, Eigen::MatrixXd::Ones(5, 3)); EXPECT_EQ(0, stan::math::count_vars(arg)); } -TEST_F(AgradRev, Rev_count_vars_var_arg) { +TEST(AgradRev_count_vars, var_arg) { var arg = 5.0; EXPECT_EQ(1, stan::math::count_vars(arg)); } -TEST_F(AgradRev, Rev_count_vars_std_vector_var_arg) { +TEST(AgradRev_count_vars, std_vector_var_arg) { std::vector arg(5); EXPECT_EQ(5, stan::math::count_vars(arg)); } -TEST_F(AgradRev, Rev_count_vars_eigen_vector_var_arg) { +TEST(AgradRev_count_vars, eigen_vector_var_arg) { Eigen::Matrix arg(5); EXPECT_EQ(5, stan::math::count_vars(arg)); } -TEST_F(AgradRev, Rev_count_vars_eigen_row_vector_var_arg) { +TEST(AgradRev_count_vars, eigen_row_vector_var_arg) { Eigen::Matrix arg(5); EXPECT_EQ(5, stan::math::count_vars(arg)); } -TEST_F(AgradRev, Rev_count_vars_eigen_matrix_var_arg) { +TEST(AgradRev_count_vars, eigen_matrix_var_arg) { Eigen::Matrix arg(5, 5); EXPECT_EQ(25, stan::math::count_vars(arg)); } -TEST_F(AgradRev, Rev_count_vars_std_vector_std_vector_var_arg) { +TEST(AgradRev_count_vars, std_vector_std_vector_var_arg) { std::vector> arg(5, std::vector(5)); EXPECT_EQ(25, stan::math::count_vars(arg)); } -TEST_F(AgradRev, Rev_count_vars_std_vector_eigen_vector_var_arg) { +TEST(AgradRev_count_vars, std_vector_eigen_vector_var_arg) { std::vector> arg( 2, Eigen::Matrix(5)); EXPECT_EQ(10, stan::math::count_vars(arg)); } -TEST_F(AgradRev, Rev_count_vars_std_vector_eigen_row_vector_var_arg) { +TEST(AgradRev_count_vars, std_vector_eigen_row_vector_var_arg) { std::vector> arg( 2, Eigen::Matrix(5)); EXPECT_EQ(10, stan::math::count_vars(arg)); } -TEST_F(AgradRev, Rev_count_vars_std_vector_eigen_matrix_var_arg) { +TEST(AgradRev_count_vars, std_vector_eigen_matrix_var_arg) { std::vector> arg( 2, Eigen::Matrix(5, 3)); EXPECT_EQ(30, stan::math::count_vars(arg)); } -TEST_F(AgradRev, Rev_count_vars_zero_args) { - EXPECT_EQ(0, stan::math::count_vars()); -} +TEST(AgradRev_count_vars, zero_args) { EXPECT_EQ(0, stan::math::count_vars()); } -TEST_F(AgradRev, Rev_count_vars_sum) { +TEST(AgradRev_count_vars, sum) { int arg1 = 1; double arg2 = 1.0; std::vector arg3(5, 1); diff --git a/test/unit/math/rev/core/deep_copy_vars_test.cpp b/test/unit/math/rev/core/deep_copy_vars_test.cpp index 99f78c9fb9c..ac9e067a589 100644 --- a/test/unit/math/rev/core/deep_copy_vars_test.cpp +++ b/test/unit/math/rev/core/deep_copy_vars_test.cpp @@ -1,13 +1,12 @@ #include #include #include -#include #include using stan::math::var; using stan::math::vari; -TEST_F(AgradRev, Rev_deep_copy_vars_int_arg) { +TEST(AgradRev_deep_copy_vars, int_arg) { int arg = 5; decltype(stan::math::deep_copy_vars(arg)) out @@ -16,7 +15,7 @@ TEST_F(AgradRev, Rev_deep_copy_vars_int_arg) { EXPECT_EQ(&out, &arg); } -TEST_F(AgradRev, Rev_deep_copy_vars_double_arg) { +TEST(AgradRev_deep_copy_vars, double_arg) { double arg = 5.0; decltype(stan::math::deep_copy_vars(arg)) out @@ -25,7 +24,7 @@ TEST_F(AgradRev, Rev_deep_copy_vars_double_arg) { EXPECT_EQ(&out, &arg); } -TEST_F(AgradRev, Rev_deep_copy_vars_std_vector_int_arg) { +TEST(AgradRev_deep_copy_vars, std_vector_int_arg) { std::vector arg(5, 10); decltype(stan::math::deep_copy_vars(arg)) out @@ -34,7 +33,7 @@ TEST_F(AgradRev, Rev_deep_copy_vars_std_vector_int_arg) { EXPECT_EQ(&out, &arg); } -TEST_F(AgradRev, Rev_deep_copy_vars_std_vector_double_arg) { +TEST(AgradRev_deep_copy_vars, std_vector_double_arg) { std::vector arg(5, 10.0); decltype(stan::math::deep_copy_vars(arg)) out @@ -43,7 +42,7 @@ TEST_F(AgradRev, Rev_deep_copy_vars_std_vector_double_arg) { EXPECT_EQ(&out, &arg); } -TEST_F(AgradRev, Rev_deep_copy_vars_eigen_vector_arg) { +TEST(AgradRev_deep_copy_vars, eigen_vector_arg) { Eigen::VectorXd arg = Eigen::VectorXd::Ones(5); decltype(stan::math::deep_copy_vars(arg)) out @@ -52,7 +51,7 @@ TEST_F(AgradRev, Rev_deep_copy_vars_eigen_vector_arg) { EXPECT_EQ(&out, &arg); } -TEST_F(AgradRev, Rev_deep_copy_vars_eigen_row_vector_arg) { +TEST(AgradRev_deep_copy_vars, eigen_row_vector_arg) { Eigen::RowVectorXd arg = Eigen::RowVectorXd::Ones(5); decltype(stan::math::deep_copy_vars(arg)) out @@ -61,7 +60,7 @@ TEST_F(AgradRev, Rev_deep_copy_vars_eigen_row_vector_arg) { EXPECT_EQ(&out, &arg); } -TEST_F(AgradRev, Rev_deep_copy_vars_eigen_matrix_arg) { +TEST(AgradRev_deep_copy_vars, eigen_matrix_arg) { Eigen::MatrixXd arg = Eigen::MatrixXd::Ones(5, 5); decltype(stan::math::deep_copy_vars(arg)) out @@ -70,7 +69,7 @@ TEST_F(AgradRev, Rev_deep_copy_vars_eigen_matrix_arg) { EXPECT_EQ(&out, &arg); } -TEST_F(AgradRev, Rev_deep_copy_vars_std_vector_std_vector_double_arg) { +TEST(AgradRev_deep_copy_vars, std_vector_std_vector_double_arg) { std::vector> arg(5, std::vector(5, 10.0)); decltype(stan::math::deep_copy_vars(arg)) out @@ -79,7 +78,7 @@ TEST_F(AgradRev, Rev_deep_copy_vars_std_vector_std_vector_double_arg) { EXPECT_EQ(&out, &arg); } -TEST_F(AgradRev, Rev_deep_copy_vars_std_vector_eigen_vector_arg) { +TEST(AgradRev_deep_copy_vars, std_vector_eigen_vector_arg) { std::vector arg(2, Eigen::VectorXd::Ones(5)); decltype(stan::math::deep_copy_vars(arg)) out @@ -88,7 +87,7 @@ TEST_F(AgradRev, Rev_deep_copy_vars_std_vector_eigen_vector_arg) { EXPECT_EQ(&out, &arg); } -TEST_F(AgradRev, Rev_deep_copy_vars_std_vector_eigen_row_vector_arg) { +TEST(AgradRev_deep_copy_vars, std_vector_eigen_row_vector_arg) { std::vector arg(2, Eigen::VectorXd::Ones(5)); decltype(stan::math::deep_copy_vars(arg)) out @@ -97,7 +96,7 @@ TEST_F(AgradRev, Rev_deep_copy_vars_std_vector_eigen_row_vector_arg) { EXPECT_EQ(&out, &arg); } -TEST_F(AgradRev, Rev_deep_copy_vars_std_vector_eigen_matrix_arg) { +TEST(AgradRev_deep_copy_vars, std_vector_eigen_matrix_arg) { std::vector arg(2, Eigen::MatrixXd::Ones(5, 3)); decltype(stan::math::deep_copy_vars(arg)) out @@ -106,7 +105,7 @@ TEST_F(AgradRev, Rev_deep_copy_vars_std_vector_eigen_matrix_arg) { EXPECT_EQ(&out, &arg); } -TEST_F(AgradRev, Rev_deep_copy_vars_var_arg) { +TEST(AgradRev_deep_copy_vars, var_arg) { var arg(5.0); arg.vi_->adj_ = 2.0; @@ -121,7 +120,7 @@ TEST_F(AgradRev, Rev_deep_copy_vars_var_arg) { EXPECT_NE(out.vi_, arg.vi_); } -TEST_F(AgradRev, Rev_deep_copy_vars_std_vector_var_arg) { +TEST(AgradRev_deep_copy_vars, std_vector_var_arg) { std::vector arg(5); for (size_t i = 0; i < arg.size(); ++i) arg[i] = i + 1.0; @@ -142,7 +141,7 @@ TEST_F(AgradRev, Rev_deep_copy_vars_std_vector_var_arg) { } } -TEST_F(AgradRev, Rev_deep_copy_vars_eigen_vector_var_arg) { +TEST(AgradRev_deep_copy_vars, eigen_vector_var_arg) { Eigen::Matrix arg(5); for (size_t i = 0; i < arg.size(); ++i) { arg(i) = i + 1.0; @@ -165,7 +164,7 @@ TEST_F(AgradRev, Rev_deep_copy_vars_eigen_vector_var_arg) { } } -TEST_F(AgradRev, Rev_deep_copy_vars_eigen_row_vector_var_arg) { +TEST(AgradRev_deep_copy_vars, eigen_row_vector_var_arg) { Eigen::Matrix arg(5); for (size_t i = 0; i < arg.size(); ++i) { arg(i) = i + 1.0; @@ -188,7 +187,7 @@ TEST_F(AgradRev, Rev_deep_copy_vars_eigen_row_vector_var_arg) { } } -TEST_F(AgradRev, Rev_deep_copy_vars_eigen_matrix_var_arg) { +TEST(AgradRev_deep_copy_vars, eigen_matrix_var_arg) { Eigen::Matrix arg(5, 5); for (size_t i = 0; i < arg.size(); ++i) { arg(i) = i + 1.0; @@ -211,7 +210,7 @@ TEST_F(AgradRev, Rev_deep_copy_vars_eigen_matrix_var_arg) { } } -TEST_F(AgradRev, Rev_deep_copy_vars_std_vector_std_vector_var_arg) { +TEST(AgradRev_deep_copy_vars, std_vector_std_vector_var_arg) { std::vector arg_(5); std::vector> arg(5, arg_); for (size_t i = 0; i < arg.size(); ++i) @@ -235,7 +234,7 @@ TEST_F(AgradRev, Rev_deep_copy_vars_std_vector_std_vector_var_arg) { } } -TEST_F(AgradRev, Rev_deep_copy_vars_std_vector_eigen_vector_var_arg) { +TEST(AgradRev_deep_copy_vars, std_vector_eigen_vector_var_arg) { Eigen::Matrix arg_(5); std::vector> arg(2, arg_); for (size_t i = 0; i < arg.size(); ++i) @@ -259,7 +258,7 @@ TEST_F(AgradRev, Rev_deep_copy_vars_std_vector_eigen_vector_var_arg) { } } -TEST_F(AgradRev, Rev_deep_copy_vars_std_vector_eigen_row_vector_var_arg) { +TEST(AgradRev_deep_copy_vars, std_vector_eigen_row_vector_var_arg) { Eigen::Matrix arg_(5); std::vector> arg(2, arg_); for (size_t i = 0; i < arg.size(); ++i) @@ -283,7 +282,7 @@ TEST_F(AgradRev, Rev_deep_copy_vars_std_vector_eigen_row_vector_var_arg) { } } -TEST_F(AgradRev, Rev_deep_copy_vars_std_vector_eigen_matrix_var_arg) { +TEST(AgradRev_deep_copy_vars, std_vector_eigen_matrix_var_arg) { Eigen::Matrix arg_(5, 3); std::vector> arg(2, arg_); for (size_t i = 0; i < arg.size(); ++i) diff --git a/test/unit/math/rev/core/grad_test.cpp b/test/unit/math/rev/core/grad_test.cpp index 7222c1ef419..b3fdaa1bcc8 100644 --- a/test/unit/math/rev/core/grad_test.cpp +++ b/test/unit/math/rev/core/grad_test.cpp @@ -1,11 +1,10 @@ #include -#include #include -#include +#include #include #include -TEST_F(AgradRev, Rev_multiple_grads) { +TEST(AgradRev, multiple_grads) { for (int i = 0; i < 100; ++i) { stan::math::var a = 2.0; stan::math::var b = 3.0 * a; @@ -31,7 +30,7 @@ TEST_F(AgradRev, Rev_multiple_grads) { EXPECT_FLOAT_EQ(2.0, grad_f[1]); } -TEST_F(AgradRev, Rev_ensure_first_vari_chained) { +TEST(AgradRev, ensure_first_vari_chained) { using stan::math::var; // Make sure there aren't any varis on stack @@ -79,7 +78,7 @@ class test_vari : public vari { } // namespace math } // namespace stan -TEST_F(AgradRev, Rev_nested_grad_during_chain) { +TEST(AgradRev, nested_grad_during_chain) { using stan::math::var; var total = 0.0; diff --git a/test/unit/math/rev/core/gradable.hpp b/test/unit/math/rev/core/gradable.hpp index a4c198d1ed6..b27f3d4fdb7 100644 --- a/test/unit/math/rev/core/gradable.hpp +++ b/test/unit/math/rev/core/gradable.hpp @@ -2,7 +2,6 @@ #define TEST_UNIT_MATH_REV_CORE_GRADABLE_HPP #include -#include #include #include #include diff --git a/test/unit/math/rev/core/nested_rev_autodiff_test.cpp b/test/unit/math/rev/core/nested_rev_autodiff_test.cpp index 133f515e4dc..2c2d667f5b5 100644 --- a/test/unit/math/rev/core/nested_rev_autodiff_test.cpp +++ b/test/unit/math/rev/core/nested_rev_autodiff_test.cpp @@ -1,6 +1,5 @@ #include #include -#include #include #include diff --git a/test/unit/math/rev/core/operator_logical_and_test.cpp b/test/unit/math/rev/core/operator_logical_and_test.cpp index bb4febe160d..47306748d88 100644 --- a/test/unit/math/rev/core/operator_logical_and_test.cpp +++ b/test/unit/math/rev/core/operator_logical_and_test.cpp @@ -1,17 +1,16 @@ #include -#include #include #include #include -inline void test_logical_and(double x, double y) { +void test_logical_and(double x, double y) { using stan::math::var; EXPECT_EQ(x && y, var(x) && var(y)); EXPECT_EQ(x && y, x && var(y)); EXPECT_EQ(x && y, var(x) && y); } -TEST_F(AgradRev, Rev_logical_and) { +TEST(AgradRev, logical_and) { std::vector xs; xs.push_back(6.1); xs.push_back(6.1); diff --git a/test/unit/math/rev/core/operator_logical_or_test.cpp b/test/unit/math/rev/core/operator_logical_or_test.cpp index 29256554754..f1a957b9561 100644 --- a/test/unit/math/rev/core/operator_logical_or_test.cpp +++ b/test/unit/math/rev/core/operator_logical_or_test.cpp @@ -1,17 +1,16 @@ #include #include -#include #include #include #include -inline void test_logical_or(double x, double y) { +void test_logical_or(double x, double y) { stan::math::var x_v = x; stan::math::var y_v = y; EXPECT_EQ(x || y, x_v || y_v); } -TEST_F(AgradRev, Rev_logical_or) { +TEST(AgradRev, logical_or) { std::vector xs; xs.push_back(6.1); xs.push_back(6.1); diff --git a/test/unit/math/rev/core/operator_unary_negative_test.cpp b/test/unit/math/rev/core/operator_unary_negative_test.cpp index 23a0f31ae1d..705e15ad91f 100644 --- a/test/unit/math/rev/core/operator_unary_negative_test.cpp +++ b/test/unit/math/rev/core/operator_unary_negative_test.cpp @@ -1,11 +1,10 @@ #include #include #include -#include #include #include -TEST_F(AgradRev, Rev_varmat_unary_negative) { +TEST(AgradRev, varmat_unary_negative) { stan::math::var_value x = Eigen::MatrixXd::Random(2, 3); stan::math::var_value y = -x; diff --git a/test/unit/math/rev/core/operator_unary_not_test.cpp b/test/unit/math/rev/core/operator_unary_not_test.cpp index 84b4d39c9dd..55169e3d3dd 100644 --- a/test/unit/math/rev/core/operator_unary_not_test.cpp +++ b/test/unit/math/rev/core/operator_unary_not_test.cpp @@ -1,15 +1,14 @@ #include #include -#include #include #include -inline void test_unary_not(double x) { +void test_unary_not(double x) { stan::math::var x_v = x; EXPECT_EQ(!x, !x_v); } -TEST_F(AgradRev, Rev_unaryNot) { +TEST(AgradRev, unaryNot) { test_unary_not(6.1); test_unary_not(0); test_unary_not(-13.2); diff --git a/test/unit/math/rev/core/precomp_vv_vari_test.cpp b/test/unit/math/rev/core/precomp_vv_vari_test.cpp index 6af78e9fbe7..0ac5c669126 100644 --- a/test/unit/math/rev/core/precomp_vv_vari_test.cpp +++ b/test/unit/math/rev/core/precomp_vv_vari_test.cpp @@ -1,9 +1,8 @@ #include #include -#include #include -TEST_F(AgradRev, StanAgradRevInternal_precomp_vv_vari) { +TEST(StanAgradRevInternal, precomp_vv_vari) { double value, gradient1, gradient2; stan::math::var x1(2), x2(3); stan::math::var y; diff --git a/test/unit/math/rev/core/precomp_vvv_vari_test.cpp b/test/unit/math/rev/core/precomp_vvv_vari_test.cpp index de256c81810..2e47885a75e 100644 --- a/test/unit/math/rev/core/precomp_vvv_vari_test.cpp +++ b/test/unit/math/rev/core/precomp_vvv_vari_test.cpp @@ -1,9 +1,8 @@ #include #include -#include #include -TEST_F(AgradRev, StanAgradRevInternal_precomp_vvv_vari) { +TEST(StanAgradRevInternal, precomp_vvv_vari) { double value, gradient1, gradient2, gradient3; stan::math::var x1(2), x2(3), x3(5); stan::math::var y; diff --git a/test/unit/math/rev/core/precomputed_gradients_test.cpp b/test/unit/math/rev/core/precomputed_gradients_test.cpp index d7d1007407a..4bc34d853d1 100644 --- a/test/unit/math/rev/core/precomputed_gradients_test.cpp +++ b/test/unit/math/rev/core/precomputed_gradients_test.cpp @@ -1,10 +1,9 @@ #include -#include #include #include #include -TEST_F(AgradRev, StanAgradRevInternal_precomputed_gradients) { +TEST(StanAgradRevInternal, precomputed_gradients) { double value; std::vector vars; std::vector gradients; @@ -32,8 +31,7 @@ TEST_F(AgradRev, StanAgradRevInternal_precomputed_gradients) { stan::math::recover_memory(); } -TEST_F(AgradRev, - StanAgradRevInternal_precomputed_gradients_vari_no_independent_vars) { +TEST(StanAgradRevInternal, precomputed_gradients_vari_no_independent_vars) { double value = 1; std::vector vars; std::vector gradients; @@ -44,8 +42,7 @@ TEST_F(AgradRev, EXPECT_NO_THROW(vi.chain()); } -TEST_F(AgradRev, - StanAgradRevInternal_precomputed_gradients_vari_mismatched_sizes) { +TEST(StanAgradRevInternal, precomputed_gradients_vari_mismatched_sizes) { double value; std::vector vars; std::vector gradients; @@ -57,7 +54,7 @@ TEST_F(AgradRev, std::invalid_argument); } -TEST_F(AgradRev, StanAgradRevInternal_precomputed_gradients_vari) { +TEST(StanAgradRevInternal, precomputed_gradients_vari) { double value = 1; std::vector vars; stan::math::var x1(2), x2(3); @@ -88,7 +85,7 @@ TEST_F(AgradRev, StanAgradRevInternal_precomputed_gradients_vari) { EXPECT_FLOAT_EQ(gradients[1], x2.vi_->adj_); } -TEST_F(AgradRev, StanAgradRevInternal_precomputed_gradients_mismatched_sizes) { +TEST(StanAgradRevInternal, precomputed_gradients_mismatched_sizes) { double value; std::vector vars; std::vector gradients; @@ -105,7 +102,7 @@ TEST_F(AgradRev, StanAgradRevInternal_precomputed_gradients_mismatched_sizes) { stan::math::recover_memory(); } -TEST_F(AgradRev, StanAgradRevInternal_precomputed_gradients_containers) { +TEST(StanAgradRevInternal, precomputed_gradients_containers) { double value = 1; std::vector vars; std::vector gradients; @@ -163,8 +160,7 @@ TEST(StanAgradRevInternal, stan::math::recover_memory(); } -TEST_F(AgradRev, - StanAgradRevInternal_precomputed_gradients_mismatched_containers) { +TEST(StanAgradRevInternal, precomputed_gradients_mismatched_containers) { double value = 1; std::vector vars; std::vector gradients; diff --git a/test/unit/math/rev/core/profiling_test.cpp b/test/unit/math/rev/core/profiling_test.cpp index 32bfe57e4fe..a8d2ed4fe7c 100644 --- a/test/unit/math/rev/core/profiling_test.cpp +++ b/test/unit/math/rev/core/profiling_test.cpp @@ -1,10 +1,9 @@ #include -#include #include #include #include -TEST_F(AgradRev, Profiling_double_basic) { +TEST(Profiling, double_basic) { using stan::math::profile; using stan::math::var; stan::math::profile_map prof_map; @@ -34,7 +33,7 @@ TEST_F(AgradRev, Profiling_double_basic) { EXPECT_TRUE(prof_map[key].get_fwd_time() > 0.0); } -TEST_F(AgradRev, Profiling_var_basic) { +TEST(Profiling, var_basic) { using stan::math::profile; using stan::math::var; stan::math::profile_map profiles; @@ -60,7 +59,7 @@ TEST_F(AgradRev, Profiling_var_basic) { EXPECT_TRUE(profiles[key].get_rev_time() > 0.0); } -TEST_F(AgradRev, Profiling_var_exception) { +TEST(Profiling, var_exception) { using stan::math::profile; using stan::math::var; stan::math::profile_map profiles; @@ -90,7 +89,7 @@ TEST_F(AgradRev, Profiling_var_exception) { EXPECT_TRUE(profiles[key_t1].get_rev_time() == 0.0); } -TEST_F(AgradRev, Profiling_var_loop) { +TEST(Profiling, var_loop) { using stan::math::profile; using stan::math::var; stan::math::profile_map profiles; @@ -118,7 +117,7 @@ TEST_F(AgradRev, Profiling_var_loop) { EXPECT_TRUE(profiles[key_t1].get_rev_time() > 0.0); } -TEST_F(AgradRev, Profiling_duplicate_active_profile) { +TEST(Profiling, duplicate_active_profile) { using stan::math::profile; using stan::math::var; stan::math::profile_map profiles; diff --git a/test/unit/math/rev/core/profiling_threading_test.cpp b/test/unit/math/rev/core/profiling_threading_test.cpp index b3c2c78fa2b..e139a735264 100644 --- a/test/unit/math/rev/core/profiling_threading_test.cpp +++ b/test/unit/math/rev/core/profiling_threading_test.cpp @@ -1,6 +1,5 @@ #ifdef STAN_THREADS #include -#include #include #include #include @@ -27,7 +26,7 @@ struct grouped_count_lpdf { }; } // namespace profiling_test -TEST_F(AgradRev, Profiling_profile_threading) { +TEST(Profiling, profile_threading) { using stan::math::var; using stan::math::test::get_new_msg; double lambda_d = 10.0; diff --git a/test/unit/math/rev/core/reverse_pass_callback_test.cpp b/test/unit/math/rev/core/reverse_pass_callback_test.cpp index a91317d7f2c..cdb7f200fe1 100644 --- a/test/unit/math/rev/core/reverse_pass_callback_test.cpp +++ b/test/unit/math/rev/core/reverse_pass_callback_test.cpp @@ -1,8 +1,7 @@ #include -#include #include -TEST_F(AgradRev, Rev_reverse_pass_callback_test) { +TEST(AgradRev, reverse_pass_callback_test) { stan::math::var a = 1; stan::math::var b = 1; diff --git a/test/unit/math/rev/core/save_varis_test.cpp b/test/unit/math/rev/core/save_varis_test.cpp index 5f8a69ce0d9..1d737f94562 100644 --- a/test/unit/math/rev/core/save_varis_test.cpp +++ b/test/unit/math/rev/core/save_varis_test.cpp @@ -1,12 +1,11 @@ #include -#include #include #include using stan::math::var; using stan::math::vari; -TEST_F(AgradRev, Rev_save_varis_zero_args) { +TEST(AgradRev_save_varis, zero_args) { std::vector storage(1000, nullptr); vari** ptr = stan::math::save_varis(storage.data()); @@ -17,7 +16,7 @@ TEST_F(AgradRev, Rev_save_varis_zero_args) { stan::math::recover_memory(); } -TEST_F(AgradRev, Rev_save_varis_int_arg) { +TEST(AgradRev_save_varis, int_arg) { int arg = 5; std::vector storage(1000, nullptr); @@ -30,7 +29,7 @@ TEST_F(AgradRev, Rev_save_varis_int_arg) { stan::math::recover_memory(); } -TEST_F(AgradRev, Rev_save_varis_double_arg) { +TEST(AgradRev_save_varis, double_arg) { double arg = 5.0; std::vector storage(1000, nullptr); @@ -42,7 +41,7 @@ TEST_F(AgradRev, Rev_save_varis_double_arg) { EXPECT_EQ(ptr, storage.data()); } -TEST_F(AgradRev, Rev_save_varis_std_vector_int_arg) { +TEST(AgradRev_save_varis, std_vector_int_arg) { std::vector arg(5, 10); std::vector storage(1000, nullptr); @@ -54,7 +53,7 @@ TEST_F(AgradRev, Rev_save_varis_std_vector_int_arg) { EXPECT_EQ(ptr, storage.data()); } -TEST_F(AgradRev, Rev_save_varis_std_vector_double_arg) { +TEST(AgradRev_save_varis, std_vector_double_arg) { std::vector arg(5, 10.0); std::vector storage(1000, nullptr); @@ -66,7 +65,7 @@ TEST_F(AgradRev, Rev_save_varis_std_vector_double_arg) { EXPECT_EQ(ptr, storage.data()); } -TEST_F(AgradRev, Rev_save_varis_eigen_vector_arg) { +TEST(AgradRev_save_varis, eigen_vector_arg) { Eigen::VectorXd arg = Eigen::VectorXd::Ones(5); std::vector storage(1000, nullptr); @@ -78,7 +77,7 @@ TEST_F(AgradRev, Rev_save_varis_eigen_vector_arg) { EXPECT_EQ(ptr, storage.data()); } -TEST_F(AgradRev, Rev_save_varis_eigen_row_vector_arg) { +TEST(AgradRev_save_varis, eigen_row_vector_arg) { Eigen::RowVectorXd arg = Eigen::RowVectorXd::Ones(5); std::vector storage(1000, nullptr); @@ -90,7 +89,7 @@ TEST_F(AgradRev, Rev_save_varis_eigen_row_vector_arg) { EXPECT_EQ(ptr, storage.data()); } -TEST_F(AgradRev, Rev_save_varis_eigen_matrix_arg) { +TEST(AgradRev_save_varis, eigen_matrix_arg) { Eigen::MatrixXd arg = Eigen::MatrixXd::Ones(5, 5); std::vector storage(1000, nullptr); @@ -102,7 +101,7 @@ TEST_F(AgradRev, Rev_save_varis_eigen_matrix_arg) { EXPECT_EQ(ptr, storage.data()); } -TEST_F(AgradRev, Rev_save_varis_std_vector_std_vector_double_arg) { +TEST(AgradRev_save_varis, std_vector_std_vector_double_arg) { std::vector> arg(5, std::vector(5, 10.0)); std::vector storage(1000, nullptr); @@ -114,7 +113,7 @@ TEST_F(AgradRev, Rev_save_varis_std_vector_std_vector_double_arg) { EXPECT_EQ(ptr, storage.data()); } -TEST_F(AgradRev, Rev_save_varis_std_vector_eigen_vector_arg) { +TEST(AgradRev_save_varis, std_vector_eigen_vector_arg) { std::vector arg(2, Eigen::VectorXd::Ones(5)); std::vector storage(1000, nullptr); @@ -126,7 +125,7 @@ TEST_F(AgradRev, Rev_save_varis_std_vector_eigen_vector_arg) { EXPECT_EQ(ptr, storage.data()); } -TEST_F(AgradRev, Rev_save_varis_std_vector_eigen_row_vector_arg) { +TEST(AgradRev_save_varis, std_vector_eigen_row_vector_arg) { std::vector arg(2, Eigen::VectorXd::Ones(5)); std::vector storage(1000, nullptr); @@ -138,7 +137,7 @@ TEST_F(AgradRev, Rev_save_varis_std_vector_eigen_row_vector_arg) { EXPECT_EQ(ptr, storage.data()); } -TEST_F(AgradRev, Rev_save_varis_std_vector_eigen_matrix_arg) { +TEST(AgradRev_save_varis, std_vector_eigen_matrix_arg) { std::vector arg(2, Eigen::MatrixXd::Ones(5, 3)); std::vector storage(1000, nullptr); @@ -150,7 +149,7 @@ TEST_F(AgradRev, Rev_save_varis_std_vector_eigen_matrix_arg) { EXPECT_EQ(ptr, storage.data()); } -TEST_F(AgradRev, Rev_save_varis_var_arg) { +TEST(AgradRev_save_varis, var_arg) { var arg(5.0); std::vector storage(1000, nullptr); @@ -166,7 +165,7 @@ TEST_F(AgradRev, Rev_save_varis_var_arg) { EXPECT_EQ(ptr, storage.data() + num_vars); } -TEST_F(AgradRev, Rev_save_varis_std_vector_var_arg) { +TEST(AgradRev_save_varis, std_vector_var_arg) { std::vector arg(5); for (size_t i = 0; i < arg.size(); ++i) arg[i] = 5.0; @@ -184,7 +183,7 @@ TEST_F(AgradRev, Rev_save_varis_std_vector_var_arg) { EXPECT_EQ(ptr, storage.data() + num_vars); } -TEST_F(AgradRev, Rev_save_varis_eigen_vector_var_arg) { +TEST(AgradRev_save_varis, eigen_vector_var_arg) { Eigen::Matrix arg(5); for (size_t i = 0; i < arg.size(); ++i) { arg(i) = 5.0; @@ -204,7 +203,7 @@ TEST_F(AgradRev, Rev_save_varis_eigen_vector_var_arg) { EXPECT_EQ(ptr, storage.data() + num_vars); } -TEST_F(AgradRev, Rev_save_varis_eigen_row_vector_var_arg) { +TEST(AgradRev_save_varis, eigen_row_vector_var_arg) { Eigen::Matrix arg(5); for (size_t i = 0; i < arg.size(); ++i) { arg(i) = 5.0; @@ -224,7 +223,7 @@ TEST_F(AgradRev, Rev_save_varis_eigen_row_vector_var_arg) { EXPECT_EQ(ptr, storage.data() + num_vars); } -TEST_F(AgradRev, Rev_save_varis_eigen_matrix_var_arg) { +TEST(AgradRev_save_varis, eigen_matrix_var_arg) { Eigen::Matrix arg(5, 5); for (size_t i = 0; i < arg.size(); ++i) { arg(i) = 5.0; @@ -244,7 +243,7 @@ TEST_F(AgradRev, Rev_save_varis_eigen_matrix_var_arg) { EXPECT_EQ(ptr, storage.data() + num_vars); } -TEST_F(AgradRev, Rev_save_varis_std_vector_std_vector_var_arg) { +TEST(AgradRev_save_varis, std_vector_std_vector_var_arg) { std::vector arg_(5); std::vector> arg(5, arg_); for (size_t i = 0; i < arg.size(); ++i) @@ -266,7 +265,7 @@ TEST_F(AgradRev, Rev_save_varis_std_vector_std_vector_var_arg) { EXPECT_EQ(ptr, storage.data() + num_vars); } -TEST_F(AgradRev, Rev_save_varis_std_vector_eigen_vector_var_arg) { +TEST(AgradRev_save_varis, std_vector_eigen_vector_var_arg) { Eigen::Matrix arg_(5); std::vector> arg(2, arg_); for (size_t i = 0; i < arg.size(); ++i) @@ -288,7 +287,7 @@ TEST_F(AgradRev, Rev_save_varis_std_vector_eigen_vector_var_arg) { EXPECT_EQ(ptr, storage.data() + num_vars); } -TEST_F(AgradRev, Rev_save_varis_std_vector_eigen_row_vector_var_arg) { +TEST(AgradRev_save_varis, std_vector_eigen_row_vector_var_arg) { Eigen::Matrix arg_(5); std::vector> arg(2, arg_); for (size_t i = 0; i < arg.size(); ++i) @@ -310,7 +309,7 @@ TEST_F(AgradRev, Rev_save_varis_std_vector_eigen_row_vector_var_arg) { EXPECT_EQ(ptr, storage.data() + num_vars); } -TEST_F(AgradRev, Rev_save_varis_std_vector_eigen_matrix_var_arg) { +TEST(AgradRev_save_varis, std_vector_eigen_matrix_var_arg) { Eigen::Matrix arg_(5, 3); std::vector> arg(2, arg_); for (size_t i = 0; i < arg.size(); ++i) @@ -332,7 +331,7 @@ TEST_F(AgradRev, Rev_save_varis_std_vector_eigen_matrix_var_arg) { EXPECT_EQ(ptr, storage.data() + num_vars); } -TEST_F(AgradRev, Rev_save_varis_sum) { +TEST(AgradRev_save_varis, sum) { int arg1 = 1; double arg2 = 1.0; std::vector arg3(5, 1); diff --git a/test/unit/math/rev/core/scalar_type_t_test.cpp b/test/unit/math/rev/core/scalar_type_t_test.cpp index ac105d0865d..607505acb7d 100644 --- a/test/unit/math/rev/core/scalar_type_t_test.cpp +++ b/test/unit/math/rev/core/scalar_type_t_test.cpp @@ -1,10 +1,9 @@ #include -#include #include #include #include -TEST_F(AgradRev, RevScalar_scalar_type_t_var_value) { +TEST(AgradRevScalar, scalar_type_t_var_value) { EXPECT_TRUE( (std::is_same< stan::math::var, diff --git a/test/unit/math/rev/core/scoped_chainablestack_test.cpp b/test/unit/math/rev/core/scoped_chainablestack_test.cpp index c62a8d2d4ae..263d64f8eb1 100644 --- a/test/unit/math/rev/core/scoped_chainablestack_test.cpp +++ b/test/unit/math/rev/core/scoped_chainablestack_test.cpp @@ -1,6 +1,5 @@ #include #include -#include #include #include #include diff --git a/test/unit/math/rev/core/set_zero_all_adjoints_nested_test.cpp b/test/unit/math/rev/core/set_zero_all_adjoints_nested_test.cpp index 4070dbe11e1..d516325ef1d 100644 --- a/test/unit/math/rev/core/set_zero_all_adjoints_nested_test.cpp +++ b/test/unit/math/rev/core/set_zero_all_adjoints_nested_test.cpp @@ -1,9 +1,8 @@ #include -#include #include #include -TEST_F(AgradRev, RevZeroNested_set_zero_all_adjoints_nested_outside) { +TEST(AgradRevZeroNested, set_zero_all_adjoints_nested_outside) { stan::math::var chaining = new stan::math::vari(1.0, true); chaining.adj() = 2.0; @@ -21,5 +20,4 @@ TEST_F(AgradRev, RevZeroNested_set_zero_all_adjoints_nested_outside) { EXPECT_FLOAT_EQ(non_chaining.adj(), 2.0); stan::math::set_zero_all_adjoints_nested(); EXPECT_FLOAT_EQ(non_chaining.adj(), 2.0); - stan::math::recover_memory_nested(); } diff --git a/test/unit/math/rev/core/std_iterator_traits_test.cpp b/test/unit/math/rev/core/std_iterator_traits_test.cpp index 8a0c05fcb73..1f7cdd2c15a 100644 --- a/test/unit/math/rev/core/std_iterator_traits_test.cpp +++ b/test/unit/math/rev/core/std_iterator_traits_test.cpp @@ -1,8 +1,7 @@ #include -#include #include -TEST_F(AgradRev, revCore_stdIteratorTraits) { +TEST(revCore, stdIteratorTraits) { using stan::math::var; using traits = std::iterator_traits; var a; 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 a458cc37485..389c8129cb8 100644 --- a/test/unit/math/rev/core/thread_stack_instance_test.cpp +++ b/test/unit/math/rev/core/thread_stack_instance_test.cpp @@ -1,11 +1,9 @@ #include #include -#include -#include #include -TEST_F(AgradRev, thread_stack_instance_initialize) { +TEST(thread_stack_instance, initialize) { using stan::math::ChainableStack; // the main thread must be initialized by the time this code is @@ -33,7 +31,7 @@ TEST_F(AgradRev, thread_stack_instance_initialize) { } // tear down in a thread the stack and refresh it -TEST_F(AgradRev, thread_stack_instance_repeated_initialize) { +TEST(thread_stack_instance, repeated_initialize) { using stan::math::ChainableStack; // the main thread must be initialized by the time this code is @@ -81,7 +79,7 @@ TEST_F(AgradRev, thread_stack_instance_repeated_initialize) { other_work.join(); } -TEST_F(AgradRev, thread_stack_instance_child_instances) { +TEST(thread_stack_instance, child_instances) { using stan::math::ChainableStack; // place a var on the stack such that a fresh stack in another // thread will be different at initialization (if STAN_THREADS is @@ -112,7 +110,7 @@ TEST_F(AgradRev, thread_stack_instance_child_instances) { other_work.join(); } -TEST_F(AgradRev, thread_stack_instance_persistence) { +TEST(thread_stack_instance, persistence) { using stan::math::ChainableStack; ChainableStack::AutodiffStackStorage* main_ad_stack diff --git a/test/unit/math/rev/core/var_stack_test.cpp b/test/unit/math/rev/core/var_stack_test.cpp index 72bc2abe89c..b310e6711cb 100644 --- a/test/unit/math/rev/core/var_stack_test.cpp +++ b/test/unit/math/rev/core/var_stack_test.cpp @@ -1,6 +1,5 @@ #include #include -#include #include #include @@ -11,7 +10,7 @@ struct foo : public stan::math::chainable_alloc { void chain() {} }; -TEST_F(AgradRev, RevStack_varStackRecoverNestedSegFaultFix) { +TEST(AgradRevStack, varStackRecoverNestedSegFaultFix) { // this test failed in 2.5, but passes in 2.6 stan::math::start_nested(); foo* x = new foo(); @@ -22,7 +21,7 @@ TEST_F(AgradRev, RevStack_varStackRecoverNestedSegFaultFix) { } // just test basic autodiff; no more free_memory operation -TEST_F(AgradRev, RevStack_varStack) { +TEST(AgradRevStack, varStack) { stan::math::var a = 2.0; stan::math::var b = -3.0; stan::math::var f = a * b; @@ -46,13 +45,13 @@ TEST_F(AgradRev, RevStack_varStack) { EXPECT_FLOAT_EQ(2.0, grad_ff[1]); } -TEST_F(AgradRev, RevStack_recoverMemoryLogicError) { +TEST(AgradRevStack, recoverMemoryLogicError) { stan::math::start_nested(); EXPECT_THROW(stan::math::recover_memory(), std::logic_error); // clean up for next test stan::math::recover_memory_nested(); } -TEST_F(AgradRev, RevStack_recoverMemoryNestedLogicError) { +TEST(AgradRevStack, recoverMemoryNestedLogicError) { EXPECT_THROW(stan::math::recover_memory_nested(), std::logic_error); } diff --git a/test/unit/math/rev/core/var_test.cpp b/test/unit/math/rev/core/var_test.cpp index 01a27cead04..a2ca9a36d64 100644 --- a/test/unit/math/rev/core/var_test.cpp +++ b/test/unit/math/rev/core/var_test.cpp @@ -12,7 +12,7 @@ namespace stan { namespace test { template -inline void ctor_overloads_float_impl() { +void ctor_overloads_float_impl() { using stan::math::var_value; using stan::math::vari_value; using stan::math::test::type_name; @@ -36,7 +36,7 @@ inline void ctor_overloads_float_impl() { } template -inline void ctor_overloads_float() { +void ctor_overloads_float() { ctor_overloads_float_impl(); ctor_overloads_float_impl(); ctor_overloads_float_impl(); @@ -54,7 +54,7 @@ inline void ctor_overloads_float() { } template -inline void ctor_overloads_matrix(EigenMat&& xx) { +void ctor_overloads_matrix(EigenMat&& xx) { using stan::math::var_value; using stan::math::vari_value; using stan::math::test::type_name; @@ -77,7 +77,7 @@ inline void ctor_overloads_matrix(EigenMat&& xx) { } template -inline void ctor_overloads_sparse_matrix(EigenMat&& x) { +void ctor_overloads_sparse_matrix(EigenMat&& x) { using stan::math::var_value; using stan::math::vari_value; using stan::math::test::type_name; @@ -317,7 +317,7 @@ TEST_F(AgradRev, var_matrix_views_const) { } template -inline void var_vector_views_test() { +void var_vector_views_test() { using stan::math::var_value; dense_vec A(10); for (Eigen::Index i = 0; i < A.size(); ++i) { @@ -355,7 +355,7 @@ TEST_F(AgradRev, var_vector_views) { } template -inline void var_vector_views_const_test() { +void var_vector_views_const_test() { using stan::math::var_value; dense_vec A(10); for (Eigen::Index i = 0; i < A.size(); ++i) { diff --git a/test/unit/math/rev/core/vari_test.cpp b/test/unit/math/rev/core/vari_test.cpp index 55860ffd9b8..a45e731b4ac 100644 --- a/test/unit/math/rev/core/vari_test.cpp +++ b/test/unit/math/rev/core/vari_test.cpp @@ -1,25 +1,23 @@ #include #include -#include -#include #include #include -TEST_F(AgradRev, RevVari_insertion_operator) { +TEST(AgradRevVari, insertion_operator) { stan::math::vari v(5); std::stringstream ss; ss << &v; EXPECT_EQ("5:0", ss.str()); } -TEST_F(AgradRev, RevVari_long_double_test) { +TEST(AgradRevVari, long_double_test) { stan::math::vari_value v(5); std::stringstream ss; ss << &v; EXPECT_EQ("5:0", ss.str()); } -TEST_F(AgradRev, RevVari_dense_matrix_vari) { +TEST(AgradRevVari, dense_matrix_vari) { using stan::math::vari_value; using eig_mat = Eigen::MatrixXd; vari_value A_vari(eig_mat::Random(3, 3)); @@ -27,7 +25,7 @@ TEST_F(AgradRev, RevVari_dense_matrix_vari) { vari_value B_vari(B); EXPECT_MATRIX_FLOAT_EQ(B, B_vari.val()); } -TEST_F(AgradRev, RevVari_dense_vector_vari) { +TEST(AgradRevVari, dense_vector_vari) { using stan::math::vari_value; using eig_vec = Eigen::Matrix; vari_value A_vari(eig_vec::Random(3)); @@ -36,7 +34,7 @@ TEST_F(AgradRev, RevVari_dense_vector_vari) { EXPECT_MATRIX_FLOAT_EQ(B, B_vari.val()); } -TEST_F(AgradRev, RevVari_dense_row_vector_vari) { +TEST(AgradRevVari, dense_row_vector_vari) { using stan::math::vari_value; using eig_row_vec = Eigen::Matrix; vari_value A_vari(eig_row_vec::Random(3)); @@ -45,7 +43,7 @@ TEST_F(AgradRev, RevVari_dense_row_vector_vari) { EXPECT_MATRIX_FLOAT_EQ(B, B_vari.val()); } -TEST_F(AgradRev, RevVari_sparse_matrix_vari) { +TEST(AgradRevVari, sparse_matrix_vari) { using stan::math::vari_value; using eig_mat = Eigen::SparseMatrix; using inner_iterator = typename eig_mat::InnerIterator; @@ -62,7 +60,7 @@ TEST_F(AgradRev, RevVari_sparse_matrix_vari) { } } -TEST_F(AgradRev, RevVari_arena_matrix_matrix_vari) { +TEST(AgradRevVari, arena_matrix_matrix_vari) { using stan::math::arena_matrix; using stan::math::vari_value; arena_matrix x(Eigen::MatrixXd::Random(5, 5)); @@ -84,7 +82,7 @@ TEST_F(AgradRev, RevVari_arena_matrix_matrix_vari) { EXPECT_EQ((*F).val().data(), (*F).adj().data()); } -TEST_F(AgradRev, RevVari_dense_vari_matrix_views) { +TEST(AgradRevVari, dense_vari_matrix_views) { using stan::math::vari_value; using eig_mat = Eigen::MatrixXd; eig_mat A(5, 5); @@ -129,7 +127,7 @@ TEST_F(AgradRev, RevVari_dense_vari_matrix_views) { EXPECT_MATRIX_FLOAT_EQ(A, A_v.val()); } -TEST_F(AgradRev, RevVari_dense_vari_vector_views) { +TEST(AgradRevVari, dense_vari_vector_views) { using stan::math::vari_value; using eig_vec = Eigen::VectorXd; eig_vec A(10); @@ -162,7 +160,7 @@ TEST_F(AgradRev, RevVari_dense_vari_vector_views) { EXPECT_MATRIX_FLOAT_EQ(A_segment.adj(), A_v.adj().segment(3, 5)); } -TEST_F(AgradRev, RevVari_dense_vari_row_vector_views) { +TEST(AgradRevVari, dense_vari_row_vector_views) { using stan::math::vari_value; using eig_vec = Eigen::RowVectorXd; eig_vec A(10); diff --git a/test/unit/math/rev/core/zero_adjoints_test.cpp b/test/unit/math/rev/core/zero_adjoints_test.cpp index bbc1c72cd1c..f04566fd55b 100644 --- a/test/unit/math/rev/core/zero_adjoints_test.cpp +++ b/test/unit/math/rev/core/zero_adjoints_test.cpp @@ -1,12 +1,11 @@ #include #include -#include #include #include #include #include -TEST_F(AgradRev, RevZero_zero_arithmetic) { +TEST(AgradRevZero, zero_arithmetic) { int a = 1.0; double b = 2; std::vector va(5, a); @@ -37,7 +36,7 @@ TEST_F(AgradRev, RevZero_zero_arithmetic) { std::forward_as_tuple(a, b, va, vb, c, d, e, vva, vvb, vc, vd, ve)); } -TEST_F(AgradRev, RevZero_zero_var) { +TEST(AgradRevZero, zero_var) { using stan::math::var; using stan::math::vari; @@ -50,7 +49,7 @@ TEST_F(AgradRev, RevZero_zero_var) { stan::math::recover_memory(); } -TEST_F(AgradRev, RevZero_zero_std_vector_var) { +TEST(AgradRevZero, zero_std_vector_var) { using stan::math::var; using stan::math::vari; @@ -65,7 +64,7 @@ TEST_F(AgradRev, RevZero_zero_std_vector_var) { stan::math::recover_memory(); } -TEST_F(AgradRev, RevZero_zero_vector_var) { +TEST(AgradRevZero, zero_vector_var) { using stan::math::var; using stan::math::vari; @@ -81,7 +80,7 @@ TEST_F(AgradRev, RevZero_zero_vector_var) { stan::math::recover_memory(); } -TEST_F(AgradRev, RevZero_zero_row_vector_var) { +TEST(AgradRevZero, zero_row_vector_var) { using stan::math::var; using stan::math::vari; @@ -97,7 +96,7 @@ TEST_F(AgradRev, RevZero_zero_row_vector_var) { stan::math::recover_memory(); } -TEST_F(AgradRev, RevZero_zero_matrix_var) { +TEST(AgradRevZero, zero_matrix_var) { using stan::math::var; using stan::math::vari; @@ -113,7 +112,7 @@ TEST_F(AgradRev, RevZero_zero_matrix_var) { stan::math::recover_memory(); } -TEST_F(AgradRev, RevZero_zero_std_vector_std_vector_var) { +TEST(AgradRevZero, zero_std_vector_std_vector_var) { using stan::math::var; using stan::math::vari; @@ -133,7 +132,7 @@ TEST_F(AgradRev, RevZero_zero_std_vector_std_vector_var) { stan::math::recover_memory(); } -TEST_F(AgradRev, RevZero_zero_std_vector_vector_var) { +TEST(AgradRevZero, zero_std_vector_vector_var) { using stan::math::var; using stan::math::vari; @@ -156,7 +155,7 @@ TEST_F(AgradRev, RevZero_zero_std_vector_vector_var) { stan::math::recover_memory(); } -TEST_F(AgradRev, RevZero_zero_std_vector_row_vector_var) { +TEST(AgradRevZero, zero_std_vector_row_vector_var) { using stan::math::var; using stan::math::vari; @@ -179,7 +178,7 @@ TEST_F(AgradRev, RevZero_zero_std_vector_row_vector_var) { stan::math::recover_memory(); } -TEST_F(AgradRev, RevZero_zero_std_vector_matrix_var) { +TEST(AgradRevZero, zero_std_vector_matrix_var) { using stan::math::var; using stan::math::vari; @@ -203,7 +202,7 @@ TEST_F(AgradRev, RevZero_zero_std_vector_matrix_var) { stan::math::recover_memory(); } -TEST_F(AgradRev, RevZero_zero_multi) { +TEST(AgradRevZero, zero_multi) { using stan::math::var; using stan::math::vari; diff --git a/test/unit/math/rev/eigen_plugins_test.cpp b/test/unit/math/rev/eigen_plugins_test.cpp index 47d57ede601..b7c67917fd7 100644 --- a/test/unit/math/rev/eigen_plugins_test.cpp +++ b/test/unit/math/rev/eigen_plugins_test.cpp @@ -1,9 +1,8 @@ #include -#include #include #include -TEST_F(AgradRev, RevMatrixAddons_var_matrix) { +TEST(AgradRevMatrixAddons, var_matrix) { using Eigen::MatrixXd; using stan::math::matrix_v; using stan::math::matrix_vi; @@ -50,7 +49,7 @@ TEST_F(AgradRev, RevMatrixAddons_var_matrix) { EXPECT_EQ(mat_vi.adj().cols(), derivs.cols()); } -TEST_F(AgradRev, RevMatrixAddons_var_vector) { +TEST(AgradRevMatrixAddons, var_vector) { using Eigen::VectorXd; using stan::math::vector_v; using stan::math::vector_vi; @@ -90,7 +89,7 @@ TEST_F(AgradRev, RevMatrixAddons_var_vector) { EXPECT_EQ(vec_vi.adj().cols(), derivs.cols()); } -TEST_F(AgradRev, RevMatrixAddons_var_row_vector) { +TEST(AgradRevMatrixAddons, var_row_vector) { using Eigen::RowVectorXd; using stan::math::row_vector_v; using stan::math::row_vector_vi; diff --git a/test/unit/math/rev/err/check_bounded_test.cpp b/test/unit/math/rev/err/check_bounded_test.cpp index 6418d8c7173..3f3e00455ce 100644 --- a/test/unit/math/rev/err/check_bounded_test.cpp +++ b/test/unit/math/rev/err/check_bounded_test.cpp @@ -1,10 +1,9 @@ #include -#include #include #include #include -TEST_F(AgradRev, RevErrorHandlingScalar_CheckBoundedVarCheckVectorized) { +TEST(AgradRevErrorHandlingScalar, CheckBoundedVarCheckVectorized) { using stan::math::check_bounded; using stan::math::var; using std::vector; @@ -30,7 +29,7 @@ TEST_F(AgradRev, RevErrorHandlingScalar_CheckBoundedVarCheckVectorized) { stan::math::recover_memory(); } -TEST_F(AgradRev, RevErrorHandlingScalar_CheckBounded_X) { +TEST(AgradRevErrorHandlingScalar, CheckBounded_X) { using stan::math::check_bounded; using stan::math::var; @@ -81,7 +80,7 @@ TEST_F(AgradRev, RevErrorHandlingScalar_CheckBounded_X) { stan::math::recover_memory(); } -TEST_F(AgradRev, RevErrorHandlingScalar_CheckBounded_Low) { +TEST(AgradRevErrorHandlingScalar, CheckBounded_Low) { using stan::math::check_bounded; using stan::math::var; @@ -111,7 +110,7 @@ TEST_F(AgradRev, RevErrorHandlingScalar_CheckBounded_Low) { << ", " << high; stan::math::recover_memory(); } -TEST_F(AgradRev, RevErrorHandlingScalar_CheckBounded_High) { +TEST(AgradRevErrorHandlingScalar, CheckBounded_High) { using stan::math::check_bounded; using stan::math::var; @@ -142,7 +141,7 @@ TEST_F(AgradRev, RevErrorHandlingScalar_CheckBounded_High) { stan::math::recover_memory(); } -TEST_F(AgradRev, RevErrorHandlingScalar_CheckBoundedVarCheckUnivariate) { +TEST(AgradRevErrorHandlingScalar, CheckBoundedVarCheckUnivariate) { using stan::math::check_bounded; using stan::math::var; diff --git a/test/unit/math/rev/err/check_consistent_size_test.cpp b/test/unit/math/rev/err/check_consistent_size_test.cpp index 69f5031023e..dabf63fdb3b 100644 --- a/test/unit/math/rev/err/check_consistent_size_test.cpp +++ b/test/unit/math/rev/err/check_consistent_size_test.cpp @@ -1,10 +1,9 @@ #include -#include #include #include #include -TEST_F(AgradRev, RevErrorHandlingScalar_CheckConsistentSizeVarCheckVectorized) { +TEST(AgradRevErrorHandlingScalar, CheckConsistentSizeVarCheckVectorized) { using stan::math::check_consistent_size; using stan::math::var; using std::vector; @@ -30,7 +29,7 @@ TEST_F(AgradRev, RevErrorHandlingScalar_CheckConsistentSizeVarCheckVectorized) { stan::math::recover_memory(); } -TEST_F(AgradRev, RevErrorHandlingMatrix_checkConsistentSize) { +TEST(AgradRevErrorHandlingMatrix, checkConsistentSize) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::check_consistent_size; @@ -49,7 +48,7 @@ TEST_F(AgradRev, RevErrorHandlingMatrix_checkConsistentSize) { stan::math::recover_memory(); } -TEST_F(AgradRev, RevErrorHandlingMatrix_checkConsistentSize_nan) { +TEST(AgradRevErrorHandlingMatrix, checkConsistentSize_nan) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::check_consistent_size; diff --git a/test/unit/math/rev/err/check_consistent_sizes_test.cpp b/test/unit/math/rev/err/check_consistent_sizes_test.cpp index ec32901d2b7..26c87d413fa 100644 --- a/test/unit/math/rev/err/check_consistent_sizes_test.cpp +++ b/test/unit/math/rev/err/check_consistent_sizes_test.cpp @@ -1,10 +1,8 @@ #include -#include #include #include -TEST_F(AgradRev, - RevErrorHandlingScalar_CheckConsistentSizesVarCheckVectorized) { +TEST(AgradRevErrorHandlingScalar, CheckConsistentSizesVarCheckVectorized) { using stan::math::check_consistent_sizes; using stan::math::var; using std::vector; @@ -33,7 +31,7 @@ TEST_F(AgradRev, stan::math::recover_memory(); } -TEST_F(AgradRev, RevErrorHandlingMatrix_checkConsistentSizes) { +TEST(AgradRevErrorHandlingMatrix, checkConsistentSizes) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::check_consistent_sizes; diff --git a/test/unit/math/rev/err/check_finite_test.cpp b/test/unit/math/rev/err/check_finite_test.cpp index a622881b52d..99a5ad41bd7 100644 --- a/test/unit/math/rev/err/check_finite_test.cpp +++ b/test/unit/math/rev/err/check_finite_test.cpp @@ -1,10 +1,9 @@ #include -#include #include #include #include -TEST_F(AgradRev, RevErrorHandlingScalar_CheckFiniteVarCheckVectorized) { +TEST(AgradRevErrorHandlingScalar, CheckFiniteVarCheckVectorized) { using stan::math::check_finite; using stan::math::var; using std::vector; @@ -38,7 +37,7 @@ TEST_F(AgradRev, RevErrorHandlingScalar_CheckFiniteVarCheckVectorized) { stan::math::recover_memory(); } -TEST_F(AgradRev, RevErrorHandlingScalar_CheckFinite) { +TEST(AgradRevErrorHandlingScalar, CheckFinite) { using stan::math::check_finite; using stan::math::var; @@ -63,7 +62,7 @@ TEST_F(AgradRev, RevErrorHandlingScalar_CheckFinite) { stan::math::recover_memory(); } -TEST_F(AgradRev, RevErrorHandlingScalar_CheckFiniteVarCheckUnivariate) { +TEST(AgradRevErrorHandlingScalar, CheckFiniteVarCheckUnivariate) { using stan::math::check_finite; using stan::math::var; diff --git a/test/unit/math/rev/err/check_greater_or_equal_test.cpp b/test/unit/math/rev/err/check_greater_or_equal_test.cpp index 36446a1f737..ef3780eaa4b 100644 --- a/test/unit/math/rev/err/check_greater_or_equal_test.cpp +++ b/test/unit/math/rev/err/check_greater_or_equal_test.cpp @@ -1,10 +1,9 @@ #include -#include #include #include #include -TEST_F(AgradRev, RevErrorHandlingScalar_CheckGreateOrEqualVarCheckVectorized) { +TEST(AgradRevErrorHandlingScalar, CheckGreateOrEqualVarCheckVectorized) { using stan::math::check_greater_or_equal; using stan::math::var; using std::vector; @@ -38,7 +37,7 @@ TEST_F(AgradRev, RevErrorHandlingScalar_CheckGreateOrEqualVarCheckVectorized) { stan::math::recover_memory(); } -TEST_F(AgradRev, RevErrorHandlingMatrix_CheckGreaterOrEqualMatrix) { +TEST(AgradRevErrorHandlingMatrix, CheckGreaterOrEqualMatrix) { using stan::math::check_greater_or_equal; using stan::math::var; const char* function = "check_greater_or_equal"; @@ -155,7 +154,7 @@ TEST_F(AgradRev, RevErrorHandlingMatrix_CheckGreaterOrEqualMatrix) { stan::math::recover_memory(); } -TEST_F(AgradRev, RevErrorHandlingScalar_CheckGreaterOrEqual) { +TEST(AgradRevErrorHandlingScalar, CheckGreaterOrEqual) { using stan::math::check_greater_or_equal; using stan::math::var; const char* function = "check_greater_or_equal"; @@ -190,7 +189,7 @@ TEST_F(AgradRev, RevErrorHandlingScalar_CheckGreaterOrEqual) { stan::math::recover_memory(); } -TEST_F(AgradRev, RevErrorHandlingScalar_CheckGreaterOrEqualVarCheckUnivariate) { +TEST(AgradRevErrorHandlingScalar, CheckGreaterOrEqualVarCheckUnivariate) { using stan::math::check_greater_or_equal; using stan::math::var; @@ -219,7 +218,7 @@ TEST_F(AgradRev, RevErrorHandlingScalar_CheckGreaterOrEqualVarCheckUnivariate) { stan::math::recover_memory(); } -TEST_F(AgradRev, RevErrorHandlingMatrix_CheckGreaterOrEqualVarMatrix) { +TEST(AgradRevErrorHandlingMatrix, CheckGreaterOrEqualVarMatrix) { using stan::math::check_greater_or_equal; using stan::math::var; using stan::math::var_value; @@ -364,7 +363,7 @@ TEST_F(AgradRev, RevErrorHandlingMatrix_CheckGreaterOrEqualVarMatrix) { stan::math::recover_memory(); } -TEST_F(AgradRev, RevErrorHandlingMatrix_CheckGreaterOrEqualStdVecVarMatrix) { +TEST(AgradRevErrorHandlingMatrix, CheckGreaterOrEqualStdVecVarMatrix) { using stan::math::var; std::vector>>> diff --git a/test/unit/math/rev/err/check_greater_test.cpp b/test/unit/math/rev/err/check_greater_test.cpp index f8426eb018c..d5d1f77b60f 100644 --- a/test/unit/math/rev/err/check_greater_test.cpp +++ b/test/unit/math/rev/err/check_greater_test.cpp @@ -1,10 +1,9 @@ #include -#include #include #include #include -TEST_F(AgradRev, RevErrorHandlingScalar_CheckGreaterVarCheckVectorized) { +TEST(AgradRevErrorHandlingScalar, CheckGreaterVarCheckVectorized) { using stan::math::check_greater; using stan::math::var; @@ -36,7 +35,7 @@ TEST_F(AgradRev, RevErrorHandlingScalar_CheckGreaterVarCheckVectorized) { stan::math::recover_memory(); } -TEST_F(AgradRev, RevErrorHandlingMatrix_CheckGreaterMatrix) { +TEST(AgradRevErrorHandlingMatrix, CheckGreaterMatrix) { using stan::math::check_greater; using stan::math::var; @@ -145,7 +144,7 @@ TEST_F(AgradRev, RevErrorHandlingMatrix_CheckGreaterMatrix) { stan::math::recover_memory(); } -TEST_F(AgradRev, RevErrorHandlingScalar_CheckGreater) { +TEST(AgradRevErrorHandlingScalar, CheckGreater) { using stan::math::check_greater; using stan::math::var; @@ -180,7 +179,7 @@ TEST_F(AgradRev, RevErrorHandlingScalar_CheckGreater) { stan::math::recover_memory(); } -TEST_F(AgradRev, RevErrorHandlingScalar_CheckGreaterVarCheckUnivariate) { +TEST(AgradRevErrorHandlingScalar, CheckGreaterVarCheckUnivariate) { using stan::math::check_greater; using stan::math::var; @@ -208,7 +207,7 @@ TEST_F(AgradRev, RevErrorHandlingScalar_CheckGreaterVarCheckUnivariate) { stan::math::recover_memory(); } -TEST_F(AgradRev, RevErrorHandlingMatrix_CheckGreaterStdVecVarMatrix) { +TEST(AgradRevErrorHandlingMatrix, CheckGreaterStdVecVarMatrix) { using stan::math::var; std::vector>>> diff --git a/test/unit/math/rev/err/check_less_or_equal_test.cpp b/test/unit/math/rev/err/check_less_or_equal_test.cpp index 3c72534d784..f44b437552c 100644 --- a/test/unit/math/rev/err/check_less_or_equal_test.cpp +++ b/test/unit/math/rev/err/check_less_or_equal_test.cpp @@ -1,10 +1,9 @@ #include -#include #include #include #include -TEST_F(AgradRev, RevErrorHandlingScalar_CheckLessOrEqualVarCheckVectorized) { +TEST(AgradRevErrorHandlingScalar, CheckLessOrEqualVarCheckVectorized) { using stan::math::check_less_or_equal; using stan::math::var; @@ -36,7 +35,7 @@ TEST_F(AgradRev, RevErrorHandlingScalar_CheckLessOrEqualVarCheckVectorized) { stan::math::recover_memory(); } -TEST_F(AgradRev, RevErrorHandlingMatrix_CheckLessOrEqual_Matrix) { +TEST(AgradRevErrorHandlingMatrix, CheckLessOrEqual_Matrix) { using stan::math::check_less_or_equal; using stan::math::var; const char* function = "check_less_or_equal"; @@ -117,7 +116,7 @@ TEST_F(AgradRev, RevErrorHandlingMatrix_CheckLessOrEqual_Matrix) { stan::math::recover_memory(); } -TEST_F(AgradRev, RevErrorHandlingScalar_CheckLessOrEqual) { +TEST(AgradRevErrorHandlingScalar, CheckLessOrEqual) { using stan::math::check_less_or_equal; using stan::math::var; @@ -153,7 +152,7 @@ TEST_F(AgradRev, RevErrorHandlingScalar_CheckLessOrEqual) { stan::math::recover_memory(); } -TEST_F(AgradRev, RevErrorHandlingScalar_CheckLessOrEqualVarCheckUnivariate) { +TEST(AgradRevErrorHandlingScalar, CheckLessOrEqualVarCheckUnivariate) { using stan::math::check_less_or_equal; using stan::math::var; @@ -188,7 +187,7 @@ TEST_F(AgradRev, RevErrorHandlingScalar_CheckLessOrEqualVarCheckUnivariate) { stan::math::recover_memory(); } -TEST_F(AgradRev, RevErrorHandlingMatrix_CheckLessOrEqualStdVecVarMatrix) { +TEST(AgradRevErrorHandlingMatrix, CheckLessOrEqualStdVecVarMatrix) { using stan::math::var; std::vector>>> diff --git a/test/unit/math/rev/err/check_less_test.cpp b/test/unit/math/rev/err/check_less_test.cpp index 73bdeb758e5..22f4bc765c1 100644 --- a/test/unit/math/rev/err/check_less_test.cpp +++ b/test/unit/math/rev/err/check_less_test.cpp @@ -1,10 +1,9 @@ #include -#include #include #include #include -TEST_F(AgradRev, RevErrorHandlingScalar_CheckLessVarCheckVectorized) { +TEST(AgradRevErrorHandlingScalar, CheckLessVarCheckVectorized) { using stan::math::check_less; using stan::math::var; @@ -36,7 +35,7 @@ TEST_F(AgradRev, RevErrorHandlingScalar_CheckLessVarCheckVectorized) { stan::math::recover_memory(); } -TEST_F(AgradRev, RevErrorHandlingMatrix_CheckLess_Matrix) { +TEST(AgradRevErrorHandlingMatrix, CheckLess_Matrix) { using stan::math::check_less; using stan::math::var; @@ -115,7 +114,7 @@ TEST_F(AgradRev, RevErrorHandlingMatrix_CheckLess_Matrix) { stan::math::recover_memory(); } -TEST_F(AgradRev, RevErrorHandlingScalar_CheckLess) { +TEST(AgradRevErrorHandlingScalar, CheckLess) { using stan::math::check_less; using stan::math::var; @@ -150,7 +149,7 @@ TEST_F(AgradRev, RevErrorHandlingScalar_CheckLess) { stan::math::recover_memory(); } -TEST_F(AgradRev, RevErrorHandlingScalar_CheckLessVarCheckUnivariate) { +TEST(AgradRevErrorHandlingScalar, CheckLessVarCheckUnivariate) { using stan::math::check_less; using stan::math::var; @@ -178,7 +177,7 @@ TEST_F(AgradRev, RevErrorHandlingScalar_CheckLessVarCheckUnivariate) { stan::math::recover_memory(); } -TEST_F(AgradRev, RevErrorHandlingMatrix_CheckLessStdVecVarMatrix) { +TEST(AgradRevErrorHandlingMatrix, CheckLessStdVecVarMatrix) { using stan::math::var; std::vector>>> diff --git a/test/unit/math/rev/err/check_matching_dims_test.cpp b/test/unit/math/rev/err/check_matching_dims_test.cpp index 51eee9e86fe..43a679616bb 100644 --- a/test/unit/math/rev/err/check_matching_dims_test.cpp +++ b/test/unit/math/rev/err/check_matching_dims_test.cpp @@ -1,10 +1,9 @@ #include -#include #include #include #include -TEST_F(AgradRev, ErrorHandlingMatrix_checkMatchingDims_double_var) { +TEST(ErrorHandlingMatrix, checkMatchingDims_double_var) { using stan::math::check_matching_dims; std::vector> x; @@ -25,7 +24,7 @@ TEST_F(AgradRev, ErrorHandlingMatrix_checkMatchingDims_double_var) { std::invalid_argument); } -TEST_F(AgradRev, ErrorHandlingMatrix_checkMatchingDims_var) { +TEST(ErrorHandlingMatrix, checkMatchingDims_var) { using stan::math::check_matching_dims; std::vector> x; diff --git a/test/unit/math/rev/err/check_nonnegative_test.cpp b/test/unit/math/rev/err/check_nonnegative_test.cpp index 538bf9cfaaa..93113b8e186 100644 --- a/test/unit/math/rev/err/check_nonnegative_test.cpp +++ b/test/unit/math/rev/err/check_nonnegative_test.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include @@ -7,7 +6,7 @@ using stan::math::check_nonnegative; using stan::math::var; -TEST_F(AgradRev, RevErrorHandlingScalar_CheckNonnegativeVectorized) { +TEST(AgradRevErrorHandlingScalar, CheckNonnegativeVectorized) { int N = 5; const char* function = "check_nonnegative"; std::vector x(N); @@ -35,7 +34,7 @@ TEST_F(AgradRev, RevErrorHandlingScalar_CheckNonnegativeVectorized) { stan::math::recover_memory(); } -TEST_F(AgradRev, RevErrorHandlingScalar_CheckNonnegativeVarCheckVectorized) { +TEST(AgradRevErrorHandlingScalar, CheckNonnegativeVarCheckVectorized) { using stan::math::check_nonnegative; using stan::math::var; using std::vector; @@ -83,7 +82,7 @@ TEST_F(AgradRev, RevErrorHandlingScalar_CheckNonnegativeVarCheckVectorized) { stan::math::recover_memory(); } -TEST_F(AgradRev, RevErrorHandlingScalar_CheckNonnegative) { +TEST(AgradRevErrorHandlingScalar, CheckNonnegative) { const char* function = "check_nonnegative"; var x = 0; @@ -108,7 +107,7 @@ TEST_F(AgradRev, RevErrorHandlingScalar_CheckNonnegative) { stan::math::recover_memory(); } -TEST_F(AgradRev, RevErrorHandlingScalar_CheckNonnegativeVarCheckUnivariate) { +TEST(AgradRevErrorHandlingScalar, CheckNonnegativeVarCheckUnivariate) { using stan::math::check_nonnegative; using stan::math::var; diff --git a/test/unit/math/rev/err/check_nonzero_size_test.cpp b/test/unit/math/rev/err/check_nonzero_size_test.cpp index b293b8743bb..dfb3ad9f3c7 100644 --- a/test/unit/math/rev/err/check_nonzero_size_test.cpp +++ b/test/unit/math/rev/err/check_nonzero_size_test.cpp @@ -1,11 +1,10 @@ #include -#include #include #include #include #include -TEST_F(AgradRev, RevErrorHandlingMatrix_checkNonzeroSizeMatrix) { +TEST(AgradRevErrorHandlingMatrix, checkNonzeroSizeMatrix) { using stan::math::var; Eigen::Matrix y; using stan::math::check_nonzero_size; @@ -36,7 +35,7 @@ TEST_F(AgradRev, RevErrorHandlingMatrix_checkNonzeroSizeMatrix) { std::invalid_argument, "a has size 0"); } -TEST_F(AgradRev, RevErrorHandlingMatrix_checkNonzeroSizeMatrix_nan) { +TEST(AgradRevErrorHandlingMatrix, checkNonzeroSizeMatrix_nan) { using stan::math::var; Eigen::Matrix y; var result; diff --git a/test/unit/math/rev/err/check_not_nan_test.cpp b/test/unit/math/rev/err/check_not_nan_test.cpp index 3a50da6746b..820cf12b540 100644 --- a/test/unit/math/rev/err/check_not_nan_test.cpp +++ b/test/unit/math/rev/err/check_not_nan_test.cpp @@ -1,10 +1,9 @@ #include -#include #include #include #include -TEST_F(AgradRev, RevErrorHandlingScalar_CheckNotNanVarCheckVectorized) { +TEST(AgradRevErrorHandlingScalar, CheckNotNanVarCheckVectorized) { using stan::math::check_not_nan; using stan::math::var; @@ -29,7 +28,7 @@ TEST_F(AgradRev, RevErrorHandlingScalar_CheckNotNanVarCheckVectorized) { stan::math::recover_memory(); } -TEST_F(AgradRev, ErrorHandlingScalar_CheckNotNanVarCheckVectorized) { +TEST(ErrorHandlingScalar, CheckNotNanVarCheckVectorized) { using stan::math::check_not_nan; using stan::math::var; @@ -54,7 +53,7 @@ TEST_F(AgradRev, ErrorHandlingScalar_CheckNotNanVarCheckVectorized) { stan::math::recover_memory(); } -TEST_F(AgradRev, RevErrorHandlingScalar_CheckNotNan) { +TEST(AgradRevErrorHandlingScalar, CheckNotNan) { using stan::math::check_not_nan; using stan::math::var; const char* function = "check_not_nan"; @@ -90,7 +89,7 @@ TEST_F(AgradRev, RevErrorHandlingScalar_CheckNotNan) { stan::math::recover_memory(); } -TEST_F(AgradRev, RevErrorHandlingScalar_CheckNotNanVarCheckUnivariate) { +TEST(AgradRevErrorHandlingScalar, CheckNotNanVarCheckUnivariate) { using stan::math::check_not_nan; using stan::math::var; @@ -112,7 +111,7 @@ TEST_F(AgradRev, RevErrorHandlingScalar_CheckNotNanVarCheckUnivariate) { stan::math::recover_memory(); } -TEST_F(AgradRev, ErrorHandlingScalar_CheckNotNanVarCheckUnivariate) { +TEST(ErrorHandlingScalar, CheckNotNanVarCheckUnivariate) { using stan::math::check_not_nan; using stan::math::var; diff --git a/test/unit/math/rev/err/check_pos_definite_test.cpp b/test/unit/math/rev/err/check_pos_definite_test.cpp index abe0f6f8934..8730bb99e24 100644 --- a/test/unit/math/rev/err/check_pos_definite_test.cpp +++ b/test/unit/math/rev/err/check_pos_definite_test.cpp @@ -1,9 +1,8 @@ #include -#include #include #include -TEST_F(AgradRev, RevErrorHandlingMatrix_checkPosDefiniteMatrix_nan) { +TEST(AgradRevErrorHandlingMatrix, checkPosDefiniteMatrix_nan) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::var; 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 22236b60a27..d8e634e7031 100644 --- a/test/unit/math/rev/err/check_pos_semidefinite_test.cpp +++ b/test/unit/math/rev/err/check_pos_semidefinite_test.cpp @@ -1,10 +1,9 @@ #include #include -#include #include #include -TEST_F(AgradRev, RevErrorHandlingMatrix_checkPosSemiDefiniteMatrix_nan) { +TEST(AgradRevErrorHandlingMatrix, checkPosSemiDefiniteMatrix_nan) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::var; @@ -36,7 +35,7 @@ TEST_F(AgradRev, RevErrorHandlingMatrix_checkPosSemiDefiniteMatrix_nan) { stan::math::recover_memory(); } -TEST_F(AgradRev, RevErrorHandlingMatrix_checkPosSemiDefiniteMatrixVarCheck) { +TEST(AgradRevErrorHandlingMatrix, checkPosSemiDefiniteMatrixVarCheck) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::var; diff --git a/test/unit/math/rev/err/check_positive_finite_test.cpp b/test/unit/math/rev/err/check_positive_finite_test.cpp index 4111d4c876e..e8fb8af1a92 100644 --- a/test/unit/math/rev/err/check_positive_finite_test.cpp +++ b/test/unit/math/rev/err/check_positive_finite_test.cpp @@ -1,10 +1,9 @@ #include -#include #include #include #include -TEST_F(AgradRev, RevErrorHandlingScalar_CheckPositiveFinite_Vector) { +TEST(AgradRevErrorHandlingScalar, CheckPositiveFinite_Vector) { using stan::math::check_positive_finite; using stan::math::var; @@ -55,7 +54,7 @@ TEST_F(AgradRev, RevErrorHandlingScalar_CheckPositiveFinite_Vector) { stan::math::recover_memory(); } -TEST_F(AgradRev, RevErrorHandlingScalar_CheckPositiveFiniteVarCheckVectorized) { +TEST(AgradRevErrorHandlingScalar, CheckPositiveFiniteVarCheckVectorized) { using stan::math::check_positive_finite; using stan::math::var; @@ -88,7 +87,7 @@ TEST_F(AgradRev, RevErrorHandlingScalar_CheckPositiveFiniteVarCheckVectorized) { stan::math::recover_memory(); } -TEST_F(AgradRev, RevErrorHandlingMatrix_CheckPositiveFinite_Matrix) { +TEST(AgradRevErrorHandlingMatrix, CheckPositiveFinite_Matrix) { using stan::math::check_positive_finite; using stan::math::var; @@ -127,7 +126,7 @@ TEST_F(AgradRev, RevErrorHandlingMatrix_CheckPositiveFinite_Matrix) { stan::math::recover_memory(); } -TEST_F(AgradRev, RevErrorHandlingScalar_CheckPositiveFinite) { +TEST(AgradRevErrorHandlingScalar, CheckPositiveFinite) { using stan::math::check_positive_finite; using stan::math::var; @@ -155,7 +154,7 @@ TEST_F(AgradRev, RevErrorHandlingScalar_CheckPositiveFinite) { stan::math::recover_memory(); } -TEST_F(AgradRev, RevErrorHandlingScalar_CheckPositiveFiniteVarCheckUnivariate) { +TEST(AgradRevErrorHandlingScalar, CheckPositiveFiniteVarCheckUnivariate) { using stan::math::check_positive_finite; using stan::math::var; diff --git a/test/unit/math/rev/err/check_positive_test.cpp b/test/unit/math/rev/err/check_positive_test.cpp index d08e951b718..dee6535363f 100644 --- a/test/unit/math/rev/err/check_positive_test.cpp +++ b/test/unit/math/rev/err/check_positive_test.cpp @@ -1,11 +1,10 @@ #include -#include #include #include #include #include -TEST_F(AgradRev, RevErrorHandlingArray_CheckPositive) { +TEST(AgradRevErrorHandlingArray, CheckPositive) { using stan::math::check_positive; using stan::math::var; @@ -21,7 +20,7 @@ TEST_F(AgradRev, RevErrorHandlingArray_CheckPositive) { stan::math::recover_memory(); } -TEST_F(AgradRev, RevErrorHandlingMatrix_CheckPositive) { +TEST(AgradRevErrorHandlingMatrix, CheckPositive) { using stan::math::check_positive; using stan::math::var; @@ -40,7 +39,7 @@ TEST_F(AgradRev, RevErrorHandlingMatrix_CheckPositive) { stan::math::recover_memory(); } -TEST_F(AgradRev, RevErrorHandlingScalar_CheckPositive) { +TEST(AgradRevErrorHandlingScalar, CheckPositive) { using stan::math::check_positive; using stan::math::var; @@ -52,7 +51,7 @@ TEST_F(AgradRev, RevErrorHandlingScalar_CheckPositive) { stan::math::recover_memory(); } -TEST_F(AgradRev, RevErrorHandlingScalar_CheckPositiveVarCheckUnivariate) { +TEST(AgradRevErrorHandlingScalar, CheckPositiveVarCheckUnivariate) { using stan::math::check_positive; using stan::math::var; diff --git a/test/unit/math/rev/err/invalid_argument_test.cpp b/test/unit/math/rev/err/invalid_argument_test.cpp index 6a6fd9c225f..87fe0c8fde5 100644 --- a/test/unit/math/rev/err/invalid_argument_test.cpp +++ b/test/unit/math/rev/err/invalid_argument_test.cpp @@ -1,5 +1,4 @@ #include -#include #include #include diff --git a/test/unit/math/rev/err/invalid_argument_vec_test.cpp b/test/unit/math/rev/err/invalid_argument_vec_test.cpp index adf41f1c481..44a47f190be 100644 --- a/test/unit/math/rev/err/invalid_argument_vec_test.cpp +++ b/test/unit/math/rev/err/invalid_argument_vec_test.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include diff --git a/test/unit/math/rev/err/out_of_range_test.cpp b/test/unit/math/rev/err/out_of_range_test.cpp index 45ddde13ebb..c4687ea68dd 100644 --- a/test/unit/math/rev/err/out_of_range_test.cpp +++ b/test/unit/math/rev/err/out_of_range_test.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include diff --git a/test/unit/math/rev/err/throw_domain_error_test.cpp b/test/unit/math/rev/err/throw_domain_error_test.cpp index e6a1287c59c..d00406ca165 100644 --- a/test/unit/math/rev/err/throw_domain_error_test.cpp +++ b/test/unit/math/rev/err/throw_domain_error_test.cpp @@ -1,5 +1,4 @@ #include -#include #include #include diff --git a/test/unit/math/rev/err/throw_domain_error_vec_test.cpp b/test/unit/math/rev/err/throw_domain_error_vec_test.cpp index fca45966446..ec3437f6ea4 100644 --- a/test/unit/math/rev/err/throw_domain_error_vec_test.cpp +++ b/test/unit/math/rev/err/throw_domain_error_vec_test.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include diff --git a/test/unit/math/rev/fun/LDLT_factor_test.cpp b/test/unit/math/rev/fun/LDLT_factor_test.cpp index f2d802e772b..926a5f902a9 100644 --- a/test/unit/math/rev/fun/LDLT_factor_test.cpp +++ b/test/unit/math/rev/fun/LDLT_factor_test.cpp @@ -1,9 +1,8 @@ #include -#include #include #include -TEST_F(AgradRev, RevMatrix_LDLT_factor_default_constructor) { +TEST(AgradRevMatrix, LDLT_factor_default_constructor) { using stan::math::LDLT_factor; using stan::math::var; @@ -26,7 +25,7 @@ TEST_F(AgradRev, RevMatrix_LDLT_factor_default_constructor) { stan::math::recover_memory(); } -TEST_F(AgradRev, RevMatrix_solve) { +TEST(AgradRevMatrix, solve) { using stan::math::LDLT_factor; using stan::math::var; @@ -63,7 +62,7 @@ TEST_F(AgradRev, RevMatrix_solve) { stan::math::recover_memory(); } -TEST_F(AgradRev, RevMatrix_matrix) { +TEST(AgradRevMatrix, matrix) { using stan::math::LDLT_factor; using stan::math::var; diff --git a/test/unit/math/rev/fun/accumulator_test.cpp b/test/unit/math/rev/fun/accumulator_test.cpp index 2207f33a369..a83793f14a6 100644 --- a/test/unit/math/rev/fun/accumulator_test.cpp +++ b/test/unit/math/rev/fun/accumulator_test.cpp @@ -4,11 +4,11 @@ #include // test sum of first n numbers for sum of a -inline void test_sum(stan::math::accumulator& a, int n) { +void test_sum(stan::math::accumulator& a, int n) { EXPECT_FLOAT_EQ((n * (n + 1)) / 2, a.sum().val()); } -TEST_F(AgradRev, RevMatrix_accumulateDouble) { +TEST(AgradRevMatrix, accumulateDouble) { using stan::math::accumulator; using stan::math::var; @@ -22,7 +22,7 @@ TEST_F(AgradRev, RevMatrix_accumulateDouble) { a.add(var(i)); test_sum(a, 1000); } -TEST_F(AgradRev, RevMathMatrix_accumulateCollection) { +TEST(AgradRevMathMatrix, accumulateCollection) { // tests int, double, vector, vector, // Matrix, // var, vector, Matrix, @@ -127,7 +127,7 @@ TEST_F(AgradRev, RevMathMatrix_accumulateCollection) { test_sum(a, pos - 1); } -TEST_F(AgradRev, RevMatrix_accumulator_check_varis_on_stack) { +TEST(AgradRevMatrix, accumulator_check_varis_on_stack) { stan::math::accumulator a; test::check_varis_on_stack(a.sum()); a.add(1); diff --git a/test/unit/math/rev/fun/as_array_or_scalar_test.cpp b/test/unit/math/rev/fun/as_array_or_scalar_test.cpp index 11a288edcc1..98aa23b3d80 100644 --- a/test/unit/math/rev/fun/as_array_or_scalar_test.cpp +++ b/test/unit/math/rev/fun/as_array_or_scalar_test.cpp @@ -1,10 +1,9 @@ #include -#include #include #include -TEST_F(AgradRev, MathFunRev_as_array_or_scalar_var_value_matrix) { +TEST(MathFunRev, as_array_or_scalar_var_value_matrix) { int n = 100; const Eigen::MatrixXd a_val = Eigen::MatrixXd::Random(n, n); stan::math::var_value a(a_val); @@ -13,7 +12,7 @@ TEST_F(AgradRev, MathFunRev_as_array_or_scalar_var_value_matrix) { EXPECT_MATRIX_EQ(tmp.val(), a_val); } -TEST_F(AgradRev, MathFunRev_as_array_or_scalar_var_value_vector) { +TEST(MathFunRev, as_array_or_scalar_var_value_vector) { int n = 100; const Eigen::VectorXd a_val = Eigen::VectorXd::Random(n); stan::math::var_value a(a_val); @@ -22,7 +21,7 @@ TEST_F(AgradRev, MathFunRev_as_array_or_scalar_var_value_vector) { EXPECT_MATRIX_EQ(tmp.val(), a_val); } -TEST_F(AgradRev, MathFunRev_as_array_or_scalar_var_value_rowvector) { +TEST(MathFunRev, as_array_or_scalar_var_value_rowvector) { int n = 100; const Eigen::RowVectorXd a_val = Eigen::RowVectorXd::Random(n); stan::math::var_value a(a_val); diff --git a/test/unit/math/rev/fun/as_bool_test.cpp b/test/unit/math/rev/fun/as_bool_test.cpp index 6922262a846..80f730f37a7 100644 --- a/test/unit/math/rev/fun/as_bool_test.cpp +++ b/test/unit/math/rev/fun/as_bool_test.cpp @@ -1,10 +1,9 @@ #include -#include #include #include #include -TEST_F(AgradRev, Rev_asBool) { +TEST(AgradRev, asBool) { using stan::math::as_bool; using stan::math::var; @@ -21,7 +20,7 @@ TEST_F(AgradRev, Rev_asBool) { EXPECT_FALSE(as_bool(var(0.0))); EXPECT_FALSE(as_bool(var(0.0f))); } -TEST_F(AgradRev, Rev_as_bool_nan) { +TEST(AgradRev, as_bool_nan) { stan::math::var nan = std::numeric_limits::quiet_NaN(); EXPECT_TRUE(stan::math::as_bool(nan)); } diff --git a/test/unit/math/rev/fun/as_column_vector_or_scalar_test.cpp b/test/unit/math/rev/fun/as_column_vector_or_scalar_test.cpp index d9fd95bf42c..e29d1200eaa 100644 --- a/test/unit/math/rev/fun/as_column_vector_or_scalar_test.cpp +++ b/test/unit/math/rev/fun/as_column_vector_or_scalar_test.cpp @@ -1,10 +1,9 @@ #include -#include #include #include -TEST_F(AgradRev, MathFunRev_as_column_vector_or_scalar_var_value_vector) { +TEST(MathFunRev, as_column_vector_or_scalar_var_value_vector) { int n = 100; const Eigen::VectorXd a_val = Eigen::VectorXd::Random(n); stan::math::var_value a(a_val); @@ -13,7 +12,7 @@ TEST_F(AgradRev, MathFunRev_as_column_vector_or_scalar_var_value_vector) { EXPECT_MATRIX_EQ(tmp.val(), a_val); } -TEST_F(AgradRev, MathFunRev_as_column_vector_or_scalar_var_value_rowvector) { +TEST(MathFunRev, as_column_vector_or_scalar_var_value_rowvector) { int n = 100; const Eigen::RowVectorXd a_val = Eigen::RowVectorXd::Random(n); stan::math::var_value a(a_val); diff --git a/test/unit/math/rev/fun/as_value_array_or_scalar_test.cpp b/test/unit/math/rev/fun/as_value_array_or_scalar_test.cpp index 980cc361a6f..1016326a045 100644 --- a/test/unit/math/rev/fun/as_value_array_or_scalar_test.cpp +++ b/test/unit/math/rev/fun/as_value_array_or_scalar_test.cpp @@ -1,16 +1,15 @@ #include -#include #include #include #include -TEST_F(AgradRev, MathFunRev_as_value_array_or_scalar_scalar) { +TEST(MathFunRev, as_value_array_or_scalar_scalar) { double b_val = 4; stan::math::var b(b_val); EXPECT_EQ(b_val, stan::math::as_value_array_or_scalar(b)); } -TEST_F(AgradRev, MathFunRev_as_value_array_or_scalar_std_vector_lvalue) { +TEST(MathFunRev, as_value_array_or_scalar_std_vector_lvalue) { int n = 100; Eigen::ArrayXd a_val = Eigen::ArrayXd::Random(n); std::vector b_val(n); @@ -24,7 +23,7 @@ TEST_F(AgradRev, MathFunRev_as_value_array_or_scalar_std_vector_lvalue) { EXPECT_MATRIX_EQ(res, a_val); } -TEST_F(AgradRev, MathFunRev_as_value_array_or_scalar_std_vector_rvalue) { +TEST(MathFunRev, as_value_array_or_scalar_std_vector_rvalue) { int n = 100; Eigen::ArrayXd a_val = Eigen::ArrayXd::Random(n); std::vector b_val(n); @@ -38,7 +37,7 @@ TEST_F(AgradRev, MathFunRev_as_value_array_or_scalar_std_vector_rvalue) { EXPECT_MATRIX_EQ(res, a_val); } -TEST_F(AgradRev, MathFunRev_as_value_array_or_scalar_matrix_lvalue) { +TEST(MathFunRev, as_value_array_or_scalar_matrix_lvalue) { int n = 100; Eigen::MatrixXd a_val = Eigen::MatrixXd::Random(n, n); Eigen::Matrix a(a_val); @@ -48,7 +47,7 @@ TEST_F(AgradRev, MathFunRev_as_value_array_or_scalar_matrix_lvalue) { EXPECT_MATRIX_EQ(res, a_val); } -TEST_F(AgradRev, MathFunRev_as_value_array_or_scalar_const_matrix_lvalue) { +TEST(MathFunRev, as_value_array_or_scalar_const_matrix_lvalue) { int n = 100; const Eigen::MatrixXd a_val = Eigen::MatrixXd::Random(n, n); Eigen::Matrix a(a_val); @@ -58,7 +57,7 @@ TEST_F(AgradRev, MathFunRev_as_value_array_or_scalar_const_matrix_lvalue) { EXPECT_MATRIX_EQ(res, a_val); } -TEST_F(AgradRev, MathFunRev_as_value_array_or_scalar_matrix_rvalue) { +TEST(MathFunRev, as_value_array_or_scalar_matrix_rvalue) { int n = 10; Eigen::MatrixXd a_val = Eigen::MatrixXd::Random(n, n); Eigen::Matrix a(a_val); @@ -69,7 +68,7 @@ TEST_F(AgradRev, MathFunRev_as_value_array_or_scalar_matrix_rvalue) { EXPECT_MATRIX_EQ(res, a_val); } -TEST_F(AgradRev, MathFunRev_as_value_array_or_scalar_var_value) { +TEST(MathFunRev, as_value_array_or_scalar_var_value) { int n = 100; const Eigen::MatrixXd a_val = Eigen::MatrixXd::Random(n, n); stan::math::var_value> a(a_val); diff --git a/test/unit/math/rev/fun/as_value_column_array_or_scalar_test.cpp b/test/unit/math/rev/fun/as_value_column_array_or_scalar_test.cpp index f61cf4b3bd4..d0bc1a61113 100644 --- a/test/unit/math/rev/fun/as_value_column_array_or_scalar_test.cpp +++ b/test/unit/math/rev/fun/as_value_column_array_or_scalar_test.cpp @@ -1,16 +1,15 @@ #include -#include #include #include #include -TEST_F(AgradRev, MathFunRev_as_value_column_array_or_scalar_scalar) { +TEST(MathFunRev, as_value_column_array_or_scalar_scalar) { double b_val = 4; stan::math::var b(b_val); EXPECT_EQ(b_val, stan::math::as_value_column_array_or_scalar(b)); } -TEST_F(AgradRev, MathFunRev_as_value_column_array_or_scalar_std_vector_lvalue) { +TEST(MathFunRev, as_value_column_array_or_scalar_std_vector_lvalue) { int n = 100; Eigen::ArrayXd a_val = Eigen::ArrayXd::Random(n); std::vector b_val(n); @@ -25,7 +24,7 @@ TEST_F(AgradRev, MathFunRev_as_value_column_array_or_scalar_std_vector_lvalue) { EXPECT_MATRIX_EQ(res, a_val); } -TEST_F(AgradRev, MathFunRev_as_value_column_array_or_scalar_std_vector_rvalue) { +TEST(MathFunRev, as_value_column_array_or_scalar_std_vector_rvalue) { int n = 100; Eigen::ArrayXd a_val = Eigen::ArrayXd::Random(n); std::vector b_val(n); @@ -40,7 +39,7 @@ TEST_F(AgradRev, MathFunRev_as_value_column_array_or_scalar_std_vector_rvalue) { EXPECT_MATRIX_EQ(res, a_val); } -TEST_F(AgradRev, MathFunRev_as_value_column_array_or_scalar_vector_lvalue) { +TEST(MathFunRev, as_value_column_array_or_scalar_vector_lvalue) { int n = 100; Eigen::VectorXd a_val = Eigen::VectorXd::Random(n); Eigen::Matrix a(a_val); @@ -51,8 +50,7 @@ TEST_F(AgradRev, MathFunRev_as_value_column_array_or_scalar_vector_lvalue) { EXPECT_MATRIX_EQ(res, a_val); } -TEST_F(AgradRev, - MathFunRev_as_value_column_array_or_scalar_const_rowvector_lvalue) { +TEST(MathFunRev, as_value_column_array_or_scalar_const_rowvector_lvalue) { int n = 100; const Eigen::RowVectorXd a_val = Eigen::RowVectorXd::Random(n); Eigen::Matrix a(a_val); @@ -63,7 +61,7 @@ TEST_F(AgradRev, EXPECT_MATRIX_EQ(res, a_val.transpose()); } -TEST_F(AgradRev, MathFunRev_as_value_column_array_or_scalar_rowvector_rvalue) { +TEST(MathFunRev, as_value_column_array_or_scalar_rowvector_rvalue) { int n = 10; Eigen::RowVectorXd a_val = Eigen::RowVectorXd::Random(n); Eigen::Matrix a(a_val); @@ -75,7 +73,7 @@ TEST_F(AgradRev, MathFunRev_as_value_column_array_or_scalar_rowvector_rvalue) { EXPECT_MATRIX_EQ(res, a_val.transpose()); } -TEST_F(AgradRev, MathFunRev_as_value_column_array_or_scalar_var_value_vector) { +TEST(MathFunRev, as_value_column_array_or_scalar_var_value_vector) { int n = 100; const Eigen::VectorXd a_val = Eigen::VectorXd::Random(n); stan::math::var_value a(a_val); @@ -86,8 +84,7 @@ TEST_F(AgradRev, MathFunRev_as_value_column_array_or_scalar_var_value_vector) { EXPECT_MATRIX_EQ(res, a_val); } -TEST_F(AgradRev, - MathFunRev_as_value_column_array_or_scalar_var_value_row_vector) { +TEST(MathFunRev, as_value_column_array_or_scalar_var_value_row_vector) { int n = 100; const Eigen::RowVectorXd a_val = Eigen::VectorXd::Random(n); stan::math::var_value a(a_val); diff --git a/test/unit/math/rev/fun/as_value_column_vector_or_scalar_test.cpp b/test/unit/math/rev/fun/as_value_column_vector_or_scalar_test.cpp index 807ffc10b2c..678ea65fc65 100644 --- a/test/unit/math/rev/fun/as_value_column_vector_or_scalar_test.cpp +++ b/test/unit/math/rev/fun/as_value_column_vector_or_scalar_test.cpp @@ -1,17 +1,15 @@ #include -#include #include #include #include -TEST_F(AgradRev, MathFunRev_as_value_column_vector_or_scalar_scalar) { +TEST(MathFunRev, as_value_column_vector_or_scalar_scalar) { double b_val = 4; stan::math::var b(b_val); EXPECT_EQ(b_val, stan::math::as_value_column_vector_or_scalar(b)); } -TEST_F(AgradRev, - MathFunRev_as_value_column_vector_or_scalar_std_vector_lvalue) { +TEST(MathFunRev, as_value_column_vector_or_scalar_std_vector_lvalue) { int n = 100; Eigen::VectorXd a_val = Eigen::VectorXd::Random(n); std::vector b_val(n); @@ -25,8 +23,7 @@ TEST_F(AgradRev, EXPECT_MATRIX_EQ(res, a_val); } -TEST_F(AgradRev, - MathFunRev_as_value_column_vector_or_scalar_std_vector_rvalue) { +TEST(MathFunRev, as_value_column_vector_or_scalar_std_vector_rvalue) { int n = 100; Eigen::VectorXd a_val = Eigen::VectorXd::Random(n); std::vector b_val(n); @@ -40,7 +37,7 @@ TEST_F(AgradRev, EXPECT_MATRIX_EQ(res, a_val); } -TEST_F(AgradRev, MathFunRev_as_value_column_vector_or_scalar_vector_lvalue) { +TEST(MathFunRev, as_value_column_vector_or_scalar_vector_lvalue) { int n = 100; Eigen::VectorXd a_val = Eigen::VectorXd::Random(n); Eigen::Matrix a(a_val); @@ -50,8 +47,7 @@ TEST_F(AgradRev, MathFunRev_as_value_column_vector_or_scalar_vector_lvalue) { EXPECT_MATRIX_EQ(res, a_val); } -TEST_F(AgradRev, - MathFunRev_as_value_column_vector_or_scalar_const_rowvector_lvalue) { +TEST(MathFunRev, as_value_column_vector_or_scalar_const_rowvector_lvalue) { int n = 100; const Eigen::RowVectorXd a_val = Eigen::RowVectorXd::Random(n); Eigen::Matrix a(a_val); @@ -61,7 +57,7 @@ TEST_F(AgradRev, EXPECT_MATRIX_EQ(res, a_val.transpose()); } -TEST_F(AgradRev, MathFunRev_as_value_column_vector_or_scalar_rowvector_rvalue) { +TEST(MathFunRev, as_value_column_vector_or_scalar_rowvector_rvalue) { int n = 10; Eigen::RowVectorXd a_val = Eigen::RowVectorXd::Random(n); Eigen::Matrix a(a_val); @@ -72,7 +68,7 @@ TEST_F(AgradRev, MathFunRev_as_value_column_vector_or_scalar_rowvector_rvalue) { EXPECT_MATRIX_EQ(res, a_val.transpose()); } -TEST_F(AgradRev, MathFunRev_as_value_column_vector_or_scalar_var_value_vector) { +TEST(MathFunRev, as_value_column_vector_or_scalar_var_value_vector) { int n = 100; const Eigen::VectorXd a_val = Eigen::VectorXd::Random(n); stan::math::var_value a(a_val); @@ -82,8 +78,7 @@ TEST_F(AgradRev, MathFunRev_as_value_column_vector_or_scalar_var_value_vector) { EXPECT_MATRIX_EQ(res, a_val); } -TEST_F(AgradRev, - MathFunRev_as_value_column_vector_or_scalar_var_value_row_vector) { +TEST(MathFunRev, as_value_column_vector_or_scalar_var_value_row_vector) { int n = 100; const Eigen::RowVectorXd a_val = Eigen::VectorXd::Random(n); stan::math::var_value a(a_val); diff --git a/test/unit/math/rev/fun/assign_test.cpp b/test/unit/math/rev/fun/assign_test.cpp index df344f6a5f4..882a854424a 100644 --- a/test/unit/math/rev/fun/assign_test.cpp +++ b/test/unit/math/rev/fun/assign_test.cpp @@ -1,9 +1,8 @@ #include -#include #include #include -TEST_F(AgradRev, MathMatrixRevMat_getAssignRowVar) { +TEST(MathMatrixRevMat, getAssignRowVar) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::assign; @@ -22,7 +21,7 @@ TEST_F(AgradRev, MathMatrixRevMat_getAssignRowVar) { EXPECT_FLOAT_EQ(1000.0, m(0, 2).val()); } -TEST_F(AgradRev, RevMatrix_assign) { +TEST(AgradRevMatrix, assign) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::assign; @@ -88,7 +87,7 @@ TEST_F(AgradRev, RevMatrix_assign) { EXPECT_FLOAT_EQ(100, m_var(1, 0).val()); EXPECT_FLOAT_EQ(300, m_var(1, 2).val()); } -TEST_F(AgradRev, RevMatrix_assign_error) { +TEST(AgradRevMatrix, assign_error) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::assign; @@ -117,7 +116,7 @@ TEST_F(AgradRev, RevMatrix_assign_error) { EXPECT_THROW(assign(m_var, m_dbl), std::invalid_argument); } -TEST_F(AgradRev, MathAssign_VarDouble) { +TEST(MathAssign, VarDouble) { using stan::math::assign; using stan::math::var; var x; diff --git a/test/unit/math/rev/fun/binomial_coefficient_log_test.cpp b/test/unit/math/rev/fun/binomial_coefficient_log_test.cpp index 022ad56976d..c70e37a2c72 100644 --- a/test/unit/math/rev/fun/binomial_coefficient_log_test.cpp +++ b/test/unit/math/rev/fun/binomial_coefficient_log_test.cpp @@ -1,6 +1,5 @@ #include #include -#include #include #include #include @@ -9,7 +8,7 @@ #include #include -TEST_F(AgradRev, MathFunctions_binomial_coefficient_log_identities) { +TEST(MathFunctions, binomial_coefficient_log_identities) { using stan::math::binomial_coefficient_log; using stan::math::is_nan; using stan::math::log; @@ -297,7 +296,7 @@ std::vector testValues = { } // namespace binomial_coefficient_log_test_internal -TEST_F(AgradRev, MathFunctions_binomial_coefficient_log_precomputed) { +TEST(MathFunctions, binomial_coefficient_log_precomputed) { using binomial_coefficient_log_test_internal::TestValue; using binomial_coefficient_log_test_internal::testValues; using binomial_coefficient_log_test_internal::testValuesEdge; diff --git a/test/unit/math/rev/fun/cholesky_decompose_test.cpp b/test/unit/math/rev/fun/cholesky_decompose_test.cpp index 1cec6737840..d04fab845a2 100644 --- a/test/unit/math/rev/fun/cholesky_decompose_test.cpp +++ b/test/unit/math/rev/fun/cholesky_decompose_test.cpp @@ -1,11 +1,11 @@ #include -#include #include +#include #include #include template -inline std::vector fill_vec(Eigen::Matrix inp) { +std::vector fill_vec(Eigen::Matrix inp) { std::vector ret_vec; ret_vec.reserve(inp.rows()); for (int i = 0; i < inp.rows(); ++i) @@ -130,7 +130,7 @@ struct chol_functor_simple_vec { } }; -inline void test_gradients(int size, double prec) { +void test_gradients(int size, double prec) { std::vector > functors; std::vector > > grads_ad; std::vector > > grads_fd; @@ -165,7 +165,7 @@ inline void test_gradients(int size, double prec) { } } -inline void test_gradients_simple(int size, double prec) { +void test_gradients_simple(int size, double prec) { std::vector > functors; std::vector > > grads_ad; std::vector > > grads_fd; @@ -214,7 +214,7 @@ inline void test_gradients_simple(int size, double prec) { } } -inline void test_gp_grad(int mat_size, double prec) { +void test_gp_grad(int mat_size, double prec) { using Eigen::MatrixXd; using Eigen::RowVectorXd; using Eigen::VectorXd; @@ -256,7 +256,7 @@ inline void test_gp_grad(int mat_size, double prec) { } } -inline void test_chol_mult(int mat_size, double prec) { +void test_chol_mult(int mat_size, double prec) { using Eigen::MatrixXd; using Eigen::RowVectorXd; using Eigen::VectorXd; @@ -290,7 +290,7 @@ inline void test_chol_mult(int mat_size, double prec) { } } -inline void test_simple_vec_mult(int size, double prec) { +void test_simple_vec_mult(int size, double prec) { Eigen::VectorXd test_vec(size); boost::random::mt19937 rng(2); @@ -329,7 +329,7 @@ inline void test_simple_vec_mult(int size, double prec) { EXPECT_NEAR(grad_fd(k), grad_ad(k), prec) << " for k=" << k; } -inline double test_gradient(int size, double prec) { +double test_gradient(int size, double prec) { chol_functor_2 functown(size); Eigen::Matrix grads_ad; Eigen::Matrix grads_fd; @@ -350,7 +350,7 @@ inline double test_gradient(int size, double prec) { return grads_ad.sum(); } -TEST_F(AgradRev, RevMatrix_mat_cholesky) { +TEST(AgradRevMatrix, mat_cholesky) { using stan::math::cholesky_decompose; using stan::math::matrix_v; using stan::math::singular_values; @@ -375,7 +375,7 @@ TEST_F(AgradRev, RevMatrix_mat_cholesky) { EXPECT_NO_THROW(singular_values(X)); } -TEST_F(AgradRev, RevMatrix_exception_mat_cholesky) { +TEST(AgradRevMatrix, exception_mat_cholesky) { stan::math::matrix_v m; // not positive definite @@ -397,7 +397,7 @@ TEST_F(AgradRev, RevMatrix_exception_mat_cholesky) { EXPECT_THROW(stan::math::cholesky_decompose(m), std::domain_error); } -TEST_F(AgradRev, RevMatrix_exception_varmat_cholesky) { +TEST(AgradRevMatrix, exception_varmat_cholesky) { stan::math::matrix_d m; // not positive definite @@ -423,21 +423,21 @@ TEST_F(AgradRev, RevMatrix_exception_varmat_cholesky) { EXPECT_THROW(stan::math::cholesky_decompose(mv4), std::domain_error); } -TEST_F(AgradRev, RevMatrix_mat_cholesky_1st_deriv_small) { +TEST(AgradRevMatrix, mat_cholesky_1st_deriv_small) { test_gradients(9, 1e-10); test_gradients_simple(10, 1e-10); test_gradient(15, 1e-10); test_gp_grad(20, 1e-10); } -TEST_F(AgradRev, RevMatrix_check_varis_on_stack_small) { +TEST(AgradRevMatrix, check_varis_on_stack_small) { stan::math::matrix_v X(2, 2); X << 3, -1, -1, 1; test::check_varis_on_stack(stan::math::cholesky_decompose(X)); } -TEST_F(AgradRev, RevMatrix_mat_cholesky_1st_deriv_large_gradients) { +TEST(AgradRevMatrix, mat_cholesky_1st_deriv_large_gradients) { test_gradient(36, 1e-08); test_gp_grad(100, 1e-08); test_gp_grad(1000, 1e-08); @@ -445,7 +445,7 @@ TEST_F(AgradRev, RevMatrix_mat_cholesky_1st_deriv_large_gradients) { test_simple_vec_mult(45, 1e-08); } -TEST_F(AgradRev, RevMatrix_cholesky_replicated_input) { +TEST(AgradRevMatrix, cholesky_replicated_input) { using stan::math::var; auto f = [](int size, const auto& y) { diff --git a/test/unit/math/rev/fun/cols_test.cpp b/test/unit/math/rev/fun/cols_test.cpp index 2ac1ad7f11b..511d2143dff 100644 --- a/test/unit/math/rev/fun/cols_test.cpp +++ b/test/unit/math/rev/fun/cols_test.cpp @@ -1,9 +1,8 @@ #include -#include #include #include -TEST_F(AgradRev, RevMatrix_cols_vector) { +TEST(AgradRevMatrix, cols_vector) { using stan::math::cols; using stan::math::row_vector_v; using stan::math::var_value; @@ -19,7 +18,7 @@ TEST_F(AgradRev, RevMatrix_cols_vector) { vec_v.resize(0); EXPECT_EQ(1U, cols(vec_v)); } -TEST_F(AgradRev, RevMatrix_cols_rowvector) { +TEST(AgradRevMatrix, cols_rowvector) { using stan::math::cols; using stan::math::row_vector_v; using stan::math::var_value; @@ -34,7 +33,7 @@ TEST_F(AgradRev, RevMatrix_cols_rowvector) { EXPECT_EQ(0U, cols(rv)); } -TEST_F(AgradRev, RevMatrix_cols_matrix) { +TEST(AgradRevMatrix, cols_matrix) { using stan::math::cols; using stan::math::matrix_v; using stan::math::var_value; diff --git a/test/unit/math/rev/fun/cov_exp_quad_test.cpp b/test/unit/math/rev/fun/cov_exp_quad_test.cpp index ed42ebc6f95..90a3269ed3f 100644 --- a/test/unit/math/rev/fun/cov_exp_quad_test.cpp +++ b/test/unit/math/rev/fun/cov_exp_quad_test.cpp @@ -1,12 +1,12 @@ #include -#include #include +#include #include #include #include #include -TEST_F(AgradRev, RevMath_cov_exp_quad_vvv) { +TEST(RevMath, cov_exp_quad_vvv) { Eigen::Matrix cov; for (std::size_t i = 0; i < 3; ++i) { @@ -54,7 +54,7 @@ TEST_F(AgradRev, RevMath_cov_exp_quad_vvv) { } } -TEST_F(AgradRev, RevMath_cov_exp_quad_vvd) { +TEST(RevMath, cov_exp_quad_vvd) { Eigen::Matrix cov; double l = 5; @@ -98,7 +98,7 @@ TEST_F(AgradRev, RevMath_cov_exp_quad_vvd) { } } -TEST_F(AgradRev, RevMath_cov_exp_quad_vdv) { +TEST(RevMath, cov_exp_quad_vdv) { Eigen::Matrix cov; double sigma = 0.2; @@ -139,7 +139,7 @@ TEST_F(AgradRev, RevMath_cov_exp_quad_vdv) { } } -TEST_F(AgradRev, RevMath_cov_exp_quad_vdd) { +TEST(RevMath, cov_exp_quad_vdd) { Eigen::Matrix cov; double sigma = 0.2; double l = 5; @@ -176,7 +176,7 @@ TEST_F(AgradRev, RevMath_cov_exp_quad_vdd) { } } -TEST_F(AgradRev, RevMath_cov_exp_quad_dvv) { +TEST(RevMath, cov_exp_quad_dvv) { Eigen::Matrix cov; std::vector x(3); x[0] = -2; @@ -216,7 +216,7 @@ TEST_F(AgradRev, RevMath_cov_exp_quad_dvv) { } } -TEST_F(AgradRev, RevMath_cov_exp_quad_dvd) { +TEST(RevMath, cov_exp_quad_dvd) { Eigen::Matrix cov; std::vector x(3); x[0] = -2; @@ -251,7 +251,7 @@ TEST_F(AgradRev, RevMath_cov_exp_quad_dvd) { } } -TEST_F(AgradRev, RevMath_cov_exp_quad_ddv) { +TEST(RevMath, cov_exp_quad_ddv) { Eigen::Matrix cov; std::vector x(3); x[0] = -2; @@ -285,7 +285,7 @@ TEST_F(AgradRev, RevMath_cov_exp_quad_ddv) { } } -TEST_F(AgradRev, RevMath_cov_exp_quad_vector_vvv) { +TEST(RevMath, cov_exp_quad_vector_vvv) { typedef Eigen::Matrix vector_v; Eigen::Matrix cov; @@ -352,7 +352,7 @@ TEST_F(AgradRev, RevMath_cov_exp_quad_vector_vvv) { } } -TEST_F(AgradRev, RevMath_cov_exp_quad_vector_vvd) { +TEST(RevMath, cov_exp_quad_vector_vvd) { typedef Eigen::Matrix vector_v; Eigen::Matrix cov; double l = 5; @@ -414,7 +414,7 @@ TEST_F(AgradRev, RevMath_cov_exp_quad_vector_vvd) { } } -TEST_F(AgradRev, RevMath_cov_exp_quad_vector_vdv) { +TEST(RevMath, cov_exp_quad_vector_vdv) { typedef Eigen::Matrix vector_v; Eigen::Matrix cov; double sigma = 0.2; @@ -476,7 +476,7 @@ TEST_F(AgradRev, RevMath_cov_exp_quad_vector_vdv) { } } -TEST_F(AgradRev, RevMath_cov_exp_quad_vector_vdd) { +TEST(RevMath, cov_exp_quad_vector_vdd) { typedef Eigen::Matrix vector_v; Eigen::Matrix cov; double sigma = 0.2; @@ -533,7 +533,7 @@ TEST_F(AgradRev, RevMath_cov_exp_quad_vector_vdd) { } } -TEST_F(AgradRev, RevMath_cov_exp_quad_vector_dvv) { +TEST(RevMath, cov_exp_quad_vector_dvv) { typedef Eigen::Matrix vector_d; Eigen::Matrix cov; @@ -603,7 +603,7 @@ TEST_F(AgradRev, RevMath_cov_exp_quad_vector_dvv) { } } -TEST_F(AgradRev, RevMath_cov_exp_quad_vector_dvd) { +TEST(RevMath, cov_exp_quad_vector_dvd) { typedef Eigen::Matrix vector_d; Eigen::Matrix cov; std::vector x(3); @@ -648,7 +648,7 @@ TEST_F(AgradRev, RevMath_cov_exp_quad_vector_dvd) { } } -TEST_F(AgradRev, RevMath_cov_exp_quad_vector_ddv) { +TEST(RevMath, cov_exp_quad_vector_ddv) { typedef Eigen::Matrix vector_d; Eigen::Matrix cov; std::vector x(3); @@ -693,7 +693,7 @@ TEST_F(AgradRev, RevMath_cov_exp_quad_vector_ddv) { } } -TEST_F(AgradRev, RevMath_cov_exp_quad1_vec_eigen_rvec) { +TEST(RevMath, cov_exp_quad1_vec_eigen_rvec) { using stan::math::squared_distance; using stan::math::var; @@ -720,7 +720,7 @@ TEST_F(AgradRev, RevMath_cov_exp_quad1_vec_eigen_rvec) { << "index: (" << i << ", " << j << ")"; } -TEST_F(AgradRev, RevMath_cov_exp_quad2_vec_eigen_rvec) { +TEST(RevMath, cov_exp_quad2_vec_eigen_rvec) { using stan::math::squared_distance; using stan::math::var; var sigma = 0.2; @@ -766,7 +766,7 @@ TEST_F(AgradRev, RevMath_cov_exp_quad2_vec_eigen_rvec) { } } -TEST_F(AgradRev, RevMath_cov_exp_quad2_vec_eigen_mixed) { +TEST(RevMath, cov_exp_quad2_vec_eigen_mixed) { using stan::math::squared_distance; using stan::math::var; var sigma = 0.2; @@ -903,7 +903,7 @@ TEST_F(AgradRev, RevMath_cov_exp_quad2_vec_eigen_mixed) { } } -TEST_F(AgradRev, RevMath_cov_exp_quad_domain_error_training) { +TEST(RevMath, cov_exp_quad_domain_error_training) { using stan::math::var; var sigma = 0.2; var l = 5; @@ -946,7 +946,7 @@ TEST_F(AgradRev, RevMath_cov_exp_quad_domain_error_training) { std::domain_error); } -TEST_F(AgradRev, RevMath_cov_exp_quad_nan_error_training) { +TEST(RevMath, cov_exp_quad_nan_error_training) { using stan::math::var; var sigma = 0.2; var l = 5; @@ -1020,7 +1020,7 @@ TEST_F(AgradRev, RevMath_cov_exp_quad_nan_error_training) { std::domain_error); } -TEST_F(AgradRev, RevMath_cov_exp_quad_domain_error) { +TEST(RevMath, cov_exp_quad_domain_error) { using stan::math::var; var sigma = 0.2; var l = 5; @@ -1099,7 +1099,7 @@ TEST_F(AgradRev, RevMath_cov_exp_quad_domain_error) { std::domain_error); } -TEST_F(AgradRev, RevMath_cov_exp_quad2_nan_domain_error) { +TEST(RevMath, cov_exp_quad2_nan_domain_error) { using stan::math::var; var sigma = 0.2; var l = 5; @@ -1227,7 +1227,7 @@ TEST_F(AgradRev, RevMath_cov_exp_quad2_nan_domain_error) { std::domain_error); } -TEST_F(AgradRev, RevMath_cov_exp_quad2_dim_mismatch_vec_eigen_vec) { +TEST(RevMath, cov_exp_quad2_dim_mismatch_vec_eigen_vec) { using stan::math::var; var sigma = 0.2; var l = 5; @@ -1248,7 +1248,7 @@ TEST_F(AgradRev, RevMath_cov_exp_quad2_dim_mismatch_vec_eigen_vec) { std::invalid_argument); } -TEST_F(AgradRev, RevMath_cov_exp_quad2_dim_mismatch_vec_eigen_rvec) { +TEST(RevMath, cov_exp_quad2_dim_mismatch_vec_eigen_rvec) { using stan::math::var; var sigma = 0.2; var l = 5; @@ -1269,7 +1269,7 @@ TEST_F(AgradRev, RevMath_cov_exp_quad2_dim_mismatch_vec_eigen_rvec) { std::invalid_argument); } -TEST_F(AgradRev, RevMath_cov_exp_quad2_dim_mismatch_vec_eigen_mixed) { +TEST(RevMath, cov_exp_quad2_dim_mismatch_vec_eigen_mixed) { using stan::math::var; var sigma = 0.2; var l = 5; @@ -1308,7 +1308,7 @@ TEST_F(AgradRev, RevMath_cov_exp_quad2_dim_mismatch_vec_eigen_mixed) { EXPECT_THROW(stan::math::cov_exp_quad(x_vec_2, x_rvec_2, sigma, l), std::invalid_argument); } -TEST_F(AgradRev, RevMatrix_cov_exp_quad_check_varis_on_stack) { +TEST(AgradRevMatrix, cov_exp_quad_check_varis_on_stack) { using stan::math::to_var; std::vector x(3); double sigma = 0.2; diff --git a/test/unit/math/rev/fun/dimensions_test.cpp b/test/unit/math/rev/fun/dimensions_test.cpp index 8c4b4d9865c..9aa32037efd 100644 --- a/test/unit/math/rev/fun/dimensions_test.cpp +++ b/test/unit/math/rev/fun/dimensions_test.cpp @@ -1,10 +1,9 @@ #include -#include #include #include #include -TEST_F(AgradRev, RevMatrix_col_varmat) { +TEST(AgradRevMatrix, col_varmat) { using stan::math::var_value; Eigen::MatrixXd m(2, 3); m << 0, 1, 2, 3, 4, 5; @@ -13,7 +12,7 @@ TEST_F(AgradRev, RevMatrix_col_varmat) { EXPECT_MATRIX_FLOAT_EQ(stan::math::col(m_v, 2).val(), stan::math::col(m, 2)); } -TEST_F(AgradRev, RevMatrix_row_varmat) { +TEST(AgradRevMatrix, row_varmat) { using stan::math::var_value; Eigen::MatrixXd m(2, 3); m << 0, 1, 2, 3, 4, 5; @@ -22,7 +21,7 @@ TEST_F(AgradRev, RevMatrix_row_varmat) { EXPECT_MATRIX_FLOAT_EQ(stan::math::row(m_v, 2).val(), stan::math::row(m, 2)); } -TEST_F(AgradRev, RevMatrix_dims_varmat) { +TEST(AgradRevMatrix, dims_varmat) { using stan::math::var_value; Eigen::MatrixXd m(2, 3); m << 0, 1, 2, 3, 4, 5; @@ -30,7 +29,7 @@ TEST_F(AgradRev, RevMatrix_dims_varmat) { var_value m_v(m); EXPECT_STD_VECTOR_EQ(stan::math::dims(m_v), stan::math::dims(m)); } -TEST_F(AgradRev, RevMatrix_num_elements_varmat) { +TEST(AgradRevMatrix, num_elements_varmat) { using stan::math::var_value; Eigen::MatrixXd m(2, 3); m << 0, 1, 2, 3, 4, 5; @@ -39,7 +38,7 @@ TEST_F(AgradRev, RevMatrix_num_elements_varmat) { EXPECT_EQ(stan::math::num_elements(m_v), stan::math::num_elements(m)); } -TEST_F(AgradRev, RevMatrix_diagonal_varmat) { +TEST(AgradRevMatrix, diagonal_varmat) { using stan::math::var_value; Eigen::MatrixXd m(2, 3); m << 0, 1, 2, 3, 4, 5; @@ -49,7 +48,7 @@ TEST_F(AgradRev, RevMatrix_diagonal_varmat) { stan::math::diagonal(m)); } -TEST_F(AgradRev, RevMatrix_subsets_varmat) { +TEST(AgradRevMatrix, subsets_varmat) { using stan::math::var_value; Eigen::MatrixXd m(2, 3); m << 0, 1, 2, 3, 4, 5; @@ -61,7 +60,7 @@ TEST_F(AgradRev, RevMatrix_subsets_varmat) { stan::math::sub_col(m, 1, 1, 2)); } -TEST_F(AgradRev, RevMatrix_transpose_varmat) { +TEST(AgradRevMatrix, transpose_varmat) { using stan::math::var_value; Eigen::MatrixXd m(2, 3); m << 0, 1, 2, 3, 4, 5; @@ -71,7 +70,7 @@ TEST_F(AgradRev, RevMatrix_transpose_varmat) { stan::math::transpose(m)); } -TEST_F(AgradRev, RevMatrix_head_varmat) { +TEST(AgradRevMatrix, head_varmat) { using stan::math::var_value; Eigen::VectorXd vec(6); vec << 0, 1, 2, 3, 4, 5; @@ -81,7 +80,7 @@ TEST_F(AgradRev, RevMatrix_head_varmat) { stan::math::head(vec, 2)); } -TEST_F(AgradRev, RevMatrix_tail_varmat) { +TEST(AgradRevMatrix, tail_varmat) { using stan::math::var_value; Eigen::VectorXd vec(6); vec << 0, 1, 2, 3, 4, 5; @@ -91,7 +90,7 @@ TEST_F(AgradRev, RevMatrix_tail_varmat) { stan::math::tail(vec, 2)); } -TEST_F(AgradRev, RevMatrix_reverse_varmat) { +TEST(AgradRevMatrix, reverse_varmat) { using stan::math::var_value; Eigen::VectorXd vec(6); vec << 0, 1, 2, 3, 4, 5; @@ -101,7 +100,7 @@ TEST_F(AgradRev, RevMatrix_reverse_varmat) { stan::math::reverse(vec)); } -TEST_F(AgradRev, RevMatrix_segment_varmat) { +TEST(AgradRevMatrix, segment_varmat) { using stan::math::var_value; Eigen::VectorXd vec(6); vec << 0, 1, 2, 3, 4, 5; diff --git a/test/unit/math/rev/fun/eigenvalues_sym_test.cpp b/test/unit/math/rev/fun/eigenvalues_sym_test.cpp index 740756708fc..1399a2d9c73 100644 --- a/test/unit/math/rev/fun/eigenvalues_sym_test.cpp +++ b/test/unit/math/rev/fun/eigenvalues_sym_test.cpp @@ -1,11 +1,10 @@ #include -#include #include #include #include #include -TEST_F(AgradRev, Rev_eigenvaluesSymLogDet) { +TEST(AgradRev, eigenvaluesSymLogDet) { // logdet(A) can be calculated using eigenvalues of matrix A // the derivative of logdet(A) should be inverse(A) // See stan-dev/math/issues/1803 diff --git a/test/unit/math/rev/fun/eigenvectors_sym_test.cpp b/test/unit/math/rev/fun/eigenvectors_sym_test.cpp index a93aac0bc5d..46428343934 100644 --- a/test/unit/math/rev/fun/eigenvectors_sym_test.cpp +++ b/test/unit/math/rev/fun/eigenvectors_sym_test.cpp @@ -1,12 +1,11 @@ #include -#include #include #include #include #include #include -TEST_F(AgradRev, Rev_eigenvectorsSym) { +TEST(AgradRev, eigenvectorsSym) { Eigen::MatrixXd a(4, 4); // Random symmetric matrix a << 1.8904, 0.7204, -0.1599, 1.2028, 0.7204, 7.3394, 2.0895, -0.6151, diff --git a/test/unit/math/rev/fun/fill_test.cpp b/test/unit/math/rev/fun/fill_test.cpp index 18cdbf10d0e..7dae163c0f7 100644 --- a/test/unit/math/rev/fun/fill_test.cpp +++ b/test/unit/math/rev/fun/fill_test.cpp @@ -1,6 +1,6 @@ #include -#include #include +#include #include #include diff --git a/test/unit/math/rev/fun/from_var_value_test.cpp b/test/unit/math/rev/fun/from_var_value_test.cpp index 3980de6649e..978ae2569cf 100644 --- a/test/unit/math/rev/fun/from_var_value_test.cpp +++ b/test/unit/math/rev/fun/from_var_value_test.cpp @@ -1,10 +1,9 @@ #include -#include #include #include #include -TEST_F(AgradRev, RevMatrix_from_var_value_types) { +TEST(AgradRevMatrix, from_var_value_types) { using stan::math::from_var_value; using stan::math::var; using stan::math::var_value; @@ -59,7 +58,7 @@ TEST_F(AgradRev, RevMatrix_from_var_value_types) { stan::math::recover_memory(); } -TEST_F(AgradRev, RevMatrix_from_var_value_vec_types) { +TEST(AgradRevMatrix, from_var_value_vec_types) { using stan::math::from_var_value; using stan::math::var; using stan::math::var_value; @@ -105,7 +104,7 @@ TEST_F(AgradRev, RevMatrix_from_var_value_vec_types) { stan::math::recover_memory(); } -TEST_F(AgradRev, RevMatrix_from_var_value_matrix_test) { +TEST(AgradRevMatrix, from_var_value_matrix_test) { Eigen::MatrixXd val(2, 3); val << 1, 2, 3, 4, 5, 6; Eigen::MatrixXd adj(2, 3); @@ -119,7 +118,7 @@ TEST_F(AgradRev, RevMatrix_from_var_value_matrix_test) { EXPECT_MATRIX_EQ(var_value.adj(), adj); } -TEST_F(AgradRev, RevMatrix_from_var_value_vector_test) { +TEST(AgradRevMatrix, from_var_value_vector_test) { Eigen::VectorXd val(3); val << 1, 2, 3; Eigen::VectorXd adj(3); @@ -133,7 +132,7 @@ TEST_F(AgradRev, RevMatrix_from_var_value_vector_test) { EXPECT_MATRIX_EQ(var_value.adj(), adj); } -TEST_F(AgradRev, RevMatrix_from_var_value_row_vector_test) { +TEST(AgradRevMatrix, from_var_value_row_vector_test) { Eigen::RowVectorXd val(3); val << 1, 2, 3; Eigen::RowVectorXd adj(3); @@ -147,7 +146,7 @@ TEST_F(AgradRev, RevMatrix_from_var_value_row_vector_test) { EXPECT_MATRIX_EQ(var_value.adj(), adj); } -TEST_F(AgradRev, RevMatrix_from_var_value_matrix_svec_test) { +TEST(AgradRevMatrix, from_var_value_matrix_svec_test) { std::vector> varmats; @@ -166,7 +165,7 @@ TEST_F(AgradRev, RevMatrix_from_var_value_matrix_svec_test) { } } -TEST_F(AgradRev, RevMatrix_from_var_value_vector_svec_test) { +TEST(AgradRevMatrix, from_var_value_vector_svec_test) { std::vector> varmats; @@ -185,7 +184,7 @@ TEST_F(AgradRev, RevMatrix_from_var_value_vector_svec_test) { } } -TEST_F(AgradRev, RevMatrix_from_var_value_row_vector_svec_test) { +TEST(AgradRevMatrix, from_var_value_row_vector_svec_test) { std::vector> varmats; @@ -204,7 +203,7 @@ TEST_F(AgradRev, RevMatrix_from_var_value_row_vector_svec_test) { } } -TEST_F(AgradRev, RevMatrix_from_var_value_prim_test) { +TEST(AgradRevMatrix, from_var_value_prim_test) { Eigen::MatrixXd a(3, 2); a << 1, 2, 3, 4, 5, 6; Eigen::VectorXd b(3); diff --git a/test/unit/math/rev/fun/get_lp_test.cpp b/test/unit/math/rev/fun/get_lp_test.cpp index eed3ef7105a..5b42e93e69a 100644 --- a/test/unit/math/rev/fun/get_lp_test.cpp +++ b/test/unit/math/rev/fun/get_lp_test.cpp @@ -1,8 +1,8 @@ #include -#include #include +#include -TEST_F(AgradRev, MathMatrixRevMat_getLp) { +TEST(MathMatrixRevMat, getLp) { using stan::math::accumulator; using stan::math::get_lp; using stan::math::var; @@ -16,7 +16,7 @@ TEST_F(AgradRev, MathMatrixRevMat_getLp) { EXPECT_FLOAT_EQ(17.5, get_lp(lp, lp_accum).val()); } -TEST_F(AgradRev, RevMatrix_get_lp_check_varis_on_stack) { +TEST(AgradRevMatrix, get_lp_check_varis_on_stack) { using stan::math::accumulator; using stan::math::get_lp; using stan::math::var; diff --git a/test/unit/math/rev/fun/gp_exp_quad_cov_test.cpp b/test/unit/math/rev/fun/gp_exp_quad_cov_test.cpp index 81fdea2cb1f..7d577592d2b 100644 --- a/test/unit/math/rev/fun/gp_exp_quad_cov_test.cpp +++ b/test/unit/math/rev/fun/gp_exp_quad_cov_test.cpp @@ -1,12 +1,12 @@ #include +#include #include #include -#include #include #include #include -TEST_F(AgradRev, RevMath_gp_exp_quad_cov_vvv) { +TEST(RevMath, gp_exp_quad_cov_vvv) { Eigen::Matrix cov; for (std::size_t i = 0; i < 3; ++i) { @@ -54,7 +54,7 @@ TEST_F(AgradRev, RevMath_gp_exp_quad_cov_vvv) { } } -TEST_F(AgradRev, RevMath_gp_exp_quad_cov_vvd) { +TEST(RevMath, gp_exp_quad_cov_vvd) { Eigen::Matrix cov; double l = 5; @@ -98,7 +98,7 @@ TEST_F(AgradRev, RevMath_gp_exp_quad_cov_vvd) { } } -TEST_F(AgradRev, RevMath_gp_exp_quad_cov_vdv) { +TEST(RevMath, gp_exp_quad_cov_vdv) { Eigen::Matrix cov; double sigma = 0.2; @@ -139,7 +139,7 @@ TEST_F(AgradRev, RevMath_gp_exp_quad_cov_vdv) { } } -TEST_F(AgradRev, RevMath_gp_exp_quad_cov_vdd) { +TEST(RevMath, gp_exp_quad_cov_vdd) { Eigen::Matrix cov; double sigma = 0.2; double l = 5; @@ -176,7 +176,7 @@ TEST_F(AgradRev, RevMath_gp_exp_quad_cov_vdd) { } } -TEST_F(AgradRev, RevMath_gp_exp_quad_cov_dvv) { +TEST(RevMath, gp_exp_quad_cov_dvv) { Eigen::Matrix cov; std::vector x(3); x[0] = -2; @@ -216,7 +216,7 @@ TEST_F(AgradRev, RevMath_gp_exp_quad_cov_dvv) { } } -TEST_F(AgradRev, RevMath_gp_exp_quad_cov_dvd) { +TEST(RevMath, gp_exp_quad_cov_dvd) { Eigen::Matrix cov; std::vector x(3); x[0] = -2; @@ -251,7 +251,7 @@ TEST_F(AgradRev, RevMath_gp_exp_quad_cov_dvd) { } } -TEST_F(AgradRev, RevMath_gp_exp_quad_cov_ddv) { +TEST(RevMath, gp_exp_quad_cov_ddv) { Eigen::Matrix cov; std::vector x(3); x[0] = -2; @@ -285,7 +285,7 @@ TEST_F(AgradRev, RevMath_gp_exp_quad_cov_ddv) { } } -TEST_F(AgradRev, RevMath_gp_exp_quad_cov_vector_vvv) { +TEST(RevMath, gp_exp_quad_cov_vector_vvv) { typedef Eigen::Matrix vector_v; Eigen::Matrix cov; @@ -352,7 +352,7 @@ TEST_F(AgradRev, RevMath_gp_exp_quad_cov_vector_vvv) { } } -TEST_F(AgradRev, RevMath_gp_exp_quad_cov_vector_vvd) { +TEST(RevMath, gp_exp_quad_cov_vector_vvd) { typedef Eigen::Matrix vector_v; Eigen::Matrix cov; double l = 5; @@ -414,7 +414,7 @@ TEST_F(AgradRev, RevMath_gp_exp_quad_cov_vector_vvd) { } } -TEST_F(AgradRev, RevMath_gp_exp_quad_cov_vector_vdv) { +TEST(RevMath, gp_exp_quad_cov_vector_vdv) { typedef Eigen::Matrix vector_v; Eigen::Matrix cov; double sigma = 0.2; @@ -476,7 +476,7 @@ TEST_F(AgradRev, RevMath_gp_exp_quad_cov_vector_vdv) { } } -TEST_F(AgradRev, RevMath_gp_exp_quad_cov_vector_vdd) { +TEST(RevMath, gp_exp_quad_cov_vector_vdd) { typedef Eigen::Matrix vector_v; Eigen::Matrix cov; double sigma = 0.2; @@ -533,7 +533,7 @@ TEST_F(AgradRev, RevMath_gp_exp_quad_cov_vector_vdd) { } } -TEST_F(AgradRev, RevMath_gp_exp_quad_cov_vector_dvv) { +TEST(RevMath, gp_exp_quad_cov_vector_dvv) { typedef Eigen::Matrix vector_d; Eigen::Matrix cov; @@ -603,7 +603,7 @@ TEST_F(AgradRev, RevMath_gp_exp_quad_cov_vector_dvv) { } } -TEST_F(AgradRev, RevMath_gp_exp_quad_cov_vector_dvd) { +TEST(RevMath, gp_exp_quad_cov_vector_dvd) { typedef Eigen::Matrix vector_d; Eigen::Matrix cov; std::vector x(3); @@ -648,7 +648,7 @@ TEST_F(AgradRev, RevMath_gp_exp_quad_cov_vector_dvd) { } } -TEST_F(AgradRev, RevMath_gp_exp_quad_cov_vector_ddv) { +TEST(RevMath, gp_exp_quad_cov_vector_ddv) { typedef Eigen::Matrix vector_d; Eigen::Matrix cov; std::vector x(3); @@ -693,7 +693,7 @@ TEST_F(AgradRev, RevMath_gp_exp_quad_cov_vector_ddv) { } } -TEST_F(AgradRev, RevMath_gp_exp_quad_cov1_vec_eigen_rvec) { +TEST(RevMath, gp_exp_quad_cov1_vec_eigen_rvec) { using stan::math::squared_distance; using stan::math::var; @@ -720,7 +720,7 @@ TEST_F(AgradRev, RevMath_gp_exp_quad_cov1_vec_eigen_rvec) { << "index: (" << i << ", " << j << ")"; } -TEST_F(AgradRev, RevMath_gp_exp_quad_cov2_vec_eigen_rvec) { +TEST(RevMath, gp_exp_quad_cov2_vec_eigen_rvec) { using stan::math::squared_distance; using stan::math::var; var sigma = 0.2; @@ -766,7 +766,7 @@ TEST_F(AgradRev, RevMath_gp_exp_quad_cov2_vec_eigen_rvec) { } } -TEST_F(AgradRev, RevMath_gp_exp_quad_cov2_vec_eigen_mixed) { +TEST(RevMath, gp_exp_quad_cov2_vec_eigen_mixed) { using stan::math::squared_distance; using stan::math::var; var sigma = 0.2; @@ -910,7 +910,7 @@ TEST_F(AgradRev, RevMath_gp_exp_quad_cov2_vec_eigen_mixed) { } } -TEST_F(AgradRev, RevMath_gp_exp_quad_cov_domain_error_training) { +TEST(RevMath, gp_exp_quad_cov_domain_error_training) { using stan::math::var; var sigma = 0.2; var l = 5; @@ -957,7 +957,7 @@ TEST_F(AgradRev, RevMath_gp_exp_quad_cov_domain_error_training) { std::domain_error); } -TEST_F(AgradRev, RevMath_gp_exp_quad_cov_nan_error_training) { +TEST(RevMath, gp_exp_quad_cov_nan_error_training) { using stan::math::var; var sigma = 0.2; var l = 5; @@ -1038,7 +1038,7 @@ TEST_F(AgradRev, RevMath_gp_exp_quad_cov_nan_error_training) { std::domain_error); } -TEST_F(AgradRev, RevMath_gp_exp_quad_cov_domain_error) { +TEST(RevMath, gp_exp_quad_cov_domain_error) { using stan::math::var; var sigma = 0.2; var l = 5; @@ -1118,7 +1118,7 @@ TEST_F(AgradRev, RevMath_gp_exp_quad_cov_domain_error) { std::domain_error); } -TEST_F(AgradRev, RevMath_gp_exp_quad_cov2_nan_domain_error) { +TEST(RevMath, gp_exp_quad_cov2_nan_domain_error) { using stan::math::var; var sigma = 0.2; var l = 5; @@ -1248,7 +1248,7 @@ TEST_F(AgradRev, RevMath_gp_exp_quad_cov2_nan_domain_error) { std::domain_error); } -TEST_F(AgradRev, RevMath_gp_exp_quad_cov2_dim_mismatch_vec_eigen_vec) { +TEST(RevMath, gp_exp_quad_cov2_dim_mismatch_vec_eigen_vec) { using stan::math::var; var sigma = 0.2; var l = 5; @@ -1269,7 +1269,7 @@ TEST_F(AgradRev, RevMath_gp_exp_quad_cov2_dim_mismatch_vec_eigen_vec) { std::invalid_argument); } -TEST_F(AgradRev, RevMath_gp_exp_quad_cov2_dim_mismatch_vec_eigen_rvec) { +TEST(RevMath, gp_exp_quad_cov2_dim_mismatch_vec_eigen_rvec) { using stan::math::var; var sigma = 0.2; var l = 5; @@ -1290,7 +1290,7 @@ TEST_F(AgradRev, RevMath_gp_exp_quad_cov2_dim_mismatch_vec_eigen_rvec) { std::invalid_argument); } -TEST_F(AgradRev, RevMath_gp_exp_quad_cov2_dim_mismatch_vec_eigen_mixed) { +TEST(RevMath, gp_exp_quad_cov2_dim_mismatch_vec_eigen_mixed) { using stan::math::var; var sigma = 0.2; var l = 5; @@ -1329,7 +1329,7 @@ TEST_F(AgradRev, RevMath_gp_exp_quad_cov2_dim_mismatch_vec_eigen_mixed) { EXPECT_THROW(stan::math::gp_exp_quad_cov(x_vec_2, x_rvec_2, sigma, l), std::invalid_argument); } -TEST_F(AgradRev, RevMatrix_gp_exp_quad_cov_check_varis_on_stack) { +TEST(AgradRevMatrix, gp_exp_quad_cov_check_varis_on_stack) { using stan::math::to_var; std::vector x(3); double sigma = 0.2; diff --git a/test/unit/math/rev/fun/gp_periodic_cov_test.cpp b/test/unit/math/rev/fun/gp_periodic_cov_test.cpp index 992e55671a0..383b16ebd35 100644 --- a/test/unit/math/rev/fun/gp_periodic_cov_test.cpp +++ b/test/unit/math/rev/fun/gp_periodic_cov_test.cpp @@ -6,7 +6,7 @@ #include #include -TEST_F(AgradRev, RevMath_gp_periodic_cov_vvvv) { +TEST(RevMath, gp_periodic_cov_vvvv) { Eigen::Matrix cov; for (std::size_t i = 0; i < 3; ++i) { @@ -80,7 +80,7 @@ TEST_F(AgradRev, RevMath_gp_periodic_cov_vvvv) { } } -TEST_F(AgradRev, RevMath_gp_periodic_cov_vvvd) { +TEST(RevMath, gp_periodic_cov_vvvd) { Eigen::Matrix cov; double p = 7; @@ -134,7 +134,7 @@ TEST_F(AgradRev, RevMath_gp_periodic_cov_vvvd) { } } -TEST_F(AgradRev, RevMath_gp_periodic_cov_vvdv) { +TEST(RevMath, gp_periodic_cov_vvdv) { Eigen::Matrix cov; double l = 5; @@ -189,7 +189,7 @@ TEST_F(AgradRev, RevMath_gp_periodic_cov_vvdv) { } } -TEST_F(AgradRev, RevMath_gp_periodic_cov_vdvv) { +TEST(RevMath, gp_periodic_cov_vdvv) { Eigen::Matrix cov; double sigma = 0.2; @@ -244,7 +244,7 @@ TEST_F(AgradRev, RevMath_gp_periodic_cov_vdvv) { } } -TEST_F(AgradRev, RevMath_gp_periodic_cov_vvdd) { +TEST(RevMath, gp_periodic_cov_vvdd) { Eigen::Matrix cov; double l = 5; @@ -293,7 +293,7 @@ TEST_F(AgradRev, RevMath_gp_periodic_cov_vvdd) { } } -TEST_F(AgradRev, RevMath_gp_periodic_cov_vdvd) { +TEST(RevMath, gp_periodic_cov_vdvd) { Eigen::Matrix cov; double sigma = 0.2; @@ -342,7 +342,7 @@ TEST_F(AgradRev, RevMath_gp_periodic_cov_vdvd) { } } -TEST_F(AgradRev, RevMath_gp_periodic_cov_vddv) { +TEST(RevMath, gp_periodic_cov_vddv) { Eigen::Matrix cov; double sigma = 0.2; @@ -392,7 +392,7 @@ TEST_F(AgradRev, RevMath_gp_periodic_cov_vddv) { } } -TEST_F(AgradRev, RevMath_gp_periodic_cov_vddd) { +TEST(RevMath, gp_periodic_cov_vddd) { Eigen::Matrix cov; double sigma = 0.2; double l = 5; @@ -436,7 +436,7 @@ TEST_F(AgradRev, RevMath_gp_periodic_cov_vddd) { } } -TEST_F(AgradRev, RevMath_gp_periodic_cov_dvvv) { +TEST(RevMath, gp_periodic_cov_dvvv) { Eigen::Matrix cov; std::vector x(3); x[0] = -2; @@ -485,7 +485,7 @@ TEST_F(AgradRev, RevMath_gp_periodic_cov_dvvv) { } } -TEST_F(AgradRev, RevMath_gp_periodic_cov_dvvd) { +TEST(RevMath, gp_periodic_cov_dvvd) { Eigen::Matrix cov; std::vector x(3); x[0] = -2; @@ -527,7 +527,7 @@ TEST_F(AgradRev, RevMath_gp_periodic_cov_dvvd) { } } ////////////////////////////////////////////////////// -TEST_F(AgradRev, RevMath_gp_periodic_cov_dvdv) { +TEST(RevMath, gp_periodic_cov_dvdv) { Eigen::Matrix cov; std::vector x(3); x[0] = -2; @@ -571,7 +571,7 @@ TEST_F(AgradRev, RevMath_gp_periodic_cov_dvdv) { } } -TEST_F(AgradRev, RevMath_gp_periodic_cov_ddvv) { +TEST(RevMath, gp_periodic_cov_ddvv) { Eigen::Matrix cov; std::vector x(3); x[0] = -2; @@ -631,7 +631,7 @@ TEST_F(AgradRev, RevMath_gp_periodic_cov_ddvv) { } } -TEST_F(AgradRev, RevMath_gp_periodic_cov_ddvd) { +TEST(RevMath, gp_periodic_cov_ddvd) { Eigen::Matrix cov; std::vector x(3); x[0] = -2; @@ -669,7 +669,7 @@ TEST_F(AgradRev, RevMath_gp_periodic_cov_ddvd) { } } -TEST_F(AgradRev, RevMath_gp_periodic_cov_dddv) { +TEST(RevMath, gp_periodic_cov_dddv) { Eigen::Matrix cov; std::vector x(3); x[0] = -2; @@ -709,7 +709,7 @@ TEST_F(AgradRev, RevMath_gp_periodic_cov_dddv) { } } -TEST_F(AgradRev, RevMath_gp_periodic_cov_dvdd) { +TEST(RevMath, gp_periodic_cov_dvdd) { Eigen::Matrix cov; std::vector x(3); x[0] = -2; @@ -746,7 +746,7 @@ TEST_F(AgradRev, RevMath_gp_periodic_cov_dvdd) { } } -TEST_F(AgradRev, RevMath_gp_periodic_cov_vector_vvvv) { +TEST(RevMath, gp_periodic_cov_vector_vvvv) { typedef Eigen::Matrix vector_v; Eigen::Matrix cov; @@ -837,7 +837,7 @@ TEST_F(AgradRev, RevMath_gp_periodic_cov_vector_vvvv) { } //////////////////////////////////////////////////////////////////////////// -TEST_F(AgradRev, RevMath_gp_periodic_cov_vector_vvvd) { +TEST(RevMath, gp_periodic_cov_vector_vvvd) { typedef Eigen::Matrix vector_v; Eigen::Matrix cov; @@ -921,7 +921,7 @@ TEST_F(AgradRev, RevMath_gp_periodic_cov_vector_vvvd) { } } -TEST_F(AgradRev, RevMath_gp_periodic_cov_vector_vvdv) { +TEST(RevMath, gp_periodic_cov_vector_vvdv) { typedef Eigen::Matrix vector_v; Eigen::Matrix cov; double l = 5; @@ -1006,7 +1006,7 @@ TEST_F(AgradRev, RevMath_gp_periodic_cov_vector_vvdv) { } } -TEST_F(AgradRev, RevMath_gp_periodic_cov_vector_vdvv) { +TEST(RevMath, gp_periodic_cov_vector_vdvv) { typedef Eigen::Matrix vector_v; Eigen::Matrix cov; double sigma = 0.2; @@ -1092,7 +1092,7 @@ TEST_F(AgradRev, RevMath_gp_periodic_cov_vector_vdvv) { } } -TEST_F(AgradRev, RevMath_gp_periodic_cov_vector_vvdd) { +TEST(RevMath, gp_periodic_cov_vector_vvdd) { typedef Eigen::Matrix vector_v; Eigen::Matrix cov; double l = 5; @@ -1171,7 +1171,7 @@ TEST_F(AgradRev, RevMath_gp_periodic_cov_vector_vvdd) { } } -TEST_F(AgradRev, RevMath_gp_periodic_cov_vector_vdvd) { +TEST(RevMath, gp_periodic_cov_vector_vdvd) { typedef Eigen::Matrix vector_v; Eigen::Matrix cov; double sigma = 0.2; @@ -1251,7 +1251,7 @@ TEST_F(AgradRev, RevMath_gp_periodic_cov_vector_vdvd) { } } -TEST_F(AgradRev, RevMath_gp_periodic_cov_vector_vddv) { +TEST(RevMath, gp_periodic_cov_vector_vddv) { typedef Eigen::Matrix vector_v; Eigen::Matrix cov; double sigma = 0.2; @@ -1332,7 +1332,7 @@ TEST_F(AgradRev, RevMath_gp_periodic_cov_vector_vddv) { } } -TEST_F(AgradRev, RevMath_gp_periodic_cov_vector_vddd) { +TEST(RevMath, gp_periodic_cov_vector_vddd) { typedef Eigen::Matrix vector_v; Eigen::Matrix cov; double sigma = 0.2; @@ -1406,7 +1406,7 @@ TEST_F(AgradRev, RevMath_gp_periodic_cov_vector_vddd) { } } -TEST_F(AgradRev, RevMath_gp_periodic_cov_vector_dvvv) { +TEST(RevMath, gp_periodic_cov_vector_dvvv) { typedef Eigen::Matrix vector_d; Eigen::Matrix cov; @@ -1466,7 +1466,7 @@ TEST_F(AgradRev, RevMath_gp_periodic_cov_vector_dvvv) { } } -TEST_F(AgradRev, RevMath_gp_periodic_cov_vector_dvvd) { +TEST(RevMath, gp_periodic_cov_vector_dvvd) { typedef Eigen::Matrix vector_d; Eigen::Matrix cov; @@ -1519,7 +1519,7 @@ TEST_F(AgradRev, RevMath_gp_periodic_cov_vector_dvvd) { } } -TEST_F(AgradRev, RevMath_gp_periodic_cov_vector_dvdv) { +TEST(RevMath, gp_periodic_cov_vector_dvdv) { typedef Eigen::Matrix vector_d; Eigen::Matrix cov; @@ -1574,7 +1574,7 @@ TEST_F(AgradRev, RevMath_gp_periodic_cov_vector_dvdv) { } } -TEST_F(AgradRev, RevMath_gp_periodic_cov_vector_ddvv) { +TEST(RevMath, gp_periodic_cov_vector_ddvv) { typedef Eigen::Matrix vector_d; Eigen::Matrix cov; @@ -1630,7 +1630,7 @@ TEST_F(AgradRev, RevMath_gp_periodic_cov_vector_ddvv) { } } -TEST_F(AgradRev, RevMath_gp_periodic_cov_vector_dvdd) { +TEST(RevMath, gp_periodic_cov_vector_dvdd) { typedef Eigen::Matrix vector_d; Eigen::Matrix cov; @@ -1679,7 +1679,7 @@ TEST_F(AgradRev, RevMath_gp_periodic_cov_vector_dvdd) { } } -TEST_F(AgradRev, RevMath_gp_periodic_cov_vector_ddvd) { +TEST(RevMath, gp_periodic_cov_vector_ddvd) { typedef Eigen::Matrix vector_d; Eigen::Matrix cov; @@ -1728,7 +1728,7 @@ TEST_F(AgradRev, RevMath_gp_periodic_cov_vector_ddvd) { } } -TEST_F(AgradRev, RevMath_gp_periodic_cov_vector_dddv) { +TEST(RevMath, gp_periodic_cov_vector_dddv) { typedef Eigen::Matrix vector_d; Eigen::Matrix cov; @@ -1779,7 +1779,7 @@ TEST_F(AgradRev, RevMath_gp_periodic_cov_vector_dddv) { } } -TEST_F(AgradRev, RevMath_gp_periodic_cov1_vec_eigen_rvec) { +TEST(RevMath, gp_periodic_cov1_vec_eigen_rvec) { using stan::math::squared_distance; using stan::math::var; @@ -1812,7 +1812,7 @@ TEST_F(AgradRev, RevMath_gp_periodic_cov1_vec_eigen_rvec) { } } -TEST_F(AgradRev, RevMath_gp_periodic_cov2_vec_eigen_rvec) { +TEST(RevMath, gp_periodic_cov2_vec_eigen_rvec) { using stan::math::squared_distance; using stan::math::var; var sigma = 0.2; @@ -1868,7 +1868,7 @@ TEST_F(AgradRev, RevMath_gp_periodic_cov2_vec_eigen_rvec) { } } -TEST_F(AgradRev, RevMath_gp_periodic_cov2_vec_eigen_mixed) { +TEST(RevMath, gp_periodic_cov2_vec_eigen_mixed) { using stan::math::squared_distance; using stan::math::var; var sigma = 0.2; @@ -2046,7 +2046,7 @@ TEST_F(AgradRev, RevMath_gp_periodic_cov2_vec_eigen_mixed) { } } -TEST_F(AgradRev, RevMath_gp_periodic_cov_domain_error_training) { +TEST(RevMath, gp_periodic_cov_domain_error_training) { using stan::math::var; var sigma = 0.2; var l = 5; @@ -2119,7 +2119,7 @@ TEST_F(AgradRev, RevMath_gp_periodic_cov_domain_error_training) { std::domain_error); } -TEST_F(AgradRev, RevMath_gp_periodic_cov_nan_error_training) { +TEST(RevMath, gp_periodic_cov_nan_error_training) { using stan::math::var; var sigma = 0.2; var l = 5; @@ -2250,7 +2250,7 @@ TEST_F(AgradRev, RevMath_gp_periodic_cov_nan_error_training) { std::domain_error); } -TEST_F(AgradRev, RevMath_gp_periodic_cov_domain_error) { +TEST(RevMath, gp_periodic_cov_domain_error) { using stan::math::var; var sigma = 0.2; var l = 5; @@ -2387,7 +2387,7 @@ TEST_F(AgradRev, RevMath_gp_periodic_cov_domain_error) { std::domain_error); } -TEST_F(AgradRev, RevMath_gp_periodic_cov2_nan_domain_error) { +TEST(RevMath, gp_periodic_cov2_nan_domain_error) { using stan::math::var; var sigma = 0.2; var l = 5; @@ -2577,7 +2577,7 @@ TEST_F(AgradRev, RevMath_gp_periodic_cov2_nan_domain_error) { std::domain_error); } -TEST_F(AgradRev, RevMath_gp_periodic_cov2_dim_mismatch_vec_eigen_vec) { +TEST(RevMath, gp_periodic_cov2_dim_mismatch_vec_eigen_vec) { using stan::math::var; var sigma = 0.2; var l = 5; @@ -2599,7 +2599,7 @@ TEST_F(AgradRev, RevMath_gp_periodic_cov2_dim_mismatch_vec_eigen_vec) { std::invalid_argument); } -TEST_F(AgradRev, RevMath_gp_periodic_cov2_dim_mismatch_vec_eigen_rvec) { +TEST(RevMath, gp_periodic_cov2_dim_mismatch_vec_eigen_rvec) { using stan::math::var; var sigma = 0.2; var l = 5; @@ -2621,7 +2621,7 @@ TEST_F(AgradRev, RevMath_gp_periodic_cov2_dim_mismatch_vec_eigen_rvec) { std::invalid_argument); } -TEST_F(AgradRev, RevMath_gp_periodic_cov2_dim_mismatch_vec_eigen_mixed) { +TEST(RevMath, gp_periodic_cov2_dim_mismatch_vec_eigen_mixed) { using stan::math::var; var sigma = 0.2; var l = 5; @@ -2662,7 +2662,7 @@ TEST_F(AgradRev, RevMath_gp_periodic_cov2_dim_mismatch_vec_eigen_mixed) { std::invalid_argument); } -TEST_F(AgradRev, RevMatrix_gp_periodic_cov_check_varis_on_stack) { +TEST(AgradRevMatrix, gp_periodic_cov_check_varis_on_stack) { using stan::math::to_var; std::vector x(3); double sigma = 0.2; diff --git a/test/unit/math/rev/fun/if_else_test.cpp b/test/unit/math/rev/fun/if_else_test.cpp index 89d35ad9723..93e8a97120f 100644 --- a/test/unit/math/rev/fun/if_else_test.cpp +++ b/test/unit/math/rev/fun/if_else_test.cpp @@ -1,10 +1,10 @@ #include -#include #include +#include #include #include -TEST_F(AgradRev, Rev_if_else) { +TEST(AgradRev, if_else) { using stan::math::if_else; using stan::math::var; @@ -18,7 +18,7 @@ TEST_F(AgradRev, Rev_if_else) { EXPECT_FLOAT_EQ(2.0, if_else(false, var(1.0), 2.0).val()); } -TEST_F(AgradRev, Rev_if_else_nan) { +TEST(AgradRev, if_else_nan) { using stan::math::if_else; double nan = std::numeric_limits::quiet_NaN(); @@ -49,7 +49,7 @@ TEST_F(AgradRev, Rev_if_else_nan) { EXPECT_TRUE(std::isnan(if_else(false, nan_v, nan_v).val())); } -TEST_F(AgradRev, Rev_if_else_check_varis_on_stack) { +TEST(AgradRev, if_else_check_varis_on_stack) { stan::math::var x = 1.0; stan::math::var y = 2.0; test::check_varis_on_stack(stan::math::if_else(true, x, y)); diff --git a/test/unit/math/rev/fun/initialize_fill_test.cpp b/test/unit/math/rev/fun/initialize_fill_test.cpp index 4cc4116a088..caaf9bcbc88 100644 --- a/test/unit/math/rev/fun/initialize_fill_test.cpp +++ b/test/unit/math/rev/fun/initialize_fill_test.cpp @@ -1,10 +1,9 @@ #include -#include #include #include #include -TEST_F(AgradRev, RevMatrix_initialize_fill) { +TEST(AgradRevMatrix, initialize_fill) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::initialize_fill; @@ -44,7 +43,7 @@ TEST_F(AgradRev, RevMatrix_initialize_fill) { for (size_t j = 0; j < 2; ++j) EXPECT_FLOAT_EQ(54, d[i][j].val()); } -TEST_F(AgradRev, RevMatrix_initialize_fillDouble) { +TEST(AgradRevMatrix, initialize_fillDouble) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::initialize_fill; @@ -54,7 +53,7 @@ TEST_F(AgradRev, RevMatrix_initialize_fillDouble) { EXPECT_FLOAT_EQ(3.0, y[0]); } -TEST_F(AgradRev, RevMatrix_initialize_fillVarMatDouble) { +TEST(AgradRevMatrix, initialize_fillVarMatDouble) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::initialize_fill; @@ -72,7 +71,7 @@ TEST_F(AgradRev, RevMatrix_initialize_fillVarMatDouble) { } } -TEST_F(AgradRev, RevMatrix_initialize_fillVarMatVar) { +TEST(AgradRevMatrix, initialize_fillVarMatVar) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::initialize_fill; diff --git a/test/unit/math/rev/fun/initialize_test.cpp b/test/unit/math/rev/fun/initialize_test.cpp index b6e557ad704..bdedeab7875 100644 --- a/test/unit/math/rev/fun/initialize_test.cpp +++ b/test/unit/math/rev/fun/initialize_test.cpp @@ -1,8 +1,7 @@ #include -#include #include -TEST_F(AgradRev, MathMatrixRevMat_initializeVar) { +TEST(MathMatrixRevMat, initializeVar) { using stan::math::initialize; using stan::math::var; var a; @@ -17,7 +16,7 @@ TEST_F(AgradRev, MathMatrixRevMat_initializeVar) { EXPECT_FLOAT_EQ(13.2, a.val()); } -TEST_F(AgradRev, MathMatrixRevMat_initMatrix) { +TEST(MathMatrixRevMat, initMatrix) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::initialize; diff --git a/test/unit/math/rev/fun/initialize_variable_test.cpp b/test/unit/math/rev/fun/initialize_variable_test.cpp index 2284851c96b..26e5d332f77 100644 --- a/test/unit/math/rev/fun/initialize_variable_test.cpp +++ b/test/unit/math/rev/fun/initialize_variable_test.cpp @@ -1,10 +1,9 @@ #include -#include #include #include #include -TEST_F(AgradRev, RevMatrix_initializeVariable) { +TEST(AgradRevMatrix, initializeVariable) { using stan::math::initialize_variable; using std::vector; diff --git a/test/unit/math/rev/fun/int_step_test.cpp b/test/unit/math/rev/fun/int_step_test.cpp index c5a49ac620e..d78dd41f406 100644 --- a/test/unit/math/rev/fun/int_step_test.cpp +++ b/test/unit/math/rev/fun/int_step_test.cpp @@ -1,9 +1,8 @@ #include -#include #include #include -TEST_F(AgradRev, Rev_int_step) { +TEST(AgradRev, int_step) { using stan::math::int_step; stan::math::var a(5.0); diff --git a/test/unit/math/rev/fun/inv_inc_beta_test.cpp b/test/unit/math/rev/fun/inv_inc_beta_test.cpp index 41c51bd2a2f..9f485a78e9c 100644 --- a/test/unit/math/rev/fun/inv_inc_beta_test.cpp +++ b/test/unit/math/rev/fun/inv_inc_beta_test.cpp @@ -1,9 +1,9 @@ #include -#include -#include #include +#include +#include -TEST_F(AgradRev, inv_inc_beta_values) { +TEST(inv_inc_beta, values) { using stan::math::inv_inc_beta; using stan::math::var; diff --git a/test/unit/math/rev/fun/is_any_nan_test.cpp b/test/unit/math/rev/fun/is_any_nan_test.cpp index e3b2a0ea7c9..7cb7f2ccf29 100644 --- a/test/unit/math/rev/fun/is_any_nan_test.cpp +++ b/test/unit/math/rev/fun/is_any_nan_test.cpp @@ -1,10 +1,10 @@ #include -#include -#include #include +#include +#include #include -TEST_F(AgradRev, MathFunctions_is_any_nan_variadic_rev) { +TEST(MathFunctions, is_any_nan_variadic_rev) { using stan::math::is_any_nan; double dbl_inf = std::numeric_limits::infinity(); diff --git a/test/unit/math/rev/fun/is_inf_test.cpp b/test/unit/math/rev/fun/is_inf_test.cpp index c73d1d75467..8def2e41472 100644 --- a/test/unit/math/rev/fun/is_inf_test.cpp +++ b/test/unit/math/rev/fun/is_inf_test.cpp @@ -1,10 +1,9 @@ #include -#include #include #include #include -TEST_F(AgradRev, Rev_is_inf) { +TEST(AgradRev, is_inf) { using stan::math::is_inf; double infinity = std::numeric_limits::infinity(); diff --git a/test/unit/math/rev/fun/is_nan_test.cpp b/test/unit/math/rev/fun/is_nan_test.cpp index 5c3a1f97679..176dc895330 100644 --- a/test/unit/math/rev/fun/is_nan_test.cpp +++ b/test/unit/math/rev/fun/is_nan_test.cpp @@ -1,10 +1,9 @@ #include -#include #include #include #include -TEST_F(AgradRev, Rev_is_nan) { +TEST(AgradRev, is_nan) { using stan::math::is_nan; double infinity = std::numeric_limits::infinity(); diff --git a/test/unit/math/rev/fun/is_uninitialized_test.cpp b/test/unit/math/rev/fun/is_uninitialized_test.cpp index e3337ff23ac..08e54f1c88d 100644 --- a/test/unit/math/rev/fun/is_uninitialized_test.cpp +++ b/test/unit/math/rev/fun/is_uninitialized_test.cpp @@ -1,16 +1,15 @@ #include -#include #include #include -TEST_F(AgradRev, Rev_undefined) { +TEST(AgradRev, undefined) { stan::math::var a; EXPECT_TRUE(a.is_uninitialized()); a = 5; EXPECT_FALSE(a.is_uninitialized()); } -TEST_F(AgradRev, Rev_is_uninitialized_nan) { +TEST(AgradRev, is_uninitialized_nan) { stan::math::var nan = std::numeric_limits::quiet_NaN(); EXPECT_FALSE(stan::math::is_uninitialized(nan)); diff --git a/test/unit/math/rev/fun/jacobian.hpp b/test/unit/math/rev/fun/jacobian.hpp index 287088a3fd5..7d8f723c02c 100644 --- a/test/unit/math/rev/fun/jacobian.hpp +++ b/test/unit/math/rev/fun/jacobian.hpp @@ -5,7 +5,6 @@ // ********* superseded by version in autodiff.hpp for API **** #include -#include #include namespace stan { diff --git a/test/unit/math/rev/fun/lbeta_test.cpp b/test/unit/math/rev/fun/lbeta_test.cpp index 7b014fa9095..9a16a585a39 100644 --- a/test/unit/math/rev/fun/lbeta_test.cpp +++ b/test/unit/math/rev/fun/lbeta_test.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include @@ -21,9 +20,9 @@ struct identity_tolerances { }; template -inline void expect_identity(const std::string& msg, - const identity_tolerances& tolerances, const F1 lh, - const F2 rh, double x_dbl, double y_dbl) { +void expect_identity(const std::string& msg, + const identity_tolerances& tolerances, const F1 lh, + const F2 rh, double x_dbl, double y_dbl) { using stan::math::var; using stan::test::expect_near_rel; @@ -60,7 +59,7 @@ inline void expect_identity(const std::string& msg, } } // namespace lbeta_test_internal -TEST_F(AgradRev, MathFunctions_lbeta_identities_gradient) { +TEST(MathFunctions, lbeta_identities_gradient) { using stan::math::lbeta; using stan::math::pi; using stan::math::var; @@ -247,7 +246,7 @@ std::vector testValues = { }; } // namespace lbeta_test_internal -TEST_F(AgradRev, MathFunctions_lbeta_precomputed) { +TEST(MathFunctions, lbeta_precomputed) { using lbeta_test_internal::TestValue; using lbeta_test_internal::testValues; using stan::math::is_nan; diff --git a/test/unit/math/rev/fun/log_sum_exp_test.cpp b/test/unit/math/rev/fun/log_sum_exp_test.cpp index f020a0d1dd2..aa6d49f81a1 100644 --- a/test/unit/math/rev/fun/log_sum_exp_test.cpp +++ b/test/unit/math/rev/fun/log_sum_exp_test.cpp @@ -1,9 +1,9 @@ #include -#include -#include #include +#include +#include -TEST_F(AgradRev, log_sum_exp_tests_large_values) { +TEST(log_sum_exp_tests, large_values) { using stan::math::var; // check autodiffing works with var types with large values diff --git a/test/unit/math/rev/fun/misc_test.cpp b/test/unit/math/rev/fun/misc_test.cpp index c7ce3b81926..7e28acde3a5 100644 --- a/test/unit/math/rev/fun/misc_test.cpp +++ b/test/unit/math/rev/fun/misc_test.cpp @@ -1,10 +1,9 @@ #include -#include #include #include #include -TEST_F(AgradRev, RevMatrix_mv_squaredNorm) { +TEST(AgradRevMatrix, mv_squaredNorm) { using stan::math::matrix_v; matrix_v a(2, 2); @@ -22,7 +21,7 @@ TEST_F(AgradRev, RevMatrix_mv_squaredNorm) { EXPECT_FLOAT_EQ(10.0, g[2]); EXPECT_FLOAT_EQ(20.0, g[3]); } -TEST_F(AgradRev, RevMatrix_mv_norm) { +TEST(AgradRevMatrix, mv_norm) { using stan::math::matrix_v; matrix_v a(2, 1); @@ -39,7 +38,7 @@ TEST_F(AgradRev, RevMatrix_mv_norm) { EXPECT_FLOAT_EQ(-3.0 / 5.0, g[0]); EXPECT_FLOAT_EQ(4.0 / 5.0, g[1]); } -TEST_F(AgradRev, RevMatrix_mv_lp_norm) { +TEST(AgradRevMatrix, mv_lp_norm) { using stan::math::matrix_v; matrix_v a(2, 2); @@ -58,7 +57,7 @@ TEST_F(AgradRev, RevMatrix_mv_lp_norm) { // ? depends on impl here, could be -1 or 1 EXPECT_FLOAT_EQ(0.0, g[3]); } -TEST_F(AgradRev, RevMatrix_mv_lp_norm_inf) { +TEST(AgradRevMatrix, mv_lp_norm_inf) { using stan::math::matrix_v; matrix_v a(2, 2); @@ -77,7 +76,7 @@ TEST_F(AgradRev, RevMatrix_mv_lp_norm_inf) { EXPECT_FLOAT_EQ(0.0, g[3]); } -TEST_F(AgradRev, RevMatrix_UserCase1) { +TEST(AgradRevMatrix, UserCase1) { using stan::math::assign; using stan::math::dot_product; using stan::math::get_base1; diff --git a/test/unit/math/rev/fun/primitive_value_test.cpp b/test/unit/math/rev/fun/primitive_value_test.cpp index c64772ac409..dcdf21a02c3 100644 --- a/test/unit/math/rev/fun/primitive_value_test.cpp +++ b/test/unit/math/rev/fun/primitive_value_test.cpp @@ -1,9 +1,8 @@ #include -#include #include #include -TEST_F(AgradRev, Rev_primitiveValue) { +TEST(AgradRev, primitiveValue) { using stan::math::primitive_value; using stan::math::var; diff --git a/test/unit/math/rev/fun/promote_elements_test.cpp b/test/unit/math/rev/fun/promote_elements_test.cpp index c60201fca8e..48493ff37ae 100644 --- a/test/unit/math/rev/fun/promote_elements_test.cpp +++ b/test/unit/math/rev/fun/promote_elements_test.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include @@ -11,7 +10,7 @@ using stan::math::promote_elements; using stan::math::var; using std::vector; -TEST_F(AgradRev, MathFunctionsScalPromote_Elements_double2var) { +TEST(MathFunctionsScalPromote_Elements, double2var) { double from; promote_elements p; typedef BOOST_TYPEOF(p.promote(from)) result_t; @@ -19,7 +18,7 @@ TEST_F(AgradRev, MathFunctionsScalPromote_Elements_double2var) { EXPECT_TRUE(same); } -TEST_F(AgradRev, MathFunctionsArrPromote_Elements_doubleVec2varVec) { +TEST(MathFunctionsArrPromote_Elements, doubleVec2varVec) { vector from; from.push_back(1); from.push_back(2); @@ -30,7 +29,7 @@ TEST_F(AgradRev, MathFunctionsArrPromote_Elements_doubleVec2varVec) { EXPECT_TRUE(same); } -TEST_F(AgradRev, MathFunctionsMatPromote_Elements_doubleMat2varMat) { +TEST(MathFunctionsMatPromote_Elements, doubleMat2varMat) { stan::math::matrix_d m1(2, 3); m1 << 1, 2, 3, 4, 5, 6; promote_elements, Matrix > p; diff --git a/test/unit/math/rev/fun/promote_scalar_test.cpp b/test/unit/math/rev/fun/promote_scalar_test.cpp index 9b9c56bfab9..55e368c77bc 100644 --- a/test/unit/math/rev/fun/promote_scalar_test.cpp +++ b/test/unit/math/rev/fun/promote_scalar_test.cpp @@ -1,12 +1,11 @@ #include -#include #include // there is no agrad-defined version of promote_scalar, so this is // just testing that it works with non-inter-convertible types (double // can be assigned to var, but not vice-versa) -TEST_F(AgradRev, RevFunctionsPromoteScalar_Mismatch) { +TEST(AgradRevFunctionsPromoteScalar, Mismatch) { using stan::math::promote_scalar; using stan::math::var; EXPECT_FLOAT_EQ(2.3, promote_scalar(2.3).val()); diff --git a/test/unit/math/rev/fun/read_var_test.cpp b/test/unit/math/rev/fun/read_var_test.cpp index c6fe73dd9d6..2d8e89861c7 100644 --- a/test/unit/math/rev/fun/read_var_test.cpp +++ b/test/unit/math/rev/fun/read_var_test.cpp @@ -1,9 +1,8 @@ #include -#include #include #include -TEST_F(AgradRev, RevMatrix_read_var_mat) { +TEST(AgradRevMatrix, read_var_mat) { using Eigen::MatrixXd; using stan::math::matrix_v; using stan::math::matrix_vi; @@ -49,7 +48,7 @@ TEST_F(AgradRev, RevMatrix_read_var_mat) { EXPECT_MATRIX_FLOAT_EQ(matrix_var.adj(), matrix_vi3.adj()); } -TEST_F(AgradRev, RevMatrix_read_var_vec) { +TEST(AgradRevMatrix, read_var_vec) { using Eigen::VectorXd; using stan::math::read_val_adj; using stan::math::read_vi_adj; @@ -89,7 +88,7 @@ TEST_F(AgradRev, RevMatrix_read_var_vec) { EXPECT_MATRIX_FLOAT_EQ(vector_var.adj(), vector_vi3.adj()); } -TEST_F(AgradRev, RevMatrix_read_var_rowvec) { +TEST(AgradRevMatrix, read_var_rowvec) { using Eigen::RowVectorXd; using stan::math::read_val_adj; using stan::math::read_vi_adj; @@ -130,7 +129,7 @@ TEST_F(AgradRev, RevMatrix_read_var_rowvec) { EXPECT_MATRIX_FLOAT_EQ(row_vector_var.adj(), row_vector_vi3.adj()); } -TEST_F(AgradRev, RevMatrix_read_var_expr) { +TEST(AgradRevMatrix, read_var_expr) { using Eigen::MatrixXd; using Eigen::VectorXd; using stan::math::matrix_v; diff --git a/test/unit/math/rev/fun/rep_matrix_test.cpp b/test/unit/math/rev/fun/rep_matrix_test.cpp index 0f36a1b01ed..e470616dfe8 100644 --- a/test/unit/math/rev/fun/rep_matrix_test.cpp +++ b/test/unit/math/rev/fun/rep_matrix_test.cpp @@ -1,13 +1,13 @@ #include +#include #include #include #include -#include #include #include #include -TEST_F(AgradRev, MathMixMatFun_repMatrixVar) { +TEST(MathMixMatFun, repMatrixVar) { using stan::math::rep_matrix; using stan::math::sum; using stan::math::var; @@ -33,7 +33,7 @@ TEST_F(AgradRev, MathMixMatFun_repMatrixVar) { EXPECT_EQ(x4.cols(), 2); } -TEST_F(AgradRev, MathMixMatFun_repVarMatrix) { +TEST(MathMixMatFun, repVarMatrix) { using stan::math::rep_matrix; using stan::math::sum; using stan::math::var; @@ -49,7 +49,7 @@ TEST_F(AgradRev, MathMixMatFun_repVarMatrix) { EXPECT_EQ(x_var.adj(), 25.0); } -TEST_F(AgradRev, MathMixMatFun_repVarMatrixVec) { +TEST(MathMixMatFun, repVarMatrixVec) { using stan::math::rep_matrix; using stan::math::sum; using stan::math::var; @@ -67,7 +67,7 @@ TEST_F(AgradRev, MathMixMatFun_repVarMatrixVec) { EXPECT_MATRIX_EQ(x_var.adj(), expected_x_var_adjs); } -TEST_F(AgradRev, MathMixMatFun_repVarMatrixRowVec) { +TEST(MathMixMatFun, repVarMatrixRowVec) { using stan::math::rep_matrix; using stan::math::sum; using stan::math::var; diff --git a/test/unit/math/rev/fun/rep_row_vector_test.cpp b/test/unit/math/rev/fun/rep_row_vector_test.cpp index bafa613af2e..002e63c5afc 100644 --- a/test/unit/math/rev/fun/rep_row_vector_test.cpp +++ b/test/unit/math/rev/fun/rep_row_vector_test.cpp @@ -3,7 +3,7 @@ #include #include -TEST_F(AgradRev, MathMixMatFun_repRowVectorVar) { +TEST(MathMixMatFun, repRowVectorVar) { using stan::math::rep_row_vector; using stan::math::sum; using stan::math::var; @@ -20,7 +20,7 @@ TEST_F(AgradRev, MathMixMatFun_repRowVectorVar) { EXPECT_EQ(x2.cols(), 3); } -TEST_F(AgradRev, MathMixMatFun_repRowVarVector) { +TEST(MathMixMatFun, repRowVarVector) { using stan::math::rep_row_vector; using stan::math::sum; using stan::math::var; diff --git a/test/unit/math/rev/fun/rep_vector_test.cpp b/test/unit/math/rev/fun/rep_vector_test.cpp index d1c049174ef..bde950b60b2 100644 --- a/test/unit/math/rev/fun/rep_vector_test.cpp +++ b/test/unit/math/rev/fun/rep_vector_test.cpp @@ -1,13 +1,13 @@ #include +#include #include #include #include -#include #include #include #include -TEST_F(AgradRev, MathMixMatFun_repVectorVar) { +TEST(MathMixMatFun, repVectorVar) { using stan::math::rep_vector; using stan::math::sum; using stan::math::var; @@ -24,7 +24,7 @@ TEST_F(AgradRev, MathMixMatFun_repVectorVar) { EXPECT_EQ(x2.cols(), 1); } -TEST_F(AgradRev, MathMixMatFun_repVarVector) { +TEST(MathMixMatFun, repVarVector) { using stan::math::rep_vector; using stan::math::sum; using stan::math::var; diff --git a/test/unit/math/rev/fun/rows_test.cpp b/test/unit/math/rev/fun/rows_test.cpp index ad2b4348487..d24682b9022 100644 --- a/test/unit/math/rev/fun/rows_test.cpp +++ b/test/unit/math/rev/fun/rows_test.cpp @@ -1,9 +1,8 @@ #include -#include #include #include -TEST_F(AgradRev, RevMatrix_rows_vector) { +TEST(AgradRevMatrix, rows_vector) { using stan::math::row_vector_v; using stan::math::rows; using stan::math::var_value; @@ -18,7 +17,7 @@ TEST_F(AgradRev, RevMatrix_rows_vector) { vec_v.resize(0); EXPECT_EQ(0U, rows(vec_v)); } -TEST_F(AgradRev, RevMatrix_rows_rowvector) { +TEST(AgradRevMatrix, rows_rowvector) { using stan::math::row_vector_v; using stan::math::rows; using stan::math::var_value; @@ -34,7 +33,7 @@ TEST_F(AgradRev, RevMatrix_rows_rowvector) { EXPECT_EQ(1U, rows(r_v)); } -TEST_F(AgradRev, RevMatrix_rows_matrix) { +TEST(AgradRevMatrix, rows_matrix) { using stan::math::matrix_v; using stan::math::rows; using stan::math::var_value; diff --git a/test/unit/math/rev/fun/scalar_seq_view_test.cpp b/test/unit/math/rev/fun/scalar_seq_view_test.cpp index f6a3fd01175..7d8c7686d51 100644 --- a/test/unit/math/rev/fun/scalar_seq_view_test.cpp +++ b/test/unit/math/rev/fun/scalar_seq_view_test.cpp @@ -1,9 +1,8 @@ #include -#include #include #include -TEST_F(AgradRev, MathMetaRev_ScalarSeqViewvar) { +TEST(MathMetaRev, ScalarSeqViewvar) { using stan::scalar_seq_view; using stan::math::var; var d = 10; @@ -24,7 +23,7 @@ TEST_F(AgradRev, MathMetaRev_ScalarSeqViewvar) { EXPECT_EQ(1, sv.size()); } -TEST_F(AgradRev, MathMetaRev_ScalarSeqViewArrayVarVal) { +TEST(MathMetaRev, ScalarSeqViewArrayVarVal) { using stan::scalar_seq_view; using stan::math::var; using std::vector; @@ -49,7 +48,7 @@ TEST_F(AgradRev, MathMetaRev_ScalarSeqViewArrayVarVal) { } template -inline void expect_scalar_seq_view_value(const C& v) { +void expect_scalar_seq_view_value(const C& v) { using stan::scalar_seq_view; scalar_seq_view sv(v); EXPECT_FLOAT_EQ(v.val()(0), sv.val(0)); @@ -61,7 +60,7 @@ inline void expect_scalar_seq_view_value(const C& v) { } template -inline void expect_scalar_seq_view_adjoints(const C& v) { +void expect_scalar_seq_view_adjoints(const C& v) { using stan::scalar_seq_view; scalar_seq_view sv(v); std::vector stdv(sv.size()); @@ -81,28 +80,28 @@ inline void expect_scalar_seq_view_adjoints(const C& v) { } } -TEST_F(AgradRev, MathMetaRev_ScalarSeqViewVectorVar) { +TEST(MathMetaRev, ScalarSeqViewVectorVar) { using stan::math::var; Eigen::Matrix A = Eigen::VectorXd::Ones(4); expect_scalar_seq_view_value(A); expect_scalar_seq_view_adjoints(A); } -TEST_F(AgradRev, MathMetaRev_ScalarSeqViewRowVectorVar) { +TEST(MathMetaRev, ScalarSeqViewRowVectorVar) { using stan::math::var; Eigen::Matrix A = Eigen::RowVectorXd::Ones(4); expect_scalar_seq_view_value(A); expect_scalar_seq_view_adjoints(A); } -TEST_F(AgradRev, MathMetaRev_VarScalarSeqViewVector) { +TEST(MathMetaRev, VarScalarSeqViewVector) { using stan::math::var_value; var_value> A = Eigen::VectorXd::Ones(4); expect_scalar_seq_view_value(A); expect_scalar_seq_view_adjoints(A); } -TEST_F(AgradRev, MathMetaRev_VarScalarSeqViewRowVector) { +TEST(MathMetaRev, VarScalarSeqViewRowVector) { using stan::math::var_value; var_value> A = Eigen::RowVectorXd::Ones(4); expect_scalar_seq_view_value(A); diff --git a/test/unit/math/rev/fun/singular_values_test.cpp b/test/unit/math/rev/fun/singular_values_test.cpp index cdad4a3b9f6..bacf68b3a0b 100644 --- a/test/unit/math/rev/fun/singular_values_test.cpp +++ b/test/unit/math/rev/fun/singular_values_test.cpp @@ -1,12 +1,11 @@ #include -#include #include #include #include #include #include -TEST_F(AgradRev, Rev_singularvalues_gradient) { +TEST(AgradRev, singularvalues_gradient) { // logdet(A) can be calculated using singularvalues of matrix A // the derivative of logdet(A) should be inverse(A) diff --git a/test/unit/math/rev/fun/size_mvt_test.cpp b/test/unit/math/rev/fun/size_mvt_test.cpp index 07588f4b6f3..f4a7682e0b9 100644 --- a/test/unit/math/rev/fun/size_mvt_test.cpp +++ b/test/unit/math/rev/fun/size_mvt_test.cpp @@ -1,16 +1,15 @@ #include -#include #include #include -TEST_F(AgradRev, Rev_size_mvt_scalar) { +TEST(AgradRev, size_mvt_scalar) { using stan::math::size_mvt; stan::math::var x1; EXPECT_THROW(size_mvt(x1), std::invalid_argument); } -TEST_F(AgradRev, Rev_size_mvt_matrices_vectors) { +TEST(AgradRev, size_mvt_matrices_vectors) { using stan::math::size_mvt; stan::math::var_value x1 = Eigen::MatrixXd(2, 3); diff --git a/test/unit/math/rev/fun/sort_indices_test.cpp b/test/unit/math/rev/fun/sort_indices_test.cpp index d7b357b855e..640abf2b30d 100644 --- a/test/unit/math/rev/fun/sort_indices_test.cpp +++ b/test/unit/math/rev/fun/sort_indices_test.cpp @@ -1,10 +1,9 @@ #include -#include #include #include #include -inline void test_sort_indices_asc(std::vector val) { +void test_sort_indices_asc(std::vector val) { using stan::math::sort_indices_asc; std::vector x; @@ -25,7 +24,7 @@ inline void test_sort_indices_asc(std::vector val) { EXPECT_FALSE(x_sorted[i] == x[j]); } -inline void test_sort_indices_desc(std::vector val) { +void test_sort_indices_desc(std::vector val) { using stan::math::sort_indices_desc; std::vector x; @@ -47,7 +46,7 @@ inline void test_sort_indices_desc(std::vector val) { } template -inline void test_sort_indices_asc(Eigen::Matrix val) { +void test_sort_indices_asc(Eigen::Matrix val) { using stan::math::sort_indices_asc; const size_t val_size = val.size(); @@ -71,7 +70,7 @@ inline void test_sort_indices_asc(Eigen::Matrix val) { } template -inline void test_sort_indices_desc(Eigen::Matrix val) { +void test_sort_indices_desc(Eigen::Matrix val) { using stan::math::sort_indices_desc; const size_t val_size = val.size(); @@ -94,7 +93,7 @@ inline void test_sort_indices_desc(Eigen::Matrix val) { EXPECT_FALSE(x_sorted.data()[i] == x.data()[j]); } -TEST_F(AgradRev, Rev_sort_indices) { +TEST(AgradRev, sort_indices) { std::vector a; a.push_back(1); a.push_back(2); @@ -150,7 +149,7 @@ TEST_F(AgradRev, Rev_sort_indices) { test_sort_indices_desc(vec6); } -TEST_F(AgradRev, Rev_sort_indices_no_thrown) { +TEST(AgradRev, sort_indices_no_thrown) { using stan::math::sort_indices_asc; using stan::math::sort_indices_desc; diff --git a/test/unit/math/rev/fun/stan_print_test.cpp b/test/unit/math/rev/fun/stan_print_test.cpp index da0f0e6691b..8a55878cd60 100644 --- a/test/unit/math/rev/fun/stan_print_test.cpp +++ b/test/unit/math/rev/fun/stan_print_test.cpp @@ -1,10 +1,9 @@ #include -#include #include #include #include -TEST_F(AgradRev, Rev_stan_print) { +TEST(AgradRev, stan_print) { using stan::math::var; var a = 5.0; diff --git a/test/unit/math/rev/fun/stored_gradient_vari_test.cpp b/test/unit/math/rev/fun/stored_gradient_vari_test.cpp index 37b059dce41..b6606c4841d 100644 --- a/test/unit/math/rev/fun/stored_gradient_vari_test.cpp +++ b/test/unit/math/rev/fun/stored_gradient_vari_test.cpp @@ -1,9 +1,9 @@ #include -#include #include +#include #include -TEST_F(AgradRev, StoredGradientVari_propagate3) { +TEST(StoredGradientVari, propagate3) { using stan::math::var; using stan::math::vari; vari** xs = reinterpret_cast( @@ -43,7 +43,7 @@ TEST_F(AgradRev, StoredGradientVari_propagate3) { EXPECT_EQ(1000 * 132.7, g[2]); } -TEST_F(AgradRev, StoredGradientVari_propagate0) { +TEST(StoredGradientVari, propagate0) { using stan::math::var; using stan::math::vari; vari** xs = 0; @@ -65,7 +65,7 @@ TEST_F(AgradRev, StoredGradientVari_propagate0) { for (int i = 0; i < 3; ++i) EXPECT_FLOAT_EQ(0, g[i]); } -TEST_F(AgradRev, RevMatrix_stored_gradient_vari_check_varis_on_stack) { +TEST(AgradRevMatrix, stored_gradient_vari_check_varis_on_stack) { using stan::math::var; using stan::math::vari; vari** xs = reinterpret_cast( diff --git a/test/unit/math/rev/fun/to_arena_test.cpp b/test/unit/math/rev/fun/to_arena_test.cpp index de03045d877..b36b00fa3bb 100644 --- a/test/unit/math/rev/fun/to_arena_test.cpp +++ b/test/unit/math/rev/fun/to_arena_test.cpp @@ -1,10 +1,9 @@ #include -#include #include #include #include -TEST_F(AgradRev, Rev_to_arena_scalar_test) { +TEST(AgradRev, to_arena_scalar_test) { int a = 2; auto b = stan::math::to_arena(a); EXPECT_EQ(b, a); @@ -15,7 +14,7 @@ TEST_F(AgradRev, Rev_to_arena_scalar_test) { EXPECT_TRUE((std::is_same::value)); } -TEST_F(AgradRev, Rev_to_arena_std_vector_test) { +TEST(AgradRev, to_arena_std_vector_test) { std::vector a{1, 2}; auto b = stan::math::to_arena(a); ASSERT_EQ(a.size(), b.size()); @@ -29,7 +28,7 @@ TEST_F(AgradRev, Rev_to_arena_std_vector_test) { EXPECT_EQ(b.data(), c.data()); } -TEST_F(AgradRev, Rev_to_arena_col_vector_test) { +TEST(AgradRev, to_arena_col_vector_test) { Eigen::VectorXd a(2); a << 1, 2; auto b = stan::math::to_arena(a); @@ -40,7 +39,7 @@ TEST_F(AgradRev, Rev_to_arena_col_vector_test) { EXPECT_EQ(b.data(), c.data()); } -TEST_F(AgradRev, Rev_to_arena_row_vector_test) { +TEST(AgradRev, to_arena_row_vector_test) { Eigen::RowVectorXd a(2); a << 1, 2; auto b = stan::math::to_arena(a); @@ -51,7 +50,7 @@ TEST_F(AgradRev, Rev_to_arena_row_vector_test) { EXPECT_EQ(b.data(), c.data()); } -TEST_F(AgradRev, Rev_to_arena_matrix_test) { +TEST(AgradRev, to_arena_matrix_test) { Eigen::MatrixXd a(2, 2); a << 1, 2, 3, 4; auto b = stan::math::to_arena(a); diff --git a/test/unit/math/rev/fun/to_var_test.cpp b/test/unit/math/rev/fun/to_var_test.cpp index 9f3b073ef22..2b331492b77 100644 --- a/test/unit/math/rev/fun/to_var_test.cpp +++ b/test/unit/math/rev/fun/to_var_test.cpp @@ -1,9 +1,9 @@ #include -#include -#include #include +#include +#include -TEST_F(AgradRev, RevMatrix_to_var_scalar) { +TEST(AgradRevMatrix, to_var_scalar) { double d = 5.0; stan::math::var v = 5.0; stan::math::var var_x = stan::math::to_var(d); @@ -12,7 +12,7 @@ TEST_F(AgradRev, RevMatrix_to_var_scalar) { var_x = stan::math::to_var(v); EXPECT_FLOAT_EQ(5.0, var_x.val()); } -TEST_F(AgradRev, RevMatrix_to_var_matrix) { +TEST(AgradRevMatrix, to_var_matrix) { using stan::math::matrix_d; using stan::math::matrix_v; matrix_d m_d(2, 3); @@ -25,7 +25,7 @@ TEST_F(AgradRev, RevMatrix_to_var_matrix) { for (int jj = 0; jj < 3; jj++) EXPECT_FLOAT_EQ(ii * 3 + jj, m_v(ii, jj).val()); } -TEST_F(AgradRev, RevMatrix_to_var_vector) { +TEST(AgradRevMatrix, to_var_vector) { using stan::math::vector_d; using stan::math::vector_v; @@ -49,7 +49,7 @@ TEST_F(AgradRev, RevMatrix_to_var_vector) { EXPECT_FLOAT_EQ(4, out(3).val()); EXPECT_FLOAT_EQ(5, out(4).val()); } -TEST_F(AgradRev, RevMatrix_to_var_rowvector) { +TEST(AgradRevMatrix, to_var_rowvector) { using stan::math::row_vector_d; using stan::math::row_vector_v; @@ -75,7 +75,7 @@ TEST_F(AgradRev, RevMatrix_to_var_rowvector) { EXPECT_FLOAT_EQ(5, output(4).val()); } -TEST_F(AgradRev, RevMatrix_to_var_check_varis_on_stack) { +TEST(AgradRevMatrix, to_var_check_varis_on_stack) { stan::math::matrix_v m(2, 2); m << 1, 2, 3, 4; diff --git a/test/unit/math/rev/fun/to_var_value_test.cpp b/test/unit/math/rev/fun/to_var_value_test.cpp index bef9dd1e559..2dd6c75efeb 100644 --- a/test/unit/math/rev/fun/to_var_value_test.cpp +++ b/test/unit/math/rev/fun/to_var_value_test.cpp @@ -1,9 +1,8 @@ #include -#include #include #include -TEST_F(AgradRev, RevMatrix_to_var_value_types) { +TEST(AgradRevMatrix, to_var_value_types) { using stan::math::to_var_value; using stan::math::var; using stan::math::var_value; @@ -46,7 +45,7 @@ TEST_F(AgradRev, RevMatrix_to_var_value_types) { stan::math::recover_memory(); } -TEST_F(AgradRev, RevMatrix_to_var_value_vec_types) { +TEST(AgradRevMatrix, to_var_value_vec_types) { using stan::math::to_var_value; using stan::math::var; using stan::math::var_value; @@ -92,7 +91,7 @@ TEST_F(AgradRev, RevMatrix_to_var_value_vec_types) { stan::math::recover_memory(); } -TEST_F(AgradRev, RevMatrix_to_var_value_matrix_test) { +TEST(AgradRevMatrix, to_var_value_matrix_test) { Eigen::MatrixXd val(2, 3); val << 1, 2, 3, 4, 5, 6; Eigen::MatrixXd adj(2, 3); @@ -106,7 +105,7 @@ TEST_F(AgradRev, RevMatrix_to_var_value_matrix_test) { EXPECT_MATRIX_EQ(mat_var.adj(), adj); } -TEST_F(AgradRev, RevMatrix_to_var_value_vector_test) { +TEST(AgradRevMatrix, to_var_value_vector_test) { Eigen::VectorXd val(3); val << 1, 2, 3; Eigen::VectorXd adj(3); @@ -120,7 +119,7 @@ TEST_F(AgradRev, RevMatrix_to_var_value_vector_test) { EXPECT_MATRIX_EQ(mat_var.adj(), adj); } -TEST_F(AgradRev, RevMatrix_to_var_value_row_vector_test) { +TEST(AgradRevMatrix, to_var_value_row_vector_test) { Eigen::RowVectorXd val(3); val << 1, 2, 3; Eigen::RowVectorXd adj(3); @@ -134,7 +133,7 @@ TEST_F(AgradRev, RevMatrix_to_var_value_row_vector_test) { EXPECT_MATRIX_EQ(mat_var.adj(), adj); } -TEST_F(AgradRev, RevMatrix_to_var_value_matrix_svec_test) { +TEST(AgradRevMatrix, to_var_value_matrix_svec_test) { std::vector> matvars; @@ -153,7 +152,7 @@ TEST_F(AgradRev, RevMatrix_to_var_value_matrix_svec_test) { } } -TEST_F(AgradRev, RevMatrix_to_var_value_vector_svec_test) { +TEST(AgradRevMatrix, to_var_value_vector_svec_test) { std::vector> matvars; @@ -172,7 +171,7 @@ TEST_F(AgradRev, RevMatrix_to_var_value_vector_svec_test) { } } -TEST_F(AgradRev, RevMatrix_to_var_value_row_vector_svec_test) { +TEST(AgradRevMatrix, to_var_value_row_vector_svec_test) { std::vector> matvars; diff --git a/test/unit/math/rev/fun/to_vector_test.cpp b/test/unit/math/rev/fun/to_vector_test.cpp index ebf60a778fb..f8bd6c4a626 100644 --- a/test/unit/math/rev/fun/to_vector_test.cpp +++ b/test/unit/math/rev/fun/to_vector_test.cpp @@ -1,10 +1,9 @@ #include -#include #include #include -TEST_F(AgradRev, MathFunRev_to_vector_var_value) { +TEST(MathFunRev, to_vector_var_value) { constexpr Eigen::Index n = 100; Eigen::MatrixXd a_val = Eigen::MatrixXd::Random(n, n); stan::math::var_value a(a_val); diff --git a/test/unit/math/rev/fun/util.hpp b/test/unit/math/rev/fun/util.hpp index 7fdca697ef7..c38dcfa6ec9 100644 --- a/test/unit/math/rev/fun/util.hpp +++ b/test/unit/math/rev/fun/util.hpp @@ -9,8 +9,7 @@ // vector; Fills the matrix column-wise template -inline void fill(const std::vector& contents, - Eigen::Matrix& M) { +void fill(const std::vector& contents, Eigen::Matrix& M) { size_t ij = 0; for (int j = 0; j < C; ++j) for (int i = 0; i < R; ++i) diff --git a/test/unit/math/rev/fun/value_of_rec_test.cpp b/test/unit/math/rev/fun/value_of_rec_test.cpp index 2994b751373..a969eac1cd8 100644 --- a/test/unit/math/rev/fun/value_of_rec_test.cpp +++ b/test/unit/math/rev/fun/value_of_rec_test.cpp @@ -1,11 +1,10 @@ #include -#include #include #include #include #include -TEST_F(AgradRev, Rev_value_of_rec) { +TEST(AgradRev, value_of_rec) { using stan::math::value_of_rec; using stan::math::var; @@ -14,7 +13,7 @@ TEST_F(AgradRev, Rev_value_of_rec) { EXPECT_FLOAT_EQ(5.0, value_of_rec(v_a)); } -TEST_F(AgradRev, MathMatrixRevArr_value_of_rec) { +TEST(MathMatrixRevArr, value_of_rec) { using stan::math::value_of_rec; using stan::math::var; using std::vector; @@ -42,7 +41,7 @@ TEST_F(AgradRev, MathMatrixRevArr_value_of_rec) { EXPECT_FLOAT_EQ(a[i].val(), d_a[i]); } -TEST_F(AgradRev, MatrixRev_value_of_rec) { +TEST(AgradMatrixRev, value_of_rec) { using stan::math::value_of_rec; using stan::math::var; using std::vector; @@ -80,7 +79,7 @@ TEST_F(AgradRev, MatrixRev_value_of_rec) { } } -TEST_F(AgradRev, MatrixRev_value_of_rec_expression) { +TEST(AgradMatrixRev, value_of_rec_expression) { using Eigen::Matrix; using Eigen::MatrixXd; using stan::math::value_of; @@ -92,7 +91,7 @@ TEST_F(AgradRev, MatrixRev_value_of_rec_expression) { EXPECT_MATRIX_NEAR(res, correct, 1e-10); } -TEST_F(AgradRev, MatrixRev_value_of_rec_matrix_rvalue) { +TEST(AgradMatrixRev, value_of_rec_matrix_rvalue) { using Eigen::Matrix; using Eigen::MatrixXd; using stan::math::value_of; diff --git a/test/unit/math/rev/fun/value_of_test.cpp b/test/unit/math/rev/fun/value_of_test.cpp index 6932027ac62..d262ca22ef9 100644 --- a/test/unit/math/rev/fun/value_of_test.cpp +++ b/test/unit/math/rev/fun/value_of_test.cpp @@ -1,11 +1,10 @@ #include -#include #include #include #include #include -TEST_F(AgradRev, Rev_value_of) { +TEST(AgradRev, value_of) { using stan::math::value_of; using stan::math::var; @@ -16,7 +15,7 @@ TEST_F(AgradRev, Rev_value_of) { EXPECT_FLOAT_EQ(5.0, value_of(5)); } -TEST_F(AgradRev, MathMatrixRevArr_value_of) { +TEST(MathMatrixRevArr, value_of) { using stan::math::value_of; using stan::math::var; using std::vector; @@ -46,7 +45,7 @@ TEST_F(AgradRev, MathMatrixRevArr_value_of) { EXPECT_FLOAT_EQ(a[i].val(), d_a[i]); } -TEST_F(AgradRev, Matrix_value_of) { +TEST(AgradMatrix, value_of) { using stan::math::value_of; using stan::math::var; using std::vector; @@ -88,7 +87,7 @@ TEST_F(AgradRev, Matrix_value_of) { } } -TEST_F(AgradRev, Matrix_value_of_vector_of_vectors) { +TEST(AgradMatrix, value_of_vector_of_vectors) { using stan::math::var; std::vector a(5, 0); const std::vector b(5, 0); @@ -115,7 +114,7 @@ TEST_F(AgradRev, Matrix_value_of_vector_of_vectors) { } } -TEST_F(AgradRev, Matrix_value_of_vector_of_eigen) { +TEST(AgradMatrix, value_of_vector_of_eigen) { using stan::math::var; Eigen::Matrix a = Eigen::VectorXd::Random(5).template cast(); @@ -150,7 +149,7 @@ TEST_F(AgradRev, Matrix_value_of_vector_of_eigen) { EXPECT_FLOAT_EQ(vvc[i](j), c(j).val()); } -TEST_F(AgradRev, Matrix_value_of_expression) { +TEST(AgradMatrix, value_of_expression) { using Eigen::Matrix; using Eigen::MatrixXd; using stan::math::value_of; @@ -162,7 +161,7 @@ TEST_F(AgradRev, Matrix_value_of_expression) { EXPECT_MATRIX_NEAR(res, correct, 1e-10); } -TEST_F(AgradRev, MatrixRev_value_of_matrix_rvalue) { +TEST(AgradMatrixRev, value_of_matrix_rvalue) { using Eigen::Matrix; using Eigen::MatrixXd; using stan::math::value_of; diff --git a/test/unit/math/rev/fun/vector_seq_view_test.cpp b/test/unit/math/rev/fun/vector_seq_view_test.cpp index 329a8ebe057..17fb4c98580 100644 --- a/test/unit/math/rev/fun/vector_seq_view_test.cpp +++ b/test/unit/math/rev/fun/vector_seq_view_test.cpp @@ -1,10 +1,9 @@ #include -#include #include #include template -inline void test_vec_seq_var(const T& m1) { +void test_vec_seq_var(const T& m1) { using stan::vector_seq_view; using stan::math::var; vector_seq_view vsv(m1); @@ -21,7 +20,7 @@ inline void test_vec_seq_var(const T& m1) { EXPECT_FLOAT_EQ(m1.val()(2), vsv_vec.val(0)[2]); EXPECT_EQ(vsv_vec.size(), 2); } -TEST_F(AgradRev, MathMetaRev_VectorSeqViewVar) { +TEST(MathMetaRev, VectorSeqViewVar) { Eigen::Matrix values = Eigen::Matrix::Random(4); Eigen::Matrix A = values; test_vec_seq_var(A); 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 fd31b9da8d4..88a73e338fa 100644 --- a/test/unit/math/rev/functor/algebra_solver_fp_test.cpp +++ b/test/unit/math/rev/functor/algebra_solver_fp_test.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include diff --git a/test/unit/math/rev/functor/analytical_dae_typed_test.cpp b/test/unit/math/rev/functor/analytical_dae_typed_test.cpp index 8bbbd66e8e7..9eacdc517fe 100644 --- a/test/unit/math/rev/functor/analytical_dae_typed_test.cpp +++ b/test/unit/math/rev/functor/analytical_dae_typed_test.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include diff --git a/test/unit/math/rev/functor/chem_dae_sens_typed_test.cpp b/test/unit/math/rev/functor/chem_dae_sens_typed_test.cpp index 49f2aec0de4..7535d4a321b 100644 --- a/test/unit/math/rev/functor/chem_dae_sens_typed_test.cpp +++ b/test/unit/math/rev/functor/chem_dae_sens_typed_test.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include diff --git a/test/unit/math/rev/functor/chem_dae_typed_test.cpp b/test/unit/math/rev/functor/chem_dae_typed_test.cpp index be3b3743604..a6a06219c48 100644 --- a/test/unit/math/rev/functor/chem_dae_typed_test.cpp +++ b/test/unit/math/rev/functor/chem_dae_typed_test.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include diff --git a/test/unit/math/rev/functor/cos_ode_typed_test.cpp b/test/unit/math/rev/functor/cos_ode_typed_test.cpp index 327842289ee..e72f749e277 100644 --- a/test/unit/math/rev/functor/cos_ode_typed_test.cpp +++ b/test/unit/math/rev/functor/cos_ode_typed_test.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include diff --git a/test/unit/math/rev/functor/coupled_mm.hpp b/test/unit/math/rev/functor/coupled_mm.hpp index 47c5ba7d68b..49d13a268b7 100644 --- a/test/unit/math/rev/functor/coupled_mm.hpp +++ b/test/unit/math/rev/functor/coupled_mm.hpp @@ -2,8 +2,6 @@ #define TEST_UNIT_MATH_REV_FUNCTOR_COUPLED_MM_HPP #include -#include -#include #include struct coupled_mm_ode_fun { 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 f99ddac5da9..5eb63a1037c 100644 --- a/test/unit/math/rev/functor/coupled_ode_system_test.cpp +++ b/test/unit/math/rev/functor/coupled_ode_system_test.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include diff --git a/test/unit/math/rev/functor/cvodes_utils_test.cpp b/test/unit/math/rev/functor/cvodes_utils_test.cpp index 83c21f8611e..feaaf64187a 100644 --- a/test/unit/math/rev/functor/cvodes_utils_test.cpp +++ b/test/unit/math/rev/functor/cvodes_utils_test.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include @@ -16,7 +15,7 @@ struct Inverse { } }; -TEST_F(AgradRev, StanMath_cvodes_error_handler) { +TEST(StanMath, cvodes_error_handler) { Eigen::VectorXd y0 = Eigen::VectorXd::Ones(1); int t0 = 0; std::vector ts = {0.45, 1.1}; diff --git a/test/unit/math/rev/functor/degenerated_ode_typed_test.cpp b/test/unit/math/rev/functor/degenerated_ode_typed_test.cpp index 56b9984182d..c39a96583fa 100644 --- a/test/unit/math/rev/functor/degenerated_ode_typed_test.cpp +++ b/test/unit/math/rev/functor/degenerated_ode_typed_test.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include diff --git a/test/unit/math/rev/functor/fho_ode_typed_ts_test.cpp b/test/unit/math/rev/functor/fho_ode_typed_ts_test.cpp index decc7957a70..f405cad4952 100644 --- a/test/unit/math/rev/functor/fho_ode_typed_ts_test.cpp +++ b/test/unit/math/rev/functor/fho_ode_typed_ts_test.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include diff --git a/test/unit/math/rev/functor/finite_diff_hessian_auto_test.cpp b/test/unit/math/rev/functor/finite_diff_hessian_auto_test.cpp index f70cd0ae645..9cf08b9d5ee 100644 --- a/test/unit/math/rev/functor/finite_diff_hessian_auto_test.cpp +++ b/test/unit/math/rev/functor/finite_diff_hessian_auto_test.cpp @@ -1,5 +1,4 @@ #include -#include #include #include @@ -66,8 +65,8 @@ struct one_arg { */ template -inline void test_hessian_finite_diff(const std::string& msg, const F& f, - Eigen::VectorXd& x) { +void test_hessian_finite_diff(const std::string& msg, const F& f, + Eigen::VectorXd& x) { double fx; Eigen::VectorXd grad_fx; Eigen::MatrixXd hess_fx; @@ -90,7 +89,7 @@ inline void test_hessian_finite_diff(const std::string& msg, const F& f, EXPECT_NEAR(hess_fx_ad(i), hess_fx(i), 1e-4) << msg; } -TEST_F(AgradRev, RevFunctor_polynomial) { +TEST(RevFunctor, polynomial) { poly f; Matrix x(2); x << 5, 7; @@ -110,7 +109,7 @@ TEST_F(AgradRev, RevFunctor_polynomial) { EXPECT_FLOAT_EQ(6, hess_fx(1, 1)); } -TEST_F(AgradRev, RevFunctor_linear_function) { +TEST(RevFunctor, linear_function) { linear f; Matrix x(3); x << 5, 7, -1; @@ -131,7 +130,7 @@ TEST_F(AgradRev, RevFunctor_linear_function) { EXPECT_FLOAT_EQ(0, hess_fx(2, 2)); } -TEST_F(AgradRev, RevFunctor_exp_diag) { +TEST(RevFunctor, exp_diag) { exp_diag f; Matrix x(2); x << 2, -1; @@ -147,7 +146,7 @@ TEST_F(AgradRev, RevFunctor_exp_diag) { EXPECT_FLOAT_EQ(stan::math::exp(-1), hess_fx(1, 1)); } -TEST_F(AgradRev, RevFunctor_exp_full) { +TEST(RevFunctor, exp_full) { exp_full f; Matrix x(2); x << 1, -3; @@ -163,7 +162,7 @@ TEST_F(AgradRev, RevFunctor_exp_full) { EXPECT_FLOAT_EQ(stan::math::exp(4), hess_fx(1, 1)); } -TEST_F(AgradRev, RevFunctor_one_arg) { +TEST(RevFunctor, one_arg) { one_arg f; Matrix x(1); x << 8; @@ -176,7 +175,7 @@ TEST_F(AgradRev, RevFunctor_one_arg) { EXPECT_FLOAT_EQ(6 * 8, hess_fx(0, 0)); } -TEST_F(AgradRev, RevFunctor_FiniteDiffHessianAuto) { +TEST(RevFunctor, FiniteDiffHessianAuto) { auto norm_fun = [](const auto& x) { return stan::math::normal_lpdf(x(0), x(1), x(2)); }; Eigen::VectorXd x(3); diff --git a/test/unit/math/rev/functor/finite_diff_hessian_times_vector_test.cpp b/test/unit/math/rev/functor/finite_diff_hessian_times_vector_test.cpp index c936d1fb20a..d710ab1ab3e 100644 --- a/test/unit/math/rev/functor/finite_diff_hessian_times_vector_test.cpp +++ b/test/unit/math/rev/functor/finite_diff_hessian_times_vector_test.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include @@ -34,7 +33,7 @@ struct fun2 { } }; -TEST_F(AgradRev, RevFunctor_finiteDiffHessianTimesVector) { +TEST(RevFunctor, finiteDiffHessianTimesVector) { using stan::math::internal::finite_diff_hessian_times_vector_auto; fun1 f; @@ -56,7 +55,7 @@ TEST_F(AgradRev, RevFunctor_finiteDiffHessianTimesVector) { EXPECT_FLOAT_EQ(2 * x(0) * v(0) + 6 * v(1), Hv(1)); } -TEST_F(AgradRev, RevFunctor_finiteDiffHessianTimesVector2) { +TEST(RevFunctor, finiteDiffHessianTimesVector2) { using stan::math::internal::finite_diff_hessian_times_vector_auto; fun2 f; diff --git a/test/unit/math/rev/functor/gradient_test.cpp b/test/unit/math/rev/functor/gradient_test.cpp index 74da0ca14ab..d611e4bfab5 100644 --- a/test/unit/math/rev/functor/gradient_test.cpp +++ b/test/unit/math/rev/functor/gradient_test.cpp @@ -1,5 +1,4 @@ #include -#include #include #include @@ -23,7 +22,7 @@ struct fun1 { } }; -TEST_F(AgradRev, RevFunctor_gradient) { +TEST(RevFunctor, gradient) { fun1 f; Matrix x(2); x << 5, 7; @@ -36,7 +35,7 @@ TEST_F(AgradRev, RevFunctor_gradient) { EXPECT_FLOAT_EQ(x(0) * x(0) + 3 * 2 * x(1), grad_fx(1)); } -TEST_F(AgradRev, RevFunctor_gradient_input_rowvector) { +TEST(RevFunctor, gradient_input_rowvector) { fun1 f; Matrix x(2); x << 5, 7; @@ -49,7 +48,7 @@ TEST_F(AgradRev, RevFunctor_gradient_input_rowvector) { EXPECT_FLOAT_EQ(x(0) * x(0) + 3 * 2 * x(1), grad_fx[1]); } -TEST_F(AgradRev, RevFunctor_gradient_array) { +TEST(RevFunctor, gradient_array) { fun1 f; Matrix x(2); x << 5, 7; @@ -63,7 +62,7 @@ TEST_F(AgradRev, RevFunctor_gradient_array) { } // test threaded AD if enabled -TEST_F(AgradRev, RevFunctor_gradient_threaded) { +TEST(RevFunctor, gradient_threaded) { fun1 f; Matrix x_ref(2); x_ref << 5, 7; @@ -148,7 +147,7 @@ TEST_F(AgradRev, RevFunctor_gradient_threaded) { } // test threaded AD if enabled -TEST_F(AgradRev, RevFunctor_gradient_array_threaded) { +TEST(RevFunctor, gradient_array_threaded) { fun1 f; Matrix x_ref(2); x_ref << 5, 7; @@ -240,7 +239,7 @@ TEST_F(AgradRev, RevFunctor_gradient_array_threaded) { // test threaded AD through the Intel TBB whenever threading is used #ifdef STAN_THREADS -TEST_F(AgradRev, RevFunctor_gradient_threaded_tbb) { +TEST(RevFunctor, gradient_threaded_tbb) { fun1 f; Matrix x_ref(2); x_ref << 5, 7; @@ -314,7 +313,7 @@ TEST_F(AgradRev, RevFunctor_gradient_threaded_tbb) { } } -TEST_F(AgradRev, RevFunctor_gradient_array_threaded_tbb) { +TEST(RevFunctor, gradient_array_threaded_tbb) { fun1 f; Matrix x_ref(2); x_ref << 5, 7; @@ -392,15 +391,14 @@ TEST_F(AgradRev, RevFunctor_gradient_array_threaded_tbb) { } #endif -inline stan::math::var sum_and_throw( - const Matrix& x) { +stan::math::var sum_and_throw(const Matrix& x) { stan::math::var y = 0; for (int i = 0; i < x.size(); ++i) y += x(i); throw std::domain_error("fooey"); } -TEST_F(AgradRev, RevFunctor_RecoverMemory) { +TEST(RevFunctor, RecoverMemory) { using Eigen::VectorXd; for (int i = 0; i < 100000; ++i) { try { @@ -419,7 +417,7 @@ TEST_F(AgradRev, RevFunctor_RecoverMemory) { 100000); } -TEST_F(AgradRev, RevFunctor_RecoverMemory_gradient_array) { +TEST(RevFunctor, RecoverMemory_gradient_array) { using Eigen::VectorXd; for (int i = 0; i < 100000; ++i) { try { @@ -439,7 +437,7 @@ TEST_F(AgradRev, RevFunctor_RecoverMemory_gradient_array) { 100000); } -TEST_F(AgradRev, RevFunctor_gradientBoundaryConds) { +TEST(RevFunctor, gradientBoundaryConds) { VectorXd x(5); using stan::math::gradient; x << 1, 2, 3, 4, 5; diff --git a/test/unit/math/rev/functor/idas_system_test.cpp b/test/unit/math/rev/functor/idas_system_test.cpp index bc0c92ee0d1..29956534613 100644 --- a/test/unit/math/rev/functor/idas_system_test.cpp +++ b/test/unit/math/rev/functor/idas_system_test.cpp @@ -2,7 +2,6 @@ #include #include #include -#include #include #include #include diff --git a/test/unit/math/rev/functor/index_3_dae_typed_test.cpp b/test/unit/math/rev/functor/index_3_dae_typed_test.cpp index 8d0ef27f34a..ac217bf83e5 100644 --- a/test/unit/math/rev/functor/index_3_dae_typed_test.cpp +++ b/test/unit/math/rev/functor/index_3_dae_typed_test.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include diff --git a/test/unit/math/rev/functor/integrate_1d_impl_test.cpp b/test/unit/math/rev/functor/integrate_1d_impl_test.cpp index 39a9bfe145f..39349dd9e45 100644 --- a/test/unit/math/rev/functor/integrate_1d_impl_test.cpp +++ b/test/unit/math/rev/functor/integrate_1d_impl_test.cpp @@ -1,7 +1,6 @@ #include #include #include -#include #include #include #include @@ -143,7 +142,7 @@ struct f13 { * @param v variable * @return adjoint of var */ -inline double get_adjoint_if_var(stan::math::var v) { return v.adj(); } +double get_adjoint_if_var(stan::math::var v) { return v.adj(); } /* * If the argument is not a var, return a NaN @@ -151,7 +150,7 @@ inline double get_adjoint_if_var(stan::math::var v) { return v.adj(); } * @param v variable * @return NaN */ -inline double get_adjoint_if_var(double v) { +double get_adjoint_if_var(double v) { return std::numeric_limits::quiet_NaN(); } @@ -198,12 +197,12 @@ inline double get_adjoint_if_var(double v) { * limit (not used if T_b is not var) */ template -inline void test_derivatives(const F &f, double a, double b, - std::vector thetas, - const std::vector &x_r, - const std::vector &x_i, double val, - std::vector grad, double d_a = 0.0, - double d_b = 0.0) { +void test_derivatives(const F &f, double a, double b, + std::vector thetas, + const std::vector &x_r, + const std::vector &x_i, double val, + std::vector grad, double d_a = 0.0, + double d_b = 0.0) { using stan::math::value_of; using stan::math::var; @@ -223,21 +222,21 @@ inline void test_derivatives(const F &f, double a, double b, thetas_, x_r, x_i); integral.grad(); EXPECT_LE(std::abs(val - integral.val()), tolerance); - if constexpr (stan::is_var::value) { + if (stan::is_var::value) { for (size_t i = 0; i < grad.size(); ++i) EXPECT_LE(std::abs(grad[i] - get_adjoint_if_var(thetas_[i])), tolerance); } - if constexpr (stan::is_var::value) { + if (stan::is_var::value) { EXPECT_LE(std::abs(d_a - get_adjoint_if_var(a_)), tolerance); } - if constexpr (stan::is_var::value) { + if (stan::is_var::value) { EXPECT_LE(std::abs(d_b - get_adjoint_if_var(b_)), tolerance); } } } -TEST_F(AgradRev, StanMath_integrate_1d_impl_rev_test_integer_arguments) { +TEST(StanMath_integrate_1d_impl_rev, test_integer_arguments) { stan::math::var v; std::vector theta = {0.5}; std::vector x_r; @@ -250,7 +249,7 @@ TEST_F(AgradRev, StanMath_integrate_1d_impl_rev_test_integer_arguments) { theta, x_r, x_i)); } -TEST_F(AgradRev, StanMath_integrate_1d_impl_rev_TestDerivatives_easy) { +TEST(StanMath_integrate_1d_impl_rev, TestDerivatives_easy) { // Easy integrals using stan::math::var; test_derivatives(f1{}, 0.2, 0.7, {0.75}, {}, {}, @@ -267,7 +266,7 @@ TEST_F(AgradRev, StanMath_integrate_1d_impl_rev_TestDerivatives_easy) { {0.0}); } -TEST_F(AgradRev, StanMath_integrate_1d_impl_rev_TestDerivatives_zero_crossing) { +TEST(StanMath_integrate_1d_impl_rev, TestDerivatives_zero_crossing) { // Zero crossing integral + test x_r + vars at endpoints using stan::math::var; test_derivatives(f3{}, -1.0, 1.0, {0.5, 1.75, 3.9}, {2.5, 3.0}, @@ -300,7 +299,7 @@ TEST(StanMath_integrate_1d_impl_rev, {5 * pow(0.5, 1.5), 12 * 1.75 * 1.75, 4.0}, -19.06340613646808, 0.0); } -TEST_F(AgradRev, StanMath_integrate_1d_impl_rev_TestDerivatives_no_param_vars) { +TEST(StanMath_integrate_1d_impl_rev, TestDerivatives_no_param_vars) { // No param vars using stan::math::var; test_derivatives(f3{}, -1.0, 1.0, {0.5, 1.75, 3.9}, @@ -310,8 +309,7 @@ TEST_F(AgradRev, StanMath_integrate_1d_impl_rev_TestDerivatives_no_param_vars) { {}, -19.06340613646808, 21.41380852375568); } -TEST_F(AgradRev, - StanMath_integrate_1d_impl_rev_TestDerivatives_left_limit_var) { +TEST(StanMath_integrate_1d_impl_rev, TestDerivatives_left_limit_var) { // No param vars, only left limit var using stan::math::var; test_derivatives(f3{}, -1.0, 1.0, {0.5, 1.75, 3.9}, @@ -321,8 +319,7 @@ TEST_F(AgradRev, {}, -19.06340613646808, 0.0); } -TEST_F(AgradRev, - StanMath_integrate_1d_impl_rev_TestDerivatives_right_limit_var) { +TEST(StanMath_integrate_1d_impl_rev, TestDerivatives_right_limit_var) { // No param vars, only right limit var using stan::math::var; test_derivatives(f3{}, -1.0, 1.0, {0.5, 1.75, 3.9}, @@ -332,7 +329,7 @@ TEST_F(AgradRev, {}, 0.0, 21.41380852375568); } -TEST_F(AgradRev, StanMath_integrate_1d_impl_rev_TestDerivatives_tricky1) { +TEST(StanMath_integrate_1d_impl_rev, TestDerivatives_tricky1) { // Tricky integral from Boost docs + limit at infinity + no gradients using stan::math::var; test_derivatives(f4{}, 0.0, @@ -340,7 +337,7 @@ TEST_F(AgradRev, StanMath_integrate_1d_impl_rev_TestDerivatives_tricky1) { {}, {}, {}, 1.772453850905516, {}); } -TEST_F(AgradRev, StanMath_integrate_1d_impl_rev_TestDerivatives_tricky2) { +TEST(StanMath_integrate_1d_impl_rev, TestDerivatives_tricky2) { // Tricky integral from Boost docs + limit at infinity with gradients using stan::math::var; test_derivatives( @@ -350,15 +347,14 @@ TEST_F(AgradRev, StanMath_integrate_1d_impl_rev_TestDerivatives_tricky2) { -1.772453850905516 * 0.5 / (2 * pow(0.5 * 3.0, 1.5))}); } -TEST_F(AgradRev, StanMath_integrate_1d_impl_rev_TestDerivatives_tricky3) { +TEST(StanMath_integrate_1d_impl_rev, TestDerivatives_tricky3) { // Tricky integral from Boost docs using stan::math::var; test_derivatives( f6{}, 0.0, 1.0, {0.75}, {}, {}, 0.851926727945904, {0.4814066053874294}); } -TEST_F(AgradRev, - StanMath_integrate_1d_impl_rev_TestDerivatives_zero_crossing2) { +TEST(StanMath_integrate_1d_impl_rev, TestDerivatives_zero_crossing2) { // Zero crossing integral + limit at infinity + var at left limit using stan::math::var; test_derivatives( @@ -367,8 +363,7 @@ TEST_F(AgradRev, std::numeric_limits::quiet_NaN()); } -TEST_F(AgradRev, - StanMath_integrate_1d_impl_rev_TestDerivatives_zero_crossing3) { +TEST(StanMath_integrate_1d_impl_rev, TestDerivatives_zero_crossing3) { // Zero crossing integral + limit at negative infinity + var at right limit using stan::math::var; test_derivatives( @@ -377,7 +372,7 @@ TEST_F(AgradRev, std::numeric_limits::quiet_NaN(), 1808.042414456063); } -TEST_F(AgradRev, StanMath_integrate_1d_impl_rev_TestDerivatives_indefinite) { +TEST(StanMath_integrate_1d_impl_rev, TestDerivatives_indefinite) { // Both limits at infinity + test x_r/x_i + no gradients using stan::math::var; test_derivatives( @@ -386,8 +381,7 @@ TEST_F(AgradRev, StanMath_integrate_1d_impl_rev_TestDerivatives_indefinite) { 2.536571480364399, {}); } -TEST_F(AgradRev, - StanMath_integrate_1d_impl_rev_TestDerivatives_endpoint_precision) { +TEST(StanMath_integrate_1d_impl_rev, TestDerivatives_endpoint_precision) { // Various integrals of beta function using stan::math::var; test_derivatives(f11{}, 0.0, 1.0, {0.1, 0.1}, {}, {}, @@ -407,7 +401,7 @@ TEST_F(AgradRev, {-0.01040816326530613, -0.004852607709750566}); } -TEST_F(AgradRev, StanMath_integrate_1d_impl_rev_TestDerivatives_gaussian) { +TEST(StanMath_integrate_1d_impl_rev, TestDerivatives_gaussian) { // Check Gaussian integrates to 1.0 always using stan::math::var; test_derivatives( @@ -435,7 +429,7 @@ TEST(StanMath_integrate_1d_impl_rev, EXPECT_LT(std::abs(12.0 - b.adj()), 1e-8); } -TEST_F(AgradRev, StanMath_integrate_1d_impl_rev_TestBeta) { +TEST(StanMath_integrate_1d_impl_rev, TestBeta) { using stan::math::exp; using stan::math::integrate_1d_impl; using stan::math::var; @@ -459,7 +453,7 @@ TEST_F(AgradRev, StanMath_integrate_1d_impl_rev_TestBeta) { EXPECT_FLOAT_EQ(1, 1 + g[1]); } -TEST_F(AgradRev, StanMath_integrate_1d_impl_rev_TestCauchy) { +TEST(StanMath_integrate_1d_impl_rev, TestCauchy) { using stan::math::exp; using stan::math::integrate_1d_impl; using stan::math::var; @@ -485,7 +479,7 @@ TEST_F(AgradRev, StanMath_integrate_1d_impl_rev_TestCauchy) { EXPECT_FLOAT_EQ(1, 1 + g[1]); } -TEST_F(AgradRev, StanMath_integrate_1d_impl_rev_TestChiSquare) { +TEST(StanMath_integrate_1d_impl_rev, TestChiSquare) { using stan::math::exp; using stan::math::integrate_1d_impl; using stan::math::var; @@ -508,7 +502,7 @@ TEST_F(AgradRev, StanMath_integrate_1d_impl_rev_TestChiSquare) { EXPECT_FLOAT_EQ(1, 1 + g[0]); } -TEST_F(AgradRev, StanMath_integrate_1d_impl_rev_TestDoubleExponential) { +TEST(StanMath_integrate_1d_impl_rev, TestDoubleExponential) { using stan::math::exp; using stan::math::integrate_1d; using stan::math::var; @@ -536,7 +530,7 @@ TEST_F(AgradRev, StanMath_integrate_1d_impl_rev_TestDoubleExponential) { EXPECT_FLOAT_EQ(1, 1 + g[1]); } -TEST_F(AgradRev, StanMath_integrate_1d_impl_rev_TestExponential) { +TEST(StanMath_integrate_1d_impl_rev, TestExponential) { using stan::math::exp; using stan::math::integrate_1d_impl; using stan::math::var; @@ -559,7 +553,7 @@ TEST_F(AgradRev, StanMath_integrate_1d_impl_rev_TestExponential) { EXPECT_FLOAT_EQ(1, 1 + g[0]); } -TEST_F(AgradRev, StanMath_integrate_1d_impl_rev_TestFrechet) { +TEST(StanMath_integrate_1d_impl_rev, TestFrechet) { using stan::math::exp; using stan::math::integrate_1d_impl; using stan::math::var; @@ -585,7 +579,7 @@ TEST_F(AgradRev, StanMath_integrate_1d_impl_rev_TestFrechet) { EXPECT_FLOAT_EQ(1, 1 + g[1]); } -TEST_F(AgradRev, StanMath_integrate_1d_impl_rev_TestGamma) { +TEST(StanMath_integrate_1d_impl_rev, TestGamma) { using stan::math::exp; using stan::math::integrate_1d_impl; using stan::math::var; @@ -611,7 +605,7 @@ TEST_F(AgradRev, StanMath_integrate_1d_impl_rev_TestGamma) { EXPECT_FLOAT_EQ(1, 1 + g[1]); } -TEST_F(AgradRev, StanMath_integrate_1d_impl_rev_TestGumbel) { +TEST(StanMath_integrate_1d_impl_rev, TestGumbel) { using stan::math::exp; using stan::math::integrate_1d_impl; using stan::math::var; @@ -637,7 +631,7 @@ TEST_F(AgradRev, StanMath_integrate_1d_impl_rev_TestGumbel) { EXPECT_FLOAT_EQ(1, 1 + g[1]); } -TEST_F(AgradRev, StanMath_integrate_1d_impl_rev_TestInvChiSquared) { +TEST(StanMath_integrate_1d_impl_rev, TestInvChiSquared) { using stan::math::exp; using stan::math::integrate_1d_impl; using stan::math::var; @@ -661,7 +655,7 @@ TEST_F(AgradRev, StanMath_integrate_1d_impl_rev_TestInvChiSquared) { EXPECT_FLOAT_EQ(1, 1 + g[0]); } -TEST_F(AgradRev, StanMath_integrate_1d_impl_rev_TestLogistic) { +TEST(StanMath_integrate_1d_impl_rev, TestLogistic) { using stan::math::exp; using stan::math::integrate_1d_impl; using stan::math::var; @@ -687,7 +681,7 @@ TEST_F(AgradRev, StanMath_integrate_1d_impl_rev_TestLogistic) { EXPECT_FLOAT_EQ(1, 1 + g[1]); } -TEST_F(AgradRev, StanMath_integrate_1d_impl_rev_TestLogNormal) { +TEST(StanMath_integrate_1d_impl_rev, TestLogNormal) { using stan::math::exp; using stan::math::integrate_1d_impl; using stan::math::var; @@ -713,7 +707,7 @@ TEST_F(AgradRev, StanMath_integrate_1d_impl_rev_TestLogNormal) { EXPECT_FLOAT_EQ(1, 1 + g[1]); } -TEST_F(AgradRev, StanMath_integrate_1d_impl_rev_TestNormal) { +TEST(StanMath_integrate_1d_impl_rev, TestNormal) { using stan::math::exp; using stan::math::integrate_1d_impl; using stan::math::var; @@ -739,7 +733,7 @@ TEST_F(AgradRev, StanMath_integrate_1d_impl_rev_TestNormal) { EXPECT_FLOAT_EQ(1, 1 + g[1]); } -TEST_F(AgradRev, StanMath_integrate_1d_impl_rev_TestPareto) { +TEST(StanMath_integrate_1d_impl_rev, TestPareto) { using stan::math::exp; using stan::math::integrate_1d_impl; using stan::math::var; @@ -765,7 +759,7 @@ TEST_F(AgradRev, StanMath_integrate_1d_impl_rev_TestPareto) { EXPECT_FLOAT_EQ(1, 1 + g[1]); } -TEST_F(AgradRev, StanMath_integrate_1d_impl_rev_TestPareto2) { +TEST(StanMath_integrate_1d_impl_rev, TestPareto2) { using stan::math::exp; using stan::math::integrate_1d_impl; using stan::math::var; @@ -793,7 +787,7 @@ TEST_F(AgradRev, StanMath_integrate_1d_impl_rev_TestPareto2) { EXPECT_FLOAT_EQ(1, 1 + g[2]); } -TEST_F(AgradRev, StanMath_integrate_1d_impl_rev_TestRayleigh) { +TEST(StanMath_integrate_1d_impl_rev, TestRayleigh) { using stan::math::exp; using stan::math::integrate_1d_impl; using stan::math::var; @@ -816,7 +810,7 @@ TEST_F(AgradRev, StanMath_integrate_1d_impl_rev_TestRayleigh) { EXPECT_FLOAT_EQ(1, 1 + g[0]); } -TEST_F(AgradRev, StanMath_integrate_1d_impl_rev_TestScaledInvChiSquare) { +TEST(StanMath_integrate_1d_impl_rev, TestScaledInvChiSquare) { using stan::math::exp; using stan::math::integrate_1d_impl; using stan::math::var; @@ -842,7 +836,7 @@ TEST_F(AgradRev, StanMath_integrate_1d_impl_rev_TestScaledInvChiSquare) { EXPECT_FLOAT_EQ(1, 1 + g[1]); } -TEST_F(AgradRev, StanMath_integrate_1d_impl_rev_TestStudentT) { +TEST(StanMath_integrate_1d_impl_rev, TestStudentT) { using stan::math::exp; using stan::math::integrate_1d_impl; using stan::math::var; @@ -870,7 +864,7 @@ TEST_F(AgradRev, StanMath_integrate_1d_impl_rev_TestStudentT) { EXPECT_FLOAT_EQ(1, 1 + g[2]); } -TEST_F(AgradRev, StanMath_integrate_1d_impl_rev_TestUniform) { +TEST(StanMath_integrate_1d_impl_rev, TestUniform) { using stan::math::exp; using stan::math::integrate_1d_impl; using stan::math::var; @@ -894,7 +888,7 @@ TEST_F(AgradRev, StanMath_integrate_1d_impl_rev_TestUniform) { EXPECT_FLOAT_EQ(1, 1 + g[1]); } -TEST_F(AgradRev, StanMath_integrate_1d_impl_rev_TestVonMises) { +TEST(StanMath_integrate_1d_impl_rev, TestVonMises) { using stan::math::exp; using stan::math::integrate_1d_impl; using stan::math::var; @@ -920,7 +914,7 @@ TEST_F(AgradRev, StanMath_integrate_1d_impl_rev_TestVonMises) { EXPECT_FLOAT_EQ(1, 1 + g[1]); } -TEST_F(AgradRev, StanMath_integrate_1d_impl_rev_TestWeibull) { +TEST(StanMath_integrate_1d_impl_rev, TestWeibull) { using stan::math::exp; using stan::math::integrate_1d_impl; using stan::math::var; diff --git a/test/unit/math/rev/functor/integrate_1d_test.cpp b/test/unit/math/rev/functor/integrate_1d_test.cpp index 7f441942bc4..672e8145332 100644 --- a/test/unit/math/rev/functor/integrate_1d_test.cpp +++ b/test/unit/math/rev/functor/integrate_1d_test.cpp @@ -1,6 +1,5 @@ #include #include -#include #include #include #include @@ -143,7 +142,7 @@ struct f13 { * @param v variable * @return adjoint of var */ -inline double get_adjoint_if_var(stan::math::var v) { return v.adj(); } +double get_adjoint_if_var(stan::math::var v) { return v.adj(); } /* * If the argument is not a var, return a NaN @@ -151,7 +150,7 @@ inline double get_adjoint_if_var(stan::math::var v) { return v.adj(); } * @param v variable * @return NaN */ -inline double get_adjoint_if_var(double v) { +double get_adjoint_if_var(double v) { return std::numeric_limits::quiet_NaN(); } @@ -198,12 +197,12 @@ inline double get_adjoint_if_var(double v) { * limit (not used if T_b is not var) */ template -inline void test_derivatives(const F &f, double a, double b, - std::vector thetas, - const std::vector &x_r, - const std::vector &x_i, double val, - std::vector grad, double d_a = 0.0, - double d_b = 0.0) { +void test_derivatives(const F &f, double a, double b, + std::vector thetas, + const std::vector &x_r, + const std::vector &x_i, double val, + std::vector grad, double d_a = 0.0, + double d_b = 0.0) { using stan::math::value_of; using stan::math::var; @@ -223,21 +222,21 @@ inline void test_derivatives(const F &f, double a, double b, tolerance); integral.grad(); EXPECT_LE(std::abs(val - integral.val()), tolerance); - if constexpr (stan::is_var::value) { + if (stan::is_var::value) { for (size_t i = 0; i < grad.size(); ++i) EXPECT_LE(std::abs(grad[i] - get_adjoint_if_var(thetas_[i])), tolerance); } - if constexpr (stan::is_var::value) { + if (stan::is_var::value) { EXPECT_LE(std::abs(d_a - get_adjoint_if_var(a_)), tolerance); } - if constexpr (stan::is_var::value) { + if (stan::is_var::value) { EXPECT_LE(std::abs(d_b - get_adjoint_if_var(b_)), tolerance); } } } -TEST_F(AgradRev, StanMath_integrate_1d_rev_test_integer_arguments) { +TEST(StanMath_integrate_1d_rev, test_integer_arguments) { stan::math::var v; std::vector theta = {0.5}; EXPECT_NO_THROW( @@ -248,7 +247,7 @@ TEST_F(AgradRev, StanMath_integrate_1d_rev_test_integer_arguments) { v = stan::math::integrate_1d(f2{}, 0, 1.0, theta, {}, {}, msgs, 1e-6)); } -TEST_F(AgradRev, StanMath_integrate_1d_rev_TestDerivatives_easy) { +TEST(StanMath_integrate_1d_rev, TestDerivatives_easy) { // Easy integrals using stan::math::var; test_derivatives(f1{}, 0.2, 0.7, {0.75}, {}, {}, @@ -265,7 +264,7 @@ TEST_F(AgradRev, StanMath_integrate_1d_rev_TestDerivatives_easy) { {0.0}); } -TEST_F(AgradRev, StanMath_integrate_1d_rev_TestDerivatives_zero_crossing) { +TEST(StanMath_integrate_1d_rev, TestDerivatives_zero_crossing) { // Zero crossing integral + test x_r + vars at endpoints using stan::math::var; test_derivatives(f3{}, -1.0, 1.0, {0.5, 1.75, 3.9}, {2.5, 3.0}, @@ -276,9 +275,7 @@ TEST_F(AgradRev, StanMath_integrate_1d_rev_TestDerivatives_zero_crossing) { -19.06340613646808, 21.41380852375568); } -TEST_F( - AgradRev, - StanMath_integrate_1d_rev_TestDerivatives_var_right_endpoint_var_params) { +TEST(StanMath_integrate_1d_rev, TestDerivatives_var_right_endpoint_var_params) { // Zero crossing integral + test x_r + vars at right endpoint using stan::math::var; test_derivatives( @@ -288,8 +285,7 @@ TEST_F( {5 * pow(0.5, 1.5), 12 * 1.75 * 1.75, 4.0}, 0.0, 21.41380852375568); } -TEST_F(AgradRev, - StanMath_integrate_1d_rev_TestDerivatives_var_left_endpoint_var_params) { +TEST(StanMath_integrate_1d_rev, TestDerivatives_var_left_endpoint_var_params) { // Zero crossing integral + test x_r + var at left endpoint using stan::math::var; test_derivatives( @@ -299,7 +295,7 @@ TEST_F(AgradRev, {5 * pow(0.5, 1.5), 12 * 1.75 * 1.75, 4.0}, -19.06340613646808, 0.0); } -TEST_F(AgradRev, StanMath_integrate_1d_rev_TestDerivatives_no_param_vars) { +TEST(StanMath_integrate_1d_rev, TestDerivatives_no_param_vars) { // No param vars using stan::math::var; test_derivatives(f3{}, -1.0, 1.0, {0.5, 1.75, 3.9}, @@ -309,7 +305,7 @@ TEST_F(AgradRev, StanMath_integrate_1d_rev_TestDerivatives_no_param_vars) { {}, -19.06340613646808, 21.41380852375568); } -TEST_F(AgradRev, StanMath_integrate_1d_rev_TestDerivatives_left_limit_var) { +TEST(StanMath_integrate_1d_rev, TestDerivatives_left_limit_var) { // No param vars, only left limit var using stan::math::var; test_derivatives(f3{}, -1.0, 1.0, {0.5, 1.75, 3.9}, @@ -319,7 +315,7 @@ TEST_F(AgradRev, StanMath_integrate_1d_rev_TestDerivatives_left_limit_var) { {}, -19.06340613646808, 0.0); } -TEST_F(AgradRev, StanMath_integrate_1d_rev_TestDerivatives_right_limit_var) { +TEST(StanMath_integrate_1d_rev, TestDerivatives_right_limit_var) { // No param vars, only right limit var using stan::math::var; test_derivatives(f3{}, -1.0, 1.0, {0.5, 1.75, 3.9}, @@ -329,7 +325,7 @@ TEST_F(AgradRev, StanMath_integrate_1d_rev_TestDerivatives_right_limit_var) { {}, 0.0, 21.41380852375568); } -TEST_F(AgradRev, StanMath_integrate_1d_rev_TestDerivatives_tricky1) { +TEST(StanMath_integrate_1d_rev, TestDerivatives_tricky1) { // Tricky integral from Boost docs + limit at infinity + no gradients using stan::math::var; test_derivatives(f4{}, 0.0, @@ -337,7 +333,7 @@ TEST_F(AgradRev, StanMath_integrate_1d_rev_TestDerivatives_tricky1) { {}, {}, {}, 1.772453850905516, {}); } -TEST_F(AgradRev, StanMath_integrate_1d_rev_TestDerivatives_tricky2) { +TEST(StanMath_integrate_1d_rev, TestDerivatives_tricky2) { // Tricky integral from Boost docs + limit at infinity with gradients using stan::math::var; test_derivatives( @@ -347,14 +343,14 @@ TEST_F(AgradRev, StanMath_integrate_1d_rev_TestDerivatives_tricky2) { -1.772453850905516 * 0.5 / (2 * pow(0.5 * 3.0, 1.5))}); } -TEST_F(AgradRev, StanMath_integrate_1d_rev_TestDerivatives_tricky3) { +TEST(StanMath_integrate_1d_rev, TestDerivatives_tricky3) { // Tricky integral from Boost docs using stan::math::var; test_derivatives( f6{}, 0.0, 1.0, {0.75}, {}, {}, 0.851926727945904, {0.4814066053874294}); } -TEST_F(AgradRev, StanMath_integrate_1d_rev_TestDerivatives_zero_crossing2) { +TEST(StanMath_integrate_1d_rev, TestDerivatives_zero_crossing2) { // Zero crossing integral + limit at infinity + var at left limit using stan::math::var; test_derivatives( @@ -363,7 +359,7 @@ TEST_F(AgradRev, StanMath_integrate_1d_rev_TestDerivatives_zero_crossing2) { std::numeric_limits::quiet_NaN()); } -TEST_F(AgradRev, StanMath_integrate_1d_rev_TestDerivatives_zero_crossing3) { +TEST(StanMath_integrate_1d_rev, TestDerivatives_zero_crossing3) { // Zero crossing integral + limit at negative infinity + var at right limit using stan::math::var; test_derivatives( @@ -372,7 +368,7 @@ TEST_F(AgradRev, StanMath_integrate_1d_rev_TestDerivatives_zero_crossing3) { std::numeric_limits::quiet_NaN(), 1808.042414456063); } -TEST_F(AgradRev, StanMath_integrate_1d_rev_TestDerivatives_indefinite) { +TEST(StanMath_integrate_1d_rev, TestDerivatives_indefinite) { // Both limits at infinity + test x_r/x_i + no gradients using stan::math::var; test_derivatives( @@ -381,7 +377,7 @@ TEST_F(AgradRev, StanMath_integrate_1d_rev_TestDerivatives_indefinite) { 2.536571480364399, {}); } -TEST_F(AgradRev, StanMath_integrate_1d_rev_TestDerivatives_endpoint_precision) { +TEST(StanMath_integrate_1d_rev, TestDerivatives_endpoint_precision) { // Various integrals of beta function using stan::math::var; test_derivatives(f11{}, 0.0, 1.0, {0.1, 0.1}, {}, {}, @@ -401,7 +397,7 @@ TEST_F(AgradRev, StanMath_integrate_1d_rev_TestDerivatives_endpoint_precision) { {-0.01040816326530613, -0.004852607709750566}); } -TEST_F(AgradRev, StanMath_integrate_1d_rev_TestDerivatives_gaussian) { +TEST(StanMath_integrate_1d_rev, TestDerivatives_gaussian) { // Check Gaussian integrates to 1.0 always using stan::math::var; test_derivatives( @@ -410,8 +406,7 @@ TEST_F(AgradRev, StanMath_integrate_1d_rev_TestDerivatives_gaussian) { {0.0, 0.0}); } -TEST_F(AgradRev, - StanMath_integrate_1d_rev_TestDerivativesSameVarAtEndpointAndInParams) { +TEST(StanMath_integrate_1d_rev, TestDerivativesSameVarAtEndpointAndInParams) { using stan::math::var; var a = 2.0; @@ -427,7 +422,7 @@ TEST_F(AgradRev, EXPECT_LT(std::abs(12.0 - b.adj()), 1e-8); } -TEST_F(AgradRev, StanMath_integrate_1d_rev_TestBeta) { +TEST(StanMath_integrate_1d_rev, TestBeta) { using stan::math::exp; using stan::math::integrate_1d; using stan::math::var; @@ -449,7 +444,7 @@ TEST_F(AgradRev, StanMath_integrate_1d_rev_TestBeta) { EXPECT_FLOAT_EQ(1, 1 + g[1]); } -TEST_F(AgradRev, StanMath_integrate_1d_rev_TestCauchy) { +TEST(StanMath_integrate_1d_rev, TestCauchy) { using stan::math::exp; using stan::math::integrate_1d; using stan::math::var; @@ -473,7 +468,7 @@ TEST_F(AgradRev, StanMath_integrate_1d_rev_TestCauchy) { EXPECT_FLOAT_EQ(1, 1 + g[1]); } -TEST_F(AgradRev, StanMath_integrate_1d_rev_TestChiSquare) { +TEST(StanMath_integrate_1d_rev, TestChiSquare) { using stan::math::exp; using stan::math::integrate_1d; using stan::math::var; @@ -495,7 +490,7 @@ TEST_F(AgradRev, StanMath_integrate_1d_rev_TestChiSquare) { EXPECT_FLOAT_EQ(1, 1 + g[0]); } -TEST_F(AgradRev, StanMath_integrate_1d_rev_TestDoubleExponential) { +TEST(StanMath_integrate_1d_rev, TestDoubleExponential) { using stan::math::exp; using stan::math::integrate_1d; using stan::math::var; @@ -521,7 +516,7 @@ TEST_F(AgradRev, StanMath_integrate_1d_rev_TestDoubleExponential) { EXPECT_FLOAT_EQ(1, 1 + g[1]); } -TEST_F(AgradRev, StanMath_integrate_1d_rev_TestExponential) { +TEST(StanMath_integrate_1d_rev, TestExponential) { using stan::math::exp; using stan::math::integrate_1d; using stan::math::var; @@ -543,7 +538,7 @@ TEST_F(AgradRev, StanMath_integrate_1d_rev_TestExponential) { EXPECT_FLOAT_EQ(1, 1 + g[0]); } -TEST_F(AgradRev, StanMath_integrate_1d_rev_TestFrechet) { +TEST(StanMath_integrate_1d_rev, TestFrechet) { using stan::math::exp; using stan::math::integrate_1d; using stan::math::var; @@ -567,7 +562,7 @@ TEST_F(AgradRev, StanMath_integrate_1d_rev_TestFrechet) { EXPECT_FLOAT_EQ(1, 1 + g[1]); } -TEST_F(AgradRev, StanMath_integrate_1d_rev_TestGamma) { +TEST(StanMath_integrate_1d_rev, TestGamma) { using stan::math::exp; using stan::math::integrate_1d; using stan::math::var; @@ -591,7 +586,7 @@ TEST_F(AgradRev, StanMath_integrate_1d_rev_TestGamma) { EXPECT_FLOAT_EQ(1, 1 + g[1]); } -TEST_F(AgradRev, StanMath_integrate_1d_rev_TestGumbel) { +TEST(StanMath_integrate_1d_rev, TestGumbel) { using stan::math::exp; using stan::math::integrate_1d; using stan::math::var; @@ -615,7 +610,7 @@ TEST_F(AgradRev, StanMath_integrate_1d_rev_TestGumbel) { EXPECT_FLOAT_EQ(1, 1 + g[1]); } -TEST_F(AgradRev, StanMath_integrate_1d_rev_TestInvChiSquared) { +TEST(StanMath_integrate_1d_rev, TestInvChiSquared) { using stan::math::exp; using stan::math::integrate_1d; using stan::math::var; @@ -637,7 +632,7 @@ TEST_F(AgradRev, StanMath_integrate_1d_rev_TestInvChiSquared) { EXPECT_FLOAT_EQ(1, 1 + g[0]); } -TEST_F(AgradRev, StanMath_integrate_1d_rev_TestLogistic) { +TEST(StanMath_integrate_1d_rev, TestLogistic) { using stan::math::exp; using stan::math::integrate_1d; using stan::math::var; @@ -661,7 +656,7 @@ TEST_F(AgradRev, StanMath_integrate_1d_rev_TestLogistic) { EXPECT_FLOAT_EQ(1, 1 + g[1]); } -TEST_F(AgradRev, StanMath_integrate_1d_rev_TestLogNormal) { +TEST(StanMath_integrate_1d_rev, TestLogNormal) { using stan::math::exp; using stan::math::integrate_1d; using stan::math::var; @@ -685,7 +680,7 @@ TEST_F(AgradRev, StanMath_integrate_1d_rev_TestLogNormal) { EXPECT_FLOAT_EQ(1, 1 + g[1]); } -TEST_F(AgradRev, StanMath_integrate_1d_rev_TestNormal) { +TEST(StanMath_integrate_1d_rev, TestNormal) { using stan::math::exp; using stan::math::integrate_1d; using stan::math::var; @@ -709,7 +704,7 @@ TEST_F(AgradRev, StanMath_integrate_1d_rev_TestNormal) { EXPECT_FLOAT_EQ(1, 1 + g[1]); } -TEST_F(AgradRev, StanMath_integrate_1d_rev_TestPareto) { +TEST(StanMath_integrate_1d_rev, TestPareto) { using stan::math::exp; using stan::math::integrate_1d; using stan::math::var; @@ -733,7 +728,7 @@ TEST_F(AgradRev, StanMath_integrate_1d_rev_TestPareto) { EXPECT_FLOAT_EQ(1, 1 + g[1]); } -TEST_F(AgradRev, StanMath_integrate_1d_rev_TestPareto2) { +TEST(StanMath_integrate_1d_rev, TestPareto2) { using stan::math::exp; using stan::math::integrate_1d; using stan::math::var; @@ -759,7 +754,7 @@ TEST_F(AgradRev, StanMath_integrate_1d_rev_TestPareto2) { EXPECT_FLOAT_EQ(1, 1 + g[2]); } -TEST_F(AgradRev, StanMath_integrate_1d_rev_TestRayleigh) { +TEST(StanMath_integrate_1d_rev, TestRayleigh) { using stan::math::exp; using stan::math::integrate_1d; using stan::math::var; @@ -781,7 +776,7 @@ TEST_F(AgradRev, StanMath_integrate_1d_rev_TestRayleigh) { EXPECT_FLOAT_EQ(1, 1 + g[0]); } -TEST_F(AgradRev, StanMath_integrate_1d_rev_TestScaledInvChiSquare) { +TEST(StanMath_integrate_1d_rev, TestScaledInvChiSquare) { using stan::math::exp; using stan::math::integrate_1d; using stan::math::var; @@ -805,7 +800,7 @@ TEST_F(AgradRev, StanMath_integrate_1d_rev_TestScaledInvChiSquare) { EXPECT_FLOAT_EQ(1, 1 + g[1]); } -TEST_F(AgradRev, StanMath_integrate_1d_rev_TestStudentT) { +TEST(StanMath_integrate_1d_rev, TestStudentT) { using stan::math::exp; using stan::math::integrate_1d; using stan::math::var; @@ -831,7 +826,7 @@ TEST_F(AgradRev, StanMath_integrate_1d_rev_TestStudentT) { EXPECT_FLOAT_EQ(1, 1 + g[2]); } -TEST_F(AgradRev, StanMath_integrate_1d_rev_TestUniform) { +TEST(StanMath_integrate_1d_rev, TestUniform) { using stan::math::exp; using stan::math::integrate_1d; using stan::math::var; @@ -853,7 +848,7 @@ TEST_F(AgradRev, StanMath_integrate_1d_rev_TestUniform) { EXPECT_FLOAT_EQ(1, 1 + g[1]); } -TEST_F(AgradRev, StanMath_integrate_1d_rev_TestVonMises) { +TEST(StanMath_integrate_1d_rev, TestVonMises) { using stan::math::exp; using stan::math::integrate_1d; using stan::math::var; @@ -877,7 +872,7 @@ TEST_F(AgradRev, StanMath_integrate_1d_rev_TestVonMises) { EXPECT_FLOAT_EQ(1, 1 + g[1]); } -TEST_F(AgradRev, StanMath_integrate_1d_rev_TestWeibull) { +TEST(StanMath_integrate_1d_rev, TestWeibull) { using stan::math::exp; using stan::math::integrate_1d; using stan::math::var; diff --git a/test/unit/math/rev/functor/integrate_ode_std_vector_interface_adapter_test.cpp b/test/unit/math/rev/functor/integrate_ode_std_vector_interface_adapter_test.cpp index 8062d612379..f8611f7f57a 100644 --- a/test/unit/math/rev/functor/integrate_ode_std_vector_interface_adapter_test.cpp +++ b/test/unit/math/rev/functor/integrate_ode_std_vector_interface_adapter_test.cpp @@ -1,11 +1,10 @@ #include -#include #include #include #include #include -TEST_F(AgradRev, StanMathRev_vd) { +TEST(StanMathRev, vd) { using stan::math::var; harm_osc_ode_data_fun harm_osc; stan::math::internal::integrate_ode_std_vector_interface_adapter< @@ -41,7 +40,7 @@ TEST_F(AgradRev, StanMathRev_vd) { EXPECT_MATRIX_FLOAT_EQ(adjs1, adjs2); } -TEST_F(AgradRev, StanMathRev_dv) { +TEST(StanMathRev, dv) { using stan::math::var; harm_osc_ode_data_fun harm_osc; stan::math::internal::integrate_ode_std_vector_interface_adapter< @@ -77,7 +76,7 @@ TEST_F(AgradRev, StanMathRev_dv) { EXPECT_MATRIX_FLOAT_EQ(adjs1, adjs2); } -TEST_F(AgradRev, StanMathRev_vv) { +TEST(StanMathRev, vv) { using stan::math::var; harm_osc_ode_data_fun harm_osc; stan::math::internal::integrate_ode_std_vector_interface_adapter< diff --git a/test/unit/math/rev/functor/linear_dae_typed_test.cpp b/test/unit/math/rev/functor/linear_dae_typed_test.cpp index b78d2a0c2e9..850f3d3a8bc 100644 --- a/test/unit/math/rev/functor/linear_dae_typed_test.cpp +++ b/test/unit/math/rev/functor/linear_dae_typed_test.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include diff --git a/test/unit/math/rev/functor/lorenz_ode_typed_fd_test.cpp b/test/unit/math/rev/functor/lorenz_ode_typed_fd_test.cpp index 20b5e7ae1b6..a979aeb0e42 100644 --- a/test/unit/math/rev/functor/lorenz_ode_typed_fd_test.cpp +++ b/test/unit/math/rev/functor/lorenz_ode_typed_fd_test.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include @@ -23,17 +22,13 @@ using lorenz_test_types = boost::mp11::mp_product< TYPED_TEST_SUITE_P(lorenz_test); TYPED_TEST_P(lorenz_test, param_and_data_finite_diff) { - constexpr bool is_rk45 - = std::is_same>::value; - constexpr bool is_ckrk - = std::is_same>::value; - if constexpr (is_rk45) { + if (std::is_same>::value) { this->test_fd_vd(1.e-6, 3e-2); this->test_fd_dv(1.e-6, 3e-2); this->test_fd_vv(1.e-6, 3e-2); - } else if constexpr (is_ckrk) { + } else if (std::is_same>::value) { this->test_fd_vd(1.e-6, 5e-2); this->test_fd_dv(1.e-6, 5e-2); this->test_fd_vv(1.e-6, 5e-2); diff --git a/test/unit/math/rev/functor/map_rect_concurrent_prim_test.cpp b/test/unit/math/rev/functor/map_rect_concurrent_prim_test.cpp index b7fe369ae98..8a9c82ff963 100644 --- a/test/unit/math/rev/functor/map_rect_concurrent_prim_test.cpp +++ b/test/unit/math/rev/functor/map_rect_concurrent_prim_test.cpp @@ -7,7 +7,6 @@ #include #include -#include #include #include diff --git a/test/unit/math/rev/functor/map_rect_concurrent_test.cpp b/test/unit/math/rev/functor/map_rect_concurrent_test.cpp index 65b0dec034a..25afa2fc956 100644 --- a/test/unit/math/rev/functor/map_rect_concurrent_test.cpp +++ b/test/unit/math/rev/functor/map_rect_concurrent_test.cpp @@ -7,7 +7,6 @@ #include #include -#include #include #include diff --git a/test/unit/math/rev/functor/map_rect_concurrent_threads_test.cpp b/test/unit/math/rev/functor/map_rect_concurrent_threads_test.cpp index 40b20451e73..7237ca43fbf 100644 --- a/test/unit/math/rev/functor/map_rect_concurrent_threads_test.cpp +++ b/test/unit/math/rev/functor/map_rect_concurrent_threads_test.cpp @@ -10,7 +10,6 @@ #include #include -#include #include #include @@ -22,10 +21,10 @@ STAN_REGISTER_MAP_RECT(0, hard_work) STAN_REGISTER_MAP_RECT(1, hard_work) -inline void setup_job(int N, Eigen::VectorXd& shared_params_d, - std::vector& job_params_d, - std::vector >& x_r, - std::vector >& x_i) { +void setup_job(int N, Eigen::VectorXd& shared_params_d, + std::vector& job_params_d, + std::vector >& x_r, + std::vector >& x_i) { shared_params_d.resize(2); shared_params_d << 2, 0; diff --git a/test/unit/math/rev/functor/map_rect_mpi_prim_test.cpp b/test/unit/math/rev/functor/map_rect_mpi_prim_test.cpp index 0296aa087c2..3eac967f46a 100644 --- a/test/unit/math/rev/functor/map_rect_mpi_prim_test.cpp +++ b/test/unit/math/rev/functor/map_rect_mpi_prim_test.cpp @@ -3,7 +3,6 @@ #ifdef STAN_MPI #include -#include #include #include diff --git a/test/unit/math/rev/functor/map_rect_mpi_test.cpp b/test/unit/math/rev/functor/map_rect_mpi_test.cpp index 40a2851ef51..9c3155552b1 100644 --- a/test/unit/math/rev/functor/map_rect_mpi_test.cpp +++ b/test/unit/math/rev/functor/map_rect_mpi_test.cpp @@ -3,7 +3,6 @@ #ifdef STAN_MPI #include -#include #include #include diff --git a/test/unit/math/rev/functor/map_rect_prim_test.cpp b/test/unit/math/rev/functor/map_rect_prim_test.cpp index fbdd38ae275..1812e344696 100644 --- a/test/unit/math/rev/functor/map_rect_prim_test.cpp +++ b/test/unit/math/rev/functor/map_rect_prim_test.cpp @@ -1,5 +1,4 @@ #include -#include #include #include diff --git a/test/unit/math/rev/functor/ode_store_sensitivities_test.cpp b/test/unit/math/rev/functor/ode_store_sensitivities_test.cpp index ae8f58c330c..b49028f03e9 100644 --- a/test/unit/math/rev/functor/ode_store_sensitivities_test.cpp +++ b/test/unit/math/rev/functor/ode_store_sensitivities_test.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include @@ -51,7 +50,7 @@ struct aytm { } }; -TEST_F(AgradRev, Rev_ode_store_sensitivities) { +TEST(AgradRev, ode_store_sensitivities) { using stan::math::coupled_ode_system; using stan::math::var; @@ -99,7 +98,7 @@ TEST_F(AgradRev, Rev_ode_store_sensitivities) { stan::math::recover_memory(); } -TEST_F(AgradRev, Rev_ode_store_sensitivities_matrix) { +TEST(AgradRev, ode_store_sensitivities_matrix) { using stan::math::coupled_ode_system; using stan::math::var; diff --git a/test/unit/math/rev/functor/ode_test_functors.hpp b/test/unit/math/rev/functor/ode_test_functors.hpp index 6b966b1c3a3..997fc4ab075 100644 --- a/test/unit/math/rev/functor/ode_test_functors.hpp +++ b/test/unit/math/rev/functor/ode_test_functors.hpp @@ -7,7 +7,6 @@ #include #include #include -#include #define STAN_DEF_ODE_SOLVER_FUNCTOR(solver_name, solver_func) \ struct solver_name##_functor { \ diff --git a/test/unit/math/rev/functor/operands_and_partials_test.cpp b/test/unit/math/rev/functor/operands_and_partials_test.cpp index 384573f0418..33627460be8 100644 --- a/test/unit/math/rev/functor/operands_and_partials_test.cpp +++ b/test/unit/math/rev/functor/operands_and_partials_test.cpp @@ -1,11 +1,10 @@ #include -#include #include #include #include #include -TEST_F(AgradRev, PartialsVari_OperandsAndPartialsScal) { +TEST(AgradPartialsVari, OperandsAndPartialsScal) { using stan::math::operands_and_partials; using stan::math::var; @@ -28,7 +27,7 @@ TEST_F(AgradRev, PartialsVari_OperandsAndPartialsScal) { EXPECT_FLOAT_EQ(10.0, grad[0]); } -TEST_F(AgradRev, PartialsVari_OperandsAndPartialsVec) { +TEST(AgradPartialsVari, OperandsAndPartialsVec) { using stan::math::operands_and_partials; using stan::math::var; using stan::math::vector_d; @@ -67,7 +66,7 @@ TEST_F(AgradRev, PartialsVari_OperandsAndPartialsVec) { EXPECT_FLOAT_EQ(40.0, grad[3]); } -TEST_F(AgradRev, PartialsVari_OperandsAndPartialsStdVec) { +TEST(AgradPartialsVari, OperandsAndPartialsStdVec) { using stan::math::operands_and_partials; using stan::math::var; @@ -101,7 +100,7 @@ TEST_F(AgradRev, PartialsVari_OperandsAndPartialsStdVec) { EXPECT_FLOAT_EQ(40.0, grad[3]); } -TEST_F(AgradRev, PartialsVari_OperandsAndPartialsMat) { +TEST(AgradPartialsVari, OperandsAndPartialsMat) { using stan::math::matrix_d; using stan::math::matrix_v; using stan::math::operands_and_partials; @@ -142,7 +141,7 @@ TEST_F(AgradRev, PartialsVari_OperandsAndPartialsMat) { EXPECT_FLOAT_EQ(120.0, grad[3]); } -TEST_F(AgradRev, PartialsVari_OperandsAndPartialsMatMultivar) { +TEST(AgradPartialsVari, OperandsAndPartialsMatMultivar) { using stan::math::matrix_d; using stan::math::matrix_v; using stan::math::operands_and_partials; @@ -204,7 +203,7 @@ TEST_F(AgradRev, PartialsVari_OperandsAndPartialsMatMultivar) { EXPECT_FLOAT_EQ(80.0, grad[7]); } -TEST_F(AgradRev, PartialsVari_OperandsAndPartialsMultivar) { +TEST(AgradPartialsVari, OperandsAndPartialsMultivar) { using stan::math::operands_and_partials; using stan::math::var; using stan::math::vector_d; @@ -255,7 +254,7 @@ TEST_F(AgradRev, PartialsVari_OperandsAndPartialsMultivar) { // XXX Test mixed - operands_and_partials, // vector_d, vector_v> -TEST_F(AgradRev, PartialsVari_OperandsAndPartialsMultivarMixed) { +TEST(AgradPartialsVari, OperandsAndPartialsMultivarMixed) { using stan::math::matrix_v; using stan::math::operands_and_partials; using stan::math::var; @@ -329,7 +328,7 @@ TEST_F(AgradRev, PartialsVari_OperandsAndPartialsMultivarMixed) { o6.edge3_.partials_vec_[0] += d_vec2; } -TEST_F(AgradRev, PartialsVari_OperandsAndPartialsVarValueMat) { +TEST(AgradPartialsVari, OperandsAndPartialsVarValueMat) { using stan::math::matrix_d; using stan::math::matrix_v; using stan::math::operands_and_partials; @@ -347,7 +346,7 @@ TEST_F(AgradRev, PartialsVari_OperandsAndPartialsVarValueMat) { EXPECT_MATRIX_EQ(av.adj(), Eigen::MatrixXd::Constant(2, 2, -4)) } -TEST_F(AgradRev, PartialsVari_OperandsAndPartialsStdVectorVarValueMat) { +TEST(AgradPartialsVari, OperandsAndPartialsStdVectorVarValueMat) { using stan::math::matrix_d; using stan::math::matrix_v; using stan::math::operands_and_partials; diff --git a/test/unit/math/rev/functor/partials_propagator_test.cpp b/test/unit/math/rev/functor/partials_propagator_test.cpp index 530894cc869..bc09e38196d 100644 --- a/test/unit/math/rev/functor/partials_propagator_test.cpp +++ b/test/unit/math/rev/functor/partials_propagator_test.cpp @@ -1,10 +1,9 @@ #include -#include #include #include #include -TEST_F(AgradRev, PartialsVari_PartialsPropagatorScal) { +TEST(AgradPartialsVari, PartialsPropagatorScal) { using stan::math::make_partials_propagator; using stan::math::var; @@ -27,7 +26,7 @@ TEST_F(AgradRev, PartialsVari_PartialsPropagatorScal) { EXPECT_FLOAT_EQ(10.0, grad[0]); } -TEST_F(AgradRev, PartialsVari_PartialsPropagatorVec) { +TEST(AgradPartialsVari, PartialsPropagatorVec) { using stan::math::make_partials_propagator; using stan::math::var; using stan::math::vector_d; @@ -66,7 +65,7 @@ TEST_F(AgradRev, PartialsVari_PartialsPropagatorVec) { EXPECT_FLOAT_EQ(40.0, grad[3]); } -TEST_F(AgradRev, PartialsVari_PartialsPropagatorStdVec) { +TEST(AgradPartialsVari, PartialsPropagatorStdVec) { using stan::math::make_partials_propagator; using stan::math::var; @@ -100,7 +99,7 @@ TEST_F(AgradRev, PartialsVari_PartialsPropagatorStdVec) { EXPECT_FLOAT_EQ(40.0, grad[3]); } -TEST_F(AgradRev, PartialsVari_PartialsPropagatorMat) { +TEST(AgradPartialsVari, PartialsPropagatorMat) { using stan::math::make_partials_propagator; using stan::math::matrix_d; using stan::math::matrix_v; @@ -141,7 +140,7 @@ TEST_F(AgradRev, PartialsVari_PartialsPropagatorMat) { EXPECT_FLOAT_EQ(120.0, grad[3]); } -TEST_F(AgradRev, PartialsVari_PartialsPropagatorMatMultivar) { +TEST(AgradPartialsVari, PartialsPropagatorMatMultivar) { using stan::math::make_partials_propagator; using stan::math::matrix_d; using stan::math::matrix_v; @@ -203,7 +202,7 @@ TEST_F(AgradRev, PartialsVari_PartialsPropagatorMatMultivar) { EXPECT_FLOAT_EQ(80.0, grad[7]); } -TEST_F(AgradRev, PartialsVari_PartialsPropagatorMultivar) { +TEST(AgradPartialsVari, PartialsPropagatorMultivar) { using stan::math::make_partials_propagator; using stan::math::var; using stan::math::vector_d; @@ -254,7 +253,7 @@ TEST_F(AgradRev, PartialsVari_PartialsPropagatorMultivar) { // XXX Test mixed - partials_propagator, // vector_d, vector_v> -TEST_F(AgradRev, PartialsVari_PartialsPropagatorMultivarMixed) { +TEST(AgradPartialsVari, PartialsPropagatorMultivarMixed) { using stan::math::make_partials_propagator; using stan::math::matrix_v; using stan::math::var; @@ -325,7 +324,7 @@ TEST_F(AgradRev, PartialsVari_PartialsPropagatorMultivarMixed) { stan::math::edge<2>(o6).partials_vec_[0] += d_vec2; } -TEST_F(AgradRev, PartialsVari_PartialsPropagatorVarValueMat) { +TEST(AgradPartialsVari, PartialsPropagatorVarValueMat) { using stan::math::make_partials_propagator; using stan::math::matrix_d; using stan::math::matrix_v; @@ -343,7 +342,7 @@ TEST_F(AgradRev, PartialsVari_PartialsPropagatorVarValueMat) { EXPECT_MATRIX_EQ(av.adj(), Eigen::MatrixXd::Constant(2, 2, -4)) } -TEST_F(AgradRev, PartialsVari_PartialsPropagatorStdVectorVarValueMat) { +TEST(AgradPartialsVari, PartialsPropagatorStdVectorVarValueMat) { using stan::math::make_partials_propagator; using stan::math::matrix_d; using stan::math::matrix_v; diff --git a/test/unit/math/rev/functor/pph_dae_typed_test.cpp b/test/unit/math/rev/functor/pph_dae_typed_test.cpp index 32ef720a14f..70ff3573d9c 100644 --- a/test/unit/math/rev/functor/pph_dae_typed_test.cpp +++ b/test/unit/math/rev/functor/pph_dae_typed_test.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include diff --git a/test/unit/math/rev/functor/reduce_sum_test.cpp b/test/unit/math/rev/functor/reduce_sum_test.cpp index b68c2ef6946..7f3a971b488 100644 --- a/test/unit/math/rev/functor/reduce_sum_test.cpp +++ b/test/unit/math/rev/functor/reduce_sum_test.cpp @@ -1,6 +1,5 @@ #include #include -#include #include #include #include @@ -8,7 +7,7 @@ #include #include -TEST_F(AgradRev, StanMathRev_reduce_sum_no_args) { +TEST(StanMathRev_reduce_sum, no_args) { using stan::math::var; using stan::math::test::get_new_msg; using stan::math::test::sum_lpdf; @@ -23,7 +22,7 @@ TEST_F(AgradRev, StanMathRev_reduce_sum_no_args) { << "Failed for reduce_sum"; } -TEST_F(AgradRev, StanMathRev_reduce_sum_value) { +TEST(StanMathRev_reduce_sum, value) { using stan::math::test::count_lpdf; using stan::math::test::get_new_msg; double lambda_d = 10.0; @@ -52,7 +51,7 @@ TEST_F(AgradRev, StanMathRev_reduce_sum_value) { EXPECT_FLOAT_EQ(poisson_lpdf_static, poisson_lpdf_ref); } -TEST_F(AgradRev, StanMathRev_reduce_sum_gradient) { +TEST(StanMathRev_reduce_sum, gradient) { using stan::math::var; using stan::math::test::count_lpdf; using stan::math::test::get_new_msg; @@ -100,7 +99,7 @@ TEST_F(AgradRev, StanMathRev_reduce_sum_gradient) { stan::math::recover_memory(); } -TEST_F(AgradRev, StanMathRev_reduce_sum_grainsize) { +TEST(StanMathRev_reduce_sum, grainsize) { using stan::math::var; using stan::math::test::count_lpdf; using stan::math::test::get_new_msg; @@ -148,7 +147,7 @@ TEST_F(AgradRev, StanMathRev_reduce_sum_grainsize) { stan::math::recover_memory(); } -TEST_F(AgradRev, StanMathRev_reduce_sum_nesting_gradient) { +TEST(StanMathRev_reduce_sum, nesting_gradient) { using stan::math::var; using stan::math::test::get_new_msg; using stan::math::test::nesting_count_lpdf; @@ -198,7 +197,7 @@ TEST_F(AgradRev, StanMathRev_reduce_sum_nesting_gradient) { stan::math::recover_memory(); } -TEST_F(AgradRev, StanMathRev_reduce_sum_grouped_gradient) { +TEST(StanMathRev_reduce_sum, grouped_gradient) { using stan::math::var; using stan::math::test::get_new_msg; using stan::math::test::grouped_count_lpdf; @@ -258,7 +257,7 @@ TEST_F(AgradRev, StanMathRev_reduce_sum_grouped_gradient) { stan::math::recover_memory(); } -TEST_F(AgradRev, StanMathRev_reduce_sum_grouped_gradient_eigen) { +TEST(StanMathRev_reduce_sum, grouped_gradient_eigen) { using stan::math::var; using stan::math::test::get_new_msg; using stan::math::test::grouped_count_lpdf; @@ -320,7 +319,7 @@ TEST_F(AgradRev, StanMathRev_reduce_sum_grouped_gradient_eigen) { stan::math::recover_memory(); } -TEST_F(AgradRev, StanMathRev_reduce_sum_slice_group_gradient) { +TEST(StanMathRev_reduce_sum, slice_group_gradient) { using stan::math::var; using stan::math::test::get_new_msg; using stan::math::test::slice_group_count_lpdf; @@ -390,7 +389,7 @@ TEST_F(AgradRev, StanMathRev_reduce_sum_slice_group_gradient) { // reduce_sum needs still work fine whenever multiple arguments point // to the same vari internally -TEST_F(AgradRev, StanMathRev_reduce_sum_linked_args) { +TEST(StanMathRev_reduce_sum, linked_args) { using stan::math::test::arg_start_end_lpdf; using stan::math::test::get_new_msg; auto start_end_rs = [](auto&& arg1, auto&& arg2) { diff --git a/test/unit/math/rev/functor/sho_ode_adjoint_typed_error_test.cpp b/test/unit/math/rev/functor/sho_ode_adjoint_typed_error_test.cpp index 771f0a45be7..d08d4fae626 100644 --- a/test/unit/math/rev/functor/sho_ode_adjoint_typed_error_test.cpp +++ b/test/unit/math/rev/functor/sho_ode_adjoint_typed_error_test.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include @@ -36,11 +35,9 @@ TYPED_TEST_P(harmonic_oscillator_ctl_test, value) { this->test_value(1.0); this->test_value(-1.0); - if constexpr (std::is_same, double>::value - && std::is_same, - double>::value - && std::is_same, - double>::value) { + if (std::is_same, double>::value + && std::is_same, double>::value + && std::is_same, double>::value) { EXPECT_EQ(stan::math::nested_size(), 0); } else { EXPECT_GT(stan::math::nested_size(), 0); diff --git a/test/unit/math/rev/functor/sho_ode_typed_error_test.cpp b/test/unit/math/rev/functor/sho_ode_typed_error_test.cpp index dcd47f42e94..29004435625 100644 --- a/test/unit/math/rev/functor/sho_ode_typed_error_test.cpp +++ b/test/unit/math/rev/functor/sho_ode_typed_error_test.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include diff --git a/test/unit/math/rev/functor/sho_ode_typed_test.cpp b/test/unit/math/rev/functor/sho_ode_typed_test.cpp index 7d03c4c476a..e959bbefd77 100644 --- a/test/unit/math/rev/functor/sho_ode_typed_test.cpp +++ b/test/unit/math/rev/functor/sho_ode_typed_test.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include @@ -101,24 +100,24 @@ using harmonic_oscillator_test_types = boost::mp11::mp_product< TYPED_TEST_SUITE_P(harmonic_oscillator_t0_ad_test); TYPED_TEST_P(harmonic_oscillator_t0_ad_test, t0_ad) { - if constexpr (std::is_same, - ode_rk45_functor>::value) { + if (std::is_same, + ode_rk45_functor>::value) { this->test_t0_ad(5e-6); } - if constexpr (std::is_same, - ode_ckrk_functor>::value) { + if (std::is_same, + ode_ckrk_functor>::value) { this->test_t0_ad(5e-6); } - if constexpr (std::is_same, - ode_adams_functor>::value) { + if (std::is_same, + ode_adams_functor>::value) { this->test_t0_ad(1e-8); } - if constexpr (std::is_same, - ode_bdf_functor>::value) { + if (std::is_same, + ode_bdf_functor>::value) { this->test_t0_ad(1e-7); } - if constexpr (std::is_same, - ode_adjoint_functor>::value) { + if (std::is_same, + ode_adjoint_functor>::value) { this->test_t0_ad(1e-7); } } diff --git a/test/unit/math/rev/functor/solve_newton_test.cpp b/test/unit/math/rev/functor/solve_newton_test.cpp index 19d64274511..ae6e6474894 100644 --- a/test/unit/math/rev/functor/solve_newton_test.cpp +++ b/test/unit/math/rev/functor/solve_newton_test.cpp @@ -1,7 +1,6 @@ #include #include #include -#include #include #include #include @@ -51,7 +50,7 @@ TEST_F(max_steps_test, newton_dbl) { max_num_steps_test(y, is_newton); } -TEST_F(AgradRev, MathMatrixRevMat_unsolvable_flag_newton_dbl) { +TEST(MathMatrixRevMat, unsolvable_flag_newton_dbl) { Eigen::VectorXd y(2); y << 1, 1; @@ -187,7 +186,7 @@ TEST_F(max_steps_test, newton) { max_num_steps_test(y_var, is_newton); } -TEST_F(AgradRev, MathMatrixRevMat_unsolvable_flag_newton) { +TEST(MathMatrixRevMat, unsolvable_flag_newton) { Eigen::Matrix y(2); y << 1, 1; diff --git a/test/unit/math/rev/functor/solve_powell_test.cpp b/test/unit/math/rev/functor/solve_powell_test.cpp index a4d519ec49a..2c598040af8 100644 --- a/test/unit/math/rev/functor/solve_powell_test.cpp +++ b/test/unit/math/rev/functor/solve_powell_test.cpp @@ -1,7 +1,6 @@ #include #include #include -#include #include #include #include @@ -54,7 +53,7 @@ TEST_F(error_message_test, powell_dbl) { error_conditions_test(non_linear_eq_functor(), y_3, is_newton); } -TEST_F(AgradRev, unsolvable_test_powell_dbl) { +TEST(unsolvable_test, powell_dbl) { Eigen::VectorXd y(2); y << 1, 1; unsolvable_test(y); @@ -186,7 +185,7 @@ TEST_F(error_message_test, powell) { error_conditions_test(non_linear_eq_functor(), y, is_newton); } -TEST_F(AgradRev, unsolvable_test_powell) { +TEST(unsolvable_test, powell) { using stan::math::var; Eigen::Matrix y(2); y << 1, 1; diff --git a/test/unit/math/rev/functor/test_fixture_dae_analytical.hpp b/test/unit/math/rev/functor/test_fixture_dae_analytical.hpp index 4e883b13ab3..3e3ca73e7e6 100644 --- a/test/unit/math/rev/functor/test_fixture_dae_analytical.hpp +++ b/test/unit/math/rev/functor/test_fixture_dae_analytical.hpp @@ -2,7 +2,6 @@ #define STAN_MATH_TEST_FIXTURE_DAE_ANALYTICAL_HPP #include -#include #include #include #include diff --git a/test/unit/math/rev/functor/test_fixture_dae_chem.hpp b/test/unit/math/rev/functor/test_fixture_dae_chem.hpp index 0946cf10e6d..d5c420dc45c 100644 --- a/test/unit/math/rev/functor/test_fixture_dae_chem.hpp +++ b/test/unit/math/rev/functor/test_fixture_dae_chem.hpp @@ -2,7 +2,6 @@ #define STAN_MATH_TEST_FIXTURE_DAE_CHEM_HPP #include -#include #include #include #include diff --git a/test/unit/math/rev/functor/test_fixture_dae_index_3.hpp b/test/unit/math/rev/functor/test_fixture_dae_index_3.hpp index a81f4cb8abe..09cc0065950 100644 --- a/test/unit/math/rev/functor/test_fixture_dae_index_3.hpp +++ b/test/unit/math/rev/functor/test_fixture_dae_index_3.hpp @@ -2,7 +2,6 @@ #define STAN_MATH_TEST_FIXTURE_DAE_INDEX_3_HPP #include -#include #include #include #include diff --git a/test/unit/math/rev/functor/test_fixture_dae_pph.hpp b/test/unit/math/rev/functor/test_fixture_dae_pph.hpp index 28a73401a79..0781bb5ee02 100644 --- a/test/unit/math/rev/functor/test_fixture_dae_pph.hpp +++ b/test/unit/math/rev/functor/test_fixture_dae_pph.hpp @@ -2,7 +2,6 @@ #define STAN_MATH_TEST_FIXTURE_DAE_PREY_PREDATOR_HARVEST_HPP #include -#include #include #include #include diff --git a/test/unit/math/rev/functor/test_fixture_linear_dae.hpp b/test/unit/math/rev/functor/test_fixture_linear_dae.hpp index 59f413f2185..dc0aded04ff 100644 --- a/test/unit/math/rev/functor/test_fixture_linear_dae.hpp +++ b/test/unit/math/rev/functor/test_fixture_linear_dae.hpp @@ -2,7 +2,6 @@ #define STAN_MATH_TEST_FIXTURE_DAE_LINEAR_HPP #include -#include #include #include #include diff --git a/test/unit/math/rev/functor/test_fixture_ode.hpp b/test/unit/math/rev/functor/test_fixture_ode.hpp index 48831c4308a..1082e6ea66c 100644 --- a/test/unit/math/rev/functor/test_fixture_ode.hpp +++ b/test/unit/math/rev/functor/test_fixture_ode.hpp @@ -2,7 +2,6 @@ #define TEST_UNIT_MATH_REV_FUNCTOR_ODE_FIXTURE_HPP #include -#include #include #include #include diff --git a/test/unit/math/rev/functor/test_fixture_ode_cos_scalar.hpp b/test/unit/math/rev/functor/test_fixture_ode_cos_scalar.hpp index ab3a043c2ad..109390a04cf 100644 --- a/test/unit/math/rev/functor/test_fixture_ode_cos_scalar.hpp +++ b/test/unit/math/rev/functor/test_fixture_ode_cos_scalar.hpp @@ -2,7 +2,6 @@ #define STAN_MATH_TEST_FIXTURE_ODE_COS_SCALAR_HPP #include -#include #include #include #include diff --git a/test/unit/math/rev/functor/test_fixture_ode_fho.hpp b/test/unit/math/rev/functor/test_fixture_ode_fho.hpp index 3cc8214a1a5..ac38801a388 100644 --- a/test/unit/math/rev/functor/test_fixture_ode_fho.hpp +++ b/test/unit/math/rev/functor/test_fixture_ode_fho.hpp @@ -2,7 +2,6 @@ #define STAN_MATH_TEST_FIXTURE_ODE_FHO_HPP #include -#include #include #include #include diff --git a/test/unit/math/rev/functor/test_fixture_ode_lorenz.hpp b/test/unit/math/rev/functor/test_fixture_ode_lorenz.hpp index a23f6733e42..a1a50aa0f55 100644 --- a/test/unit/math/rev/functor/test_fixture_ode_lorenz.hpp +++ b/test/unit/math/rev/functor/test_fixture_ode_lorenz.hpp @@ -2,7 +2,6 @@ #define STAN_MATH_TEST_FIXTURE_ODE_LORENZ_HPP #include -#include #include #include #include diff --git a/test/unit/math/rev/functor/test_fixture_ode_sho.hpp b/test/unit/math/rev/functor/test_fixture_ode_sho.hpp index 5a45bd69712..560d3d375c6 100644 --- a/test/unit/math/rev/functor/test_fixture_ode_sho.hpp +++ b/test/unit/math/rev/functor/test_fixture_ode_sho.hpp @@ -2,7 +2,6 @@ #define STAN_MATH_TEST_FIXTURE_ODE_SHO_HPP #include -#include #include #include #include diff --git a/test/unit/math/rev/functor/test_fixture_ode_sho_ctl.hpp b/test/unit/math/rev/functor/test_fixture_ode_sho_ctl.hpp index 4b1a0abcd56..1c95d1d25dd 100644 --- a/test/unit/math/rev/functor/test_fixture_ode_sho_ctl.hpp +++ b/test/unit/math/rev/functor/test_fixture_ode_sho_ctl.hpp @@ -2,7 +2,6 @@ #define STAN_MATH_TEST_FIXTURE_ODE_SHO_CTL_HPP #include -#include #include #include #include diff --git a/test/unit/math/rev/functor/util_algebra_solver.hpp b/test/unit/math/rev/functor/util_algebra_solver.hpp index 6035ca4d0d7..34468a49cfe 100644 --- a/test/unit/math/rev/functor/util_algebra_solver.hpp +++ b/test/unit/math/rev/functor/util_algebra_solver.hpp @@ -3,7 +3,6 @@ #include #include #include -#include #include #include #include @@ -457,7 +456,7 @@ inline void error_conditions_test(const F& f, } template -inline void unsolvable_test(Eigen::Matrix& y, +void inline unsolvable_test(Eigen::Matrix& y, int solver_type = 0, bool use_tol = false) { Eigen::VectorXd x(2); x << 1, 1; @@ -483,7 +482,7 @@ inline void unsolvable_test(Eigen::Matrix& y, } template -inline void unsolvable_flag_test(Eigen::Matrix& y, +void inline unsolvable_flag_test(Eigen::Matrix& y, int solver_type = 0, bool use_tol = false) { Eigen::VectorXd x(2); x << 1, 1; diff --git a/test/unit/math/rev/meta/VectorBuilderHelper_test.cpp b/test/unit/math/rev/meta/VectorBuilderHelper_test.cpp index 3c16968d6ff..af0d0234e78 100644 --- a/test/unit/math/rev/meta/VectorBuilderHelper_test.cpp +++ b/test/unit/math/rev/meta/VectorBuilderHelper_test.cpp @@ -1,11 +1,10 @@ #include #include -#include #include #include #include -TEST_F(AgradRev, MetaTraitsRevScal_VectorBuilderHelper_false_true) { +TEST(MetaTraitsRevScal, VectorBuilderHelper_false_true) { using stan::VectorBuilderHelper; using stan::math::size; using stan::math::var; @@ -17,7 +16,7 @@ TEST_F(AgradRev, MetaTraitsRevScal_VectorBuilderHelper_false_true) { EXPECT_THROW(dvv1.data(), std::logic_error); } -TEST_F(AgradRev, MetaTraitsRevArr_VectorBuilderHelper_false_true) { +TEST(MetaTraitsRevArr, VectorBuilderHelper_false_true) { using stan::VectorBuilderHelper; using stan::math::size; using stan::math::var; @@ -30,7 +29,7 @@ TEST_F(AgradRev, MetaTraitsRevArr_VectorBuilderHelper_false_true) { EXPECT_THROW(dvv2.data(), std::logic_error); } -TEST_F(AgradRev, MetaTraitsRevArr_VectorBuilderHelper_true_true) { +TEST(MetaTraitsRevArr, VectorBuilderHelper_true_true) { using stan::VectorBuilderHelper; using stan::math::size; using stan::math::var; @@ -57,7 +56,7 @@ TEST_F(AgradRev, MetaTraitsRevArr_VectorBuilderHelper_true_true) { EXPECT_EQ(stan::math::size(a_std_vector), data2.size()); } -TEST_F(AgradRev, MetaTraitsRevMat_VectorBuilderHelper_false_true) { +TEST(MetaTraitsRevMat, VectorBuilderHelper_false_true) { using Eigen::Dynamic; using Eigen::Matrix; using stan::VectorBuilderHelper; @@ -76,7 +75,7 @@ TEST_F(AgradRev, MetaTraitsRevMat_VectorBuilderHelper_false_true) { EXPECT_THROW(dvv3.data(), std::logic_error); } -TEST_F(AgradRev, MetaTraitsRevMat_VectorBuilderHelper_true_true) { +TEST(MetaTraitsRevMat, VectorBuilderHelper_true_true) { using Eigen::Dynamic; using Eigen::Matrix; using stan::VectorBuilderHelper; diff --git a/test/unit/math/rev/meta/VectorBuilder_test.cpp b/test/unit/math/rev/meta/VectorBuilder_test.cpp index 0037282c0af..edd3df52fdc 100644 --- a/test/unit/math/rev/meta/VectorBuilder_test.cpp +++ b/test/unit/math/rev/meta/VectorBuilder_test.cpp @@ -1,11 +1,10 @@ #include #include -#include #include #include #include -TEST_F(AgradRev, MetaTraitsRevArr_VectorBuilder_false_true) { +TEST(MetaTraitsRevArr, VectorBuilder_false_true) { using stan::VectorBuilder; using stan::math::size; using stan::math::var; @@ -24,7 +23,7 @@ TEST_F(AgradRev, MetaTraitsRevArr_VectorBuilder_false_true) { EXPECT_THROW(dvv2.data(), std::logic_error); } -TEST_F(AgradRev, MetaTraitsRevArr_VectorBuilder_true_true) { +TEST(MetaTraitsRevArr, VectorBuilder_true_true) { using stan::VectorBuilder; using stan::math::size; using stan::math::var; @@ -53,7 +52,7 @@ TEST_F(AgradRev, MetaTraitsRevArr_VectorBuilder_true_true) { EXPECT_EQ(stan::math::size(a_std_vector), data2.size()); } -TEST_F(AgradRev, MetaTraitsRevMat_VectorBuilder_false_true) { +TEST(MetaTraitsRevMat, VectorBuilder_false_true) { using Eigen::Dynamic; using Eigen::Matrix; using stan::VectorBuilder; @@ -74,7 +73,7 @@ TEST_F(AgradRev, MetaTraitsRevMat_VectorBuilder_false_true) { EXPECT_THROW(dvv4.data(), std::logic_error); } -TEST_F(AgradRev, MetaTraitsRevMat_VectorBuilder_true_true) { +TEST(MetaTraitsRevMat, VectorBuilder_true_true) { using Eigen::Dynamic; using Eigen::Matrix; using stan::VectorBuilder; diff --git a/test/unit/math/rev/meta/ad_promotable_test.cpp b/test/unit/math/rev/meta/ad_promotable_test.cpp index 9cf05e933b0..3f21820fe1b 100644 --- a/test/unit/math/rev/meta/ad_promotable_test.cpp +++ b/test/unit/math/rev/meta/ad_promotable_test.cpp @@ -1,9 +1,8 @@ #include -#include #include #include -TEST_F(AgradRev, MathMetaRevScal_primitive_to_var) { +TEST(MathMetaRevScal, primitive_to_var) { EXPECT_TRUE((stan::math::ad_promotable::value)); EXPECT_TRUE((stan::math::ad_promotable::value)); EXPECT_TRUE( @@ -26,7 +25,7 @@ TEST_F(AgradRev, MathMetaRevScal_primitive_to_var) { EXPECT_TRUE((stan::math::ad_promotable::value)); } -TEST_F(AgradRev, MathMetaRevScal_nonprimitive_to_var) { +TEST(MathMetaRevScal, nonprimitive_to_var) { EXPECT_FALSE( (stan::math::ad_promotable::value)); } diff --git a/test/unit/math/rev/meta/conditional_var_value_test.cpp b/test/unit/math/rev/meta/conditional_var_value_test.cpp index ee6791a600e..73c160f4390 100644 --- a/test/unit/math/rev/meta/conditional_var_value_test.cpp +++ b/test/unit/math/rev/meta/conditional_var_value_test.cpp @@ -1,23 +1,22 @@ #include #include -#include #include -TEST_F(AgradRev, MathMetaRev_conditional_var_value_scalar) { +TEST(MathMetaRev, conditional_var_value_scalar) { using stan::conditional_var_value_t; using stan::math::var; EXPECT_SAME_TYPE(double, conditional_var_value_t); EXPECT_SAME_TYPE(var, conditional_var_value_t); } -TEST_F(AgradRev, MathMetaRev_conditional_var_value_reference) { +TEST(MathMetaRev, conditional_var_value_reference) { using stan::conditional_var_value_t; EXPECT_SAME_TYPE(double, conditional_var_value_t); EXPECT_SAME_TYPE(double, conditional_var_value_t); EXPECT_SAME_TYPE(double, conditional_var_value_t); } -TEST_F(AgradRev, MathMetaRev_conditional_var_value_vector) { +TEST(MathMetaRev, conditional_var_value_vector) { using stan::conditional_var_value_t; using stan::math::var; using stan::math::var_value; @@ -27,7 +26,7 @@ TEST_F(AgradRev, MathMetaRev_conditional_var_value_vector) { conditional_var_value_t); } -TEST_F(AgradRev, MathMetaRev_conditional_var_value_row_vector) { +TEST(MathMetaRev, conditional_var_value_row_vector) { using stan::conditional_var_value_t; using stan::math::var; using stan::math::var_value; @@ -37,7 +36,7 @@ TEST_F(AgradRev, MathMetaRev_conditional_var_value_row_vector) { conditional_var_value_t); } -TEST_F(AgradRev, MathMetaRev_conditional_var_value_matrix) { +TEST(MathMetaRev, conditional_var_value_matrix) { using stan::conditional_var_value_t; using stan::math::var; using stan::math::var_value; @@ -49,7 +48,7 @@ TEST_F(AgradRev, MathMetaRev_conditional_var_value_matrix) { conditional_var_value_t>); } -TEST_F(AgradRev, MathMetaRev_conditional_var_value_expression) { +TEST(MathMetaRev, conditional_var_value_expression) { using stan::conditional_var_value_t; using stan::math::var; using stan::math::var_value; @@ -63,7 +62,7 @@ TEST_F(AgradRev, MathMetaRev_conditional_var_value_expression) { conditional_var_value_t); } -TEST_F(AgradRev, MathMetaRev_conditional_var_value_container_T_scalar) { +TEST(MathMetaRev, conditional_var_value_container_T_scalar) { using stan::conditional_var_value_t; using stan::math::var; using stan::math::var_value; diff --git a/test/unit/math/rev/meta/include_summand_test.cpp b/test/unit/math/rev/meta/include_summand_test.cpp index 6c2ecde818f..6f519c8de99 100644 --- a/test/unit/math/rev/meta/include_summand_test.cpp +++ b/test/unit/math/rev/meta/include_summand_test.cpp @@ -1,16 +1,15 @@ #include #include -#include #include using stan::math::include_summand; using stan::math::var; -TEST_F(AgradRev, MetaTraitsRevScal_IncludeSummandProptoTrueVar) { +TEST(MetaTraitsRevScal, IncludeSummandProptoTrueVar) { EXPECT_TRUE((include_summand::value)); } -TEST_F(AgradRev, MetaTraitsRevScal_IncludeSummandProtoTrueVarTen) { +TEST(MetaTraitsRevScal, IncludeSummandProtoTrueVarTen) { EXPECT_TRUE((include_summand::value)); } diff --git a/test/unit/math/rev/meta/is_arena_matrix_test.cpp b/test/unit/math/rev/meta/is_arena_matrix_test.cpp index b8d6b1bd4af..dfc63f3fff6 100644 --- a/test/unit/math/rev/meta/is_arena_matrix_test.cpp +++ b/test/unit/math/rev/meta/is_arena_matrix_test.cpp @@ -1,10 +1,8 @@ #include #include -#include -#include #include -TEST_F(AgradRev, MetaTraitsRevScal_is_arena_matrix_test) { +TEST(MetaTraitsRevScal, is_arena_matrix_test) { using stan::is_arena_matrix; using stan::math::arena_matrix; using stan::math::var; diff --git a/test/unit/math/rev/meta/is_constant_all_test.cpp b/test/unit/math/rev/meta/is_constant_all_test.cpp index 0c6e68df240..8c523c1bde5 100644 --- a/test/unit/math/rev/meta/is_constant_all_test.cpp +++ b/test/unit/math/rev/meta/is_constant_all_test.cpp @@ -1,16 +1,15 @@ #include -#include #include #include template -inline void expect_not_const() { +void expect_not_const() { using stan::is_constant_all; bool temp = is_constant_all::value; EXPECT_FALSE(temp); } -TEST_F(AgradRev, MetaTraitsRevScal_isConstantStruct) { +TEST(MetaTraitsRevScal, isConstantStruct) { expect_not_const(); expect_not_const(); expect_not_const(); @@ -19,7 +18,7 @@ TEST_F(AgradRev, MetaTraitsRevScal_isConstantStruct) { stan::math::var, stan::math::var, double, double>(); } -TEST_F(AgradRev, MetaTraitsRevArr_isConstantStruct) { +TEST(MetaTraitsRevArr, isConstantStruct) { using std::vector; expect_not_const >(); @@ -47,7 +46,7 @@ using var_v1 = Eigen::Matrix; using var_v2 = std::vector; using var_v3 = std::vector; -TEST_F(AgradRev, MetaTraitsRevMat_isConstantStruct) { +TEST(MetaTraitsRevMat, isConstantStruct) { using Eigen::Dynamic; using Eigen::Matrix; using std::vector; diff --git a/test/unit/math/rev/meta/is_fvar_test.cpp b/test/unit/math/rev/meta/is_fvar_test.cpp index 927e04d8a46..46e38837ca7 100644 --- a/test/unit/math/rev/meta/is_fvar_test.cpp +++ b/test/unit/math/rev/meta/is_fvar_test.cpp @@ -1,10 +1,8 @@ #include #include -#include -#include #include -TEST_F(AgradRev, MetaTraitsRevScal_is_fvar) { +TEST(MetaTraitsRevScal, is_fvar) { using stan::is_fvar; EXPECT_FALSE(is_fvar::value); } diff --git a/test/unit/math/rev/meta/is_rev_matrix_test.cpp b/test/unit/math/rev/meta/is_rev_matrix_test.cpp index 44ebf3ae8df..b7457c78c29 100644 --- a/test/unit/math/rev/meta/is_rev_matrix_test.cpp +++ b/test/unit/math/rev/meta/is_rev_matrix_test.cpp @@ -1,10 +1,8 @@ #include #include -#include -#include #include -TEST_F(AgradRev, MetaTraitsRevScal_is_rev_matrix_test) { +TEST(MetaTraitsRevScal, is_rev_matrix_test) { using stan::is_rev_matrix; using stan::math::var; using stan::math::var_value; @@ -21,7 +19,7 @@ TEST_F(AgradRev, MetaTraitsRevScal_is_rev_matrix_test) { EXPECT_FALSE((is_rev_matrix>>::value)); } -TEST_F(AgradRev, MetaTraitsRevScal_is_rev_col_vector_test) { +TEST(MetaTraitsRevScal, is_rev_col_vector_test) { using stan::is_rev_col_vector; using stan::math::var; using stan::math::var_value; @@ -52,7 +50,7 @@ TEST_F(AgradRev, MetaTraitsRevScal_is_rev_col_vector_test) { EXPECT_FALSE((is_rev_col_vector::value)); } -TEST_F(AgradRev, MetaTraitsRevScal_is_rev_row_vector_test) { +TEST(MetaTraitsRevScal, is_rev_row_vector_test) { using stan::is_rev_row_vector; using stan::math::var; using stan::math::var_value; @@ -83,7 +81,7 @@ TEST_F(AgradRev, MetaTraitsRevScal_is_rev_row_vector_test) { EXPECT_FALSE((is_rev_row_vector::value)); } -TEST_F(AgradRev, MetaTraitsRevScal_is_rev_vector_test) { +TEST(MetaTraitsRevScal, is_rev_vector_test) { using stan::is_rev_vector; using stan::math::var; using stan::math::var_value; diff --git a/test/unit/math/rev/meta/is_var_matrix_test.cpp b/test/unit/math/rev/meta/is_var_matrix_test.cpp index 97227016b7e..cd0f11b31d4 100644 --- a/test/unit/math/rev/meta/is_var_matrix_test.cpp +++ b/test/unit/math/rev/meta/is_var_matrix_test.cpp @@ -1,10 +1,8 @@ #include #include -#include -#include #include -TEST_F(AgradRev, MetaTraitsRevScal_is_var_matrix_test) { +TEST(MetaTraitsRevScal, is_var_matrix_test) { using stan::is_var_matrix; using stan::math::var; using stan::math::var_value; @@ -20,7 +18,7 @@ TEST_F(AgradRev, MetaTraitsRevScal_is_var_matrix_test) { EXPECT_FALSE((is_var_matrix::value)); } -TEST_F(AgradRev, MetaTraitsRevScal_is_var_col_vector_test) { +TEST(MetaTraitsRevScal, is_var_col_vector_test) { using stan::is_var_col_vector; using stan::math::var; using stan::math::var_value; @@ -49,7 +47,7 @@ TEST_F(AgradRev, MetaTraitsRevScal_is_var_col_vector_test) { EXPECT_FALSE((is_var_col_vector::value)); } -TEST_F(AgradRev, MetaTraitsRevScal_is_var_row_vector_test) { +TEST(MetaTraitsRevScal, is_var_row_vector_test) { using stan::is_var_row_vector; using stan::math::var; using stan::math::var_value; @@ -78,7 +76,7 @@ TEST_F(AgradRev, MetaTraitsRevScal_is_var_row_vector_test) { EXPECT_FALSE((is_var_row_vector::value)); } -TEST_F(AgradRev, MetaTraitsRevScal_is_var_vector_test) { +TEST(MetaTraitsRevScal, is_var_vector_test) { using stan::is_var_vector; using stan::math::var; using stan::math::var_value; diff --git a/test/unit/math/rev/meta/is_var_or_arithmetic_test.cpp b/test/unit/math/rev/meta/is_var_or_arithmetic_test.cpp index 0372c87cfda..4778049da7a 100644 --- a/test/unit/math/rev/meta/is_var_or_arithmetic_test.cpp +++ b/test/unit/math/rev/meta/is_var_or_arithmetic_test.cpp @@ -1,11 +1,10 @@ #include #include -#include #include #include #include -TEST_F(AgradRev, MathMetaRevScal_is_var_or_arithmetic_simple) { +TEST(MathMetaRevScal, is_var_or_arithmetic_simple) { using stan::is_var_or_arithmetic; EXPECT_TRUE(stan::is_var_or_arithmetic::value); EXPECT_TRUE(stan::is_var_or_arithmetic::value); diff --git a/test/unit/math/rev/meta/is_var_test.cpp b/test/unit/math/rev/meta/is_var_test.cpp index e71ad57c250..6c8148d2b2e 100644 --- a/test/unit/math/rev/meta/is_var_test.cpp +++ b/test/unit/math/rev/meta/is_var_test.cpp @@ -1,9 +1,8 @@ #include #include -#include #include -TEST_F(AgradRev, MetaTraitsRevScal_is_var) { +TEST(MetaTraitsRevScal, is_var) { using stan::is_var; using stan::math::var; using stan::math::var_value; @@ -15,7 +14,7 @@ TEST_F(AgradRev, MetaTraitsRevScal_is_var) { EXPECT_FALSE((is_var>::value)); } -TEST_F(AgradRev, MetaTraitsRevScal_is_any_var_scalar) { +TEST(MetaTraitsRevScal, is_any_var_scalar) { using stan::is_any_var_scalar; using stan::is_any_var_scalar_v; using stan::math::var; diff --git a/test/unit/math/rev/meta/is_vari_test.cpp b/test/unit/math/rev/meta/is_vari_test.cpp index 65fa38e4916..818d6c3b4d7 100644 --- a/test/unit/math/rev/meta/is_vari_test.cpp +++ b/test/unit/math/rev/meta/is_vari_test.cpp @@ -1,8 +1,7 @@ #include -#include #include -TEST_F(AgradRev, MetaTraitsRevScal_is_vari) { +TEST(MetaTraitsRevScal, is_vari) { using stan::is_vari; using stan::math::vari; using stan::math::vari_value; diff --git a/test/unit/math/rev/meta/is_vector_test.cpp b/test/unit/math/rev/meta/is_vector_test.cpp index 58ea3101b61..23a4280bc4e 100644 --- a/test/unit/math/rev/meta/is_vector_test.cpp +++ b/test/unit/math/rev/meta/is_vector_test.cpp @@ -1,9 +1,8 @@ #include #include -#include #include -TEST_F(AgradRev, MetaTraitsRevScal_is_col_vector_test) { +TEST(MetaTraitsRevScal, is_col_vector_test) { using stan::is_col_vector; using stan::math::var; using stan::math::var_value; @@ -26,7 +25,7 @@ TEST_F(AgradRev, MetaTraitsRevScal_is_col_vector_test) { EXPECT_FALSE((is_col_vector::value)); } -TEST_F(AgradRev, MetaTraitsRevScal_is_row_vector_test) { +TEST(MetaTraitsRevScal, is_row_vector_test) { using stan::is_row_vector; using stan::math::var; using stan::math::var_value; @@ -49,7 +48,7 @@ TEST_F(AgradRev, MetaTraitsRevScal_is_row_vector_test) { EXPECT_FALSE((is_row_vector::value)); } -TEST_F(AgradRev, MetaTraitsRevScal_is_vector_test) { +TEST(MetaTraitsRevScal, is_vector_test) { using stan::is_vector; using stan::math::var; using stan::math::var_value; diff --git a/test/unit/math/rev/meta/partials_return_type_test.cpp b/test/unit/math/rev/meta/partials_return_type_test.cpp index 8498459d4fe..cf083fbcc2b 100644 --- a/test/unit/math/rev/meta/partials_return_type_test.cpp +++ b/test/unit/math/rev/meta/partials_return_type_test.cpp @@ -1,23 +1,22 @@ #include #include -#include #include #include using stan::partials_return_type; using stan::math::var; -TEST_F(AgradRev, MetaTraitsRevScal_PartialsReturnTypeVar) { +TEST(MetaTraitsRevScal, PartialsReturnTypeVar) { EXPECT_SAME_TYPE(double, partials_return_type::type); } -TEST_F(AgradRev, MetaTraitsRevScal_PartialsReturnTypeVarTenParams) { +TEST(MetaTraitsRevScal, PartialsReturnTypeVarTenParams) { EXPECT_SAME_TYPE(double, partials_return_type::type); } -TEST_F(AgradRev, MetaTraitsRevArr_partials_return_type) { +TEST(MetaTraitsRevArr, partials_return_type) { using stan::partials_return_type; using stan::math::var; diff --git a/test/unit/math/rev/meta/partials_type_test.cpp b/test/unit/math/rev/meta/partials_type_test.cpp index 2bfefafc59c..d3187a0ec47 100644 --- a/test/unit/math/rev/meta/partials_type_test.cpp +++ b/test/unit/math/rev/meta/partials_type_test.cpp @@ -1,8 +1,7 @@ #include -#include #include -TEST_F(AgradRev, MetaTraitsRevScal_partials_type) { +TEST(MetaTraitsRevScal, partials_type) { using stan::partials_type; using stan::math::var; diff --git a/test/unit/math/rev/meta/promote_scalar_type_test.cpp b/test/unit/math/rev/meta/promote_scalar_type_test.cpp index 2d0dd8db213..372a238c6a9 100644 --- a/test/unit/math/rev/meta/promote_scalar_type_test.cpp +++ b/test/unit/math/rev/meta/promote_scalar_type_test.cpp @@ -1,9 +1,8 @@ #include -#include #include #include -TEST_F(AgradRev, MathFunctionsPromoteScalar_VarMatrix) { +TEST(MathFunctionsPromoteScalar, VarMatrix) { using stan::math::var; using stan::math::var_value; expect_promote_type, var, 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 4e42a27f663..2c94fbc3267 100644 --- a/test/unit/math/rev/meta/promote_var_matrix_test.cpp +++ b/test/unit/math/rev/meta/promote_var_matrix_test.cpp @@ -1,8 +1,7 @@ #include -#include #include -TEST_F(AgradRev, MathFunctions_PromoteVarMatrix) { +TEST(MathFunctions, PromoteVarMatrix) { using stan::promote_var_matrix_t; using stan::math::var; using stan::math::var_value; diff --git a/test/unit/math/rev/meta/require_generics_test.cpp b/test/unit/math/rev/meta/require_generics_test.cpp index b13140a0f67..f2f0e80d4ef 100644 --- a/test/unit/math/rev/meta/require_generics_test.cpp +++ b/test/unit/math/rev/meta/require_generics_test.cpp @@ -3,104 +3,103 @@ #include #include #include -#include #include #include #include #include -TEST_F(AgradRev, requires_rev_scal_var_test) { +TEST(requires_rev_scal, var_test) { using stan::math::var; using stan::test::require_scal_checker; require_scal_checker::unary(); } -TEST_F(AgradRev, requires_rev_scal_var_not_test) { +TEST(requires_rev_scal, var_not_test) { using stan::math::var; using stan::test::require_scal_checker; require_scal_checker::not_unary(); } -TEST_F(AgradRev, requires_rev_scal_var_all_test) { +TEST(requires_rev_scal, var_all_test) { using stan::math::var; using stan::test::require_scal_checker; require_scal_checker::all(); } -TEST_F(AgradRev, requires_rev_scal_var_all_not_test) { +TEST(requires_rev_scal, var_all_not_test) { using stan::math::var; using stan::test::require_scal_checker; require_scal_checker::all_not(); } -TEST_F(AgradRev, requires_rev_scal_var_any_test) { +TEST(requires_rev_scal, var_any_test) { using stan::math::var; using stan::test::require_scal_checker; require_scal_checker::any(); } -TEST_F(AgradRev, requires_rev_scal_var_any_not_test) { +TEST(requires_rev_scal, var_any_not_test) { using stan::math::var; using stan::test::require_scal_checker; require_scal_checker::any_not(); } -TEST_F(AgradRev, requires_rev_scal_autodiff_test) { +TEST(requires_rev_scal, autodiff_test) { using stan::math::var; using stan::test::require_scal_checker; require_scal_checker::unary(); } -TEST_F(AgradRev, requires_rev_scal_autodiff_not_test) { +TEST(requires_rev_scal, autodiff_not_test) { using stan::math::var; using stan::test::require_scal_checker; require_scal_checker::not_unary(); } -TEST_F(AgradRev, requires_rev_scal_autodiff_all_test) { +TEST(requires_rev_scal, autodiff_all_test) { using stan::math::var; using stan::test::require_scal_checker; require_scal_checker::all(); } -TEST_F(AgradRev, requires_rev_scal_autodiff_all_not_test) { +TEST(requires_rev_scal, autodiff_all_not_test) { using stan::math::var; using stan::test::require_scal_checker; require_scal_checker::all_not(); } -TEST_F(AgradRev, requires_rev_scal_autodiff_any_test) { +TEST(requires_rev_scal, autodiff_any_test) { using stan::math::var; using stan::test::require_scal_checker; require_scal_checker::any(); } -TEST_F(AgradRev, requires_rev_scal_autodiff_any_not_test) { +TEST(requires_rev_scal, autodiff_any_not_test) { using stan::math::var; using stan::test::require_scal_checker; require_scal_checker::any_not(); } -TEST_F(AgradRev, requires_rev_scal_stan_scalar_test) { +TEST(requires_rev_scal, stan_scalar_test) { using stan::math::var; using stan::test::require_scal_checker; require_scal_checker::unary(); } -TEST_F(AgradRev, requires_rev_scal_stan_scalar_not_test) { +TEST(requires_rev_scal, stan_scalar_not_test) { using stan::math::var; using stan::test::require_scal_checker; require_scal_checker::not_unary(); } -TEST_F(AgradRev, requires_rev_scal_stan_scalar_all_test) { +TEST(requires_rev_scal, stan_scalar_all_test) { using stan::math::var; using stan::test::require_scal_checker; require_scal_checker::all(); } -TEST_F(AgradRev, requires_rev_scal_stan_scalar_all_not_test) { +TEST(requires_rev_scal, stan_scalar_all_not_test) { using stan::math::var; using stan::test::require_scal_checker; require_scal_checker::all_not(); } -TEST_F(AgradRev, requires_rev_scal_stan_scalar_any_test) { +TEST(requires_rev_scal, stan_scalar_any_test) { using stan::math::var; using stan::test::require_scal_checker; require_scal_checker::any(); } -TEST_F(AgradRev, requires_rev_scal_stan_scalar_any_not_test) { +TEST(requires_rev_scal, stan_scalar_any_not_test) { using stan::math::var; using stan::test::require_scal_checker; require_scal_checker using require_test_not_arithmetic_return_t = stan::require_not_return_type_t; -TEST_F(AgradRev, requires_rev_scal_return_type_t_test) { +TEST(requires_rev_scal, return_type_t_test) { using stan::require_return_type_t; using stan::math::var; using stan::math::var_value; 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 a75eb22b7bf..a532c503302 100644 --- a/test/unit/math/rev/meta/return_var_matrix_test.cpp +++ b/test/unit/math/rev/meta/return_var_matrix_test.cpp @@ -1,9 +1,8 @@ #include -#include #include -TEST_F(AgradRev, MathFunctions_ReturnVarMatrix) { +TEST(MathFunctions, ReturnVarMatrix) { using stan::return_var_matrix_t; using stan::math::var; using stan::math::var_value; diff --git a/test/unit/math/rev/meta/rev_matrix_type_test.cpp b/test/unit/math/rev/meta/rev_matrix_type_test.cpp index 8fb88e1f34c..bddcd0eac26 100644 --- a/test/unit/math/rev/meta/rev_matrix_type_test.cpp +++ b/test/unit/math/rev/meta/rev_matrix_type_test.cpp @@ -2,10 +2,9 @@ #include #include #include -#include #include -TEST_F(AgradRev, MetaTraitsRev_rev_matrix_type_test) { +TEST(MetaTraitsRev, rev_matrix_type_test) { using v_matrix = stan::math::var_value; using v_vector = stan::math::var_value; using stan::math::matrix_d; 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 0137821e327..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 @@ -1,13 +1,13 @@ #include -#include #include +#include #include #include #include // We check that the values of the new regression match those of one built // from existing primitives. -TEST_F(AgradRev, bernoulli_glm_matches_bernoulli_logit_doubles) { +TEST(ProbDistributionsBernoulliLogitGLM, glm_matches_bernoulli_logit_doubles) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::var; @@ -31,7 +31,8 @@ TEST_F(AgradRev, bernoulli_glm_matches_bernoulli_logit_doubles) { // We check that the values of the new regression match those of one built // from existing primitives. -TEST_F(AgradRev, bernoulli_glm_matches_bernoulli_logit_doubles_rand) { +TEST(ProbDistributionsBernoulliLogitGLM, + glm_matches_bernoulli_logit_doubles_rand) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::var; diff --git a/test/unit/math/rev/prob/binomial_lpmf_test.cpp b/test/unit/math/rev/prob/binomial_lpmf_test.cpp index bf4c5593310..d6219f78801 100644 --- a/test/unit/math/rev/prob/binomial_lpmf_test.cpp +++ b/test/unit/math/rev/prob/binomial_lpmf_test.cpp @@ -1,8 +1,7 @@ #include -#include #include -TEST_F(AgradRev, ProbBinomial_N_equals_0) { +TEST(ProbBinomial, N_equals_0) { using stan::math::var; for (double theta_val : {0.0, 0.5, 1.0}) { var theta = theta_val; @@ -16,7 +15,7 @@ TEST_F(AgradRev, ProbBinomial_N_equals_0) { stan::math::recover_memory(); } -TEST_F(AgradRev, ProbBinomial_N_equals_1) { +TEST(ProbBinomial, N_equals_1) { using stan::math::var; for (double theta_val : {0.0, 0.5, 1.0}) { for (int n : {0, 1}) { @@ -47,7 +46,7 @@ TEST_F(AgradRev, ProbBinomial_N_equals_1) { } } -TEST_F(AgradRev, ProbBinomial_N_equals_2) { +TEST(ProbBinomial, N_equals_2) { using stan::math::var; for (double theta_val : {0.0, 0.5, 1.0}) { for (int n : {0, 1, 2}) { @@ -85,7 +84,7 @@ TEST_F(AgradRev, ProbBinomial_N_equals_2) { } } -TEST_F(AgradRev, ProbBinomial_n_equals_N) { +TEST(ProbBinomial, n_equals_N) { using stan::math::var; var theta = 1.0; @@ -97,7 +96,7 @@ TEST_F(AgradRev, ProbBinomial_n_equals_N) { stan::math::recover_memory(); } -TEST_F(AgradRev, ProbBinomial_n_equals_N_vec) { +TEST(ProbBinomial, n_equals_N_vec) { using stan::math::var; var theta = 1.0; std::vector n = {2, 3}; @@ -111,7 +110,7 @@ TEST_F(AgradRev, ProbBinomial_n_equals_N_vec) { stan::math::recover_memory(); } -TEST_F(AgradRev, ProbBinomial_n_equals_zero) { +TEST(ProbBinomial, n_equals_zero) { using stan::math::var; var theta = 0.0; @@ -123,7 +122,7 @@ TEST_F(AgradRev, ProbBinomial_n_equals_zero) { stan::math::recover_memory(); } -TEST_F(AgradRev, ProbBinomial_n_equals_0_vec) { +TEST(ProbBinomial, n_equals_0_vec) { using stan::math::var; var theta = 0.0; std::vector n = {0, 0}; @@ -137,7 +136,7 @@ TEST_F(AgradRev, ProbBinomial_n_equals_0_vec) { stan::math::recover_memory(); } -TEST_F(AgradRev, ProbBinomial_N_equals_0_vec) { +TEST(ProbBinomial, N_equals_0_vec) { using stan::math::var; var theta = 0.0; std::vector n = {0, 0}; diff --git a/test/unit/math/rev/prob/categorical2_test.cpp b/test/unit/math/rev/prob/categorical2_test.cpp index 6ed5cff763d..97b3344a84e 100644 --- a/test/unit/math/rev/prob/categorical2_test.cpp +++ b/test/unit/math/rev/prob/categorical2_test.cpp @@ -1,20 +1,19 @@ #include -#include #include #include #include template -inline void expect_propto_categorical_lpmf(unsigned int n1, T_prob theta1, - unsigned int n2, T_prob theta2, - std::string message) { +void expect_propto_categorical_lpmf(unsigned int n1, T_prob theta1, + unsigned int n2, T_prob theta2, + std::string message) { expect_eq_diffs(stan::math::categorical_lpmf(n1, theta1), stan::math::categorical_lpmf(n2, theta2), stan::math::categorical_lpmf(n1, theta1), stan::math::categorical_lpmf(n2, theta2), message); } -TEST_F(AgradRev, DistributionsCategorical_Propto) { +TEST(AgradDistributionsCategorical, Propto) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::var; 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 ac406b643fe..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 @@ -1,14 +1,14 @@ #include -#include #include +#include #include #include #include template -inline 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) { +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_return = stan::return_type_t; const size_t N_instances = x.rows(); @@ -651,7 +651,7 @@ TYPED_TEST(ProbDistributionsCategoricalLogitGLM, glm_interfaces) { categorical_logit_glm_lpmf(y_scal, x_var_row, alpha_var, beta_var)); } -TEST_F(AgradRev, ProbDistributionsCategoricalLogitGLM_glm_errors) { +TEST(ProbDistributionsCategoricalLogitGLM, glm_errors) { using Eigen::Dynamic; using Eigen::Matrix; using Eigen::MatrixXd; diff --git a/test/unit/math/rev/prob/dirichlet2_test.cpp b/test/unit/math/rev/prob/dirichlet2_test.cpp index 7c866349628..57f23995c63 100644 --- a/test/unit/math/rev/prob/dirichlet2_test.cpp +++ b/test/unit/math/rev/prob/dirichlet2_test.cpp @@ -1,15 +1,12 @@ #include -#include #include #include #include template -inline void expect_propto_dirichlet_lpdf(T_prob theta, - T_prior_sample_size alpha, - T_prob theta2, - T_prior_sample_size alpha2, - std::string message) { +void expect_propto_dirichlet_lpdf(T_prob theta, T_prior_sample_size alpha, + T_prob theta2, T_prior_sample_size alpha2, + std::string message) { expect_eq_diffs(stan::math::dirichlet_lpdf(theta, alpha), stan::math::dirichlet_lpdf(theta2, alpha2), stan::math::dirichlet_lpdf(theta, alpha), diff --git a/test/unit/math/rev/prob/expect_eq_diffs.hpp b/test/unit/math/rev/prob/expect_eq_diffs.hpp index 3abc4f98890..0dd9f507133 100644 --- a/test/unit/math/rev/prob/expect_eq_diffs.hpp +++ b/test/unit/math/rev/prob/expect_eq_diffs.hpp @@ -2,23 +2,20 @@ #define TEST_UNIT_MATH_REV_PROB_EXPECT_EQ_DIFFS_HPP #include -#include #include #include -inline void expect_eq_diffs(double x1, double x2, double y1, double y2, - std::string message = "") { +void expect_eq_diffs(double x1, double x2, double y1, double y2, + std::string message = "") { if (std::isnan(x1 - x2)) EXPECT_TRUE(std::isnan(y1 - y2)) << message; else EXPECT_FLOAT_EQ(x1 - x2, y1 - y2) << message; } -inline void expect_eq_diffs(const stan::math::var& x1, - const stan::math::var& x2, - const stan::math::var& y1, - const stan::math::var& y2, - std::string message = "") { +void expect_eq_diffs(const stan::math::var& x1, const stan::math::var& x2, + const stan::math::var& y1, const stan::math::var& y2, + std::string message = "") { expect_eq_diffs(x1.val(), x2.val(), y1.val(), y2.val(), message); } diff --git a/test/unit/math/rev/prob/gamma_lccdf_test.cpp b/test/unit/math/rev/prob/gamma_lccdf_test.cpp deleted file mode 100644 index 1066773e060..00000000000 --- a/test/unit/math/rev/prob/gamma_lccdf_test.cpp +++ /dev/null @@ -1,382 +0,0 @@ -#include -#include -#include -#include - -TEST(ProbDistributionsGamma, lccdf_values) { - using stan::math::gamma_lccdf; - using stan::math::var; - - double y_d = 0.8; - double alpha_d = 1.1; - double beta_d = 2.3; - - var y_v = y_d; - var alpha_v = alpha_d; - var beta_v = beta_d; - - var lccdf_var = gamma_lccdf(y_v, alpha_v, beta_v); - - EXPECT_NO_THROW(lccdf_var.val()); - EXPECT_FALSE(std::isnan(lccdf_var.val())); - EXPECT_LE(lccdf_var.val(), 0.0); -} - -TEST(ProbDistributionsGamma, lccdf_derivatives_y) { - using stan::math::gamma_lccdf; - using stan::math::var; - - // Test derivative with respect to y - double y_d = 2.5; - double alpha_d = 3.0; - double beta_d = 1.5; - - var y_v = y_d; - var alpha_v = alpha_d; - var beta_v = beta_d; - - var lccdf_var = gamma_lccdf(y_v, alpha_v, beta_v); - - std::vector vars = {y_v}; - std::vector grads; - lccdf_var.grad(vars, grads); - - // Derivative should be negative (LCCDF decreases as y increases) - EXPECT_LT(grads[0], 0.0); - EXPECT_FALSE(std::isnan(grads[0])); - EXPECT_TRUE(std::isfinite(grads[0])); -} - -TEST(ProbDistributionsGamma, lccdf_derivatives_alpha) { - using stan::math::gamma_lccdf; - using stan::math::var; - - // Test derivative with respect to alpha - double y_d = 2.5; - double alpha_d = 3.0; - double beta_d = 1.5; - - var y_v = y_d; - var alpha_v = alpha_d; - var beta_v = beta_d; - - var lccdf_var = gamma_lccdf(y_v, alpha_v, beta_v); - - std::vector vars = {alpha_v}; - std::vector grads; - lccdf_var.grad(vars, grads); - - EXPECT_FALSE(std::isnan(grads[0])); - EXPECT_TRUE(std::isfinite(grads[0])); -} - -TEST(ProbDistributionsGamma, lccdf_derivatives_beta) { - using stan::math::gamma_lccdf; - using stan::math::var; - - // Test derivative with respect to beta - double y_d = 2.5; - double alpha_d = 3.0; - double beta_d = 1.5; - - var y_v = y_d; - var alpha_v = alpha_d; - var beta_v = beta_d; - - var lccdf_var = gamma_lccdf(y_v, alpha_v, beta_v); - - std::vector vars = {beta_v}; - std::vector grads; - lccdf_var.grad(vars, grads); - - EXPECT_FALSE(std::isnan(grads[0])); - EXPECT_TRUE(std::isfinite(grads[0])); -} - -TEST(ProbDistributionsGamma, lccdf_derivatives_all_params) { - using stan::math::gamma_lccdf; - using stan::math::var; - - // Test all derivatives together - double y_d = 2.5; - double alpha_d = 3.0; - double beta_d = 1.5; - - var y_v = y_d; - var alpha_v = alpha_d; - var beta_v = beta_d; - - var lccdf_var = gamma_lccdf(y_v, alpha_v, beta_v); - - std::vector vars = {y_v, alpha_v, beta_v}; - std::vector grads; - lccdf_var.grad(vars, grads); - - // Check all gradients are finite and not NaN - for (size_t i = 0; i < grads.size(); ++i) { - EXPECT_FALSE(std::isnan(grads[i])) << "Gradient " << i << " is NaN"; - EXPECT_TRUE(std::isfinite(grads[i])) - << "Gradient " << i << " is not finite"; - } - - // d/dy should be negative - EXPECT_LT(grads[0], 0.0) << "d/dy should be negative"; -} - -TEST(ProbDistributionsGamma, lccdf_finite_diff_y) { - using stan::math::gamma_lccdf; - using stan::math::var; - - // Test derivative w.r.t. y using finite differences - double y_d = 1.5; - double alpha_d = 2.0; - double beta_d = 3.0; - double eps = 1e-6; - - // Compute gradient using autodiff - var y_v = y_d; - var lccdf_var = gamma_lccdf(y_v, alpha_d, beta_d); - std::vector vars = {y_v}; - std::vector grads; - lccdf_var.grad(vars, grads); - double grad_autodiff = grads[0]; - - // Compute gradient using finite differences - double f_plus = stan::math::gamma_lccdf(y_d + eps, alpha_d, beta_d); - double f_minus = stan::math::gamma_lccdf(y_d - eps, alpha_d, beta_d); - double grad_findiff = (f_plus - f_minus) / (2.0 * eps); - - EXPECT_NEAR(grad_autodiff, grad_findiff, 1e-5); -} - -TEST(ProbDistributionsGamma, lccdf_finite_diff_alpha) { - using stan::math::gamma_lccdf; - using stan::math::var; - - // Test derivative w.r.t. alpha using finite differences - double y_d = 1.5; - double alpha_d = 2.0; - double beta_d = 3.0; - double eps = 1e-6; - - // Compute gradient using autodiff - var alpha_v = alpha_d; - var lccdf_var = gamma_lccdf(y_d, alpha_v, beta_d); - std::vector vars = {alpha_v}; - std::vector grads; - lccdf_var.grad(vars, grads); - double grad_autodiff = grads[0]; - - // Compute gradient using finite differences - double f_plus = stan::math::gamma_lccdf(y_d, alpha_d + eps, beta_d); - double f_minus = stan::math::gamma_lccdf(y_d, alpha_d - eps, beta_d); - double grad_findiff = (f_plus - f_minus) / (2.0 * eps); - - // Alpha derivative is more numerically sensitive, use larger tolerance - EXPECT_NEAR(grad_autodiff, grad_findiff, 1e-3); -} - -TEST(ProbDistributionsGamma, lccdf_finite_diff_beta) { - using stan::math::gamma_lccdf; - using stan::math::var; - - // Test derivative w.r.t. beta using finite differences - double y_d = 1.5; - double alpha_d = 2.0; - double beta_d = 3.0; - double eps = 1e-6; - - // Compute gradient using autodiff - var beta_v = beta_d; - var lccdf_var = gamma_lccdf(y_d, alpha_d, beta_v); - std::vector vars = {beta_v}; - std::vector grads; - lccdf_var.grad(vars, grads); - double grad_autodiff = grads[0]; - - // Compute gradient using finite differences - double f_plus = stan::math::gamma_lccdf(y_d, alpha_d, beta_d + eps); - double f_minus = stan::math::gamma_lccdf(y_d, alpha_d, beta_d - eps); - double grad_findiff = (f_plus - f_minus) / (2.0 * eps); - - EXPECT_NEAR(grad_autodiff, grad_findiff, 1e-5); -} - -TEST(ProbDistributionsGamma, lccdf_extreme_values_small) { - using stan::math::gamma_lccdf; - using stan::math::var; - - // Test with very small values - double y_d = 0.001; - double alpha_d = 0.1; - double beta_d = 1.0; - - var y_v = y_d; - var alpha_v = alpha_d; - var beta_v = beta_d; - - var lccdf_var = gamma_lccdf(y_v, alpha_v, beta_v); - - std::vector vars = {y_v, alpha_v, beta_v}; - std::vector grads; - lccdf_var.grad(vars, grads); - - // All gradients should be finite - for (size_t i = 0; i < grads.size(); ++i) { - EXPECT_TRUE(std::isfinite(grads[i])) - << "Gradient " << i << " not finite for small values"; - EXPECT_FALSE(std::isnan(grads[i])) - << "Gradient " << i << " is NaN for small values"; - } -} - -TEST(ProbDistributionsGamma, lccdf_extreme_values_large) { - using stan::math::gamma_lccdf; - using stan::math::var; - - // Test with large values - double y_d = 100.0; - double alpha_d = 50.0; - double beta_d = 0.5; - - var y_v = y_d; - var alpha_v = alpha_d; - var beta_v = beta_d; - - var lccdf_var = gamma_lccdf(y_v, alpha_v, beta_v); - - std::vector vars = {y_v, alpha_v, beta_v}; - std::vector grads; - lccdf_var.grad(vars, grads); - - // All gradients should be finite - for (size_t i = 0; i < grads.size(); ++i) { - EXPECT_TRUE(std::isfinite(grads[i])) - << "Gradient " << i << " not finite for large values"; - EXPECT_FALSE(std::isnan(grads[i])) - << "Gradient " << i << " is NaN for large values"; - } -} - -TEST(ProbDistributionsGamma, lccdf_alpha_one_derivatives) { - using stan::math::gamma_lccdf; - using stan::math::var; - - // When alpha = 1, gamma is exponential - // LCCDF(y) = -beta * y - // d/dy = -beta - // d/dbeta = -y - double y_d = 2.0; - double alpha_d = 1.0; - double beta_d = 3.0; - - var y_v = y_d; - var alpha_v = alpha_d; - var beta_v = beta_d; - - var lccdf_var = gamma_lccdf(y_v, alpha_v, beta_v); - - std::vector vars = {y_v, alpha_v, beta_v}; - std::vector grads; - lccdf_var.grad(vars, grads); - - // For exponential: d/dy LCCDF = d/dy (-beta*y) = -beta - EXPECT_NEAR(grads[0], -beta_d, 1e-10); - - // d/dbeta LCCDF = d/dbeta (-beta*y) = -y - EXPECT_NEAR(grads[2], -y_d, 1e-10); -} - -TEST(ProbDistributionsGamma, lccdf_various_parameter_combinations) { - using stan::math::gamma_lccdf; - using stan::math::var; - - std::vector> test_cases = { - {0.5, 0.5, 1.0}, {1.0, 1.0, 1.0}, {2.0, 3.0, 0.5}, - {10.0, 2.0, 0.1}, {0.1, 10.0, 2.0}, {5.0, 5.0, 1.0}, - }; - - for (const auto& test_case : test_cases) { - double y_d = std::get<0>(test_case); - double alpha_d = std::get<1>(test_case); - double beta_d = std::get<2>(test_case); - - var y_v = y_d; - var alpha_v = alpha_d; - var beta_v = beta_d; - - var lccdf_var = gamma_lccdf(y_v, alpha_v, beta_v); - - std::vector vars = {y_v, alpha_v, beta_v}; - std::vector grads; - lccdf_var.grad(vars, grads); - - // All gradients should be finite - for (size_t i = 0; i < grads.size(); ++i) { - EXPECT_FALSE(std::isnan(grads[i])) - << "NaN gradient for y=" << y_d << ", alpha=" << alpha_d - << ", beta=" << beta_d; - EXPECT_TRUE(std::isfinite(grads[i])) - << "Non-finite gradient for y=" << y_d << ", alpha=" << alpha_d - << ", beta=" << beta_d; - } - } -} - -TEST(ProbDistributionsGamma, lccdf_second_derivative_y) { - using stan::math::gamma_lccdf; - using stan::math::var; - - // Test that second derivatives work (for models using Hessians) - double y_d = 2.0; - double alpha_d = 3.0; - double beta_d = 1.5; - - var y_v = y_d; - - var lccdf_var = gamma_lccdf(y_v, alpha_d, beta_d); - - std::vector vars = {y_v}; - std::vector grads; - lccdf_var.grad(vars, grads); - - // If we can compute gradients without error, second derivatives should work - EXPECT_FALSE(std::isnan(grads[0])); - EXPECT_TRUE(std::isfinite(grads[0])); -} - -TEST(ProbDistributionsGamma, lccdf_numerically_challenging_derivatives) { - using stan::math::gamma_lccdf; - using stan::math::var; - - // Test numerically challenging cases - std::vector> challenging_cases = { - {1e-6, 1e-5, 1.0}, // Very small y and alpha - {0.001, 100.0, 0.01}, // Small y, large alpha, small beta - {1000.0, 0.5, 1e-3}, // Large y, small alpha, very small beta - {50.0, 50.0, 1.0}, // Matched moderate values - }; - - for (const auto& test_case : challenging_cases) { - double y_d = std::get<0>(test_case); - double alpha_d = std::get<1>(test_case); - double beta_d = std::get<2>(test_case); - - var y_v = y_d; - var alpha_v = alpha_d; - var beta_v = beta_d; - - var lccdf_var = gamma_lccdf(y_v, alpha_v, beta_v); - - std::vector vars = {y_v, alpha_v, beta_v}; - std::vector grads; - lccdf_var.grad(vars, grads); - - // Gradients should not be NaN - for (size_t i = 0; i < grads.size(); ++i) { - EXPECT_FALSE(std::isnan(grads[i])) - << "NaN gradient " << i << " for y=" << y_d << ", alpha=" << alpha_d - << ", beta=" << beta_d; - } - } -} diff --git a/test/unit/math/rev/prob/gamma_lcdf_test.cpp b/test/unit/math/rev/prob/gamma_lcdf_test.cpp deleted file mode 100644 index 218ef77a423..00000000000 --- a/test/unit/math/rev/prob/gamma_lcdf_test.cpp +++ /dev/null @@ -1,440 +0,0 @@ -#include -#include -#include -#include - -TEST(ProbDistributionsGamma, lcdf_values) { - using stan::math::gamma_lcdf; - using stan::math::var; - - double y_d = 0.8; - double alpha_d = 1.1; - double beta_d = 2.3; - - var y_v = y_d; - var alpha_v = alpha_d; - var beta_v = beta_d; - - var lcdf_var = gamma_lcdf(y_v, alpha_v, beta_v); - - EXPECT_NO_THROW(lcdf_var.val()); - EXPECT_FALSE(std::isnan(lcdf_var.val())); - EXPECT_LE(lcdf_var.val(), 0.0); // log of probability -} - -TEST(ProbDistributionsGamma, lcdf_derivatives_y) { - using stan::math::gamma_lcdf; - using stan::math::var; - - // Test derivative with respect to y - double y_d = 2.5; - double alpha_d = 3.0; - double beta_d = 1.5; - - var y_v = y_d; - var alpha_v = alpha_d; - var beta_v = beta_d; - - var lcdf_var = gamma_lcdf(y_v, alpha_v, beta_v); - - std::vector vars = {y_v}; - std::vector grads; - lcdf_var.grad(vars, grads); - - // Derivative should be positive (LCDF increases as y increases) - EXPECT_GT(grads[0], 0.0); - EXPECT_FALSE(std::isnan(grads[0])); - EXPECT_TRUE(std::isfinite(grads[0])); -} - -TEST(ProbDistributionsGamma, lcdf_derivatives_alpha) { - using stan::math::gamma_lcdf; - using stan::math::var; - - // Test derivative with respect to alpha - double y_d = 2.5; - double alpha_d = 3.0; - double beta_d = 1.5; - - var y_v = y_d; - var alpha_v = alpha_d; - var beta_v = beta_d; - - var lcdf_var = gamma_lcdf(y_v, alpha_v, beta_v); - - std::vector vars = {alpha_v}; - std::vector grads; - lcdf_var.grad(vars, grads); - - EXPECT_FALSE(std::isnan(grads[0])); - EXPECT_TRUE(std::isfinite(grads[0])); -} - -TEST(ProbDistributionsGamma, lcdf_derivatives_beta) { - using stan::math::gamma_lcdf; - using stan::math::var; - - // Test derivative with respect to beta - double y_d = 2.5; - double alpha_d = 3.0; - double beta_d = 1.5; - - var y_v = y_d; - var alpha_v = alpha_d; - var beta_v = beta_d; - - var lcdf_var = gamma_lcdf(y_v, alpha_v, beta_v); - - std::vector vars = {beta_v}; - std::vector grads; - lcdf_var.grad(vars, grads); - - EXPECT_FALSE(std::isnan(grads[0])); - EXPECT_TRUE(std::isfinite(grads[0])); -} - -TEST(ProbDistributionsGamma, lcdf_derivatives_all_params) { - using stan::math::gamma_lcdf; - using stan::math::var; - - // Test all derivatives together - double y_d = 2.5; - double alpha_d = 3.0; - double beta_d = 1.5; - - var y_v = y_d; - var alpha_v = alpha_d; - var beta_v = beta_d; - - var lcdf_var = gamma_lcdf(y_v, alpha_v, beta_v); - - std::vector vars = {y_v, alpha_v, beta_v}; - std::vector grads; - lcdf_var.grad(vars, grads); - - // Check all gradients are finite and not NaN - for (size_t i = 0; i < grads.size(); ++i) { - EXPECT_FALSE(std::isnan(grads[i])) << "Gradient " << i << " is NaN"; - EXPECT_TRUE(std::isfinite(grads[i])) - << "Gradient " << i << " is not finite"; - } - - // d/dy should be positive - EXPECT_GT(grads[0], 0.0) << "d/dy should be positive"; -} - -TEST(ProbDistributionsGamma, lcdf_finite_diff_y) { - using stan::math::gamma_lcdf; - using stan::math::var; - - // Test derivative w.r.t. y using finite differences - double y_d = 1.5; - double alpha_d = 2.0; - double beta_d = 3.0; - double eps = 1e-6; - - // Compute gradient using autodiff - var y_v = y_d; - var lcdf_var = gamma_lcdf(y_v, alpha_d, beta_d); - std::vector vars = {y_v}; - std::vector grads; - lcdf_var.grad(vars, grads); - double grad_autodiff = grads[0]; - - // Compute gradient using finite differences - double f_plus = stan::math::gamma_lcdf(y_d + eps, alpha_d, beta_d); - double f_minus = stan::math::gamma_lcdf(y_d - eps, alpha_d, beta_d); - double grad_findiff = (f_plus - f_minus) / (2.0 * eps); - - EXPECT_NEAR(grad_autodiff, grad_findiff, 1e-5); -} - -TEST(ProbDistributionsGamma, lcdf_finite_diff_alpha) { - using stan::math::gamma_lcdf; - using stan::math::var; - - // Test derivative w.r.t. alpha using finite differences - double y_d = 1.5; - double alpha_d = 2.0; - double beta_d = 3.0; - double eps = 1e-6; - - // Compute gradient using autodiff - var alpha_v = alpha_d; - var lcdf_var = gamma_lcdf(y_d, alpha_v, beta_d); - std::vector vars = {alpha_v}; - std::vector grads; - lcdf_var.grad(vars, grads); - double grad_autodiff = grads[0]; - - // Compute gradient using finite differences - double f_plus = stan::math::gamma_lcdf(y_d, alpha_d + eps, beta_d); - double f_minus = stan::math::gamma_lcdf(y_d, alpha_d - eps, beta_d); - double grad_findiff = (f_plus - f_minus) / (2.0 * eps); - - // Alpha derivative is numerically sensitive, use larger tolerance - EXPECT_NEAR(grad_autodiff, grad_findiff, 1e-3); -} - -TEST(ProbDistributionsGamma, lcdf_finite_diff_beta) { - using stan::math::gamma_lcdf; - using stan::math::var; - - // Test derivative w.r.t. beta using finite differences - double y_d = 1.5; - double alpha_d = 2.0; - double beta_d = 3.0; - double eps = 1e-6; - - // Compute gradient using autodiff - var beta_v = beta_d; - var lcdf_var = gamma_lcdf(y_d, alpha_d, beta_v); - std::vector vars = {beta_v}; - std::vector grads; - lcdf_var.grad(vars, grads); - double grad_autodiff = grads[0]; - - // Compute gradient using finite differences - double f_plus = stan::math::gamma_lcdf(y_d, alpha_d, beta_d + eps); - double f_minus = stan::math::gamma_lcdf(y_d, alpha_d, beta_d - eps); - double grad_findiff = (f_plus - f_minus) / (2.0 * eps); - - EXPECT_NEAR(grad_autodiff, grad_findiff, 1e-5); -} - -TEST(ProbDistributionsGamma, lcdf_extreme_values_small) { - using stan::math::gamma_lcdf; - using stan::math::var; - - // Test with very small values - double y_d = 0.001; - double alpha_d = 0.1; - double beta_d = 1.0; - - var y_v = y_d; - var alpha_v = alpha_d; - var beta_v = beta_d; - - var lcdf_var = gamma_lcdf(y_v, alpha_v, beta_v); - - std::vector vars = {y_v, alpha_v, beta_v}; - std::vector grads; - lcdf_var.grad(vars, grads); - - // All gradients should be finite - for (size_t i = 0; i < grads.size(); ++i) { - EXPECT_TRUE(std::isfinite(grads[i])) - << "Gradient " << i << " not finite for small values"; - EXPECT_FALSE(std::isnan(grads[i])) - << "Gradient " << i << " is NaN for small values"; - } -} - -TEST(ProbDistributionsGamma, lcdf_extreme_values_large) { - using stan::math::gamma_lcdf; - using stan::math::var; - - // Test with large values - double y_d = 100.0; - double alpha_d = 50.0; - double beta_d = 0.5; - - var y_v = y_d; - var alpha_v = alpha_d; - var beta_v = beta_d; - - var lcdf_var = gamma_lcdf(y_v, alpha_v, beta_v); - - std::vector vars = {y_v, alpha_v, beta_v}; - std::vector grads; - lcdf_var.grad(vars, grads); - - // All gradients should be finite - for (size_t i = 0; i < grads.size(); ++i) { - EXPECT_TRUE(std::isfinite(grads[i])) - << "Gradient " << i << " not finite for large values"; - EXPECT_FALSE(std::isnan(grads[i])) - << "Gradient " << i << " is NaN for large values"; - } -} - -TEST(ProbDistributionsGamma, lcdf_alpha_one_derivatives) { - using stan::math::gamma_lcdf; - using stan::math::var; - - // When alpha = 1, gamma is exponential - // CDF(y) = 1 - exp(-beta*y) - // LCDF(y) = log(1 - exp(-beta*y)) - // d/dy LCDF = beta * exp(-beta*y) / (1 - exp(-beta*y)) - double y_d = 2.0; - double alpha_d = 1.0; - double beta_d = 3.0; - - var y_v = y_d; - var alpha_v = alpha_d; - var beta_v = beta_d; - - var lcdf_var = gamma_lcdf(y_v, alpha_v, beta_v); - - std::vector vars = {y_v, alpha_v, beta_v}; - std::vector grads; - lcdf_var.grad(vars, grads); - - // For exponential: d/dy LCDF = beta*exp(-beta*y) / (1-exp(-beta*y)) - double exp_neg_beta_y = std::exp(-beta_d * y_d); - double expected_dy = beta_d * exp_neg_beta_y / (1.0 - exp_neg_beta_y); - EXPECT_NEAR(grads[0], expected_dy, 1e-10); -} - -TEST(ProbDistributionsGamma, lcdf_various_parameter_combinations) { - using stan::math::gamma_lcdf; - using stan::math::var; - - std::vector> test_cases = { - {0.5, 0.5, 1.0}, {1.0, 1.0, 1.0}, {2.0, 3.0, 0.5}, - {10.0, 2.0, 0.1}, {0.1, 10.0, 2.0}, {5.0, 5.0, 1.0}, - }; - - for (const auto& test_case : test_cases) { - double y_d = std::get<0>(test_case); - double alpha_d = std::get<1>(test_case); - double beta_d = std::get<2>(test_case); - - var y_v = y_d; - var alpha_v = alpha_d; - var beta_v = beta_d; - - var lcdf_var = gamma_lcdf(y_v, alpha_v, beta_v); - - std::vector vars = {y_v, alpha_v, beta_v}; - std::vector grads; - lcdf_var.grad(vars, grads); - - // All gradients should be finite - for (size_t i = 0; i < grads.size(); ++i) { - EXPECT_FALSE(std::isnan(grads[i])) - << "NaN gradient for y=" << y_d << ", alpha=" << alpha_d - << ", beta=" << beta_d; - EXPECT_TRUE(std::isfinite(grads[i])) - << "Non-finite gradient for y=" << y_d << ", alpha=" << alpha_d - << ", beta=" << beta_d; - } - } -} - -TEST(ProbDistributionsGamma, lcdf_consistency_with_lccdf) { - using stan::math::gamma_lccdf; - using stan::math::gamma_lcdf; - using stan::math::var; - - // Test that lcdf and lccdf derivatives are related - // lcdf(y) + lccdf(y) should be related through log1p_exp - double y_d = 1.5; - double alpha_d = 2.0; - double beta_d = 1.5; - - // Test LCDF derivatives - var y_v1 = y_d; - var alpha_v1 = alpha_d; - var beta_v1 = beta_d; - var lcdf_var = gamma_lcdf(y_v1, alpha_v1, beta_v1); - std::vector vars1 = {y_v1, alpha_v1, beta_v1}; - std::vector grads_lcdf; - lcdf_var.grad(vars1, grads_lcdf); - - // Test LCCDF derivatives - var y_v2 = y_d; - var alpha_v2 = alpha_d; - var beta_v2 = beta_d; - var lccdf_var = gamma_lccdf(y_v2, alpha_v2, beta_v2); - std::vector vars2 = {y_v2, alpha_v2, beta_v2}; - std::vector grads_lccdf; - lccdf_var.grad(vars2, grads_lccdf); - - // The derivatives should have opposite signs for y - // d/dy lcdf > 0, d/dy lccdf < 0 - EXPECT_GT(grads_lcdf[0], 0.0); - EXPECT_LT(grads_lccdf[0], 0.0); -} - -TEST(ProbDistributionsGamma, lcdf_second_derivative_y) { - using stan::math::gamma_lcdf; - using stan::math::var; - - // Test that second derivatives work (for models using Hessians) - double y_d = 2.0; - double alpha_d = 3.0; - double beta_d = 1.5; - - var y_v = y_d; - - var lcdf_var = gamma_lcdf(y_v, alpha_d, beta_d); - - std::vector vars = {y_v}; - std::vector grads; - lcdf_var.grad(vars, grads); - - // If we can compute gradients without error, second derivatives should work - EXPECT_FALSE(std::isnan(grads[0])); - EXPECT_TRUE(std::isfinite(grads[0])); -} - -TEST(ProbDistributionsGamma, lcdf_numerically_challenging_derivatives) { - using stan::math::gamma_lcdf; - using stan::math::var; - - // Test numerically challenging cases - std::vector> challenging_cases = { - {1e-6, 1e-5, 1.0}, // Very small y and alpha - // {0.001, 100.0, 0.01}, // This case causes NaN - numerically too - // challenging - {1000.0, 0.5, 1e-3}, // Large y, small alpha, very small beta - {50.0, 50.0, 1.0}, // Matched moderate values - }; - - for (const auto& test_case : challenging_cases) { - double y_d = std::get<0>(test_case); - double alpha_d = std::get<1>(test_case); - double beta_d = std::get<2>(test_case); - - var y_v = y_d; - var alpha_v = alpha_d; - var beta_v = beta_d; - - var lcdf_var = gamma_lcdf(y_v, alpha_v, beta_v); - - std::vector vars = {y_v, alpha_v, beta_v}; - std::vector grads; - lcdf_var.grad(vars, grads); - - // Gradients should not be NaN - for (size_t i = 0; i < grads.size(); ++i) { - EXPECT_FALSE(std::isnan(grads[i])) - << "NaN gradient " << i << " for y=" << y_d << ", alpha=" << alpha_d - << ", beta=" << beta_d; - } - } -} - -TEST(ProbDistributionsGamma, lcdf_monotonic_derivative) { - using stan::math::gamma_lcdf; - using stan::math::var; - - // The derivative d/dy should always be positive - // (CDF is monotonically increasing in y) - double alpha_d = 2.0; - double beta_d = 1.5; - - std::vector y_values = {0.5, 1.0, 2.0, 5.0, 10.0}; - - for (double y_d : y_values) { - var y_v = y_d; - var lcdf_var = gamma_lcdf(y_v, alpha_d, beta_d); - - std::vector vars = {y_v}; - std::vector grads; - lcdf_var.grad(vars, grads); - - EXPECT_GT(grads[0], 0.0) << "d/dy should be positive for y=" << y_d; - } -} diff --git a/test/unit/math/rev/prob/inv_gamma_test.cpp b/test/unit/math/rev/prob/inv_gamma_test.cpp index ec7d3cb27ce..bb729ec0597 100644 --- a/test/unit/math/rev/prob/inv_gamma_test.cpp +++ b/test/unit/math/rev/prob/inv_gamma_test.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include @@ -418,7 +417,7 @@ std::vector testValues = { } // namespace inv_gamma_test_internal -TEST_F(AgradRev, ProbDistributionsInvGamma_derivativesPrecomputed) { +TEST(ProbDistributionsInvGamma, derivativesPrecomputed) { using inv_gamma_test_internal::TestValue; using inv_gamma_test_internal::testValues; using stan::math::inv_gamma_lpdf; diff --git a/test/unit/math/rev/prob/inv_wishart2_test.cpp b/test/unit/math/rev/prob/inv_wishart2_test.cpp index adf08386b70..cc70da88423 100644 --- a/test/unit/math/rev/prob/inv_wishart2_test.cpp +++ b/test/unit/math/rev/prob/inv_wishart2_test.cpp @@ -5,9 +5,9 @@ #include template -inline void expect_propto_inv_wishart_lpdf(T_y W1, T_dof nu1, T_scale S1, - T_y W2, T_dof nu2, T_scale S2, - std::string message) { +void expect_propto_inv_wishart_lpdf(T_y W1, T_dof nu1, T_scale S1, T_y W2, + T_dof nu2, T_scale S2, + std::string message) { expect_eq_diffs(stan::math::inv_wishart_lpdf(W1, nu1, S1), stan::math::inv_wishart_lpdf(W2, nu2, S2), stan::math::inv_wishart_lpdf(W1, nu1, S1), @@ -78,7 +78,7 @@ TEST_F(AgradDistributionsInvWishart, ProptoSigma) { "var: sigma"); } -TEST_F(AgradRev, InvWishart_check_varis_on_stack) { +TEST(InvWishart, check_varis_on_stack) { using stan::math::to_var; Eigen::MatrixXd W(2, 2); W << 2.011108, -11.20661, -11.20661, 112.94139; diff --git a/test/unit/math/rev/prob/inv_wishart_cholesky_test.cpp b/test/unit/math/rev/prob/inv_wishart_cholesky_test.cpp index 2e12f30da32..8eab1bf18b0 100644 --- a/test/unit/math/rev/prob/inv_wishart_cholesky_test.cpp +++ b/test/unit/math/rev/prob/inv_wishart_cholesky_test.cpp @@ -5,10 +5,9 @@ #include template -inline void expect_propto_inv_wishart_cholesky_lpdf(T_y L_Y1, T_dof nu1, - T_scale L_S1, T_y L_Y2, - T_dof nu2, T_scale L_S2, - std::string message) { +void expect_propto_inv_wishart_cholesky_lpdf(T_y L_Y1, T_dof nu1, T_scale L_S1, + T_y L_Y2, T_dof nu2, T_scale L_S2, + std::string message) { expect_eq_diffs(stan::math::inv_wishart_cholesky_lpdf(L_Y1, nu1, L_S1), stan::math::inv_wishart_cholesky_lpdf(L_Y2, nu2, L_S2), stan::math::inv_wishart_cholesky_lpdf(L_Y1, nu1, L_S1), @@ -103,7 +102,7 @@ TEST_F(AgradDistributionsInvWishartCholesky, ProptoL_S) { stan::math::recover_memory(); } -TEST_F(AgradRev, InvWishartCholesky_check_varis_on_stack) { +TEST(InvWishartCholesky, check_varis_on_stack) { using stan::math::to_var; Eigen::MatrixXd Y(2, 2); Y << 2.011108, -11.20661, -11.20661, 112.94139; diff --git a/test/unit/math/rev/prob/lkj_corr_cholesky_test_functors.hpp b/test/unit/math/rev/prob/lkj_corr_cholesky_test_functors.hpp index 3a4de3c204f..e3871ef7c43 100644 --- a/test/unit/math/rev/prob/lkj_corr_cholesky_test_functors.hpp +++ b/test/unit/math/rev/prob/lkj_corr_cholesky_test_functors.hpp @@ -1,7 +1,6 @@ #ifndef TEST_UNIT_MATH_REV_PROB_LKJ_CORR_CHOLESKY_TEST_FUNCTORS #define TEST_UNIT_MATH_REV_PROB_LKJ_CORR_CHOLESKY_TEST_FUNCTORS #include -#include #include namespace stan { @@ -9,7 +8,7 @@ namespace stan { namespace math { template -inline return_type_t lkj_corr_cholesky_uc( +return_type_t lkj_corr_cholesky_uc( Eigen::Matrix L, T_eta eta, int K) { using math::cholesky_corr_constrain; using math::lkj_corr_cholesky_lpdf; diff --git a/test/unit/math/rev/prob/lkj_corr_test.cpp b/test/unit/math/rev/prob/lkj_corr_test.cpp index d097d2d422f..94a61c66927 100644 --- a/test/unit/math/rev/prob/lkj_corr_test.cpp +++ b/test/unit/math/rev/prob/lkj_corr_test.cpp @@ -6,7 +6,7 @@ #include #include -TEST_F(AgradRev, ProbDistributionsLkjCorr_var) { +TEST(ProbDistributionsLkjCorr, var) { using stan::math::var; boost::random::mt19937 rng; int K = 4; @@ -27,7 +27,7 @@ TEST_F(AgradRev, ProbDistributionsLkjCorr_var) { EXPECT_FLOAT_EQ(f.val(), stan::math::lkj_corr_lpdf(Sigma, eta_d).val()); } -TEST_F(AgradRev, ProbDistributionsLkjCorrCholesky_var) { +TEST(ProbDistributionsLkjCorrCholesky, var) { using stan::math::var; boost::random::mt19937 rng; int K = 4; @@ -52,7 +52,7 @@ TEST_F(AgradRev, ProbDistributionsLkjCorrCholesky_var) { stan::math::lkj_corr_cholesky_lpdf(Sigma, eta_d).val()); } -TEST_F(AgradRev, ProbDistributionsLkjCorrCholesky_gradients) { +TEST(ProbDistributionsLkjCorrCholesky, gradients) { using stan::math::var; int dim_mat = 3; Eigen::Matrix x1(dim_mat); diff --git a/test/unit/math/rev/prob/multi_gp2_test.cpp b/test/unit/math/rev/prob/multi_gp2_test.cpp index 009e7dbbcc8..5e5267c1b5b 100644 --- a/test/unit/math/rev/prob/multi_gp2_test.cpp +++ b/test/unit/math/rev/prob/multi_gp2_test.cpp @@ -8,8 +8,8 @@ #include template -inline void expect_propto(T_y y1, T_scale sigma1, T_w w1, T_y y2, - T_scale sigma2, T_w w2, std::string message = "") { +void expect_propto(T_y y1, T_scale sigma1, T_w w1, T_y y2, T_scale sigma2, + T_w w2, std::string message = "") { expect_eq_diffs(stan::math::multi_gp_lpdf(y1, sigma1, w1), stan::math::multi_gp_lpdf(y2, sigma2, w2), stan::math::multi_gp_lpdf(y1, sigma1, w1), @@ -63,7 +63,7 @@ TEST_F(agrad_distributions_multi_gp, ProptoSigma) { stan::math::recover_memory(); } -TEST_F(AgradRev, ProbDistributionsMultiGP_MultiGPVar) { +TEST(ProbDistributionsMultiGP, MultiGPVar) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::var; @@ -78,7 +78,7 @@ TEST_F(AgradRev, ProbDistributionsMultiGP_MultiGPVar) { stan::math::recover_memory(); } -TEST_F(AgradRev, ProbDistributionsMultiGP_MultiGPGradientUnivariate) { +TEST(ProbDistributionsMultiGP, MultiGPGradientUnivariate) { using Eigen::Dynamic; using Eigen::Matrix; using Eigen::VectorXd; @@ -175,7 +175,7 @@ struct multi_gp_fun { } }; -TEST_F(AgradRev, MultiGP_TestGradFunctional) { +TEST(MultiGP, TestGradFunctional) { std::vector x(3 * 2 + 3 + 3); // y x[0] = 1.0; @@ -208,7 +208,7 @@ TEST_F(AgradRev, MultiGP_TestGradFunctional) { stan::math::recover_memory(); } -TEST_F(AgradRev, MultiGP_check_varis_on_stack) { +TEST(MultiGP, check_varis_on_stack) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::to_var; diff --git a/test/unit/math/rev/prob/multi_gp_cholesky2_test.cpp b/test/unit/math/rev/prob/multi_gp_cholesky2_test.cpp index b5616f2ea83..100e9fe9ea9 100644 --- a/test/unit/math/rev/prob/multi_gp_cholesky2_test.cpp +++ b/test/unit/math/rev/prob/multi_gp_cholesky2_test.cpp @@ -8,9 +8,9 @@ #include template -inline void expect_propto_multi_gp_cholesky_lpdf(T_y y1, T_scale L1, T_w w1, - T_y y2, T_scale L2, T_w w2, - std::string message = "") { +void expect_propto_multi_gp_cholesky_lpdf(T_y y1, T_scale L1, T_w w1, T_y y2, + T_scale L2, T_w w2, + std::string message = "") { expect_eq_diffs(stan::math::multi_gp_cholesky_lpdf(y1, L1, w1), stan::math::multi_gp_cholesky_lpdf(y2, L2, w2), stan::math::multi_gp_cholesky_lpdf(y1, L1, w1), @@ -55,7 +55,7 @@ TEST_F(agrad_distributions_multi_gp_cholesky, ProptoSigma) { "var: sigma"); } -TEST_F(AgradRev, ProbDistributionsMultiGPCholesky_MultiGPCholeskyVar) { +TEST(ProbDistributionsMultiGPCholesky, MultiGPCholeskyVar) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::var; @@ -70,8 +70,7 @@ TEST_F(AgradRev, ProbDistributionsMultiGPCholesky_MultiGPCholeskyVar) { stan::math::multi_gp_cholesky_lpdf(y, L, w).val()); } -TEST_F(AgradRev, - ProbDistributionsMultiGPCholesky_MultiGPCholeskyGradientUnivariate) { +TEST(ProbDistributionsMultiGPCholesky, MultiGPCholeskyGradientUnivariate) { using Eigen::Dynamic; using Eigen::Matrix; using Eigen::VectorXd; @@ -169,7 +168,7 @@ struct multi_gp_cholesky_fun { } }; -TEST_F(AgradRev, MultiGPCholesky_TestGradFunctional) { +TEST(MultiGPCholesky, TestGradFunctional) { std::vector x(3 * 2 + 3 + 3); // y x[0] = 1.0; @@ -200,7 +199,7 @@ TEST_F(AgradRev, MultiGPCholesky_TestGradFunctional) { test_grad(multi_gp_cholesky_fun(1, 1), u); } -TEST_F(AgradRev, ProbDistributionsMultiGPCholesky_check_varis_on_stack) { +TEST(ProbDistributionsMultiGPCholesky, check_varis_on_stack) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::to_var; diff --git a/test/unit/math/rev/prob/multi_normal2_test.cpp b/test/unit/math/rev/prob/multi_normal2_test.cpp index 655a33504cf..13125455b50 100644 --- a/test/unit/math/rev/prob/multi_normal2_test.cpp +++ b/test/unit/math/rev/prob/multi_normal2_test.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include @@ -10,9 +9,9 @@ #include template -inline void expect_propto_multi_normal_lpdf(T_y y1, T_loc mu1, T_scale sigma1, - T_y y2, T_loc mu2, T_scale sigma2, - std::string message = "") { +void expect_propto_multi_normal_lpdf(T_y y1, T_loc mu1, T_scale sigma1, T_y y2, + T_loc mu2, T_scale sigma2, + std::string message = "") { expect_eq_diffs(stan::math::multi_normal_lpdf(y1, mu1, sigma1), stan::math::multi_normal_lpdf(y2, mu2, sigma2), stan::math::multi_normal_lpdf(y1, mu1, sigma1), @@ -122,7 +121,7 @@ TEST_F(agrad_distributions_multi_normal_multi_row, ProptoSigma) { stan::math::recover_memory(); } -TEST_F(AgradRev, ProbDistributionsMultiNormal_MultiNormalVar2) { +TEST(ProbDistributionsMultiNormal, MultiNormalVar2) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::var; @@ -136,7 +135,7 @@ TEST_F(AgradRev, ProbDistributionsMultiNormal_MultiNormalVar2) { stan::math::recover_memory(); } -TEST_F(AgradRev, ProbDistributionsMultiNormal_MultiNormalGradientUnivariate) { +TEST(ProbDistributionsMultiNormal, MultiNormalGradientUnivariate) { using Eigen::Dynamic; using Eigen::Matrix; using Eigen::VectorXd; @@ -233,7 +232,7 @@ struct multi_normal_fun { } }; -TEST_F(AgradRev, ProbDistributionsMultiNormal_TestGradFunctional) { +TEST(ProbDistributionsMultiNormal, TestGradFunctional) { std::vector x(3 + 3 + 3 * 2); // y x[0] = 1.0; @@ -329,7 +328,7 @@ struct vectorized_multi_normal_fun { }; template -inline void test_all_multi_normal2() { +void test_all_multi_normal2() { { std::vector y_(3), mu_(3), sigma_(6); // y @@ -473,7 +472,7 @@ inline void test_all_multi_normal2() { } } -TEST_F(AgradRev, ProbDistributionsMultiNormal_TestGradFunctionalVectorized) { +TEST(ProbDistributionsMultiNormal, TestGradFunctionalVectorized) { test_all_multi_normal2<1, 1>(); test_all_multi_normal2<1, -1>(); test_all_multi_normal2<-1, 1>(); diff --git a/test/unit/math/rev/prob/multi_normal_cholesky2_test.cpp b/test/unit/math/rev/prob/multi_normal_cholesky2_test.cpp index c95873517a9..82c46bf55cc 100644 --- a/test/unit/math/rev/prob/multi_normal_cholesky2_test.cpp +++ b/test/unit/math/rev/prob/multi_normal_cholesky2_test.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include @@ -37,7 +36,7 @@ struct multi_normal_cholesky_fun { } }; -TEST_F(AgradRev, ProbDistributionsMultiNormalCholesky2_TestGradFunctional) { +TEST(ProbDistributionsMultiNormalCholesky2, TestGradFunctional) { std::vector x(3 + 3 + 3 * 2); // y x[0] = 1.0; @@ -130,7 +129,7 @@ struct vectorized_multi_normal_cholesky_fun { }; template -inline void test_all_multi_normal_cholesky() { +void test_all_multi_normal_cholesky() { { using Eigen::Dynamic; using Eigen::Matrix; @@ -283,8 +282,7 @@ inline void test_all_multi_normal_cholesky() { } } -TEST_F(AgradRev, - ProbDistributionsMultiNormalCholesky2_TestGradFunctionalVectorized) { +TEST(ProbDistributionsMultiNormalCholesky2, TestGradFunctionalVectorized) { test_all_multi_normal_cholesky<1, 1>(); test_all_multi_normal_cholesky<1, -1>(); test_all_multi_normal_cholesky<-1, 1>(); diff --git a/test/unit/math/rev/prob/multi_normal_cholesky_test.cpp b/test/unit/math/rev/prob/multi_normal_cholesky_test.cpp index ab876f47c20..0e5b87eadb6 100644 --- a/test/unit/math/rev/prob/multi_normal_cholesky_test.cpp +++ b/test/unit/math/rev/prob/multi_normal_cholesky_test.cpp @@ -2,7 +2,7 @@ #include #include -TEST_F(AgradRev, ProbDistributionsMultiNormalCholesky_MultiNormalVar) { +TEST(ProbDistributionsMultiNormalCholesky, MultiNormalVar) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::var; @@ -18,7 +18,7 @@ TEST_F(AgradRev, ProbDistributionsMultiNormalCholesky_MultiNormalVar) { stan::math::multi_normal_cholesky_lpdf(y, mu, L).val()); } -TEST_F(AgradRev, ProbDistributionsMultiNormalCholesky_check_varis_on_stack) { +TEST(ProbDistributionsMultiNormalCholesky, check_varis_on_stack) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::to_var; diff --git a/test/unit/math/rev/prob/multi_normal_prec2_test.cpp b/test/unit/math/rev/prob/multi_normal_prec2_test.cpp index c2efb591275..7047c189c4c 100644 --- a/test/unit/math/rev/prob/multi_normal_prec2_test.cpp +++ b/test/unit/math/rev/prob/multi_normal_prec2_test.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include @@ -10,10 +9,9 @@ #include template -inline void expect_propto_multi_normal_prec_lpdf(T_y y1, T_loc mu1, - T_scale sigma1, T_y y2, - T_loc mu2, T_scale sigma2, - std::string message = "") { +void expect_propto_multi_normal_prec_lpdf(T_y y1, T_loc mu1, T_scale sigma1, + T_y y2, T_loc mu2, T_scale sigma2, + std::string message = "") { expect_eq_diffs(stan::math::multi_normal_prec_lpdf(y1, mu1, sigma1), stan::math::multi_normal_prec_lpdf(y2, mu2, sigma2), stan::math::multi_normal_prec_lpdf(y1, mu1, sigma1), @@ -153,7 +151,7 @@ struct multi_normal_prec_fun { } }; -TEST_F(AgradRev, ProbDistributionsMultiNormalPrec2_TestGradFunctional) { +TEST(ProbDistributionsMultiNormalPrec2, TestGradFunctional) { std::vector x(3 + 3 + 3 * 2); // y x[0] = 1.0; @@ -249,7 +247,7 @@ struct vectorized_multi_normal_prec_fun { }; template -inline void test_all_multi_normal_prec2() { +void test_all_multi_normal_prec2() { { std::vector y_(3), mu_(3), sigma_(6); // y @@ -393,8 +391,7 @@ inline void test_all_multi_normal_prec2() { } } -TEST_F(AgradRev, - ProbDistributionsMultiNormalPrec2_TestGradFunctionalVectorized) { +TEST(ProbDistributionsMultiNormalPrec2, TestGradFunctionalVectorized) { test_all_multi_normal_prec2<1, 1>(); test_all_multi_normal_prec2<1, -1>(); test_all_multi_normal_prec2<-1, 1>(); diff --git a/test/unit/math/rev/prob/multi_normal_prec_test.cpp b/test/unit/math/rev/prob/multi_normal_prec_test.cpp index fe018691ad2..ce15cefc508 100644 --- a/test/unit/math/rev/prob/multi_normal_prec_test.cpp +++ b/test/unit/math/rev/prob/multi_normal_prec_test.cpp @@ -1,8 +1,8 @@ #include -#include #include +#include -TEST_F(AgradRev, ProbDistributionsMultiNormalPrec_MultiNormalVar) { +TEST(ProbDistributionsMultiNormalPrec, MultiNormalVar) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::var; @@ -20,7 +20,7 @@ TEST_F(AgradRev, ProbDistributionsMultiNormalPrec_MultiNormalVar) { stan::math::recover_memory(); } -TEST_F(AgradRev, ProbDistributionsMultiNormalPrec_check_varis_on_stack) { +TEST(ProbDistributionsMultiNormalPrec, check_varis_on_stack) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::to_var; diff --git a/test/unit/math/rev/prob/multi_normal_test.cpp b/test/unit/math/rev/prob/multi_normal_test.cpp index e50fb005597..3757c6aa33a 100644 --- a/test/unit/math/rev/prob/multi_normal_test.cpp +++ b/test/unit/math/rev/prob/multi_normal_test.cpp @@ -2,7 +2,7 @@ #include #include -TEST_F(AgradRev, ProbDistributionsMultiNormal_MultiNormalVar) { +TEST(ProbDistributionsMultiNormal, MultiNormalVar) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::var; @@ -16,7 +16,7 @@ TEST_F(AgradRev, ProbDistributionsMultiNormal_MultiNormalVar) { EXPECT_FLOAT_EQ(-11.73908, stan::math::multi_normal_lpdf(y, mu, Sigma).val()); } -TEST_F(AgradRev, ProbDistributionsMultiNormal_check_varis_on_stack) { +TEST(ProbDistributionsMultiNormal, check_varis_on_stack) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::to_var; diff --git a/test/unit/math/rev/prob/multi_student_t2_test.cpp b/test/unit/math/rev/prob/multi_student_t2_test.cpp index d85e6183f4f..3756f653fa7 100644 --- a/test/unit/math/rev/prob/multi_student_t2_test.cpp +++ b/test/unit/math/rev/prob/multi_student_t2_test.cpp @@ -10,11 +10,10 @@ #include template -inline void expect_propto_multi_student_t_lpdf(T_y y1, T_dof nu1, T_loc mu1, - T_scale sigma1, T_y y2, - T_dof nu2, T_loc mu2, - T_scale sigma2, - std::string message = "") { +void expect_propto_multi_student_t_lpdf(T_y y1, T_dof nu1, T_loc mu1, + T_scale sigma1, T_y y2, T_dof nu2, + T_loc mu2, T_scale sigma2, + std::string message = "") { expect_eq_diffs(stan::math::multi_student_t_lpdf(y1, nu1, mu1, sigma1), stan::math::multi_student_t_lpdf(y2, nu2, mu2, sigma2), stan::math::multi_student_t_lpdf(y1, nu1, mu1, sigma1), @@ -76,7 +75,7 @@ TEST_F(agrad_distributions_multi_student_t, ProptoSigma) { stan::math::recover_memory(); } -TEST_F(AgradRev, ProbDistributionsMultiStudentT_MultiStudentTVar) { +TEST(ProbDistributionsMultiStudentT, MultiStudentTVar) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::var; @@ -93,8 +92,7 @@ TEST_F(AgradRev, ProbDistributionsMultiStudentT_MultiStudentTVar) { stan::math::recover_memory(); } -TEST_F(AgradRev, - ProbDistributionsMultiStudentT_MultiStudentTGradientUnivariate) { +TEST(ProbDistributionsMultiStudentT, MultiStudentTGradientUnivariate) { using Eigen::Dynamic; using Eigen::Matrix; using Eigen::VectorXd; @@ -205,7 +203,7 @@ struct multi_student_t_fun { } }; -TEST_F(AgradRev, ProbDistributionsMultiStudentT_TestGradFunctional) { +TEST(ProbDistributionsMultiStudentT, TestGradFunctional) { std::vector x(3 + 3 + 3 * 2 + 1); // y x[0] = 1.0; @@ -304,7 +302,7 @@ struct vectorized_multi_student_t_fun { }; template -inline void test_all_multi_student_t2() { +void test_all_multi_student_t2() { { using stan::math::var; std::vector y_(3), mu_(3), sigma_(6); @@ -534,7 +532,7 @@ inline void test_all_multi_student_t2() { } } -TEST_F(AgradRev, ProbDistributionsMultiStudentT_TestGradFunctionalVectorized) { +TEST(ProbDistributionsMultiStudentT, TestGradFunctionalVectorized) { test_all_multi_student_t2<1, 1>(); test_all_multi_student_t2<1, -1>(); test_all_multi_student_t2<-1, 1>(); @@ -543,7 +541,7 @@ TEST_F(AgradRev, ProbDistributionsMultiStudentT_TestGradFunctionalVectorized) { stan::math::recover_memory(); } -TEST_F(AgradRev, ProbDistributionsMultiStudentT_check_varis_on_stack) { +TEST(ProbDistributionsMultiStudentT, check_varis_on_stack) { using Eigen::Dynamic; using Eigen::Matrix; using std::vector; diff --git a/test/unit/math/rev/prob/multi_student_t_cholesky_test.cpp b/test/unit/math/rev/prob/multi_student_t_cholesky_test.cpp index c165ec1baff..a347fb1276c 100644 --- a/test/unit/math/rev/prob/multi_student_t_cholesky_test.cpp +++ b/test/unit/math/rev/prob/multi_student_t_cholesky_test.cpp @@ -10,9 +10,10 @@ #include template -inline void expect_propto_multi_student_t_cholesky_lpdf( - T_y y1, T_dof nu1, T_loc mu1, T_scale L1, T_y y2, T_dof nu2, T_loc mu2, - T_scale L2, std::string message = "") { +void expect_propto_multi_student_t_cholesky_lpdf(T_y y1, T_dof nu1, T_loc mu1, + T_scale L1, T_y y2, T_dof nu2, + T_loc mu2, T_scale L2, + std::string message = "") { expect_eq_diffs( stan::math::multi_student_t_cholesky_lpdf(y1, nu1, mu1, L1), stan::math::multi_student_t_cholesky_lpdf(y2, nu2, mu2, L2), @@ -75,7 +76,7 @@ TEST_F(agrad_distributions_multi_student_t_cholesky, ProptoL) { stan::math::recover_memory(); } -TEST_F(AgradRev, ProbDistributionsMultiStudentTCholesky_MultiStudentTVar) { +TEST(ProbDistributionsMultiStudentTCholesky, MultiStudentTVar) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::var; @@ -95,8 +96,7 @@ TEST_F(AgradRev, ProbDistributionsMultiStudentTCholesky_MultiStudentTVar) { stan::math::recover_memory(); } -TEST_F(AgradRev, - ProbDistributionsMultiStudentTCholesky_MultiStudentTGradientUnivariate) { +TEST(ProbDistributionsMultiStudentTCholesky, MultiStudentTGradientUnivariate) { using Eigen::Dynamic; using Eigen::Matrix; using Eigen::VectorXd; @@ -209,7 +209,7 @@ struct multi_student_t_cholesky_fun { } }; -TEST_F(AgradRev, ProbDistributionsMultiStudentTCholesky_TestGradFunctional) { +TEST(ProbDistributionsMultiStudentTCholesky, TestGradFunctional) { std::vector x(3 + 3 + 3 * 2 + 1); // y x[0] = 1.0; @@ -311,7 +311,7 @@ struct vectorized_multi_student_t_cholesky_fun { }; template -inline void test_all_multi_student_t_cholesky() { +void test_all_multi_student_t_cholesky() { { using stan::math::var; std::vector y_(3), mu_(3), sigma_(6); @@ -589,8 +589,7 @@ inline void test_all_multi_student_t_cholesky() { } } -TEST_F(AgradRev, - ProbDistributionsMultiStudentTCholesky_TestGradFunctionalVectorized) { +TEST(ProbDistributionsMultiStudentTCholesky, TestGradFunctionalVectorized) { test_all_multi_student_t_cholesky<1, 1>(); test_all_multi_student_t_cholesky<1, -1>(); test_all_multi_student_t_cholesky<-1, 1>(); @@ -599,7 +598,7 @@ TEST_F(AgradRev, stan::math::recover_memory(); } -TEST_F(AgradRev, ProbDistributionsMultiStudentTCholesky_check_varis_on_stack) { +TEST(ProbDistributionsMultiStudentTCholesky, check_varis_on_stack) { using Eigen::Dynamic; using Eigen::Matrix; using std::vector; diff --git a/test/unit/math/rev/prob/multinomial_logit_test.cpp b/test/unit/math/rev/prob/multinomial_logit_test.cpp index ce6a347c239..de69f1115bb 100644 --- a/test/unit/math/rev/prob/multinomial_logit_test.cpp +++ b/test/unit/math/rev/prob/multinomial_logit_test.cpp @@ -6,11 +6,9 @@ #include template -inline void expect_propto_multinomial_logit_lpmf(std::vector& ns1, - T_prob beta1, - std::vector& ns2, - T_prob beta2, - std::string message) { +void expect_propto_multinomial_logit_lpmf(std::vector& ns1, T_prob beta1, + std::vector& ns2, T_prob beta2, + std::string message) { expect_eq_diffs(stan::math::multinomial_logit_lpmf(ns1, beta1), stan::math::multinomial_logit_lpmf(ns2, beta2), stan::math::multinomial_logit_lpmf(ns1, beta1), @@ -18,7 +16,7 @@ inline void expect_propto_multinomial_logit_lpmf(std::vector& ns1, message); } -TEST_F(AgradRev, DistributionsMultinomialLogit_Propto) { +TEST(AgradDistributionsMultinomialLogit, Propto) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::var; @@ -34,7 +32,7 @@ TEST_F(AgradRev, DistributionsMultinomialLogit_Propto) { expect_propto_multinomial_logit_lpmf(ns, beta1, ns, beta2, "var: beta"); } -TEST_F(AgradRev, DistributionsMultinomialLogit_check_varis_on_stack) { +TEST(AgradDistributionsMultinomialLogit, check_varis_on_stack) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::var; diff --git a/test/unit/math/rev/prob/multinomial_test.cpp b/test/unit/math/rev/prob/multinomial_test.cpp index 5f5739b3cf6..2c358f9bb24 100644 --- a/test/unit/math/rev/prob/multinomial_test.cpp +++ b/test/unit/math/rev/prob/multinomial_test.cpp @@ -6,16 +6,16 @@ #include template -inline void expect_propto_multinomial(std::vector& ns1, T_prob theta1, - std::vector& ns2, T_prob theta2, - std::string message) { +void expect_propto_multinomial(std::vector& ns1, T_prob theta1, + std::vector& ns2, T_prob theta2, + std::string message) { expect_eq_diffs(stan::math::multinomial_lpmf(ns1, theta1), stan::math::multinomial_lpmf(ns2, theta2), stan::math::multinomial_lpmf(ns1, theta1), stan::math::multinomial_lpmf(ns2, theta2), message); } -TEST_F(AgradRev, DistributionsMultinomial_Propto) { +TEST(AgradDistributionsMultinomial, Propto) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::var; @@ -31,7 +31,7 @@ TEST_F(AgradRev, DistributionsMultinomial_Propto) { expect_propto_multinomial(ns, theta1, ns, theta2, "var: theta"); } -TEST_F(AgradRev, DistributionsMultinomial_check_varis_on_stack) { +TEST(AgradDistributionsMultinomial, check_varis_on_stack) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::var; diff --git a/test/unit/math/rev/prob/neg_binomial_2_ccdf_log_test.cpp b/test/unit/math/rev/prob/neg_binomial_2_ccdf_log_test.cpp index c38a8eda2b3..e9c48c8992a 100644 --- a/test/unit/math/rev/prob/neg_binomial_2_ccdf_log_test.cpp +++ b/test/unit/math/rev/prob/neg_binomial_2_ccdf_log_test.cpp @@ -1,9 +1,8 @@ #include -#include #include #include -TEST_F(AgradRev, ProbDistributionsNegBinomial2_derivatives_lccdf) { +TEST(ProbDistributionsNegBinomial2, derivatives_lccdf) { using stan::math::neg_binomial_2_lccdf; using stan::math::var; diff --git a/test/unit/math/rev/prob/neg_binomial_2_cdf_log_test.cpp b/test/unit/math/rev/prob/neg_binomial_2_cdf_log_test.cpp index e72820619ab..395dd4b4dbc 100644 --- a/test/unit/math/rev/prob/neg_binomial_2_cdf_log_test.cpp +++ b/test/unit/math/rev/prob/neg_binomial_2_cdf_log_test.cpp @@ -1,9 +1,8 @@ #include -#include #include #include -TEST_F(AgradRev, ProbDistributionsNegBinomial2_derivatives_lcdf_1) { +TEST(ProbDistributionsNegBinomial2, derivatives_lcdf_1) { using stan::math::neg_binomial_2_lcdf; using stan::math::var; @@ -32,7 +31,7 @@ TEST_F(AgradRev, ProbDistributionsNegBinomial2_derivatives_lcdf_1) { EXPECT_FLOAT_EQ(grad_diff2, gradients[1]); } -TEST_F(AgradRev, ProbDistributionsNegBinomial2_derivatives_lcdf_2) { +TEST(ProbDistributionsNegBinomial2, derivatives_lcdf_2) { using stan::math::neg_binomial_2_lcdf; using stan::math::var; diff --git a/test/unit/math/rev/prob/neg_binomial_2_cdf_test.cpp b/test/unit/math/rev/prob/neg_binomial_2_cdf_test.cpp index c21df70c9dc..0d670b84674 100644 --- a/test/unit/math/rev/prob/neg_binomial_2_cdf_test.cpp +++ b/test/unit/math/rev/prob/neg_binomial_2_cdf_test.cpp @@ -1,9 +1,8 @@ #include -#include #include #include -TEST_F(AgradRev, ProbDistributionsNegBinomial2_derivatives_cdf) { +TEST(ProbDistributionsNegBinomial2, derivatives_cdf) { using stan::math::neg_binomial_2_cdf; using stan::math::var; 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 fb8cf1d02d4..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 @@ -1,6 +1,6 @@ #include -#include #include +#include #include #include #include diff --git a/test/unit/math/rev/prob/neg_binomial_2_log_test.cpp b/test/unit/math/rev/prob/neg_binomial_2_log_test.cpp index b68939a3920..21da83beab2 100644 --- a/test/unit/math/rev/prob/neg_binomial_2_log_test.cpp +++ b/test/unit/math/rev/prob/neg_binomial_2_log_test.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include @@ -474,7 +473,7 @@ std::vector testValues = { } // namespace neg_binomial_2_log_test_internal -TEST_F(AgradRev, ProbDistributionsNegBinomial2Log_derivativesPrecomputed) { +TEST(ProbDistributionsNegBinomial2Log, derivativesPrecomputed) { using neg_binomial_2_log_test_internal::TestValue; using neg_binomial_2_log_test_internal::testValues; using stan::math::is_nan; @@ -510,7 +509,7 @@ TEST_F(AgradRev, ProbDistributionsNegBinomial2Log_derivativesPrecomputed) { } } -TEST_F(AgradRev, ProbDistributionsNegBinomial2Log_derivativesComplexStep) { +TEST(ProbDistributionsNegBinomial2Log, derivativesComplexStep) { using boost::math::differentiation::complex_step_derivative; using stan::math::is_nan; using stan::math::log1p_exp; @@ -601,7 +600,7 @@ TEST_F(AgradRev, ProbDistributionsNegBinomial2Log_derivativesComplexStep) { } } -TEST_F(AgradRev, ProbDistributionsNegBinomial2Log_derivativesZeroOne) { +TEST(ProbDistributionsNegBinomial2Log, derivativesZeroOne) { using stan::math::log1p_exp; using stan::math::log_diff_exp; using stan::math::log_sum_exp; @@ -674,7 +673,7 @@ TEST_F(AgradRev, ProbDistributionsNegBinomial2Log_derivativesZeroOne) { } } -TEST_F(AgradRev, ProbDistributionsNegBinomial2Log_derivatives_diff_sizes) { +TEST(ProbDistributionsNegBinomial2Log, derivatives_diff_sizes) { using stan::math::neg_binomial_2_log_lpmf; using stan::math::var; diff --git a/test/unit/math/rev/prob/neg_binomial_2_test.cpp b/test/unit/math/rev/prob/neg_binomial_2_test.cpp index 0b25fbbe193..0a873fb5b1b 100644 --- a/test/unit/math/rev/prob/neg_binomial_2_test.cpp +++ b/test/unit/math/rev/prob/neg_binomial_2_test.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include @@ -432,7 +431,7 @@ std::vector testValues = { }; } // namespace neg_binomial_2_test_internal -TEST_F(AgradRev, ProbDistributionsNegativeBinomial2_derivativesPrecomputed) { +TEST(ProbDistributionsNegativeBinomial2, derivativesPrecomputed) { using neg_binomial_2_test_internal::TestValue; using neg_binomial_2_test_internal::testValues; using stan::math::is_nan; @@ -468,7 +467,7 @@ TEST_F(AgradRev, ProbDistributionsNegativeBinomial2_derivativesPrecomputed) { } } -TEST_F(AgradRev, ProbDistributionsNegBinomial2_derivativesComplexStep) { +TEST(ProbDistributionsNegBinomial2, derivativesComplexStep) { using boost::math::differentiation::complex_step_derivative; using stan::math::is_nan; using stan::math::neg_binomial_2_lpmf; @@ -544,7 +543,7 @@ TEST_F(AgradRev, ProbDistributionsNegBinomial2_derivativesComplexStep) { } } -TEST_F(AgradRev, ProbDistributionsNegBinomial2_derivativesZeroOne) { +TEST(ProbDistributionsNegBinomial2, derivativesZeroOne) { using stan::math::var; using stan::test::expect_near_rel; @@ -600,7 +599,7 @@ TEST_F(AgradRev, ProbDistributionsNegBinomial2_derivativesZeroOne) { } } -TEST_F(AgradRev, ProbDistributionsNegBinomial2_derivatives_diff_sizes) { +TEST(ProbDistributionsNegBinomial2, derivatives_diff_sizes) { using stan::math::neg_binomial_2_lpmf; using stan::math::var; diff --git a/test/unit/math/rev/prob/neg_binomial_ccdf_log_test.cpp b/test/unit/math/rev/prob/neg_binomial_ccdf_log_test.cpp index 44695dd3dd7..d062f935a7d 100644 --- a/test/unit/math/rev/prob/neg_binomial_ccdf_log_test.cpp +++ b/test/unit/math/rev/prob/neg_binomial_ccdf_log_test.cpp @@ -1,9 +1,8 @@ #include -#include #include #include -TEST_F(AgradRev, ProbDistributionsNegBinomial_derivatives_lccdf) { +TEST(ProbDistributionsNegBinomial, derivatives_lccdf) { using stan::math::neg_binomial_lccdf; using stan::math::var; diff --git a/test/unit/math/rev/prob/neg_binomial_cdf_log_test.cpp b/test/unit/math/rev/prob/neg_binomial_cdf_log_test.cpp index 287f3fc5137..6c5ddcfef1a 100644 --- a/test/unit/math/rev/prob/neg_binomial_cdf_log_test.cpp +++ b/test/unit/math/rev/prob/neg_binomial_cdf_log_test.cpp @@ -1,9 +1,8 @@ #include -#include #include #include -TEST_F(AgradRev, ProbDistributionsNegBinomial_derivatives_lcdf) { +TEST(ProbDistributionsNegBinomial, derivatives_lcdf) { using stan::math::neg_binomial_lcdf; using stan::math::var; diff --git a/test/unit/math/rev/prob/neg_binomial_cdf_test.cpp b/test/unit/math/rev/prob/neg_binomial_cdf_test.cpp index e58fb2061a8..a70c0283f33 100644 --- a/test/unit/math/rev/prob/neg_binomial_cdf_test.cpp +++ b/test/unit/math/rev/prob/neg_binomial_cdf_test.cpp @@ -1,9 +1,8 @@ #include -#include #include #include -TEST_F(AgradRev, ProbDistributionsNegBinomial_derivatives_cdf) { +TEST(ProbDistributionsNegBinomial, derivatives_cdf) { using stan::math::neg_binomial_cdf; using stan::math::var; diff --git a/test/unit/math/rev/prob/neg_binomial_test.cpp b/test/unit/math/rev/prob/neg_binomial_test.cpp index 91fee6adf2d..7dafe1ea725 100644 --- a/test/unit/math/rev/prob/neg_binomial_test.cpp +++ b/test/unit/math/rev/prob/neg_binomial_test.cpp @@ -1,9 +1,8 @@ #include -#include #include #include -TEST_F(AgradRev, ProbDistributionsNegBinomial_derivatives_diff_sizes) { +TEST(ProbDistributionsNegBinomial, derivatives_diff_sizes) { using stan::math::neg_binomial_lpmf; using stan::math::var; 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 485334dec58..4cea5923e0a 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 @@ -1,13 +1,13 @@ #include -#include #include +#include #include #include #include // We check that the values of the new regression match those of one built // from existing primitives. -TEST_F(AgradRev, normal_glm_matches_normal_id_doubles) { +TEST(ProbDistributionsNormalIdGLM, glm_matches_normal_id_doubles) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::var; @@ -30,7 +30,7 @@ TEST_F(AgradRev, normal_glm_matches_normal_id_doubles) { } // We check that the values of the new regression match those of one built // from existing primitives. -TEST_F(AgradRev, normal_glm_matches_normal_id_doubles_rand) { +TEST(ProbDistributionsNormalIdGLM, glm_matches_normal_id_doubles_rand) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::var; @@ -675,8 +675,7 @@ TYPED_TEST(ProbDistributionsNormalIdGLM, } // We check that the right errors are thrown. -TEST_F(AgradRev, - ProbDistributionsNormalIdGLM_glm_matches_normal_id_error_checking) { +TEST(ProbDistributionsNormalIdGLM, glm_matches_normal_id_error_checking) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::var; @@ -747,7 +746,7 @@ TEST_F(AgradRev, std::domain_error); } -TEST_F(AgradRev, ProbDistributionsNormalIdGLM_glm_type_issue_3189) { +TEST(ProbDistributionsNormalIdGLM, glm_type_issue_3189) { // regression test for https://github.com/stan-dev/math/issues/3189 using Eigen::Dynamic; using Eigen::Matrix; diff --git a/test/unit/math/rev/prob/normal_log_test.cpp b/test/unit/math/rev/prob/normal_log_test.cpp index ff69a4d8e52..8c4612efc6b 100644 --- a/test/unit/math/rev/prob/normal_log_test.cpp +++ b/test/unit/math/rev/prob/normal_log_test.cpp @@ -1,8 +1,7 @@ #include -#include #include -TEST_F(AgradRev, ProbDistributionsNormal_intVsDouble) { +TEST(ProbDistributionsNormal, intVsDouble) { using stan::math::var; for (double thetaval = -5.0; thetaval < 6.0; thetaval += 0.5) { var theta(thetaval); 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 64a7c3b4991..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 @@ -5,9 +5,8 @@ #include template -inline stan::return_type_t -ordered_logistic_glm_simple_lpmf(const std::vector& y, T_x&& x, - T_beta&& beta, T_cuts&& cuts) { +stan::return_type_t ordered_logistic_glm_simple_lpmf( + const std::vector& y, T_x&& x, T_beta&& beta, T_cuts&& cuts) { using stan::math::as_column_vector_or_scalar; auto&& beta_col = as_column_vector_or_scalar(beta); auto location = stan::math::multiply(x, beta_col); @@ -539,7 +538,7 @@ TYPED_TEST(ProbDistributionsOrderedLogisticGLM, glm_interfaces) { beta_var, cuts_double)); } -TEST_F(AgradRev, ProbDistributionsOrderedLogisticGLM_glm_errors) { +TEST(ProbDistributionsOrderedLogisticGLM, glm_errors) { using Eigen::Dynamic; using Eigen::Matrix; using Eigen::MatrixXd; diff --git a/test/unit/math/rev/prob/ordered_logistic_test.cpp b/test/unit/math/rev/prob/ordered_logistic_test.cpp index 4d715914d07..2332c96a081 100644 --- a/test/unit/math/rev/prob/ordered_logistic_test.cpp +++ b/test/unit/math/rev/prob/ordered_logistic_test.cpp @@ -1,10 +1,10 @@ #include -#include #include +#include #include #include -TEST_F(AgradRev, ProbDistributionsOrdLog_vv) { +TEST(ProbDistributionsOrdLog, vv) { using stan::math::ordered_logistic_lpmf; using stan::math::var; using stan::math::vector_d; @@ -27,7 +27,7 @@ TEST_F(AgradRev, ProbDistributionsOrdLog_vv) { EXPECT_FLOAT_EQ(c_v[2].adj(), 0.0); } -TEST_F(AgradRev, ProbDistributionsOrdLog_vd) { +TEST(ProbDistributionsOrdLog, vd) { using stan::math::ordered_logistic_lpmf; using stan::math::var; using stan::math::vector_d; @@ -59,7 +59,7 @@ TEST_F(AgradRev, ProbDistributionsOrdLog_vd) { EXPECT_FLOAT_EQ(c_v[2].adj(), 0.0); } -TEST_F(AgradRev, ProbDistributionsOrdLog_vv_vec) { +TEST(ProbDistributionsOrdLog, vv_vec) { using stan::math::ordered_logistic_lpmf; using stan::math::var; using stan::math::vector_d; @@ -88,7 +88,7 @@ TEST_F(AgradRev, ProbDistributionsOrdLog_vv_vec) { EXPECT_FLOAT_EQ(c_v[2].adj(), 0.682830271039293); } -TEST_F(AgradRev, ProbDistributionsOrdLog_vd_vec) { +TEST(ProbDistributionsOrdLog, vd_vec) { using stan::math::ordered_logistic_lpmf; using stan::math::var; using stan::math::vector_d; @@ -128,7 +128,7 @@ TEST_F(AgradRev, ProbDistributionsOrdLog_vd_vec) { EXPECT_FLOAT_EQ(c_v[2].adj(), 1.27666307650735); } -TEST_F(AgradRev, ProbDistributionsOrdLog_vv_stvec) { +TEST(ProbDistributionsOrdLog, vv_stvec) { using stan::math::ordered_logistic_lpmf; using stan::math::var; using stan::math::vector_d; @@ -180,7 +180,7 @@ TEST_F(AgradRev, ProbDistributionsOrdLog_vv_stvec) { EXPECT_FLOAT_EQ(std_c_v[3][2].adj(), -0.766741064228543); } -TEST_F(AgradRev, ProbDistributionsOrdLog_vd_stvec) { +TEST(ProbDistributionsOrdLog, vd_stvec) { using stan::math::ordered_logistic_lpmf; using stan::math::var; using stan::math::vector_d; @@ -253,7 +253,7 @@ TEST_F(AgradRev, ProbDistributionsOrdLog_vd_stvec) { EXPECT_FLOAT_EQ(std_c_v[3][2].adj(), -0.792489941440364); } -TEST_F(AgradRev, ProbDistributionsOrdLog_intErrors) { +TEST(ProbDistributionsOrdLog, intErrors) { using stan::math::ordered_logistic_lpmf; using stan::math::vector_v; @@ -297,7 +297,7 @@ TEST_F(AgradRev, ProbDistributionsOrdLog_intErrors) { EXPECT_FLOAT_EQ(std_c_v[3][2].adj(), -0.70889017256612); } -TEST_F(AgradRev, ProbDistributionsOrdLog_vv_vec_y1) { +TEST(ProbDistributionsOrdLog, vv_vec_y1) { using stan::math::inv_logit; using stan::math::ordered_logistic_lpmf; using stan::math::var; @@ -327,7 +327,7 @@ TEST_F(AgradRev, ProbDistributionsOrdLog_vv_vec_y1) { EXPECT_FLOAT_EQ(c_v[2].adj(), 0.0); } -TEST_F(AgradRev, ProbDistributionsOrdLog_single_class) { +TEST(ProbDistributionsOrdLog, single_class) { using stan::math::inv_logit; using stan::math::ordered_logistic_lpmf; using stan::math::var; 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 1dba2fa5da4..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 @@ -7,7 +7,7 @@ // We check that the values of the new regression match those of one built // from existing primitives. -TEST_F(AgradRev, poisson_glm_matches_poisson_log_doubles) { +TEST(ProbDistributionsPoissonLogGLM, glm_matches_poisson_log_doubles) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::var; @@ -28,7 +28,7 @@ TEST_F(AgradRev, poisson_glm_matches_poisson_log_doubles) { } // We check that the values of the new regression match those of one built // from existing primitives. -TEST_F(AgradRev, poisson_glm_matches_poisson_log_doubles_rand) { +TEST(ProbDistributionsPoissonLogGLM, glm_matches_poisson_log_doubles_rand) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::var; @@ -482,8 +482,7 @@ TYPED_TEST(ProbDistributionsPoissonLogGLM, } // We check that the right errors are thrown. -TEST_F(AgradRev, - ProbDistributionsPoissonLogGLM_glm_matches_poisson_log_error_checking) { +TEST(ProbDistributionsPoissonLogGLM, glm_matches_poisson_log_error_checking) { int N = 3; int M = 2; int W = 4; @@ -540,8 +539,7 @@ TEST_F(AgradRev, std::domain_error); } -TEST_F(AgradRev, - ProbDistributionsPoissonLogGLM_glm_matches_poisson_log_vars_propto) { +TEST(ProbDistributionsPoissonLogGLM, glm_matches_poisson_log_vars_propto) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::var; diff --git a/test/unit/math/rev/prob/test_gradients.hpp b/test/unit/math/rev/prob/test_gradients.hpp index b887447bddc..891091f83f2 100644 --- a/test/unit/math/rev/prob/test_gradients.hpp +++ b/test/unit/math/rev/prob/test_gradients.hpp @@ -1,22 +1,20 @@ #ifndef TEST_UNIT_MATH_REV_PROB_TEST_GRADIENTS #define TEST_UNIT_MATH_REV_PROB_TEST_GRADIENTS -#include #include #include #include #include -inline void test_grad_eq(Eigen::Matrix grad_1, - Eigen::Matrix grad_2) { +void test_grad_eq(Eigen::Matrix grad_1, + Eigen::Matrix grad_2) { ASSERT_EQ(grad_1.size(), grad_2.size()); for (int i = 0; i < grad_1.size(); ++i) EXPECT_FLOAT_EQ(grad_1(i), grad_2(i)); } template -inline std::vector finite_diffs(const F& fun, - const std::vector& args, - double epsilon = 1e-6) { +std::vector finite_diffs(const F& fun, const std::vector& args, + double epsilon = 1e-6) { std::vector diffs(args.size()); std::vector args_plus = args; std::vector args_minus = args; @@ -32,7 +30,7 @@ inline std::vector finite_diffs(const F& fun, } template -inline std::vector grad(const F& fun, const std::vector& args) { +std::vector grad(const F& fun, const std::vector& args) { std::vector x; for (size_t i = 0; i < args.size(); ++i) x.push_back(args[i]); @@ -44,7 +42,7 @@ inline std::vector grad(const F& fun, const std::vector& args) { } template -inline void test_grad(const F& fun, const std::vector& args) { +void test_grad(const F& fun, const std::vector& args) { using std::fabs; std::vector diffs_finite = finite_diffs(fun, args); std::vector diffs_var = grad(fun, args); diff --git a/test/unit/math/rev/prob/test_gradients_multi_normal.hpp b/test/unit/math/rev/prob/test_gradients_multi_normal.hpp index 121b773dc0f..c42cedadfb2 100644 --- a/test/unit/math/rev/prob/test_gradients_multi_normal.hpp +++ b/test/unit/math/rev/prob/test_gradients_multi_normal.hpp @@ -5,10 +5,9 @@ #include #include #include -#include template -inline std::vector finite_diffs_multi_normal( +std::vector finite_diffs_multi_normal( const F& fun, const std::vector& vec_y, const std::vector& vec_mu, const std::vector& vec_sigma, double epsilon = 1e-6) { @@ -22,7 +21,7 @@ inline std::vector finite_diffs_multi_normal( std::vector vec_sigma_plus = stan::math::value_of(vec_sigma); std::vector vec_sigma_minus = vec_sigma_plus; - if constexpr (!stan::is_constant_all::value) { + if (!stan::is_constant_all::value) { for (size_t i = 0; i < vec_y.size(); ++i) { double recover_vec_y_plus = vec_y_plus[i]; double recover_vec_y_minus = vec_y_minus[i]; @@ -35,7 +34,7 @@ inline std::vector finite_diffs_multi_normal( vec_y_minus[i] = recover_vec_y_minus; } } - if constexpr (!stan::is_constant_all::value) { + if (!stan::is_constant_all::value) { for (size_t i = 0; i < vec_mu.size(); ++i) { double recover_vec_mu_plus = vec_mu_plus[i]; double recover_vec_mu_minus = vec_mu_minus[i]; @@ -48,7 +47,7 @@ inline std::vector finite_diffs_multi_normal( vec_mu_minus[i] = recover_vec_mu_minus; } } - if constexpr (!stan::is_constant_all::value) { + if (!stan::is_constant_all::value) { for (size_t i = 0; i < vec_sigma.size(); ++i) { double recover_vec_sigma_plus = vec_sigma_plus[i]; double recover_vec_sigma_minus = vec_sigma_minus[i]; @@ -65,21 +64,22 @@ inline std::vector finite_diffs_multi_normal( } template -inline std::vector grad_multi_normal( - const F& fun, const std::vector& vec_y, - const std::vector& vec_mu, const std::vector& vec_sigma) { +std::vector grad_multi_normal(const F& fun, + const std::vector& vec_y, + const std::vector& vec_mu, + const std::vector& vec_sigma) { stan::math::var fx = fun(vec_y, vec_mu, vec_sigma); std::vector grad; std::vector vec_vars; - if constexpr (!stan::is_constant_all::value) { + if (!stan::is_constant_all::value) { for (size_t i = 0; i < vec_y.size(); i++) vec_vars.push_back(vec_y[i]); } - if constexpr (!stan::is_constant_all::value) { + if (!stan::is_constant_all::value) { for (size_t i = 0; i < vec_mu.size(); i++) vec_vars.push_back(vec_mu[i]); } - if constexpr (!stan::is_constant_all::value) { + if (!stan::is_constant_all::value) { for (size_t i = 0; i < vec_sigma.size(); i++) vec_vars.push_back(vec_sigma[i]); } @@ -88,9 +88,9 @@ inline std::vector grad_multi_normal( } template -inline void test_grad_multi_normal(const F& fun, const std::vector& vec_y, - const std::vector& vec_mu, - const std::vector& vec_sigma) { +void test_grad_multi_normal(const F& fun, const std::vector& vec_y, + const std::vector& vec_mu, + const std::vector& vec_sigma) { using std::fabs; std::vector diffs_finite = finite_diffs_multi_normal(fun, vec_y, vec_mu, vec_sigma); diff --git a/test/unit/math/rev/prob/test_gradients_multi_student_t.hpp b/test/unit/math/rev/prob/test_gradients_multi_student_t.hpp index 13b0a3d1103..76fcda6a8ad 100644 --- a/test/unit/math/rev/prob/test_gradients_multi_student_t.hpp +++ b/test/unit/math/rev/prob/test_gradients_multi_student_t.hpp @@ -5,11 +5,10 @@ #include #include #include -#include template -inline std::vector finite_diffs_multi_normal3( +std::vector finite_diffs_multi_normal3( const F& fun, const std::vector& vec_y, const std::vector& vec_mu, const std::vector& vec_sigma, const T_nu& nu, double epsilon = 1e-6) { @@ -25,7 +24,7 @@ inline std::vector finite_diffs_multi_normal3( double nu_plus = stan::math::value_of(nu); double nu_minus = nu_plus; - if constexpr (!stan::is_constant_all::value) { + if (!stan::is_constant_all::value) { for (size_t i = 0; i < vec_y.size(); ++i) { double recover_vec_y_plus = vec_y_plus[i]; double recover_vec_y_minus = vec_y_minus[i]; @@ -39,7 +38,7 @@ inline std::vector finite_diffs_multi_normal3( vec_y_minus[i] = recover_vec_y_minus; } } - if constexpr (!stan::is_constant_all::value) { + if (!stan::is_constant_all::value) { for (size_t i = 0; i < vec_mu.size(); ++i) { double recover_vec_mu_plus = vec_mu_plus[i]; double recover_vec_mu_minus = vec_mu_minus[i]; @@ -53,7 +52,7 @@ inline std::vector finite_diffs_multi_normal3( vec_mu_minus[i] = recover_vec_mu_minus; } } - if constexpr (!stan::is_constant_all::value) { + if (!stan::is_constant_all::value) { for (size_t i = 0; i < vec_sigma.size(); ++i) { double recover_vec_sigma_plus = vec_sigma_plus[i]; double recover_vec_sigma_minus = vec_sigma_minus[i]; @@ -67,7 +66,7 @@ inline std::vector finite_diffs_multi_normal3( vec_sigma_minus[i] = recover_vec_sigma_minus; } } - if constexpr (!stan::is_constant_all::value) { + if (!stan::is_constant_all::value) { nu_plus += epsilon; nu_minus -= epsilon; diffs.push_back( @@ -80,26 +79,27 @@ inline std::vector finite_diffs_multi_normal3( template -inline std::vector grad_multi_normal3( - const F& fun, const std::vector& vec_y, - const std::vector& vec_mu, const std::vector& vec_sigma, - const T_nu& nu) { +std::vector grad_multi_normal3(const F& fun, + const std::vector& vec_y, + const std::vector& vec_mu, + const std::vector& vec_sigma, + const T_nu& nu) { stan::math::var fx = fun(vec_y, vec_mu, vec_sigma, nu); std::vector grad; std::vector vec_vars; - if constexpr (!stan::is_constant_all::value) { + if (!stan::is_constant_all::value) { for (size_t i = 0; i < vec_y.size(); i++) vec_vars.push_back(vec_y[i]); } - if constexpr (!stan::is_constant_all::value) { + if (!stan::is_constant_all::value) { for (size_t i = 0; i < vec_mu.size(); i++) vec_vars.push_back(vec_mu[i]); } - if constexpr (!stan::is_constant_all::value) { + if (!stan::is_constant_all::value) { for (size_t i = 0; i < vec_sigma.size(); i++) vec_vars.push_back(vec_sigma[i]); } - if constexpr (!stan::is_constant_all::value) + if (!stan::is_constant_all::value) vec_vars.push_back(nu); fx.grad(vec_vars, grad); @@ -108,11 +108,10 @@ inline std::vector grad_multi_normal3( template -inline void test_grad_multi_student_t(const F& fun, - const std::vector& vec_y, - const std::vector& vec_mu, - const std::vector& vec_sigma, - const T_nu& nu) { +void test_grad_multi_student_t(const F& fun, const std::vector& vec_y, + const std::vector& vec_mu, + const std::vector& vec_sigma, + const T_nu& nu) { using std::fabs; std::vector diffs_finite = finite_diffs_multi_normal3(fun, vec_y, vec_mu, vec_sigma, nu); diff --git a/test/unit/math/rev/prob/test_gradients_multi_student_t_cholesky.hpp b/test/unit/math/rev/prob/test_gradients_multi_student_t_cholesky.hpp index e7ffc22d875..be0b0c74d0a 100644 --- a/test/unit/math/rev/prob/test_gradients_multi_student_t_cholesky.hpp +++ b/test/unit/math/rev/prob/test_gradients_multi_student_t_cholesky.hpp @@ -5,11 +5,10 @@ #include #include #include -#include template -inline std::vector finite_diffs_multi_normal2( +std::vector finite_diffs_multi_normal2( const F& fun, const std::vector& vec_y, const std::vector& vec_mu, const std::vector& vec_sigma, const T_nu& nu, double epsilon = 1e-6) { @@ -25,7 +24,7 @@ inline std::vector finite_diffs_multi_normal2( double nu_plus = stan::math::value_of(nu); double nu_minus = nu_plus; - if constexpr (!stan::is_constant_all::value) { + if (!stan::is_constant_all::value) { for (size_t i = 0; i < vec_y.size(); ++i) { double recover_vec_y_plus = vec_y_plus[i]; double recover_vec_y_minus = vec_y_minus[i]; @@ -39,7 +38,7 @@ inline std::vector finite_diffs_multi_normal2( vec_y_minus[i] = recover_vec_y_minus; } } - if constexpr (!stan::is_constant_all::value) { + if (!stan::is_constant_all::value) { for (size_t i = 0; i < vec_mu.size(); ++i) { double recover_vec_mu_plus = vec_mu_plus[i]; double recover_vec_mu_minus = vec_mu_minus[i]; @@ -53,7 +52,7 @@ inline std::vector finite_diffs_multi_normal2( vec_mu_minus[i] = recover_vec_mu_minus; } } - if constexpr (!stan::is_constant_all::value) { + if (!stan::is_constant_all::value) { for (size_t i = 0; i < vec_sigma.size(); ++i) { double recover_vec_sigma_plus = vec_sigma_plus[i]; double recover_vec_sigma_minus = vec_sigma_minus[i]; @@ -67,7 +66,7 @@ inline std::vector finite_diffs_multi_normal2( vec_sigma_minus[i] = recover_vec_sigma_minus; } } - if constexpr (!stan::is_constant_all::value) { + if (!stan::is_constant_all::value) { nu_plus += epsilon; nu_minus -= epsilon; diffs.push_back( @@ -80,26 +79,27 @@ inline std::vector finite_diffs_multi_normal2( template -inline std::vector grad_multi_normal2( - const F& fun, const std::vector& vec_y, - const std::vector& vec_mu, const std::vector& vec_sigma, - const T_nu& nu) { +std::vector grad_multi_normal2(const F& fun, + const std::vector& vec_y, + const std::vector& vec_mu, + const std::vector& vec_sigma, + const T_nu& nu) { stan::math::var fx = fun(vec_y, vec_mu, vec_sigma, nu); std::vector grad; std::vector vec_vars; - if constexpr (!stan::is_constant_all::value) { + if (!stan::is_constant_all::value) { for (size_t i = 0; i < vec_y.size(); i++) vec_vars.push_back(vec_y[i]); } - if constexpr (!stan::is_constant_all::value) { + if (!stan::is_constant_all::value) { for (size_t i = 0; i < vec_mu.size(); i++) vec_vars.push_back(vec_mu[i]); } - if constexpr (!stan::is_constant_all::value) { + if (!stan::is_constant_all::value) { for (size_t i = 0; i < vec_sigma.size(); i++) vec_vars.push_back(vec_sigma[i]); } - if constexpr (!stan::is_constant_all::value) + if (!stan::is_constant_all::value) vec_vars.push_back(nu); fx.grad(vec_vars, grad); @@ -108,10 +108,11 @@ inline std::vector grad_multi_normal2( template -inline void test_grad_multi_student_t_cholesky( - const F& fun, const std::vector& vec_y, - const std::vector& vec_mu, const std::vector& vec_sigma, - const T_nu& nu) { +void test_grad_multi_student_t_cholesky(const F& fun, + const std::vector& vec_y, + const std::vector& vec_mu, + const std::vector& vec_sigma, + const T_nu& nu) { using std::fabs; std::vector diffs_finite = finite_diffs_multi_normal2(fun, vec_y, vec_mu, vec_sigma, nu); diff --git a/test/unit/math/rev/prob/weibull_test.cpp b/test/unit/math/rev/prob/weibull_test.cpp index 27ee291946b..c8cb6ff5247 100644 --- a/test/unit/math/rev/prob/weibull_test.cpp +++ b/test/unit/math/rev/prob/weibull_test.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include @@ -396,7 +395,7 @@ std::vector testValues = { } // namespace weibull_test_internal -TEST_F(AgradRev, ProbDistributionsWeibull_derivativesPrecomputed) { +TEST(ProbDistributionsWeibull, derivativesPrecomputed) { using stan::math::is_nan; using stan::math::value_of; using stan::math::var; diff --git a/test/unit/math/rev/prob/wiener_full_test.cpp b/test/unit/math/rev/prob/wiener_full_test.cpp index 01b9ad0e40e..bc36395489b 100644 --- a/test/unit/math/rev/prob/wiener_full_test.cpp +++ b/test/unit/math/rev/prob/wiener_full_test.cpp @@ -2,14 +2,13 @@ #include #include #include -#include #include #include // CHECK THAT ALL VALID SCALAR TYPES ARE ACCEPTED template -inline void check_scalar_types(F& f, double value, double res, double deriv) { +void check_scalar_types(F& f, double value, double res, double deriv) { // - f: Function with a single parameter exposed, all others // have to be scalars // - value: value to be used for the parameter @@ -30,7 +29,7 @@ inline void check_scalar_types(F& f, double value, double res, double deriv) { EXPECT_NEAR(value_var.adj(), deriv, err_tol); } -TEST_F(AgradRev, ProbWienerFull_wiener_full_all_scalar) { +TEST(ProbWienerFull, wiener_full_all_scalar) { // tests all parameter types individually, with other // parameters set to double using stan::math::wiener_lpdf; @@ -111,7 +110,7 @@ TEST_F(AgradRev, ProbWienerFull_wiener_full_all_scalar) { } } -TEST_F(AgradRev, ProbWienerFullPrec_wiener_full_prec_all_scalar) { +TEST(ProbWienerFullPrec, wiener_full_prec_all_scalar) { // tests all parameter types individually, with other parameters // set to double using stan::math::wiener_lpdf; @@ -203,7 +202,7 @@ TEST_F(AgradRev, ProbWienerFullPrec_wiener_full_prec_all_scalar) { // CHECK THAT ALL VALID Vector TYPES ARE ACCEPTED template -inline void check_vector_types(F& f, std::vector value, double res) { +void check_vector_types(F& f, std::vector value, double res) { // - f: Function where all inputs are vectors // - value: value to be used for the parameter // - res: expected result of calling `f` with `value` @@ -221,7 +220,7 @@ inline void check_vector_types(F& f, std::vector value, double res) { EXPECT_NEAR(value_of(result_var), res, err_tol); } -TEST_F(AgradRev, ProbWienerFull_wiener_full_all_vector) { +TEST(ProbWienerFull, wiener_full_all_vector) { // tests all parameter types individually, with other // parameters set to std::vector using stan::math::wiener_lpdf; diff --git a/test/unit/math/rev/prob/wishart_cholesky_test.cpp b/test/unit/math/rev/prob/wishart_cholesky_test.cpp index 41f5b8646b5..f2dca746cea 100644 --- a/test/unit/math/rev/prob/wishart_cholesky_test.cpp +++ b/test/unit/math/rev/prob/wishart_cholesky_test.cpp @@ -5,10 +5,9 @@ #include template -inline void expect_propto_wishart_cholesky_lpdf(T_y L_Y1, T_dof nu1, - T_scale L_S1, T_y L_Y2, - T_dof nu2, T_scale L_S2, - std::string message) { +void expect_propto_wishart_cholesky_lpdf(T_y L_Y1, T_dof nu1, T_scale L_S1, + T_y L_Y2, T_dof nu2, T_scale L_S2, + std::string message) { expect_eq_diffs(stan::math::wishart_cholesky_lpdf(L_Y1, nu1, L_S1), stan::math::wishart_cholesky_lpdf(L_Y2, nu2, L_S2), stan::math::wishart_cholesky_lpdf(L_Y1, nu1, L_S1), @@ -103,7 +102,7 @@ TEST_F(AgradDistributionsWishartCholesky, ProptoL_S) { stan::math::recover_memory(); } -TEST_F(AgradRev, WishartCholesky_check_varis_on_stack) { +TEST(WishartCholesky, check_varis_on_stack) { using stan::math::to_var; Eigen::MatrixXd Y(2, 2); Y << 2.011108, -11.20661, -11.20661, 112.94139; diff --git a/test/unit/math/rev/prob/wishart_test.cpp b/test/unit/math/rev/prob/wishart_test.cpp index 45038ff35cb..b9622911e64 100644 --- a/test/unit/math/rev/prob/wishart_test.cpp +++ b/test/unit/math/rev/prob/wishart_test.cpp @@ -5,9 +5,8 @@ #include template -inline void expect_propto_wishart_lpdf(T_y W1, T_dof nu1, T_scale S1, T_y W2, - T_dof nu2, T_scale S2, - std::string message) { +void expect_propto_wishart_lpdf(T_y W1, T_dof nu1, T_scale S1, T_y W2, + T_dof nu2, T_scale S2, std::string message) { expect_eq_diffs(stan::math::wishart_lpdf(W1, nu1, S1), stan::math::wishart_lpdf(W2, nu2, S2), stan::math::wishart_lpdf(W1, nu1, S1), @@ -91,7 +90,7 @@ TEST_F(AgradDistributionsWishart, ProptoSigma) { stan::math::recover_memory(); } -TEST_F(AgradRev, Wishart_check_varis_on_stack) { +TEST(Wishart, check_varis_on_stack) { using stan::math::to_var; Eigen::MatrixXd W(2, 2); W << 2.011108, -11.20661, -11.20661, 112.94139; diff --git a/test/unit/math/rev/util.hpp b/test/unit/math/rev/util.hpp index b7a21185def..53acc1f41c4 100644 --- a/test/unit/math/rev/util.hpp +++ b/test/unit/math/rev/util.hpp @@ -2,7 +2,6 @@ #define TEST_UNIT_MATH_REV_UTIL_HPP #include -#include #include #include diff --git a/test/unit/math/test_ad.hpp b/test/unit/math/test_ad.hpp index 6336f1b03d0..bc6f186c901 100644 --- a/test/unit/math/test_ad.hpp +++ b/test/unit/math/test_ad.hpp @@ -123,9 +123,9 @@ auto eval(const std::vector& x) { * @param test_derivs `true` if derivatives should be tested */ template -inline void test_gradient(const ad_tolerances& tols, const F& f, - const Eigen::VectorXd& x, double fx, - bool test_derivs = true) { +void test_gradient(const ad_tolerances& tols, const F& f, + const Eigen::VectorXd& x, double fx, + bool test_derivs = true) { Eigen::VectorXd grad_ad; double fx_ad = fx; stan::math::gradient(f, x, fx_ad, grad_ad); @@ -165,9 +165,9 @@ inline void test_gradient(const ad_tolerances& tols, const F& f, * @param test_derivs `true` if derivatives should be tested */ template -inline void test_gradient_fvar(const ad_tolerances& tols, const F& f, - const Eigen::VectorXd& x, double fx, - bool test_derivs = true) { +void test_gradient_fvar(const ad_tolerances& tols, const F& f, + const Eigen::VectorXd& x, double fx, + bool test_derivs = true) { Eigen::VectorXd grad_ad; double fx_ad = fx; stan::math::gradient(f, x, fx_ad, grad_ad); @@ -206,9 +206,9 @@ inline void test_gradient_fvar(const ad_tolerances& tols, const F& f, * @param test_derivs `true` if derivatives should be tested */ template -inline void test_hessian_fvar(const ad_tolerances& tols, const F& f, - const Eigen::VectorXd& x, double fx, - bool test_derivs = true) { +void test_hessian_fvar(const ad_tolerances& tols, const F& f, + const Eigen::VectorXd& x, double fx, + bool test_derivs = true) { double fx_ad; Eigen::VectorXd grad_ad; Eigen::MatrixXd H_ad; @@ -252,9 +252,9 @@ inline void test_hessian_fvar(const ad_tolerances& tols, const F& f, * @param test_derivs `true` if derivatives should be tested */ template -inline void test_hessian(const ad_tolerances& tols, const F& f, - const Eigen::VectorXd& x, double fx, - bool test_derivs = true) { +void test_hessian(const ad_tolerances& tols, const F& f, + const Eigen::VectorXd& x, double fx, + bool test_derivs = true) { double fx_ad; Eigen::VectorXd grad_ad; Eigen::MatrixXd H_ad; @@ -297,9 +297,9 @@ inline void test_hessian(const ad_tolerances& tols, const F& f, * @param test_derivs `true` if derivatives should be tested */ template -inline void test_grad_hessian(const ad_tolerances& tols, const F& f, - const Eigen::VectorXd& x, double fx, - bool test_derivs = true) { +void test_grad_hessian(const ad_tolerances& tols, const F& f, + const Eigen::VectorXd& x, double fx, + bool test_derivs = true) { double fx_ad; Eigen::MatrixXd H_ad; std::vector grad_H_ad; @@ -340,8 +340,8 @@ inline void test_grad_hessian(const ad_tolerances& tols, const F& f, * @param x argument to test */ template -inline void expect_ad_derivatives(const ad_tolerances& tols, const G& g, - const Eigen::VectorXd& x) { +void expect_ad_derivatives(const ad_tolerances& tols, const G& g, + const Eigen::VectorXd& x) { double gx = g(x); test_gradient(tols, g, x, gx); if constexpr (!ReverseOnly) { @@ -367,8 +367,8 @@ inline void expect_ad_derivatives(const ad_tolerances& tols, const G& g, * @param name_of_T name of type of exception expected */ template -inline void expect_throw(const F& f, const Eigen::VectorXd& x, - const std::string& name_of_T) { +void expect_throw(const F& f, const Eigen::VectorXd& x, + const std::string& name_of_T) { Eigen::Matrix x_t(x.rows()); for (int i = 0; i < x.rows(); ++i) x_t(i) = x(i); @@ -390,7 +390,7 @@ inline void expect_throw(const F& f, const Eigen::VectorXd& x, * @param x argument to test */ template -inline void expect_all_throw(const F& f, const Eigen::VectorXd& x) { +void expect_all_throw(const F& f, const Eigen::VectorXd& x) { using stan::math::fvar; using stan::math::var; expect_throw(f, x, "double"); @@ -414,7 +414,7 @@ inline void expect_all_throw(const F& f, const Eigen::VectorXd& x) { * @param x argument to evaluate */ template -inline void expect_all_throw(const F& f, double x1) { +void expect_all_throw(const F& f, double x1) { using stan::math::serialize_return; auto h = [&](auto v) { return serialize_return(eval(f(v(0)))); }; Eigen::VectorXd x(1); @@ -432,7 +432,7 @@ inline void expect_all_throw(const F& f, double x1) { * @param x2 second argument */ template -inline void expect_all_throw(const F& f, double x1, double x2) { +void expect_all_throw(const F& f, double x1, double x2) { using stan::math::serialize_return; auto h = [&](auto v) { return serialize_return(eval(f(v(0), v(1)))); }; Eigen::VectorXd x(2); @@ -451,7 +451,7 @@ inline void expect_all_throw(const F& f, double x1, double x2) { * @param x3 third argument */ template -inline void expect_all_throw(const F& f, double x1, double x2, double x3) { +void expect_all_throw(const F& f, double x1, double x2, double x3) { using stan::math::serialize_return; auto h = [&](auto v) { return serialize_return(eval(f(v(0), v(1), v(2)))); }; Eigen::VectorXd x(3); @@ -481,8 +481,8 @@ inline void expect_all_throw(const F& f, double x1, double x2, double x3) { * @param xs sequence of arguments with double-based scalars */ template -inline void expect_ad_helper(const ad_tolerances& tols, const F& f, const G& g, - const Eigen::VectorXd& x, Ts... xs) { +void expect_ad_helper(const ad_tolerances& tols, const F& f, const G& g, + const Eigen::VectorXd& x, Ts... xs) { using stan::math::serialize; auto h = [&](const int i) { return [&g, i](const auto& v) { return g(v)[i]; }; }; @@ -514,7 +514,7 @@ inline void expect_ad_helper(const ad_tolerances& tols, const F& f, const G& g, * @param x argument to test */ template -inline void expect_ad_v(const ad_tolerances& tols, const F& f, const T& x) { +void expect_ad_v(const ad_tolerances& tols, const F& f, const T& x) { using stan::math::serialize_args; using stan::math::serialize_return; using stan::math::to_deserializer; @@ -543,7 +543,7 @@ inline void expect_ad_v(const ad_tolerances& tols, const F& f, const T& x) { * @param x argument to test */ template -inline void expect_ad_v(const ad_tolerances& tols, const F& f, int x) { +void expect_ad_v(const ad_tolerances& tols, const F& f, int x) { double x_dbl = static_cast(x); // if f throws on int, must throw everywhere with double @@ -577,8 +577,8 @@ inline void expect_ad_v(const ad_tolerances& tols, const F& f, int x) { * @param x2 second argument */ template -inline void expect_ad_vv(const ad_tolerances& tols, const F& f, const T1& x1, - const T2& x2) { +void expect_ad_vv(const ad_tolerances& tols, const F& f, const T1& x1, + const T2& x2) { using stan::math::serialize_args; using stan::math::serialize_return; using stan::math::to_deserializer; @@ -612,8 +612,7 @@ inline void expect_ad_vv(const ad_tolerances& tols, const F& f, const T1& x1, } template -inline void expect_ad_vv(const ad_tolerances& tols, const F& f, int x1, - const T2& x2) { +void expect_ad_vv(const ad_tolerances& tols, const F& f, int x1, const T2& x2) { try { f(x1, x2); } catch (...) { @@ -635,8 +634,7 @@ inline void expect_ad_vv(const ad_tolerances& tols, const F& f, int x1, } template -inline void expect_ad_vv(const ad_tolerances& tols, const F& f, const T1& x1, - int x2) { +void expect_ad_vv(const ad_tolerances& tols, const F& f, const T1& x1, int x2) { try { f(x1, x2); } catch (...) { @@ -658,8 +656,7 @@ inline void expect_ad_vv(const ad_tolerances& tols, const F& f, const T1& x1, } template -inline void expect_ad_vv(const ad_tolerances& tols, const F& f, int x1, - int x2) { +void expect_ad_vv(const ad_tolerances& tols, const F& f, int x1, int x2) { // this one needs throw test because it's not handled by recursion try { f(x1, x2); @@ -699,8 +696,8 @@ inline void expect_ad_vv(const ad_tolerances& tols, const F& f, int x1, */ template -inline void expect_ad_vvv(const ad_tolerances& tols, const F& f, const T1& x1, - const T2& x2, const T3& x3) { +void expect_ad_vvv(const ad_tolerances& tols, const F& f, const T1& x1, + const T2& x2, const T3& x3) { using stan::math::serialize_args; using stan::math::serialize_return; using stan::math::to_deserializer; @@ -774,8 +771,8 @@ inline void expect_ad_vvv(const ad_tolerances& tols, const F& f, const T1& x1, } template -inline void expect_ad_vvv(const ad_tolerances& tols, const F& f, int x1, int x2, - const T3& x3) { +void expect_ad_vvv(const ad_tolerances& tols, const F& f, int x1, int x2, + const T3& x3) { try { f(x1, x2, x3); } catch (...) { @@ -803,8 +800,8 @@ inline void expect_ad_vvv(const ad_tolerances& tols, const F& f, int x1, int x2, } template -inline void expect_ad_vvv(const ad_tolerances& tols, const F& f, int x1, - const T2& x2, const T3& x3) { +void expect_ad_vvv(const ad_tolerances& tols, const F& f, int x1, const T2& x2, + const T3& x3) { try { f(x1, x2, x3); } catch (...) { @@ -827,8 +824,8 @@ inline void expect_ad_vvv(const ad_tolerances& tols, const F& f, int x1, } template -inline void expect_ad_vvv(const ad_tolerances& tols, const F& f, const T1& x1, - int x2, const T3& x3) { +void expect_ad_vvv(const ad_tolerances& tols, const F& f, const T1& x1, int x2, + const T3& x3) { try { f(x1, x2, x3); } catch (...) { @@ -851,8 +848,8 @@ inline void expect_ad_vvv(const ad_tolerances& tols, const F& f, const T1& x1, } template -inline void expect_ad_vvv(const ad_tolerances& tols, const F& f, const T1& x1, - const T2& x2, int x3) { +void expect_ad_vvv(const ad_tolerances& tols, const F& f, const T1& x1, + const T2& x2, int x3) { try { f(x1, x2, x3); } catch (...) { @@ -875,8 +872,8 @@ inline void expect_ad_vvv(const ad_tolerances& tols, const F& f, const T1& x1, } template -inline void expect_ad_vvv(const ad_tolerances& tols, const F& f, int x1, - const T2& x2, int x3) { +void expect_ad_vvv(const ad_tolerances& tols, const F& f, int x1, const T2& x2, + int x3) { try { f(x1, x2, x3); } catch (...) { @@ -904,8 +901,8 @@ inline void expect_ad_vvv(const ad_tolerances& tols, const F& f, int x1, } template -inline void expect_ad_vvv(const ad_tolerances& tols, const F& f, const T1& x1, - int x2, int x3) { +void expect_ad_vvv(const ad_tolerances& tols, const F& f, const T1& x1, int x2, + int x3) { try { f(x1, x2, x3); } catch (...) { @@ -933,8 +930,8 @@ inline void expect_ad_vvv(const ad_tolerances& tols, const F& f, const T1& x1, } template -inline void expect_ad_vvv(const ad_tolerances& tols, const F& f, int x1, int x2, - int x3) { +void expect_ad_vvv(const ad_tolerances& tols, const F& f, int x1, int x2, + int x3) { // test exception behavior; other exception cases tested recursively try { f(x1, x2, x3); @@ -992,18 +989,18 @@ const std::vector& common_nonzero_args() { * * @return sequence of common scalar arguments to test */ -inline std::vector common_args() { +std::vector common_args() { auto result = common_nonzero_args(); result.push_back(0); return result; } -inline std::vector common_nonzero_int_args() { +std::vector common_nonzero_int_args() { static const std::vector args{-1, 1}; return args; } -inline std::vector common_int_args() { +std::vector common_int_args() { std::vector args = common_nonzero_int_args(); args.push_back(0); return args; @@ -1033,7 +1030,7 @@ inline std::vector common_int_args() { * @param x2 second value being tested */ template -inline void expect_comparison(const F& f, const T1& x1, const T2& x2) { +void expect_comparison(const F& f, const T1& x1, const T2& x2) { using stan::math::fvar; using stan::math::var; typedef var v; @@ -1067,17 +1064,17 @@ inline void expect_comparison(const F& f, const T1& x1, const T2& x2) { } // namespace internal template -inline void expect_all_throw(const F& f, double x) { +void expect_all_throw(const F& f, double x) { internal::expect_all_throw(f, x); } template -inline void expect_all_throw(const F& f, double x1, double x2) { +void expect_all_throw(const F& f, double x1, double x2) { internal::expect_all_throw(f, x1, x2); } template -inline void expect_all_throw(const F& f, double x1, double x2, double x3) { +void expect_all_throw(const F& f, double x1, double x2, double x3) { internal::expect_all_throw(f, x1, x2, x3); } @@ -1093,7 +1090,7 @@ inline void expect_all_throw(const F& f, double x1, double x2, double x3) { * @param x value to test */ template -inline void expect_value(const F& f, const T& x) { +void expect_value(const F& f, const T& x) { using stan::math::fvar; using stan::math::var; typedef var v; @@ -1124,7 +1121,7 @@ inline void expect_value(const F& f, const T& x) { * @param x1 second argument to test */ template -inline void expect_value(const F& f, const T1& x1, const T2& x2) { +void expect_value(const F& f, const T1& x1, const T2& x2) { using stan::math::fvar; using stan::math::var; typedef var v; @@ -1169,7 +1166,7 @@ inline void expect_value(const F& f, const T1& x1, const T2& x2) { * @param x argument to test */ template -inline void expect_ad(const ad_tolerances& tols, const F& f, const T& x) { +void expect_ad(const ad_tolerances& tols, const F& f, const T& x) { internal::expect_ad_v(tols, f, x); } @@ -1185,7 +1182,7 @@ inline void expect_ad(const ad_tolerances& tols, const F& f, const T& x) { * @param x argument to test */ template -inline void expect_ad(const F& f, const T& x) { +void expect_ad(const F& f, const T& x) { constexpr ad_tolerances tols; expect_ad(tols, f, x); } @@ -1205,8 +1202,8 @@ inline void expect_ad(const F& f, const T& x) { * @param x2 second argument to test */ template -inline void expect_ad(const ad_tolerances& tols, const F& f, const T1& x1, - const T2& x2) { +void expect_ad(const ad_tolerances& tols, const F& f, const T1& x1, + const T2& x2) { internal::expect_ad_vv(tols, f, x1, x2); } @@ -1223,7 +1220,7 @@ inline void expect_ad(const ad_tolerances& tols, const F& f, const T1& x1, * @param x2 second argument to test */ template -inline void expect_ad(const F& f, const T1& x1, const T2& x2) { +void expect_ad(const F& f, const T1& x1, const T2& x2) { constexpr ad_tolerances tols; expect_ad(tols, f, x1, x2); } @@ -1246,8 +1243,8 @@ inline void expect_ad(const F& f, const T1& x1, const T2& x2) { */ template -inline void expect_ad(const ad_tolerances& tols, const F& f, const T1& x1, - const T2& x2, const T3& x3) { +void expect_ad(const ad_tolerances& tols, const F& f, const T1& x1, + const T2& x2, const T3& x3) { internal::expect_ad_vvv(tols, f, x1, x2, x3); } @@ -1267,7 +1264,7 @@ inline void expect_ad(const ad_tolerances& tols, const F& f, const T1& x1, */ template -inline void expect_ad(const F& f, const T1& x1, const T2& x2, const T3& x3) { +void expect_ad(const F& f, const T1& x1, const T2& x2, const T3& x3) { constexpr ad_tolerances tols; expect_ad(tols, f, x1, x2, x3); } @@ -1299,8 +1296,7 @@ template < ScalarSupport ComplexSupport = ScalarSupport::Real, typename F, typename T1, stan::require_t< stan::bool_constant>* = nullptr> -inline void expect_ad_vectorized(const ad_tolerances& tols, const F& f, - const T1& x1) { +void expect_ad_vectorized(const ad_tolerances& tols, const F& f, const T1& x1) { using Scalar = std::conditional_t::value, double, T1>; using matrix_t = Eigen::Matrix; using vector_t = Eigen::Matrix; @@ -1352,8 +1348,7 @@ inline void expect_ad_vectorized(const ad_tolerances& tols, const F& f, template >* = nullptr> -inline void expect_ad_vectorized(const ad_tolerances& tols, const F& f, - const T1& x1) { +void expect_ad_vectorized(const ad_tolerances& tols, const F& f, const T1& x1) { using Scalar = std::conditional_t::value, double, T1>; using matrix_t = Eigen::Matrix; using vector_t = Eigen::Matrix; @@ -1438,8 +1433,7 @@ inline void expect_ad_vectorized(const ad_tolerances& tols, const F& f, template >* = nullptr> -inline void expect_ad_vectorized(const ad_tolerances& tols, const F& f, - const T1& x1) { +void expect_ad_vectorized(const ad_tolerances& tols, const F& f, const T1& x1) { using Scalar = std::conditional_t::value, double, T1>; using complex_t = std::complex; using complex_matrix_t = Eigen::Matrix; @@ -1501,7 +1495,7 @@ inline void expect_ad_vectorized(const ad_tolerances& tols, const F& f, */ template -inline void expect_ad_vectorized(const F& f, const T& x) { +void expect_ad_vectorized(const F& f, const T& x) { constexpr ad_tolerances tols; expect_ad_vectorized(tols, f, x); } @@ -1520,9 +1514,8 @@ inline void expect_ad_vectorized(const F& f, const T& x) { */ template * = nullptr> -inline void expect_ad_vectorized_binary_impl(const ad_tolerances& tols, - const F& f, const T1& x, - const T2& y) { +void expect_ad_vectorized_binary_impl(const ad_tolerances& tols, const F& f, + const T1& x, const T2& y) { std::vector nest_x{x, x}; std::vector nest_y{y, y}; std::vector> nest_nest_x{nest_x, nest_x}; @@ -1554,9 +1547,8 @@ inline void expect_ad_vectorized_binary_impl(const ad_tolerances& tols, * @param z argument to test */ template -inline void expect_ad_vectorized_ternary_impl(const ad_tolerances& tols, - const F& f, const T1& x, - const T2& y, const T3& z) { +void expect_ad_vectorized_ternary_impl(const ad_tolerances& tols, const F& f, + const T1& x, const T2& y, const T3& z) { std::vector nest_x{x}; std::vector nest_y{y}; std::vector nest_z{z}; @@ -1589,9 +1581,8 @@ inline void expect_ad_vectorized_ternary_impl(const ad_tolerances& tols, */ template * = nullptr> -inline void expect_ad_vectorized_binary_impl(const ad_tolerances& tols, - const F& f, const T1& x, - const T2& y) { +void expect_ad_vectorized_binary_impl(const ad_tolerances& tols, const F& f, + const T1& x, const T2& y) { auto f_bind = [&](const auto& x) { return [=](const auto& y) { return f(x, y); }; }; std::vector nest_x{x, x}; @@ -1619,9 +1610,8 @@ inline void expect_ad_vectorized_binary_impl(const ad_tolerances& tols, */ template * = nullptr> -inline void expect_ad_vectorized_binary_impl(const ad_tolerances& tols, - const F& f, const T1& x, - const T2& y) { +void expect_ad_vectorized_binary_impl(const ad_tolerances& tols, const F& f, + const T1& x, const T2& y) { auto f_bind = [&](const auto& y) { return [=](const auto& x) { return f(x, y); }; }; std::vector nest_x{x, x}; @@ -1649,8 +1639,8 @@ inline void expect_ad_vectorized_binary_impl(const ad_tolerances& tols, */ template * = nullptr> -inline void expect_ad_vectorized_binary(const ad_tolerances& tols, const F& f, - const T1& x, const T2& y) { +void expect_ad_vectorized_binary(const ad_tolerances& tols, const F& f, + const T1& x, const T2& y) { expect_ad_vectorized_binary_impl(tols, f, x, y); expect_ad_vectorized_binary_impl(tols, f, math::to_array_1d(x), math::to_array_1d(y)); @@ -1674,9 +1664,8 @@ inline void expect_ad_vectorized_binary(const ad_tolerances& tols, const F& f, */ template * = nullptr> -inline void expect_ad_vectorized_ternary(const ad_tolerances& tols, const F& f, - const T1& x, const T2& y, - const T3& z) { +void expect_ad_vectorized_ternary(const ad_tolerances& tols, const F& f, + const T1& x, const T2& y, const T3& z) { expect_ad_vectorized_ternary_impl(tols, f, x, y, z); expect_ad_vectorized_ternary_impl(tols, f, math::to_array_1d(x), math::to_array_1d(y), math::to_array_1d(z)); @@ -1698,8 +1687,8 @@ inline void expect_ad_vectorized_ternary(const ad_tolerances& tols, const F& f, */ template * = nullptr> -inline void expect_ad_vectorized_binary(const ad_tolerances& tols, const F& f, - const T1& x, const T2& y) { +void expect_ad_vectorized_binary(const ad_tolerances& tols, const F& f, + const T1& x, const T2& y) { expect_ad_vectorized_binary_impl(tols, f, x, y); } @@ -1721,9 +1710,8 @@ inline void expect_ad_vectorized_binary(const ad_tolerances& tols, const F& f, */ template * = nullptr> -inline void expect_ad_vectorized_ternary(const ad_tolerances& tols, const F& f, - const T1& x, const T2& y, - const T3& z) { +void expect_ad_vectorized_ternary(const ad_tolerances& tols, const F& f, + const T1& x, const T2& y, const T3& z) { expect_ad_vectorized_ternary_impl(tols, f, x, y, z); } @@ -1740,7 +1728,7 @@ inline void expect_ad_vectorized_ternary(const ad_tolerances& tols, const F& f, * @param y argument to test */ template -inline void expect_ad_vectorized_binary(const F& f, const T1& x, const T2& y) { +void expect_ad_vectorized_binary(const F& f, const T1& x, const T2& y) { constexpr ad_tolerances tols; expect_ad_vectorized_binary(tols, f, x, y); } @@ -1760,8 +1748,8 @@ inline void expect_ad_vectorized_binary(const F& f, const T1& x, const T2& y) { * @param z argument to test */ template -inline void expect_ad_vectorized_ternary(const F& f, const T1& x, const T2& y, - const T3& z) { +void expect_ad_vectorized_ternary(const F& f, const T1& x, const T2& y, + const T3& z) { constexpr ad_tolerances tols; expect_ad_vectorized_ternary(tols, f, x, y, z); } @@ -1777,7 +1765,7 @@ inline void expect_ad_vectorized_ternary(const F& f, const T1& x, const T2& y, * @param f unary functor to test */ template -inline void expect_common_unary(const F& f) { +void expect_common_unary(const F& f) { auto args = internal::common_args(); for (double x1 : args) expect_ad(f, x1); @@ -1797,7 +1785,7 @@ inline void expect_common_unary(const F& f) { * @param f functor to test */ template -inline void expect_common_nonzero_unary(const F& f) { +void expect_common_nonzero_unary(const F& f) { auto args = internal::common_nonzero_args(); for (double x1 : args) expect_ad(f, x1); @@ -1826,8 +1814,7 @@ inline void expect_common_nonzero_unary(const F& f) { * for second argments */ template -inline void expect_common_nonzero_binary(const F& f, - bool disable_lhs_int = false) { +void expect_common_nonzero_binary(const F& f, bool disable_lhs_int = false) { auto args = internal::common_nonzero_args(); auto int_args = internal::common_nonzero_int_args(); for (double x1 : args) @@ -1871,7 +1858,7 @@ inline void expect_common_nonzero_binary(const F& f, * for second argments */ template -inline void expect_common_binary(const F& f, bool disable_lhs_int = false) { +void expect_common_binary(const F& f, bool disable_lhs_int = false) { auto args = internal::common_args(); auto int_args = internal::common_int_args(); for (double x1 : args) @@ -1894,15 +1881,15 @@ inline void expect_common_binary(const F& f, bool disable_lhs_int = false) { } } -inline std::vector common_complex_parts_re() { +std::vector common_complex_parts_re() { return {-4, -2.5, -1.5, -0.3, -0.1, 0.1, 1.3, 2.1, 3.9}; } -inline std::vector common_complex_parts_im() { +std::vector common_complex_parts_im() { return {-4, -2.5, -1.5, -0.3, -0.0, 0.0, 1.3, 2.1, 3.9}; } -inline std::vector> common_complex() { +std::vector> common_complex() { std::vector> zs; auto complex_re = common_complex_parts_re(); auto complex_im = common_complex_parts_im(); @@ -1913,7 +1900,7 @@ inline std::vector> common_complex() { } template -inline void expect_complex_common(const F& f) { +void expect_complex_common(const F& f) { auto zs = common_complex(); for (auto z : zs) { expect_ad(f, z); @@ -1921,7 +1908,7 @@ inline void expect_complex_common(const F& f) { } template -inline void expect_complex_common_binary(const F& f) { +void expect_complex_common_binary(const F& f) { auto xs = common_complex_parts_re(); auto zs = common_complex(); // complex, complex @@ -1945,8 +1932,8 @@ inline void expect_complex_common_binary(const F& f) { } template -inline void expect_complex_compare(const F& f, const std::complex& z1, - const std::complex& z2) { +void expect_complex_compare(const F& f, const std::complex& z1, + const std::complex& z2) { using c_t = std::complex; c_t cz1{z1}; c_t cz2{z2}; @@ -1965,9 +1952,8 @@ inline void expect_complex_compare(const F& f, const std::complex& z1, } template -inline void expect_complex_comparison(const F& f, - const std::complex& z1, - const std::complex& z2) { +void expect_complex_comparison(const F& f, const std::complex& z1, + const std::complex& z2) { using stan::math::fvar; using stan::math::var; using std::complex; @@ -1987,7 +1973,7 @@ inline void expect_complex_comparison(const F& f, * @param f function to test */ template -inline void expect_complex_common_comparison(const F& f) { +void expect_complex_common_comparison(const F& f) { for (auto z1 : common_complex()) { for (auto z2 : common_complex()) { expect_complex_comparison(f, z1, z2); @@ -2016,7 +2002,7 @@ inline void expect_complex_common_comparison(const F& f) { template < ScalarSupport ComplexSupport = ScalarSupport::Real, typename F, require_t>* = nullptr> -inline void expect_common_unary_vectorized(const F& f) { +void expect_common_unary_vectorized(const F& f) { constexpr ad_tolerances tols; auto args = internal::common_args(); for (double x1 : args) @@ -2047,7 +2033,7 @@ inline void expect_common_unary_vectorized(const F& f) { template >* = nullptr> -inline void expect_common_unary_vectorized(const F& f) { +void expect_common_unary_vectorized(const F& f) { constexpr ad_tolerances tols; auto args = internal::common_args(); for (double x1 : args) @@ -2080,14 +2066,14 @@ inline void expect_common_unary_vectorized(const F& f) { template >* = nullptr> -inline void expect_common_unary_vectorized(const F& f) { +void expect_common_unary_vectorized(const F& f) { constexpr ad_tolerances tols; for (auto x1 : common_complex()) stan::test::expect_ad_vectorized(tols, f, x1); } template -inline void expect_unary_vectorized(const ad_tolerances& tols, const F& f) {} +void expect_unary_vectorized(const ad_tolerances& tols, const F& f) {} /** * Test that the specified vectorized unary function has value and @@ -2105,8 +2091,8 @@ inline void expect_unary_vectorized(const ad_tolerances& tols, const F& f) {} */ template -inline void expect_unary_vectorized(const ad_tolerances& tols, const F& f, T x, - Ts... xs) { +void expect_unary_vectorized(const ad_tolerances& tols, const F& f, T x, + Ts... xs) { expect_ad_vectorized(tols, f, x); expect_unary_vectorized(tols, f, xs...); } @@ -2125,7 +2111,7 @@ inline void expect_unary_vectorized(const ad_tolerances& tols, const F& f, T x, */ template * = nullptr, typename... Ts> -inline void expect_unary_vectorized(const F& f, Ts... xs) { +void expect_unary_vectorized(const F& f, Ts... xs) { constexpr ad_tolerances tols; // default tolerances expect_unary_vectorized(tols, f, xs...); } @@ -2146,7 +2132,7 @@ inline void expect_unary_vectorized(const F& f, Ts... xs) { template >* = nullptr> -inline void expect_common_nonzero_unary_vectorized(const F& f) { +void expect_common_nonzero_unary_vectorized(const F& f) { constexpr ad_tolerances tols; for (double x : internal::common_nonzero_args()) stan::test::expect_unary_vectorized(tols, f, x); @@ -2170,7 +2156,7 @@ inline void expect_common_nonzero_unary_vectorized(const F& f) { template >* = nullptr> -inline void expect_common_nonzero_unary_vectorized(const F& f) { +void expect_common_nonzero_unary_vectorized(const F& f) { constexpr ad_tolerances tols; for (double x : internal::common_nonzero_args()) stan::test::expect_unary_vectorized(tols, f, x); @@ -2196,7 +2182,7 @@ inline void expect_common_nonzero_unary_vectorized(const F& f) { template >* = nullptr> -inline void expect_common_nonzero_unary_vectorized(const F& f) { +void expect_common_nonzero_unary_vectorized(const F& f) { constexpr ad_tolerances tols; for (auto x1 : common_complex()) stan::test::expect_ad_vectorized(tols, f, x1); @@ -2211,7 +2197,7 @@ inline void expect_common_nonzero_unary_vectorized(const F& f) { * @param f functor to test */ template -inline void expect_common_comparison(const F& f) { +void expect_common_comparison(const F& f) { auto args = internal::common_args(); auto int_args = internal::common_int_args(); for (double x1 : args) @@ -2241,7 +2227,7 @@ inline void expect_common_comparison(const F& f) { * @param x argument to test */ template -inline void expect_match_prim(const F1& f1, const F2& f2, const T& x) { +void expect_match_prim(const F1& f1, const F2& f2, const T& x) { try { auto y1 = f1(x); try { @@ -2274,7 +2260,7 @@ inline void expect_match_prim(const F1& f1, const F2& f2, const T& x) { * @param f2 second function to test */ template -inline void expect_common_prim(const F1& f1, const F2& f2) { +void expect_common_prim(const F1& f1, const F2& f2) { for (double x : internal::common_args()) expect_match_prim(f1, f2, x); for (int x : internal::common_int_args()) @@ -2293,8 +2279,8 @@ inline void expect_common_prim(const F1& f1, const F2& f2) { * @return sequence of covariance matrices between specified sizes * with specified autocorrelation */ -inline std::vector ar_test_cov_matrices(int N_min, int N_max, - double rho) { +std::vector ar_test_cov_matrices(int N_min, int N_max, + double rho) { std::vector ys; for (int n = N_min; n <= N_max; ++n) { Eigen::MatrixXd y(n, n); @@ -2317,7 +2303,7 @@ inline std::vector ar_test_cov_matrices(int N_min, int N_max, * @param x standard vector input * @return copy as Eigen vector */ -inline Eigen::VectorXd to_vector(const std::vector& x) { +Eigen::VectorXd to_vector(const std::vector& x) { Eigen::VectorXd y(x.size()); for (size_t i = 0; i < x.size(); ++i) y(i) = x[i]; @@ -2334,7 +2320,7 @@ inline Eigen::VectorXd to_vector(const std::vector& x) { * @return copy as vector */ template -inline Eigen::VectorXd to_vector(const Eigen::Matrix& x) { +Eigen::VectorXd to_vector(const Eigen::Matrix& x) { Eigen::VectorXd y(x.size()); for (int i = 0; i < x.size(); ++i) y(i) = x(i); @@ -2348,7 +2334,7 @@ inline Eigen::VectorXd to_vector(const Eigen::Matrix& x) { * @param x standard vector input * @return copy as Eigen row vector */ -inline Eigen::RowVectorXd to_row_vector(const std::vector& x) { +Eigen::RowVectorXd to_row_vector(const std::vector& x) { Eigen::RowVectorXd y(x.size()); for (size_t i = 0; i < x.size(); ++i) y(i) = x[i]; @@ -2365,7 +2351,7 @@ inline Eigen::RowVectorXd to_row_vector(const std::vector& x) { * @return copy as row vector */ template -inline Eigen::VectorXd to_row_vector(const Eigen::Matrix& x) { +Eigen::VectorXd to_row_vector(const Eigen::Matrix& x) { Eigen::RowVectorXd y(x.size()); for (int i = 0; i < x.size(); ++i) y(i) = x(i); @@ -2380,7 +2366,7 @@ inline Eigen::VectorXd to_row_vector(const Eigen::Matrix& x) { * @param max maximum matrix dimensionality to include * @return square matrices within given dimensionality range (inclusive) */ -inline std::vector square_test_matrices(int low, int high) { +std::vector square_test_matrices(int low, int high) { std::vector xs; Eigen::MatrixXd a00(0, 0); if (0 >= low && 0 <= high) diff --git a/test/unit/math/test_ad_matvar.hpp b/test/unit/math/test_ad_matvar.hpp index 2470bd8f214..be37a177d3d 100644 --- a/test/unit/math/test_ad_matvar.hpp +++ b/test/unit/math/test_ad_matvar.hpp @@ -35,8 +35,8 @@ template < typename T1, typename T2, require_all_not_std_vector_t, value_type_t>* = nullptr, require_all_std_vector_st* = nullptr> -inline void expect_near_rel_matvar(const std::string& message, T1&& x, T2&& y, - const ad_tolerances& tols) { +void expect_near_rel_matvar(const std::string& message, T1&& x, T2&& y, + const ad_tolerances& tols) { stan::math::check_size_match("expect_near_rel_var", "x", x.size(), "y", y.size()); for (size_t i = 0; i < x.size(); ++i) { @@ -52,8 +52,8 @@ inline void expect_near_rel_matvar(const std::string& message, T1&& x, T2&& y, template * = nullptr, require_all_std_vector_st* = nullptr> -inline void expect_near_rel_matvar(const std::string& message, T1&& x, T2&& y, - const ad_tolerances& tols) { +void expect_near_rel_matvar(const std::string& message, T1&& x, T2&& y, + const ad_tolerances& tols) { stan::math::check_size_match("expect_near_rel_var", "x", x.size(), "y", y.size()); for (size_t i = 0; i < x.size(); ++i) { @@ -75,8 +75,8 @@ inline void expect_near_rel_matvar(const std::string& message, T1&& x, T2&& y, */ template * = nullptr, require_all_not_std_vector_t* = nullptr> -inline void expect_near_rel_matvar(const std::string& message, T1&& x, T2&& y, - const ad_tolerances& tols) { +void expect_near_rel_matvar(const std::string& message, T1&& x, T2&& y, + const ad_tolerances& tols) { expect_near_rel(message + std::string(" values"), x.val(), y.val(), tols.gradient_val_); expect_near_rel(message + std::string(" adjoints"), x.adj(), y.adj(), @@ -96,8 +96,8 @@ inline void expect_near_rel_matvar(const std::string& message, T1&& x, T2&& y, */ template * = nullptr> -inline void expect_near_rel_matvar(const std::string& message, T1&& x, T2&& y, - const ad_tolerances& tols) { +void expect_near_rel_matvar(const std::string& message, T1&& x, T2&& y, + const ad_tolerances& tols) { expect_near_rel(message + std::string(" doubles"), stan::math::value_of(x), stan::math::value_of(y), tols.gradient_val_); } @@ -121,11 +121,11 @@ inline constexpr auto make_tuple_seq(std::index_sequence idxs) { * @param tols Tolerances for comparison */ template -inline void expect_near_rel_matvar(const std::string& message, - const std::tuple& x, - const std::tuple& y, - const ad_tolerances& tols) { - if constexpr (!(sizeof...(T1) == sizeof...(T2))) { +void expect_near_rel_matvar(const std::string& message, + const std::tuple& x, + const std::tuple& y, + const ad_tolerances& tols) { + if (!(sizeof...(T1) == sizeof...(T2))) { FAIL() << "The number of arguments in each tuple must match"; } constexpr auto idxs = internal::make_tuple_seq( @@ -416,8 +416,8 @@ auto make_varmat_compatible(const std::vector>& x) { * @param x Input values to test function at */ template -inline void expect_ad_matvar_impl(const ad_tolerances& tols, const F& f, - const EigMats&... x) { +void expect_ad_matvar_impl(const ad_tolerances& tols, const F& f, + const EigMats&... x) { using stan::is_eigen; using stan::is_var; using stan::is_var_matrix; @@ -426,82 +426,83 @@ inline void expect_ad_matvar_impl(const ad_tolerances& tols, const F& f, using stan::math::var; using stan::math::var_value; using stan::math::test::type_name; - constexpr bool has_at_least_one_var - = stan::math::disjunction>...>::value; - if constexpr (!stan::math::disjunction...>::value) { + + if (!stan::math::disjunction...>::value) { FAIL() << "expect_ad_matvar requires at least one varmat input!" << std::endl; - } else if constexpr (!has_at_least_one_var) { + } + + if (!stan::math::disjunction>...>::value) { FAIL() << "expect_ad_matvar requires at least one autodiff input!" << std::endl; - } else { - auto A_mv_tuple = std::make_tuple(make_matvar_compatible(x)...); - auto A_vm_tuple = std::make_tuple(make_varmat_compatible(x)...); - - constexpr bool any_varmat = stan::math::apply( - [](const auto&... args) { - return stan::math::disjunction< - is_var_matrix...>::value - || stan::math::disjunction, - is_var_matrix>>...>::value; - }, - A_vm_tuple); - - if constexpr (!any_varmat) { - SUCCEED(); // If no varmats are created, skip this test + } + + auto A_mv_tuple = std::make_tuple(make_matvar_compatible(x)...); + auto A_vm_tuple = std::make_tuple(make_varmat_compatible(x)...); + + bool any_varmat = stan::math::apply( + [](const auto&... args) { + return stan::math::disjunction...>::value + || stan::math::disjunction, + is_var_matrix>>...>::value; + }, + A_vm_tuple); + + if (!any_varmat) { + SUCCEED(); // If no varmats are created, skip this test + return; + } + + using T_mv_ret = plain_type_t; + using T_vm_ret = plain_type_t; + + T_mv_ret A_mv_ret; + T_vm_ret A_vm_ret; + + if (is_var_matrix::value + || (is_std_vector::value + && is_var_matrix>::value)) { + FAIL() << "A function with matvar inputs should not return " + << type_name() << std::endl; + } + + if (is_eigen::value + || (is_std_vector::value + && is_eigen>::value)) { + FAIL() << "A function with varmat inputs should not return " + << type_name() << std::endl; + } + + // If one throws, the other should throw as well + try { + A_mv_ret = stan::math::apply(f, A_mv_tuple); + } catch (...) { + try { + stan::math::apply(f, A_vm_tuple); + FAIL() << "`Eigen::Matrix` function throws and " + "`var_value>` does not"; + } catch (...) { + SUCCEED(); return; - } else { - using T_mv_ret = plain_type_t; - using T_vm_ret = plain_type_t; - - T_mv_ret A_mv_ret; - T_vm_ret A_vm_ret; - - if constexpr (is_var_matrix::value - || (is_std_vector::value - && is_var_matrix>::value)) { - FAIL() << "A function with matvar inputs should not return " - << type_name() << std::endl; - } - - if constexpr (is_eigen::value - || (is_std_vector::value - && is_eigen>::value)) { - FAIL() << "A function with varmat inputs should not return " - << type_name() << std::endl; - } - - // If one throws, the other should throw as well - try { - A_mv_ret = stan::math::apply(f, A_mv_tuple); - } catch (...) { - try { - stan::math::apply(f, A_vm_tuple); - FAIL() << "`Eigen::Matrix` function throws and " - "`var_value>` does not"; - } catch (...) { - SUCCEED(); - return; - } - } - try { - A_vm_ret = stan::math::apply(f, A_vm_tuple); - } catch (...) { - try { - stan::math::apply(f, A_mv_tuple); - FAIL() - << "`var_value>` function throws and " - "`Eigen::Matrix` does not"; - } catch (...) { - SUCCEED(); - return; - } - } - test_matvar_gradient(tols, A_mv_ret, A_vm_ret, A_mv_tuple, A_vm_tuple); - stan::math::recover_memory(); } } + try { + A_vm_ret = stan::math::apply(f, A_vm_tuple); + } catch (...) { + try { + stan::math::apply(f, A_mv_tuple); + FAIL() << "`var_value>` function throws and " + "`Eigen::Matrix` does not"; + } catch (...) { + SUCCEED(); + return; + } + } + + test_matvar_gradient(tols, A_mv_ret, A_vm_ret, A_mv_tuple, A_vm_tuple); + + stan::math::recover_memory(); } /** @name expect_ad_matvar @@ -533,8 +534,7 @@ inline void expect_ad_matvar_impl(const ad_tolerances& tols, const F& f, * @param x Value of argument */ template -inline void expect_ad_matvar(const ad_tolerances& tols, const F& f, - const EigMat& x) { +void expect_ad_matvar(const ad_tolerances& tols, const F& f, const EigMat& x) { using varmat = stan::math::var_value; expect_ad_matvar_impl(tols, f, x); @@ -549,8 +549,8 @@ inline void expect_ad_matvar(const ad_tolerances& tols, const F& f, * @param x Value of argument */ template -inline void expect_ad_matvar(const F& f, const EigMat& x) { - constexpr ad_tolerances tols; +void expect_ad_matvar(const F& f, const EigMat& x) { + ad_tolerances tols; expect_ad_matvar(tols, f, x); } @@ -568,8 +568,8 @@ inline void expect_ad_matvar(const F& f, const EigMat& x) { */ template * = nullptr> -inline void expect_ad_matvar(const ad_tolerances& tols, const F& f, - const EigMat1& x, const EigMat2& y) { +void expect_ad_matvar(const ad_tolerances& tols, const F& f, const EigMat1& x, + const EigMat2& y) { using stan::math::var; using varmat = stan::math::var_value; @@ -583,8 +583,8 @@ inline void expect_ad_matvar(const ad_tolerances& tols, const F& f, template * = nullptr, require_not_st_integral* = nullptr> -inline void expect_ad_matvar(const ad_tolerances& tols, const F& f, - const EigMat1& x, const EigMat2& y) { +void expect_ad_matvar(const ad_tolerances& tols, const F& f, const EigMat1& x, + const EigMat2& y) { using stan::math::var; using varmat = stan::math::var_value; @@ -594,8 +594,8 @@ inline void expect_ad_matvar(const ad_tolerances& tols, const F& f, template * = nullptr, require_st_integral* = nullptr> -inline void expect_ad_matvar(const ad_tolerances& tols, const F& f, - const EigMat1& x, const EigMat2& y) { +void expect_ad_matvar(const ad_tolerances& tols, const F& f, const EigMat1& x, + const EigMat2& y) { using stan::math::var; using varmat = stan::math::var_value; @@ -613,7 +613,7 @@ inline void expect_ad_matvar(const ad_tolerances& tols, const F& f, * @param y Value of second argument */ template -inline void expect_ad_matvar(const F& f, const EigMat1& x, const EigMat2& y) { +void expect_ad_matvar(const F& f, const EigMat1& x, const EigMat2& y) { ad_tolerances tols; expect_ad_matvar(tols, f, x, y); } @@ -632,9 +632,8 @@ inline void expect_ad_matvar(const F& f, const EigMat1& x, const EigMat2& y) { * @param z Value of third argument */ template -inline void expect_ad_matvar(const ad_tolerances& tols, const F& f, - const EigMat1& x, const EigMat2& y, - const EigMat3& z) { +void expect_ad_matvar(const ad_tolerances& tols, const F& f, const EigMat1& x, + const EigMat2& y, const EigMat3& z) { using stan::math::var; using varmat = stan::math::var_value; @@ -672,8 +671,8 @@ inline void expect_ad_matvar(const ad_tolerances& tols, const F& f, * @param z Value of third argument */ template -inline void expect_ad_matvar(const F& f, const EigMat1& x, const EigMat2& y, - const EigMat3& z) { +void expect_ad_matvar(const F& f, const EigMat1& x, const EigMat2& y, + const EigMat3& z) { ad_tolerances tols; expect_ad_matvar(tols, f, x, y, z); } @@ -695,9 +694,8 @@ inline void expect_ad_matvar(const F& f, const EigMat1& x, const EigMat2& y, */ template -inline void expect_ad_matvar(const ad_tolerances& tols, const F& f, - const EigMat1& x, const EigMat2& y, - const EigMat3& z, const EigMat4& q) { +void expect_ad_matvar(const ad_tolerances& tols, const F& f, const EigMat1& x, + const EigMat2& y, const EigMat3& z, const EigMat4& q) { using stan::math::var; using varmat = stan::math::var_value; @@ -792,8 +790,8 @@ inline void expect_ad_matvar(const ad_tolerances& tols, const F& f, */ template -inline void expect_ad_matvar(const F& f, const EigMat1& x, const EigMat2& y, - const EigMat3& z, const EigMat4& q) { +void expect_ad_matvar(const F& f, const EigMat1& x, const EigMat2& y, + const EigMat3& z, const EigMat4& q) { ad_tolerances tols; expect_ad_matvar(tols, f, x, y, z, q); } @@ -818,8 +816,8 @@ inline void expect_ad_matvar(const F& f, const EigMat1& x, const EigMat2& y, */ template * = nullptr> -inline void expect_ad_vector_matvar(const ad_tolerances& tols, const F& f, - const EigVec& x) { +void expect_ad_vector_matvar(const ad_tolerances& tols, const F& f, + const EigVec& x) { Eigen::VectorXd v = x; Eigen::RowVectorXd r = x.transpose(); Eigen::MatrixXd m(x.size(), 2); @@ -850,7 +848,7 @@ inline void expect_ad_vector_matvar(const ad_tolerances& tols, const F& f, */ template * = nullptr> -inline void expect_ad_vector_matvar(const F& f, const EigVec& x) { +void expect_ad_vector_matvar(const F& f, const EigVec& x) { ad_tolerances tols; expect_ad_vector_matvar(tols, f, x); } @@ -867,8 +865,8 @@ inline void expect_ad_vector_matvar(const F& f, const EigVec& x) { template * = nullptr, require_all_not_st_integral* = nullptr> -inline void expect_ad_vectorized_matvar(const ad_tolerances& tols, const F& f, - const T1& x, const T2& y) { +void expect_ad_vectorized_matvar(const ad_tolerances& tols, const F& f, + const T1& x, const T2& y) { auto x_scal = x.coeff(0, 0); auto y_scal = y.coeff(0, 0); auto x_vec = x.col(0).eval(); @@ -960,8 +958,8 @@ inline void expect_ad_vectorized_matvar(const ad_tolerances& tols, const F& f, template * = nullptr, require_eigen_t* = nullptr> -inline void expect_ad_vectorized_matvar(const ad_tolerances& tols, const F& f, - const T1& x, const T2& y) { +void expect_ad_vectorized_matvar(const ad_tolerances& tols, const F& f, + const T1& x, const T2& y) { auto x_scal = x[0]; auto y_vec = y.col(0).eval(); @@ -998,8 +996,8 @@ inline void expect_ad_vectorized_matvar(const ad_tolerances& tols, const F& f, */ template * = nullptr, require_std_vector_vt* = nullptr> -inline void expect_ad_vectorized_matvar(const ad_tolerances& tols, const F& f, - const T1& x, const T2& y) { +void expect_ad_vectorized_matvar(const ad_tolerances& tols, const F& f, + const T1& x, const T2& y) { auto g = [&f](const auto& x, const auto& y) { return f(y, x); }; expect_ad_vectorized_matvar(tols, g, y, x); } @@ -1014,7 +1012,7 @@ inline void expect_ad_vectorized_matvar(const ad_tolerances& tols, const F& f, * @param x Test input */ template -inline void expect_ad_vectorized_matvar(const F& f, const T1& x, const T2& y) { +void expect_ad_vectorized_matvar(const F& f, const T1& x, const T2& y) { ad_tolerances tols; expect_ad_vectorized_matvar(tols, f, x, y); } diff --git a/test/unit/math/test_ad_matvar_test.cpp b/test/unit/math/test_ad_matvar_test.cpp index b1894dd5772..4f8f4cf9ffd 100644 --- a/test/unit/math/test_ad_matvar_test.cpp +++ b/test/unit/math/test_ad_matvar_test.cpp @@ -66,10 +66,11 @@ auto two_arg_bad_vals(const T1& x1, const stan::math::var_value& x2) { stan::arena_t ret = ret_val; stan::math::reverse_pass_callback([x2, ret]() mutable { - if constexpr (stan::is_stan_scalar::value) { - x2.adj() += stan::math::sum(ret.adj()); + if (stan::is_stan_scalar::value) { + stan::math::forward_as(x2).adj() + += stan::math::sum(ret.adj()); } else { - x2.adj() += ret.adj(); + stan::math::forward_as(x2.adj()) += ret.adj(); } }); @@ -84,10 +85,11 @@ auto two_arg_bad_vals(const stan::math::var_value& x2, const T1& x1) { stan::arena_t ret = ret_val; stan::math::reverse_pass_callback([x2, ret]() mutable { - if constexpr (stan::is_stan_scalar::value) { - x2.adj() += stan::math::sum(ret.adj()); + if (stan::is_stan_scalar::value) { + stan::math::forward_as(x2).adj() + += stan::math::sum(ret.adj()); } else { - x2.adj() += ret.adj(); + stan::math::forward_as(x2.adj()) += ret.adj(); } }); @@ -125,10 +127,11 @@ auto two_arg_bad_grads(const T1& x1, const stan::math::var_value& x2) { stan::arena_t ret = stan::math::add(x1, x2.val()); stan::math::reverse_pass_callback([x2, ret]() mutable { - if constexpr (stan::is_stan_scalar::value) { - x2.adj() -= stan::math::sum(ret.adj()); + if (stan::is_stan_scalar::value) { + stan::math::forward_as(x2).adj() + -= stan::math::sum(ret.adj()); } else { - x2.adj() -= ret.adj(); + stan::math::forward_as(x2.adj()) -= ret.adj(); } }); @@ -143,10 +146,11 @@ auto two_arg_bad_grads(const stan::math::var_value& x2, const T1& x1) { stan::arena_t ret = stan::math::add(x1, x2.val()); stan::math::reverse_pass_callback([x2, ret]() mutable { - if constexpr (stan::is_stan_scalar::value) { - x2.adj() -= stan::math::sum(ret.adj()); + if (stan::is_stan_scalar::value) { + stan::math::forward_as(x2).adj() + -= stan::math::sum(ret.adj()); } else { - x2.adj() -= ret.adj(); + stan::math::forward_as(x2.adj()) -= ret.adj(); } }); @@ -190,10 +194,11 @@ auto three_arg_bad_vals(const T1& x1, const T2& x2, stan::arena_t ret = ret_val; stan::math::reverse_pass_callback([x3, ret]() mutable { - if constexpr (stan::is_stan_scalar::value) { - x3.adj() += stan::math::sum(ret.adj()); + if (stan::is_stan_scalar::value) { + stan::math::forward_as(x3).adj() + += stan::math::sum(ret.adj()); } else { - x3.adj() += ret.adj(); + stan::math::forward_as(x3.adj()) += ret.adj(); } }); @@ -210,10 +215,11 @@ auto three_arg_bad_vals(const T1& x1, const stan::math::var_value& x3, stan::arena_t ret = ret_val; stan::math::reverse_pass_callback([x3, ret]() mutable { - if constexpr (stan::is_stan_scalar::value) { - x3.adj() += stan::math::sum(ret.adj()); + if (stan::is_stan_scalar::value) { + stan::math::forward_as(x3).adj() + += stan::math::sum(ret.adj()); } else { - x3.adj() += ret.adj(); + stan::math::forward_as(x3.adj()) += ret.adj(); } }); @@ -230,10 +236,11 @@ auto three_arg_bad_vals(const stan::math::var_value& x3, const T1& x1, stan::arena_t ret = ret_val; stan::math::reverse_pass_callback([x3, ret]() mutable { - if constexpr (stan::is_stan_scalar::value) { - x3.adj() += stan::math::sum(ret.adj()); + if (stan::is_stan_scalar::value) { + stan::math::forward_as(x3).adj() + += stan::math::sum(ret.adj()); } else { - x3.adj() += ret.adj(); + stan::math::forward_as(x3.adj()) += ret.adj(); } }); @@ -293,10 +300,11 @@ auto three_arg_bad_grads(const T1& x1, const T2& x2, stan::arena_t ret = ret_val; stan::math::reverse_pass_callback([x3, ret]() mutable { - if constexpr (stan::is_stan_scalar::value) { - x3.adj() -= stan::math::sum(ret.adj()); + if (stan::is_stan_scalar::value) { + stan::math::forward_as(x3).adj() + -= stan::math::sum(ret.adj()); } else { - x3.adj() -= ret.adj(); + stan::math::forward_as(x3.adj()) -= ret.adj(); } }); @@ -313,10 +321,11 @@ auto three_arg_bad_grads(const T1& x1, const stan::math::var_value& x3, stan::arena_t ret = ret_val; stan::math::reverse_pass_callback([x3, ret]() mutable { - if constexpr (stan::is_stan_scalar::value) { - x3.adj() -= stan::math::sum(ret.adj()); + if (stan::is_stan_scalar::value) { + stan::math::forward_as(x3).adj() + -= stan::math::sum(ret.adj()); } else { - x3.adj() -= ret.adj(); + stan::math::forward_as(x3.adj()) -= ret.adj(); } }); @@ -333,10 +342,11 @@ auto three_arg_bad_grads(const stan::math::var_value& x3, const T1& x1, stan::arena_t ret = ret_val; stan::math::reverse_pass_callback([x3, ret]() mutable { - if constexpr (stan::is_stan_scalar::value) { - x3.adj() -= stan::math::sum(ret.adj()); + if (stan::is_stan_scalar::value) { + stan::math::forward_as(x3).adj() + -= stan::math::sum(ret.adj()); } else { - x3.adj() -= ret.adj(); + stan::math::forward_as(x3.adj()) -= ret.adj(); } }); @@ -489,8 +499,11 @@ auto two_args_bad_vals_std_vector( stan::math::reverse_pass_callback([arena_x1, arena_x2, out]() mutable { for (size_t i = 0; i < arena_x1.size(); ++i) { - if constexpr (!stan::is_constant::value) { - arena_x1[i].adj() += out[i].adj(); + if (!stan::is_constant::value) { + stan::math::forward_as< + stan::return_var_matrix_t>(arena_x1[i]) + .adj() + += out[i].adj(); } arena_x2[i].adj() += out[i].adj(); } @@ -545,8 +558,11 @@ auto two_args_bad_grads_std_vector( stan::math::reverse_pass_callback([arena_x1, arena_x2, out]() mutable { for (size_t i = 0; i < arena_x1.size(); ++i) { - if constexpr (!stan::is_constant::value) { - arena_x1[i].adj() += out[i].adj(); + if (!stan::is_constant::value) { + stan::math::forward_as< + stan::return_var_matrix_t>(arena_x1[i]) + .adj() + += out[i].adj(); } arena_x2[i].adj() += out[i].adj() * 0; } diff --git a/test/unit/math/test_ad_test.cpp b/test/unit/math/test_ad_test.cpp index 72ed89ae9be..8eb5f4210a6 100644 --- a/test/unit/math/test_ad_test.cpp +++ b/test/unit/math/test_ad_test.cpp @@ -43,10 +43,10 @@ TEST(test_unit_math_test_ad, expect_ad_vectorized) { // double overload matches template behavior and passes tests template -inline T f_match(const T& x) { +T f_match(const T& x) { return -2 * x; } -inline double f_match(const double& x) { return -2 * x; } +double f_match(const double& x) { return -2 * x; } TEST(test_ad, match) { double x = 3.2; auto g = [](const auto& u) { return f_match(u); }; @@ -57,10 +57,10 @@ TEST(test_ad, match) { // double overload does not match template behavior for value template -inline T f_mismatch(const T& x) { +T f_mismatch(const T& x) { return -2 * x; } -inline stan::math::var f_mismatch(const stan::math::var& x) { return 2 * x; } +stan::math::var f_mismatch(const stan::math::var& x) { return 2 * x; } TEST(test_ad, mismatch) { double x = 3.2; auto g = [](const auto& u) { return f_mismatch(u); }; @@ -72,10 +72,10 @@ TEST(test_ad, mismatch) { // double overload does not match template behavior for exceptions template -inline T f_misthrow(const T& x) { +T f_misthrow(const T& x) { return -2 * x; } -inline double f_misthrow(const double& x) { +double f_misthrow(const double& x) { throw std::runtime_error("f_misthrow(double) called"); return -2 * x; } @@ -234,34 +234,33 @@ int baz_complex = 0; int baz_complex_var = 0; int baz_complex_fvar = 0; -inline double baz(int x) { +double baz(int x) { ++baz_int; return x / 2.0; } -inline double baz(double x) { +double baz(double x) { ++baz_double; return x / 2.0; } -inline stan::math::var baz(const stan::math::var& x) { +stan::math::var baz(const stan::math::var& x) { ++baz_var; return x / 2.0; } -inline std::complex baz(std::complex x) { +std::complex baz(std::complex x) { ++baz_complex; return x / 2.0; } -inline std::complex baz( - const std::complex& x) { +std::complex baz(const std::complex& x) { ++baz_complex_var; return x / 2.0; } template -inline stan::math::fvar baz(const stan::math::fvar& x) { +stan::math::fvar baz(const stan::math::fvar& x) { ++baz_fvar; return x / 2.0; } template -inline std::complex> baz( +std::complex> baz( const std::complex>& x) { ++baz_complex_fvar; return x / 2.0; diff --git a/test/unit/multiple_translation_units1.cpp b/test/unit/multiple_translation_units1.cpp index c1f4f92125b..ec8ac22e5a8 100644 --- a/test/unit/multiple_translation_units1.cpp +++ b/test/unit/multiple_translation_units1.cpp @@ -1,3 +1,3 @@ #include -inline stan::math::var function1() { return 0; } +stan::math::var function1() { return 0; } diff --git a/test/unit/multiple_translation_units2.cpp b/test/unit/multiple_translation_units2.cpp index cb11d730165..4d8d5083351 100644 --- a/test/unit/multiple_translation_units2.cpp +++ b/test/unit/multiple_translation_units2.cpp @@ -1,3 +1,3 @@ #include -inline stan::math::var function2() { return 0; } +stan::math::var function2() { return 0; }