diff --git a/stan/math/prim/meta/ref_type.hpp b/stan/math/prim/meta/ref_type.hpp index 93d37df0387..1db4b7e7cfb 100644 --- a/stan/math/prim/meta/ref_type.hpp +++ b/stan/math/prim/meta/ref_type.hpp @@ -2,6 +2,7 @@ #define STAN_MATH_PRIM_META_REF_TYPE_HPP #include +#include #include #include #include @@ -56,6 +57,10 @@ using ref_type_t = typename ref_type_if::type; template using ref_type_if_t = typename ref_type_if::type; +template +using ref_type_if_not_constant_t = + typename ref_type_if::value, T>::type; + } // namespace stan #endif diff --git a/stan/math/prim/prob/bernoulli_logit_glm_lpmf.hpp b/stan/math/prim/prob/bernoulli_logit_glm_lpmf.hpp index cb6983ef400..1c5029ca1b4 100644 --- a/stan/math/prim/prob/bernoulli_logit_glm_lpmf.hpp +++ b/stan/math/prim/prob/bernoulli_logit_glm_lpmf.hpp @@ -65,9 +65,9 @@ return_type_t bernoulli_logit_glm_lpmf( using T_xbeta_tmp = typename std::conditional_t>; - using T_x_ref = ref_type_if_t::value, T_x>; - using T_alpha_ref = ref_type_if_t::value, T_alpha>; - using T_beta_ref = ref_type_if_t::value, T_beta>; + 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; const size_t N_instances = T_x_rows == 1 ? stan::math::size(y) : x.rows(); const size_t N_attributes = x.cols(); diff --git a/stan/math/prim/prob/bernoulli_logit_lpmf.hpp b/stan/math/prim/prob/bernoulli_logit_lpmf.hpp index c4431668b1f..c63a5c45fce 100644 --- a/stan/math/prim/prob/bernoulli_logit_lpmf.hpp +++ b/stan/math/prim/prob/bernoulli_logit_lpmf.hpp @@ -37,8 +37,8 @@ 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; - using T_n_ref = ref_type_if_t::value, T_n>; - using T_theta_ref = ref_type_if_t::value, T_prob>; + using T_n_ref = ref_type_if_not_constant_t; + using T_theta_ref = ref_type_if_not_constant_t; static const char* function = "bernoulli_logit_lpmf"; check_consistent_sizes(function, "Random variable", n, "Probability parameter", theta); diff --git a/stan/math/prim/prob/beta_lpdf.hpp b/stan/math/prim/prob/beta_lpdf.hpp index 4f73292a514..13341cabf67 100644 --- a/stan/math/prim/prob/beta_lpdf.hpp +++ b/stan/math/prim/prob/beta_lpdf.hpp @@ -47,11 +47,9 @@ template 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_t::value, T_y>; - using T_alpha_ref - = ref_type_if_t::value, T_scale_succ>; - using T_beta_ref - = ref_type_if_t::value, T_scale_fail>; + using T_y_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; static const char* function = "beta_lpdf"; check_consistent_sizes(function, "Random variable", y, "First shape parameter", alpha, diff --git a/stan/math/prim/prob/beta_proportion_lpdf.hpp b/stan/math/prim/prob/beta_proportion_lpdf.hpp index 752b190f7b6..36b3ba7f3f5 100644 --- a/stan/math/prim/prob/beta_proportion_lpdf.hpp +++ b/stan/math/prim/prob/beta_proportion_lpdf.hpp @@ -53,9 +53,9 @@ return_type_t beta_proportion_lpdf(const T_y& y, const T_prec& kappa) { using T_partials_return = partials_return_t; using std::log; - using T_y_ref = ref_type_if_t::value, T_y>; - using T_mu_ref = ref_type_if_t::value, T_loc>; - using T_kappa_ref = ref_type_if_t::value, T_prec>; + using T_y_ref = ref_type_if_not_constant_t; + using T_mu_ref = ref_type_if_not_constant_t; + using T_kappa_ref = ref_type_if_not_constant_t; static const char* function = "beta_proportion_lpdf"; check_consistent_sizes(function, "Random variable", y, "Location parameter", mu, "Precision parameter", kappa); diff --git a/stan/math/prim/prob/binomial_logit_lpmf.hpp b/stan/math/prim/prob/binomial_logit_lpmf.hpp index 1fc7dfd30ec..48415e0a346 100644 --- a/stan/math/prim/prob/binomial_logit_lpmf.hpp +++ b/stan/math/prim/prob/binomial_logit_lpmf.hpp @@ -37,9 +37,9 @@ template 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_t::value, T_n>; - using T_N_ref = ref_type_if_t::value, T_N>; - using T_alpha_ref = ref_type_if_t::value, T_prob>; + using T_n_ref = ref_type_if_not_constant_t; + using T_N_ref = ref_type_if_not_constant_t; + using T_alpha_ref = ref_type_if_not_constant_t; static const char* function = "binomial_logit_lpmf"; check_consistent_sizes(function, "Successes variable", n, "Population size parameter", N, diff --git a/stan/math/prim/prob/categorical_logit_glm_lpmf.hpp b/stan/math/prim/prob/categorical_logit_glm_lpmf.hpp index 4636d9687f9..f13f5484cc6 100644 --- a/stan/math/prim/prob/categorical_logit_glm_lpmf.hpp +++ b/stan/math/prim/prob/categorical_logit_glm_lpmf.hpp @@ -54,9 +54,9 @@ return_type_t categorical_logit_glm_lpmf( using std::isfinite; using std::log; using T_y_ref = ref_type_t; - using T_x_ref = ref_type_if_t::value, T_x>; - using T_alpha_ref = ref_type_if_t::value, T_alpha>; - using T_beta_ref = ref_type_if_t::value, T_beta>; + 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; using T_beta_partials = partials_type_t>; constexpr int T_x_rows = T_x::RowsAtCompileTime; diff --git a/stan/math/prim/prob/cauchy_lpdf.hpp b/stan/math/prim/prob/cauchy_lpdf.hpp index 30d9552f49f..c8ddfead074 100644 --- a/stan/math/prim/prob/cauchy_lpdf.hpp +++ b/stan/math/prim/prob/cauchy_lpdf.hpp @@ -44,9 +44,9 @@ 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_t::value, T_y>; - using T_mu_ref = ref_type_if_t::value, T_loc>; - using T_sigma_ref = ref_type_if_t::value, T_scale>; + 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; static const char* function = "cauchy_lpdf"; check_consistent_sizes(function, "Random variable", y, "Location parameter", mu, "Scale parameter", sigma); diff --git a/stan/math/prim/prob/double_exponential_cdf.hpp b/stan/math/prim/prob/double_exponential_cdf.hpp index db0ca5d6f59..36a36ebb371 100644 --- a/stan/math/prim/prob/double_exponential_cdf.hpp +++ b/stan/math/prim/prob/double_exponential_cdf.hpp @@ -45,9 +45,9 @@ return_type_t double_exponential_cdf( || is_vector::value, T_partials_array, T_partials_return>; using std::exp; - using T_y_ref = ref_type_if_t::value, T_y>; - using T_mu_ref = ref_type_if_t::value, T_loc>; - using T_sigma_ref = ref_type_if_t::value, T_scale>; + 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; static const char* function = "double_exponential_cdf"; T_y_ref y_ref = y; T_mu_ref mu_ref = mu; diff --git a/stan/math/prim/prob/double_exponential_lpdf.hpp b/stan/math/prim/prob/double_exponential_lpdf.hpp index b751d805674..d188947ed5a 100644 --- a/stan/math/prim/prob/double_exponential_lpdf.hpp +++ b/stan/math/prim/prob/double_exponential_lpdf.hpp @@ -42,9 +42,9 @@ template 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_t::value, T_y>; - using T_mu_ref = ref_type_if_t::value, T_loc>; - using T_sigma_ref = ref_type_if_t::value, T_scale>; + 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; static const char* function = "double_exponential_lpdf"; check_consistent_sizes(function, "Random variable", y, "Location parameter", mu, "Shape parameter", sigma); diff --git a/stan/math/prim/prob/exp_mod_normal_cdf.hpp b/stan/math/prim/prob/exp_mod_normal_cdf.hpp index 7c854f0df45..b1e0785c2b5 100644 --- a/stan/math/prim/prob/exp_mod_normal_cdf.hpp +++ b/stan/math/prim/prob/exp_mod_normal_cdf.hpp @@ -31,11 +31,10 @@ return_type_t exp_mod_normal_cdf( 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_t::value, T_y>; - using T_mu_ref = ref_type_if_t::value, T_loc>; - using T_sigma_ref = ref_type_if_t::value, T_scale>; - using T_lambda_ref - = ref_type_if_t::value, T_inv_scale>; + 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; + using T_lambda_ref = ref_type_if_not_constant_t; static const char* function = "exp_mod_normal_cdf"; check_consistent_sizes(function, "Random variable", y, "Location parameter", mu, "Scale parameter", sigma, "Inv_scale paramter", diff --git a/stan/math/prim/prob/exp_mod_normal_lccdf.hpp b/stan/math/prim/prob/exp_mod_normal_lccdf.hpp index b8f67eaa4db..9103eaadfd8 100644 --- a/stan/math/prim/prob/exp_mod_normal_lccdf.hpp +++ b/stan/math/prim/prob/exp_mod_normal_lccdf.hpp @@ -32,11 +32,10 @@ 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; - using T_y_ref = ref_type_if_t::value, T_y>; - using T_mu_ref = ref_type_if_t::value, T_loc>; - using T_sigma_ref = ref_type_if_t::value, T_scale>; - using T_lambda_ref - = ref_type_if_t::value, T_inv_scale>; + 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; + using T_lambda_ref = ref_type_if_not_constant_t; static const char* function = "exp_mod_normal_lccdf"; check_consistent_sizes(function, "Random variable", y, "Location parameter", mu, "Scale parameter", sigma, "Inv_scale paramter", diff --git a/stan/math/prim/prob/exp_mod_normal_lcdf.hpp b/stan/math/prim/prob/exp_mod_normal_lcdf.hpp index ee1fe9876eb..441d43dd5cd 100644 --- a/stan/math/prim/prob/exp_mod_normal_lcdf.hpp +++ b/stan/math/prim/prob/exp_mod_normal_lcdf.hpp @@ -32,11 +32,10 @@ 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; - using T_y_ref = ref_type_if_t::value, T_y>; - using T_mu_ref = ref_type_if_t::value, T_loc>; - using T_sigma_ref = ref_type_if_t::value, T_scale>; - using T_lambda_ref - = ref_type_if_t::value, T_inv_scale>; + 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; + using T_lambda_ref = ref_type_if_not_constant_t; static const char* function = "exp_mod_normal_lcdf"; check_consistent_sizes(function, "Random variable", y, "Location parameter", mu, "Scale parameter", sigma, "Inv_scale paramter", diff --git a/stan/math/prim/prob/exp_mod_normal_lpdf.hpp b/stan/math/prim/prob/exp_mod_normal_lpdf.hpp index 93e58b6ef19..c1903665c10 100644 --- a/stan/math/prim/prob/exp_mod_normal_lpdf.hpp +++ b/stan/math/prim/prob/exp_mod_normal_lpdf.hpp @@ -30,11 +30,10 @@ 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; - using T_y_ref = ref_type_if_t::value, T_y>; - using T_mu_ref = ref_type_if_t::value, T_loc>; - using T_sigma_ref = ref_type_if_t::value, T_scale>; - using T_lambda_ref - = ref_type_if_t::value, T_inv_scale>; + 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; + using T_lambda_ref = ref_type_if_not_constant_t; static const char* function = "exp_mod_normal_lpdf"; check_consistent_sizes(function, "Random variable", y, "Location parameter", mu, "Scale parameter", sigma, "Inv_scale paramter", diff --git a/stan/math/prim/prob/exponential_cdf.hpp b/stan/math/prim/prob/exponential_cdf.hpp index c1825872fdc..bd21c64042d 100644 --- a/stan/math/prim/prob/exponential_cdf.hpp +++ b/stan/math/prim/prob/exponential_cdf.hpp @@ -36,9 +36,8 @@ 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_t::value, T_y>; - using T_beta_ref - = ref_type_if_t::value, T_inv_scale>; + using T_y_ref = ref_type_if_not_constant_t; + using T_beta_ref = ref_type_if_not_constant_t; static const char* function = "exponential_cdf"; T_y_ref y_ref = y; T_beta_ref beta_ref = beta; diff --git a/stan/math/prim/prob/exponential_lccdf.hpp b/stan/math/prim/prob/exponential_lccdf.hpp index e9482368c78..19c32c17342 100644 --- a/stan/math/prim/prob/exponential_lccdf.hpp +++ b/stan/math/prim/prob/exponential_lccdf.hpp @@ -21,9 +21,8 @@ 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_t::value, T_y>; - using T_beta_ref - = ref_type_if_t::value, T_inv_scale>; + using T_y_ref = ref_type_if_not_constant_t; + using T_beta_ref = ref_type_if_not_constant_t; static const char* function = "exponential_lccdf"; T_y_ref y_ref = y; T_beta_ref beta_ref = beta; diff --git a/stan/math/prim/prob/exponential_lcdf.hpp b/stan/math/prim/prob/exponential_lcdf.hpp index ca739a4f8d2..0ed9d41047e 100644 --- a/stan/math/prim/prob/exponential_lcdf.hpp +++ b/stan/math/prim/prob/exponential_lcdf.hpp @@ -24,9 +24,8 @@ template 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_t::value, T_y>; - using T_beta_ref - = ref_type_if_t::value, T_inv_scale>; + using T_y_ref = ref_type_if_not_constant_t; + using T_beta_ref = ref_type_if_not_constant_t; static const char* function = "exponential_lcdf"; T_y_ref y_ref = y; T_beta_ref beta_ref = beta; diff --git a/stan/math/prim/prob/exponential_lpdf.hpp b/stan/math/prim/prob/exponential_lpdf.hpp index 91422e3b5c7..26f22a0cf5e 100644 --- a/stan/math/prim/prob/exponential_lpdf.hpp +++ b/stan/math/prim/prob/exponential_lpdf.hpp @@ -53,9 +53,8 @@ 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_t::value, T_y>; - using T_beta_ref - = ref_type_if_t::value, T_inv_scale>; + using T_y_ref = ref_type_if_not_constant_t; + using T_beta_ref = ref_type_if_not_constant_t; static const char* function = "exponential_lpdf"; check_consistent_sizes(function, "Random variable", y, "Inverse scale parameter", beta); diff --git a/stan/math/prim/prob/gamma_lpdf.hpp b/stan/math/prim/prob/gamma_lpdf.hpp index 0a617dfb6dd..891ccdc2283 100644 --- a/stan/math/prim/prob/gamma_lpdf.hpp +++ b/stan/math/prim/prob/gamma_lpdf.hpp @@ -53,10 +53,9 @@ 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_t::value, T_y>; - using T_alpha_ref = ref_type_if_t::value, T_shape>; - using T_beta_ref - = ref_type_if_t::value, T_inv_scale>; + using T_y_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; static const char* function = "gamma_lpdf"; check_consistent_sizes(function, "Random variable", y, "Shape parameter", alpha, "Inverse scale parameter", beta); diff --git a/stan/math/prim/prob/gumbel_cdf.hpp b/stan/math/prim/prob/gumbel_cdf.hpp index fb656733fc4..ade82c83b27 100644 --- a/stan/math/prim/prob/gumbel_cdf.hpp +++ b/stan/math/prim/prob/gumbel_cdf.hpp @@ -40,9 +40,9 @@ 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_t::value, T_y>; - using T_mu_ref = ref_type_if_t::value, T_loc>; - using T_beta_ref = ref_type_if_t::value, T_scale>; + 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; static const char* function = "gumbel_cdf"; check_consistent_sizes(function, "Random variable", y, "Location parameter", mu, "Scale parameter", beta); diff --git a/stan/math/prim/prob/gumbel_lccdf.hpp b/stan/math/prim/prob/gumbel_lccdf.hpp index 30377018207..13e6c2ff503 100644 --- a/stan/math/prim/prob/gumbel_lccdf.hpp +++ b/stan/math/prim/prob/gumbel_lccdf.hpp @@ -39,9 +39,9 @@ template 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_t::value, T_y>; - using T_mu_ref = ref_type_if_t::value, T_loc>; - using T_beta_ref = ref_type_if_t::value, T_scale>; + 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; static const char* function = "gumbel_lccdf"; T_y_ref y_ref = y; T_mu_ref mu_ref = mu; diff --git a/stan/math/prim/prob/gumbel_lcdf.hpp b/stan/math/prim/prob/gumbel_lcdf.hpp index dc318e932e7..8cb57ddb2f9 100644 --- a/stan/math/prim/prob/gumbel_lcdf.hpp +++ b/stan/math/prim/prob/gumbel_lcdf.hpp @@ -38,9 +38,9 @@ template 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_t::value, T_y>; - using T_mu_ref = ref_type_if_t::value, T_loc>; - using T_beta_ref = ref_type_if_t::value, T_scale>; + 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; static const char* function = "gumbel_lcdf"; check_consistent_sizes(function, "Random variable", y, "Location parameter", mu, "Scale parameter", beta); diff --git a/stan/math/prim/prob/gumbel_lpdf.hpp b/stan/math/prim/prob/gumbel_lpdf.hpp index 12ed12938c7..24d3f453e5e 100644 --- a/stan/math/prim/prob/gumbel_lpdf.hpp +++ b/stan/math/prim/prob/gumbel_lpdf.hpp @@ -40,9 +40,9 @@ template 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_t::value, T_y>; - using T_mu_ref = ref_type_if_t::value, T_loc>; - using T_beta_ref = ref_type_if_t::value, T_scale>; + 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; static const char* function = "gumbel_lpdf"; check_consistent_sizes(function, "Random variable", y, "Location parameter", mu, "Scale parameter", beta); diff --git a/stan/math/prim/prob/hmm_marginal.hpp b/stan/math/prim/prob/hmm_marginal.hpp index d6dd03859d7..e8e7d065d6e 100644 --- a/stan/math/prim/prob/hmm_marginal.hpp +++ b/stan/math/prim/prob/hmm_marginal.hpp @@ -79,9 +79,9 @@ inline auto hmm_marginal(const T_omega& log_omegas, const T_Gamma& Gamma, using eig_matrix_partial = Eigen::Matrix; using eig_vector_partial = Eigen::Matrix; - using T_omega_ref = ref_type_if_t::value, T_omega>; - using T_Gamma_ref = ref_type_if_t::value, T_Gamma>; - using T_rho_ref = ref_type_if_t::value, T_rho>; + using T_omega_ref = ref_type_if_not_constant_t; + using T_Gamma_ref = ref_type_if_not_constant_t; + using T_rho_ref = ref_type_if_not_constant_t; int n_states = log_omegas.rows(); int n_transitions = log_omegas.cols() - 1; diff --git a/stan/math/prim/prob/inv_chi_square_lpdf.hpp b/stan/math/prim/prob/inv_chi_square_lpdf.hpp index 948584d40fe..3b5250184fd 100644 --- a/stan/math/prim/prob/inv_chi_square_lpdf.hpp +++ b/stan/math/prim/prob/inv_chi_square_lpdf.hpp @@ -48,8 +48,8 @@ template * = nullptr> 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_t::value, T_y>; - using T_nu_ref = ref_type_if_t::value, T_dof>; + using T_y_ref = ref_type_if_not_constant_t; + using T_nu_ref = ref_type_if_not_constant_t; static const char* function = "inv_chi_square_lpdf"; check_consistent_sizes(function, "Random variable", y, "Degrees of freedom parameter", nu); diff --git a/stan/math/prim/prob/inv_gamma_lpdf.hpp b/stan/math/prim/prob/inv_gamma_lpdf.hpp index 09101ad6e9b..3be797349e1 100644 --- a/stan/math/prim/prob/inv_gamma_lpdf.hpp +++ b/stan/math/prim/prob/inv_gamma_lpdf.hpp @@ -45,9 +45,9 @@ 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_t::value, T_y>; - using T_alpha_ref = ref_type_if_t::value, T_shape>; - using T_beta_ref = ref_type_if_t::value, T_scale>; + using T_y_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; static const char* function = "inv_gamma_lpdf"; check_consistent_sizes(function, "Random variable", y, "Shape parameter", alpha, "Scale parameter", beta); diff --git a/stan/math/prim/prob/logistic_lpdf.hpp b/stan/math/prim/prob/logistic_lpdf.hpp index d52745a11ff..0c3b895fe58 100644 --- a/stan/math/prim/prob/logistic_lpdf.hpp +++ b/stan/math/prim/prob/logistic_lpdf.hpp @@ -28,9 +28,9 @@ template 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_t::value, T_y>; - using T_mu_ref = ref_type_if_t::value, T_loc>; - using T_sigma_ref = ref_type_if_t::value, T_scale>; + 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; static const char* function = "logistic_lpdf"; check_consistent_sizes(function, "Random variable", y, "Location parameter", mu, "Scale parameter", sigma); diff --git a/stan/math/prim/prob/loglogistic_lpdf.hpp b/stan/math/prim/prob/loglogistic_lpdf.hpp index 97f88cf8cfe..8fa49ac5976 100644 --- a/stan/math/prim/prob/loglogistic_lpdf.hpp +++ b/stan/math/prim/prob/loglogistic_lpdf.hpp @@ -46,9 +46,9 @@ 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_t::value, T_y>; - using T_scale_ref = ref_type_if_t::value, T_scale>; - using T_shape_ref = ref_type_if_t::value, T_shape>; + using T_y_ref = ref_type_if_not_constant_t; + using T_scale_ref = ref_type_if_not_constant_t; + using T_shape_ref = ref_type_if_not_constant_t; using std::pow; static const char* function = "loglogistic_lpdf"; check_consistent_sizes(function, "Random variable", y, "Scale parameter", diff --git a/stan/math/prim/prob/lognormal_cdf.hpp b/stan/math/prim/prob/lognormal_cdf.hpp index 2a950c95fb2..d34493ce0e4 100644 --- a/stan/math/prim/prob/lognormal_cdf.hpp +++ b/stan/math/prim/prob/lognormal_cdf.hpp @@ -28,9 +28,9 @@ template 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_t::value, T_y>; - using T_mu_ref = ref_type_if_t::value, T_loc>; - using T_sigma_ref = ref_type_if_t::value, T_scale>; + 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; static const char* function = "lognormal_cdf"; T_y_ref y_ref = y; diff --git a/stan/math/prim/prob/lognormal_lccdf.hpp b/stan/math/prim/prob/lognormal_lccdf.hpp index 177c835c094..0c3fa95cae5 100644 --- a/stan/math/prim/prob/lognormal_lccdf.hpp +++ b/stan/math/prim/prob/lognormal_lccdf.hpp @@ -29,9 +29,9 @@ 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_t::value, T_y>; - using T_mu_ref = ref_type_if_t::value, T_loc>; - using T_sigma_ref = ref_type_if_t::value, T_scale>; + 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; static const char* function = "lognormal_lccdf"; T_y_ref y_ref = y; diff --git a/stan/math/prim/prob/lognormal_lcdf.hpp b/stan/math/prim/prob/lognormal_lcdf.hpp index 73bd8edbfe4..edfb40e5ecc 100644 --- a/stan/math/prim/prob/lognormal_lcdf.hpp +++ b/stan/math/prim/prob/lognormal_lcdf.hpp @@ -28,9 +28,9 @@ template 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_t::value, T_y>; - using T_mu_ref = ref_type_if_t::value, T_loc>; - using T_sigma_ref = ref_type_if_t::value, T_scale>; + 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; static const char* function = "lognormal_lcdf"; T_y_ref y_ref = y; diff --git a/stan/math/prim/prob/lognormal_lpdf.hpp b/stan/math/prim/prob/lognormal_lpdf.hpp index b7c028c328b..08e8f700ee8 100644 --- a/stan/math/prim/prob/lognormal_lpdf.hpp +++ b/stan/math/prim/prob/lognormal_lpdf.hpp @@ -28,9 +28,9 @@ template 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_t::value, T_y>; - using T_mu_ref = ref_type_if_t::value, T_loc>; - using T_sigma_ref = ref_type_if_t::value, T_scale>; + 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; static const char* function = "lognormal_lpdf"; check_consistent_sizes(function, "Random variable", y, "Location parameter", mu, "Scale parameter", sigma); 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 8e4eb959211..e8ec741a2dc 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 @@ -90,11 +90,10 @@ return_type_t neg_binomial_2_log_glm_lpmf( using T_xbeta_tmp = typename std::conditional_t>; - using T_x_ref = ref_type_if_t::value, T_x>; - using T_alpha_ref = ref_type_if_t::value, T_alpha>; - using T_beta_ref = ref_type_if_t::value, T_beta>; - using T_phi_ref - = ref_type_if_t::value, T_precision>; + 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; + using T_phi_ref = ref_type_if_not_constant_t; const size_t N_instances = T_x_rows == 1 ? stan::math::size(y) : x.rows(); const size_t N_attributes = x.cols(); diff --git a/stan/math/prim/prob/normal_id_glm_lpdf.hpp b/stan/math/prim/prob/normal_id_glm_lpdf.hpp index c42ecdf5f7b..fe6a1084244 100644 --- a/stan/math/prim/prob/normal_id_glm_lpdf.hpp +++ b/stan/math/prim/prob/normal_id_glm_lpdf.hpp @@ -71,11 +71,11 @@ return_type_t normal_id_glm_lpdf( using T_y_scaled_tmp = typename std::conditional_t>; - using T_y_ref = ref_type_if_t::value, T_y>; - using T_x_ref = ref_type_if_t::value, T_x>; - using T_alpha_ref = ref_type_if_t::value, T_alpha>; - using T_beta_ref = ref_type_if_t::value, T_beta>; - using T_sigma_ref = ref_type_if_t::value, T_scale>; + using T_y_ref = ref_type_if_not_constant_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; + using T_sigma_ref = ref_type_if_not_constant_t; const size_t N_instances = T_x_rows == 1 ? stan::math::size(y) : x.rows(); const size_t N_attributes = x.cols(); diff --git a/stan/math/prim/prob/normal_lpdf.hpp b/stan/math/prim/prob/normal_lpdf.hpp index af473f88311..a7f238dea24 100644 --- a/stan/math/prim/prob/normal_lpdf.hpp +++ b/stan/math/prim/prob/normal_lpdf.hpp @@ -45,9 +45,9 @@ inline return_type_t normal_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_t::value, T_y>; - using T_mu_ref = ref_type_if_t::value, T_loc>; - using T_sigma_ref = ref_type_if_t::value, T_scale>; + 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; static const char* function = "normal_lpdf"; check_consistent_sizes(function, "Random variable", y, "Location parameter", mu, "Scale parameter", sigma); diff --git a/stan/math/prim/prob/normal_sufficient_lpdf.hpp b/stan/math/prim/prob/normal_sufficient_lpdf.hpp index e0df89739f3..27f8a75e5c9 100644 --- a/stan/math/prim/prob/normal_sufficient_lpdf.hpp +++ b/stan/math/prim/prob/normal_sufficient_lpdf.hpp @@ -55,11 +55,11 @@ 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; - using T_y_ref = ref_type_if_t::value, T_y>; - using T_s_ref = ref_type_if_t::value, T_s>; - using T_n_ref = ref_type_if_t::value, T_n>; - using T_mu_ref = ref_type_if_t::value, T_loc>; - using T_sigma_ref = ref_type_if_t::value, T_scale>; + using T_y_ref = ref_type_if_not_constant_t; + using T_s_ref = ref_type_if_not_constant_t; + using T_n_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; static const char* function = "normal_sufficient_lpdf"; check_consistent_sizes(function, "Location parameter sufficient statistic", y_bar, "Scale parameter sufficient statistic", diff --git a/stan/math/prim/prob/ordered_logistic_glm_lpmf.hpp b/stan/math/prim/prob/ordered_logistic_glm_lpmf.hpp index b9bf0862fbe..b7124ac1e70 100644 --- a/stan/math/prim/prob/ordered_logistic_glm_lpmf.hpp +++ b/stan/math/prim/prob/ordered_logistic_glm_lpmf.hpp @@ -63,9 +63,9 @@ return_type_t ordered_logistic_glm_lpmf( Eigen::Matrix> T_location; using T_y_ref = ref_type_t; - using T_x_ref = ref_type_if_t::value, T_x>; - using T_beta_ref = ref_type_if_t::value, T_beta>; - using T_cuts_ref = ref_type_if_t::value, T_cuts>; + using T_x_ref = ref_type_if_not_constant_t; + using T_beta_ref = ref_type_if_not_constant_t; + using T_cuts_ref = ref_type_if_not_constant_t; const size_t N_instances = T_x_rows == 1 ? stan::math::size(y) : x.rows(); const size_t N_attributes = x.cols(); diff --git a/stan/math/prim/prob/ordered_logistic_lpmf.hpp b/stan/math/prim/prob/ordered_logistic_lpmf.hpp index 143c35a557a..b7b0886e220 100644 --- a/stan/math/prim/prob/ordered_logistic_lpmf.hpp +++ b/stan/math/prim/prob/ordered_logistic_lpmf.hpp @@ -78,8 +78,8 @@ return_type_t ordered_logistic_lpmf(const T_y& y, using T_partials_return = partials_return_t; using T_cuts_val = partials_return_t; using T_y_ref = ref_type_t; - using T_lambda_ref = ref_type_if_t::value, T_loc>; - using T_cut_ref = ref_type_if_t::value, T_cut>; + using T_lambda_ref = ref_type_if_not_constant_t; + using T_cut_ref = ref_type_if_not_constant_t; using Eigen::Array; using Eigen::Dynamic; static const char* function = "ordered_logistic"; diff --git a/stan/math/prim/prob/pareto_lccdf.hpp b/stan/math/prim/prob/pareto_lccdf.hpp index 7d11e87a53a..f70e3cddc4b 100644 --- a/stan/math/prim/prob/pareto_lccdf.hpp +++ b/stan/math/prim/prob/pareto_lccdf.hpp @@ -28,9 +28,9 @@ 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_t::value, T_y>; - using T_y_min_ref = ref_type_if_t::value, T_scale>; - using T_alpha_ref = ref_type_if_t::value, T_shape>; + using T_y_ref = ref_type_if_not_constant_t; + using T_y_min_ref = ref_type_if_not_constant_t; + using T_alpha_ref = ref_type_if_not_constant_t; using std::isinf; static const char* function = "pareto_lccdf"; check_consistent_sizes(function, "Random variable", y, "Scale parameter", diff --git a/stan/math/prim/prob/pareto_lcdf.hpp b/stan/math/prim/prob/pareto_lcdf.hpp index f140905b9cb..54d6dcfeb6d 100644 --- a/stan/math/prim/prob/pareto_lcdf.hpp +++ b/stan/math/prim/prob/pareto_lcdf.hpp @@ -28,9 +28,9 @@ 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_t::value, T_y>; - using T_y_min_ref = ref_type_if_t::value, T_scale>; - using T_alpha_ref = ref_type_if_t::value, T_shape>; + using T_y_ref = ref_type_if_not_constant_t; + using T_y_min_ref = ref_type_if_not_constant_t; + using T_alpha_ref = ref_type_if_not_constant_t; using std::isinf; static const char* function = "pareto_lcdf"; check_consistent_sizes(function, "Random variable", y, "Scale parameter", diff --git a/stan/math/prim/prob/pareto_lpdf.hpp b/stan/math/prim/prob/pareto_lpdf.hpp index cab38fe86ea..4a23d0e6be4 100644 --- a/stan/math/prim/prob/pareto_lpdf.hpp +++ b/stan/math/prim/prob/pareto_lpdf.hpp @@ -28,9 +28,9 @@ 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_t::value, T_y>; - using T_y_min_ref = ref_type_if_t::value, T_scale>; - using T_alpha_ref = ref_type_if_t::value, T_shape>; + using T_y_ref = ref_type_if_not_constant_t; + using T_y_min_ref = ref_type_if_not_constant_t; + using T_alpha_ref = ref_type_if_not_constant_t; static const char* function = "pareto_lpdf"; check_consistent_sizes(function, "Random variable", y, "Scale parameter", y_min, "Shape parameter", alpha); diff --git a/stan/math/prim/prob/pareto_type_2_cdf.hpp b/stan/math/prim/prob/pareto_type_2_cdf.hpp index 01a25f88f21..c4aacfabe67 100644 --- a/stan/math/prim/prob/pareto_type_2_cdf.hpp +++ b/stan/math/prim/prob/pareto_type_2_cdf.hpp @@ -25,10 +25,10 @@ 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; - using T_y_ref = ref_type_if_t::value, T_y>; - using T_mu_ref = ref_type_if_t::value, T_loc>; - using T_lambda_ref = ref_type_if_t::value, T_scale>; - using T_alpha_ref = ref_type_if_t::value, T_shape>; + using T_y_ref = ref_type_if_not_constant_t; + using T_mu_ref = ref_type_if_not_constant_t; + using T_lambda_ref = ref_type_if_not_constant_t; + using T_alpha_ref = ref_type_if_not_constant_t; using std::pow; static const char* function = "pareto_type_2_cdf"; check_consistent_sizes(function, "Random variable", y, "Location parameter", diff --git a/stan/math/prim/prob/pareto_type_2_lccdf.hpp b/stan/math/prim/prob/pareto_type_2_lccdf.hpp index 39bd7fc1d3f..6556f94e6cb 100644 --- a/stan/math/prim/prob/pareto_type_2_lccdf.hpp +++ b/stan/math/prim/prob/pareto_type_2_lccdf.hpp @@ -25,10 +25,10 @@ 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; - using T_y_ref = ref_type_if_t::value, T_y>; - using T_mu_ref = ref_type_if_t::value, T_loc>; - using T_lambda_ref = ref_type_if_t::value, T_scale>; - using T_alpha_ref = ref_type_if_t::value, T_shape>; + using T_y_ref = ref_type_if_not_constant_t; + using T_mu_ref = ref_type_if_not_constant_t; + using T_lambda_ref = ref_type_if_not_constant_t; + using T_alpha_ref = ref_type_if_not_constant_t; static const char* function = "pareto_type_2_lccdf"; check_consistent_sizes(function, "Random variable", y, "Location parameter", mu, "Scale parameter", lambda, "Shape parameter", diff --git a/stan/math/prim/prob/pareto_type_2_lcdf.hpp b/stan/math/prim/prob/pareto_type_2_lcdf.hpp index dfad586a604..ac22927ed4b 100644 --- a/stan/math/prim/prob/pareto_type_2_lcdf.hpp +++ b/stan/math/prim/prob/pareto_type_2_lcdf.hpp @@ -25,10 +25,10 @@ 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; - using T_y_ref = ref_type_if_t::value, T_y>; - using T_mu_ref = ref_type_if_t::value, T_loc>; - using T_lambda_ref = ref_type_if_t::value, T_scale>; - using T_alpha_ref = ref_type_if_t::value, T_shape>; + using T_y_ref = ref_type_if_not_constant_t; + using T_mu_ref = ref_type_if_not_constant_t; + using T_lambda_ref = ref_type_if_not_constant_t; + using T_alpha_ref = ref_type_if_not_constant_t; using std::pow; static const char* function = "pareto_type_2_lcdf"; check_consistent_sizes(function, "Random variable", y, "Location parameter", diff --git a/stan/math/prim/prob/pareto_type_2_lpdf.hpp b/stan/math/prim/prob/pareto_type_2_lpdf.hpp index ffda52e1629..c41eee893a4 100644 --- a/stan/math/prim/prob/pareto_type_2_lpdf.hpp +++ b/stan/math/prim/prob/pareto_type_2_lpdf.hpp @@ -28,10 +28,10 @@ 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; - using T_y_ref = ref_type_if_t::value, T_y>; - using T_mu_ref = ref_type_if_t::value, T_loc>; - using T_lambda_ref = ref_type_if_t::value, T_scale>; - using T_alpha_ref = ref_type_if_t::value, T_shape>; + using T_y_ref = ref_type_if_not_constant_t; + using T_mu_ref = ref_type_if_not_constant_t; + using T_lambda_ref = ref_type_if_not_constant_t; + using T_alpha_ref = ref_type_if_not_constant_t; static const char* function = "pareto_type_2_lpdf"; check_consistent_sizes(function, "Random variable", y, "Location parameter", mu, "Scale parameter", lambda, "Shape parameter", diff --git a/stan/math/prim/prob/poisson_cdf.hpp b/stan/math/prim/prob/poisson_cdf.hpp index 69d95bbd355..446487136f1 100644 --- a/stan/math/prim/prob/poisson_cdf.hpp +++ b/stan/math/prim/prob/poisson_cdf.hpp @@ -26,8 +26,8 @@ namespace math { template 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_t::value, T_n>; - using T_lambda_ref = ref_type_if_t::value, T_rate>; + using T_n_ref = ref_type_if_not_constant_t; + using T_lambda_ref = ref_type_if_not_constant_t; using std::pow; static const char* function = "poisson_cdf"; check_consistent_sizes(function, "Random variable", n, "Rate parameter", diff --git a/stan/math/prim/prob/poisson_lccdf.hpp b/stan/math/prim/prob/poisson_lccdf.hpp index 6faf06af3e9..d95ecb77c02 100644 --- a/stan/math/prim/prob/poisson_lccdf.hpp +++ b/stan/math/prim/prob/poisson_lccdf.hpp @@ -27,8 +27,8 @@ namespace math { template 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_t::value, T_n>; - using T_lambda_ref = ref_type_if_t::value, T_rate>; + using T_n_ref = ref_type_if_not_constant_t; + using T_lambda_ref = ref_type_if_not_constant_t; static const char* function = "poisson_lccdf"; check_consistent_sizes(function, "Random variable", n, "Rate parameter", lambda); diff --git a/stan/math/prim/prob/poisson_lcdf.hpp b/stan/math/prim/prob/poisson_lcdf.hpp index 8d5134c6fa5..24962b283f5 100644 --- a/stan/math/prim/prob/poisson_lcdf.hpp +++ b/stan/math/prim/prob/poisson_lcdf.hpp @@ -27,8 +27,8 @@ namespace math { template 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_t::value, T_n>; - using T_lambda_ref = ref_type_if_t::value, T_rate>; + using T_n_ref = ref_type_if_not_constant_t; + using T_lambda_ref = ref_type_if_not_constant_t; static const char* function = "poisson_lcdf"; check_consistent_sizes(function, "Random variable", n, "Rate parameter", lambda); diff --git a/stan/math/prim/prob/poisson_log_glm_lpmf.hpp b/stan/math/prim/prob/poisson_log_glm_lpmf.hpp index f28a2b6b380..9e081bfbfe6 100644 --- a/stan/math/prim/prob/poisson_log_glm_lpmf.hpp +++ b/stan/math/prim/prob/poisson_log_glm_lpmf.hpp @@ -68,9 +68,9 @@ return_type_t poisson_log_glm_lpmf(const T_y& y, using T_xbeta_tmp = typename std::conditional_t>; - using T_x_ref = ref_type_if_t::value, T_x>; - using T_alpha_ref = ref_type_if_t::value, T_alpha>; - using T_beta_ref = ref_type_if_t::value, T_beta>; + 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; const size_t N_instances = T_x_rows == 1 ? stan::math::size(y) : x.rows(); const size_t N_attributes = x.cols(); diff --git a/stan/math/prim/prob/poisson_log_lpmf.hpp b/stan/math/prim/prob/poisson_log_lpmf.hpp index ec6f3c90113..c1c3538f919 100644 --- a/stan/math/prim/prob/poisson_log_lpmf.hpp +++ b/stan/math/prim/prob/poisson_log_lpmf.hpp @@ -29,9 +29,8 @@ template 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_t::value, T_n>; - using T_alpha_ref - = ref_type_if_t::value, T_log_rate>; + using T_n_ref = ref_type_if_not_constant_t; + using T_alpha_ref = ref_type_if_not_constant_t; using std::isinf; static const char* function = "poisson_log_lpmf"; check_consistent_sizes(function, "Random variable", n, "Log rate parameter", diff --git a/stan/math/prim/prob/poisson_lpmf.hpp b/stan/math/prim/prob/poisson_lpmf.hpp index 66bde4fb345..289d0c12c6f 100644 --- a/stan/math/prim/prob/poisson_lpmf.hpp +++ b/stan/math/prim/prob/poisson_lpmf.hpp @@ -28,8 +28,8 @@ template * = nullptr> 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_t::value, T_n>; - using T_lambda_ref = ref_type_if_t::value, T_rate>; + using T_n_ref = ref_type_if_not_constant_t; + using T_lambda_ref = ref_type_if_not_constant_t; using std::isinf; static const char* function = "poisson_lpmf"; check_consistent_sizes(function, "Random variable", n, "Rate parameter", diff --git a/stan/math/prim/prob/rayleigh_cdf.hpp b/stan/math/prim/prob/rayleigh_cdf.hpp index 4ae44c76048..231256831cb 100644 --- a/stan/math/prim/prob/rayleigh_cdf.hpp +++ b/stan/math/prim/prob/rayleigh_cdf.hpp @@ -24,8 +24,8 @@ template * = nullptr> 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_t::value, T_y>; - using T_sigma_ref = ref_type_if_t::value, T_scale>; + using T_y_ref = ref_type_if_not_constant_t; + using T_sigma_ref = ref_type_if_not_constant_t; static const char* function = "rayleigh_cdf"; check_consistent_sizes(function, "Random variable", y, "Scale parameter", sigma); diff --git a/stan/math/prim/prob/rayleigh_lccdf.hpp b/stan/math/prim/prob/rayleigh_lccdf.hpp index f8ea1a7b092..c72090b8c09 100644 --- a/stan/math/prim/prob/rayleigh_lccdf.hpp +++ b/stan/math/prim/prob/rayleigh_lccdf.hpp @@ -22,8 +22,8 @@ template * = nullptr> 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_t::value, T_y>; - using T_sigma_ref = ref_type_if_t::value, T_scale>; + using T_y_ref = ref_type_if_not_constant_t; + using T_sigma_ref = ref_type_if_not_constant_t; static const char* function = "rayleigh_lccdf"; check_consistent_sizes(function, "Random variable", y, "Scale parameter", sigma); diff --git a/stan/math/prim/prob/rayleigh_lcdf.hpp b/stan/math/prim/prob/rayleigh_lcdf.hpp index 394c9607e35..cb07f4707e0 100644 --- a/stan/math/prim/prob/rayleigh_lcdf.hpp +++ b/stan/math/prim/prob/rayleigh_lcdf.hpp @@ -24,8 +24,8 @@ template * = nullptr> 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_t::value, T_y>; - using T_sigma_ref = ref_type_if_t::value, T_scale>; + using T_y_ref = ref_type_if_not_constant_t; + using T_sigma_ref = ref_type_if_not_constant_t; static const char* function = "rayleigh_lcdf"; check_consistent_sizes(function, "Random variable", y, "Scale parameter", sigma); diff --git a/stan/math/prim/prob/rayleigh_lpdf.hpp b/stan/math/prim/prob/rayleigh_lpdf.hpp index ef2dab8ec18..a00d34d1259 100644 --- a/stan/math/prim/prob/rayleigh_lpdf.hpp +++ b/stan/math/prim/prob/rayleigh_lpdf.hpp @@ -24,8 +24,8 @@ template * = nullptr> 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_t::value, T_y>; - using T_sigma_ref = ref_type_if_t::value, T_scale>; + using T_y_ref = ref_type_if_not_constant_t; + using T_sigma_ref = ref_type_if_not_constant_t; static const char* function = "rayleigh_lpdf"; check_consistent_sizes(function, "Random variable", y, "Scale parameter", sigma); diff --git a/stan/math/prim/prob/skew_double_exponential_lpdf.hpp b/stan/math/prim/prob/skew_double_exponential_lpdf.hpp index 415f6ab6f59..53bc9c5b718 100644 --- a/stan/math/prim/prob/skew_double_exponential_lpdf.hpp +++ b/stan/math/prim/prob/skew_double_exponential_lpdf.hpp @@ -44,10 +44,10 @@ 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_t::value, T_y>; - using T_mu_ref = ref_type_if_t::value, T_loc>; - using T_sigma_ref = ref_type_if_t::value, T_scale>; - using T_tau_ref = ref_type_if_t::value, T_skewness>; + 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; + using T_tau_ref = ref_type_if_not_constant_t; static const char* function = "skew_double_exponential_lpdf"; check_consistent_sizes(function, "Random variable", y, "Location parameter", mu, "Shape parameter", sigma, "Skewness parameter", diff --git a/stan/math/prim/prob/skew_normal_cdf.hpp b/stan/math/prim/prob/skew_normal_cdf.hpp index 96ab6889fb9..ee6745cf409 100644 --- a/stan/math/prim/prob/skew_normal_cdf.hpp +++ b/stan/math/prim/prob/skew_normal_cdf.hpp @@ -28,10 +28,10 @@ template 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_t::value, T_y>; - using T_mu_ref = ref_type_if_t::value, T_loc>; - using T_sigma_ref = ref_type_if_t::value, T_scale>; - using T_alpha_ref = ref_type_if_t::value, T_shape>; + 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; + using T_alpha_ref = ref_type_if_not_constant_t; static const char* function = "skew_normal_cdf"; check_consistent_sizes(function, "Random variable", y, "Location parameter", mu, "Scale parameter", sigma, "Shape paramter", alpha); diff --git a/stan/math/prim/prob/skew_normal_lccdf.hpp b/stan/math/prim/prob/skew_normal_lccdf.hpp index 64016860a28..500e962a95e 100644 --- a/stan/math/prim/prob/skew_normal_lccdf.hpp +++ b/stan/math/prim/prob/skew_normal_lccdf.hpp @@ -26,10 +26,10 @@ template 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_t::value, T_y>; - using T_mu_ref = ref_type_if_t::value, T_loc>; - using T_sigma_ref = ref_type_if_t::value, T_scale>; - using T_alpha_ref = ref_type_if_t::value, T_shape>; + 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; + using T_alpha_ref = ref_type_if_not_constant_t; static const char* function = "skew_normal_lccdf"; check_consistent_sizes(function, "Random variable", y, "Location parameter", mu, "Scale parameter", sigma, "Shape paramter", alpha); diff --git a/stan/math/prim/prob/skew_normal_lcdf.hpp b/stan/math/prim/prob/skew_normal_lcdf.hpp index b34fe1dd95a..64d2077d7ef 100644 --- a/stan/math/prim/prob/skew_normal_lcdf.hpp +++ b/stan/math/prim/prob/skew_normal_lcdf.hpp @@ -28,10 +28,10 @@ template 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_t::value, T_y>; - using T_mu_ref = ref_type_if_t::value, T_loc>; - using T_sigma_ref = ref_type_if_t::value, T_scale>; - using T_alpha_ref = ref_type_if_t::value, T_shape>; + 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; + using T_alpha_ref = ref_type_if_not_constant_t; static const char* function = "skew_normal_lcdf"; check_consistent_sizes(function, "Random variable", y, "Location parameter", mu, "Scale parameter", sigma, "Shape parameter", diff --git a/stan/math/prim/prob/skew_normal_lpdf.hpp b/stan/math/prim/prob/skew_normal_lpdf.hpp index 1e189a6ee5a..a1a9fb41991 100644 --- a/stan/math/prim/prob/skew_normal_lpdf.hpp +++ b/stan/math/prim/prob/skew_normal_lpdf.hpp @@ -29,10 +29,10 @@ template 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_t::value, T_y>; - using T_mu_ref = ref_type_if_t::value, T_loc>; - using T_sigma_ref = ref_type_if_t::value, T_scale>; - using T_alpha_ref = ref_type_if_t::value, T_shape>; + 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; + using T_alpha_ref = ref_type_if_not_constant_t; static const char* function = "skew_normal_lpdf"; check_consistent_sizes(function, "Random variable", y, "Location parameter", mu, "Scale parameter", sigma, "Shape paramter", alpha); diff --git a/stan/math/prim/prob/student_t_lpdf.hpp b/stan/math/prim/prob/student_t_lpdf.hpp index 1e17400a9c6..cc593ae2985 100644 --- a/stan/math/prim/prob/student_t_lpdf.hpp +++ b/stan/math/prim/prob/student_t_lpdf.hpp @@ -61,10 +61,10 @@ return_type_t student_t_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_t::value, T_y>; - using T_nu_ref = ref_type_if_t::value, T_dof>; - using T_mu_ref = ref_type_if_t::value, T_loc>; - using T_sigma_ref = ref_type_if_t::value, T_scale>; + using T_y_ref = ref_type_if_not_constant_t; + using T_nu_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; static const char* function = "student_t_lpdf"; check_consistent_sizes(function, "Random variable", y, "Degrees of freedom parameter", nu, diff --git a/stan/math/prim/prob/uniform_cdf.hpp b/stan/math/prim/prob/uniform_cdf.hpp index d9687002eea..1be99363bf7 100644 --- a/stan/math/prim/prob/uniform_cdf.hpp +++ b/stan/math/prim/prob/uniform_cdf.hpp @@ -23,9 +23,9 @@ template 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_t::value, T_y>; - using T_alpha_ref = ref_type_if_t::value, T_low>; - using T_beta_ref = ref_type_if_t::value, T_high>; + using T_y_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; static const char* function = "uniform_cdf"; check_consistent_sizes(function, "Random variable", y, "Lower bound parameter", alpha, diff --git a/stan/math/prim/prob/uniform_lccdf.hpp b/stan/math/prim/prob/uniform_lccdf.hpp index 77de727b79a..37f5a5b45f9 100644 --- a/stan/math/prim/prob/uniform_lccdf.hpp +++ b/stan/math/prim/prob/uniform_lccdf.hpp @@ -26,9 +26,9 @@ 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_t::value, T_y>; - using T_alpha_ref = ref_type_if_t::value, T_low>; - using T_beta_ref = ref_type_if_t::value, T_high>; + using T_y_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; static const char* function = "uniform_lccdf"; check_consistent_sizes(function, "Random variable", y, "Lower bound parameter", alpha, diff --git a/stan/math/prim/prob/uniform_lcdf.hpp b/stan/math/prim/prob/uniform_lcdf.hpp index fadac176836..c35b4e9a20b 100644 --- a/stan/math/prim/prob/uniform_lcdf.hpp +++ b/stan/math/prim/prob/uniform_lcdf.hpp @@ -25,9 +25,9 @@ template 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_t::value, T_y>; - using T_alpha_ref = ref_type_if_t::value, T_low>; - using T_beta_ref = ref_type_if_t::value, T_high>; + using T_y_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; static const char* function = "uniform_lcdf"; check_consistent_sizes(function, "Random variable", y, "Lower bound parameter", alpha, diff --git a/stan/math/prim/prob/uniform_lpdf.hpp b/stan/math/prim/prob/uniform_lpdf.hpp index 39c91214cef..252a1584308 100644 --- a/stan/math/prim/prob/uniform_lpdf.hpp +++ b/stan/math/prim/prob/uniform_lpdf.hpp @@ -47,9 +47,9 @@ template 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_t::value, T_y>; - using T_alpha_ref = ref_type_if_t::value, T_low>; - using T_beta_ref = ref_type_if_t::value, T_high>; + using T_y_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; static const char* function = "uniform_lpdf"; check_consistent_sizes(function, "Random variable", y, "Lower bound parameter", alpha, diff --git a/stan/math/prim/prob/von_mises_lpdf.hpp b/stan/math/prim/prob/von_mises_lpdf.hpp index 15af9fdc71c..7e4bfb7d2a4 100644 --- a/stan/math/prim/prob/von_mises_lpdf.hpp +++ b/stan/math/prim/prob/von_mises_lpdf.hpp @@ -26,9 +26,9 @@ template 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_t::value, T_y>; - using T_mu_ref = ref_type_if_t::value, T_loc>; - using T_kappa_ref = ref_type_if_t::value, T_scale>; + using T_y_ref = ref_type_if_not_constant_t; + using T_mu_ref = ref_type_if_not_constant_t; + using T_kappa_ref = ref_type_if_not_constant_t; static char const* const function = "von_mises_lpdf"; check_consistent_sizes(function, "Random variable", y, "Location parameter", mu, "Scale parameter", kappa); diff --git a/stan/math/prim/prob/weibull_cdf.hpp b/stan/math/prim/prob/weibull_cdf.hpp index 50c54a7f2f2..abf6c71a33d 100644 --- a/stan/math/prim/prob/weibull_cdf.hpp +++ b/stan/math/prim/prob/weibull_cdf.hpp @@ -40,9 +40,9 @@ 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_t::value, T_y>; - using T_alpha_ref = ref_type_if_t::value, T_shape>; - using T_sigma_ref = ref_type_if_t::value, T_scale>; + 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; using std::pow; static const char* function = "weibull_cdf"; diff --git a/stan/math/prim/prob/weibull_lccdf.hpp b/stan/math/prim/prob/weibull_lccdf.hpp index ea711cc9f59..031051f486a 100644 --- a/stan/math/prim/prob/weibull_lccdf.hpp +++ b/stan/math/prim/prob/weibull_lccdf.hpp @@ -38,9 +38,9 @@ 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_t::value, T_y>; - using T_alpha_ref = ref_type_if_t::value, T_shape>; - using T_sigma_ref = ref_type_if_t::value, T_scale>; + 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; using std::pow; static const char* function = "weibull_lccdf"; diff --git a/stan/math/prim/prob/weibull_lcdf.hpp b/stan/math/prim/prob/weibull_lcdf.hpp index a8e256b868c..34e2b65d1f3 100644 --- a/stan/math/prim/prob/weibull_lcdf.hpp +++ b/stan/math/prim/prob/weibull_lcdf.hpp @@ -40,9 +40,9 @@ return_type_t weibull_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_if_t::value, T_y>; - using T_alpha_ref = ref_type_if_t::value, T_shape>; - using T_sigma_ref = ref_type_if_t::value, T_scale>; + 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; using std::pow; static const char* function = "weibull_lcdf"; diff --git a/stan/math/prim/prob/weibull_lpdf.hpp b/stan/math/prim/prob/weibull_lpdf.hpp index 7b141b7b014..66df5a21303 100644 --- a/stan/math/prim/prob/weibull_lpdf.hpp +++ b/stan/math/prim/prob/weibull_lpdf.hpp @@ -41,9 +41,9 @@ 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_t::value, T_y>; - using T_alpha_ref = ref_type_if_t::value, T_shape>; - using T_sigma_ref = ref_type_if_t::value, T_scale>; + 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; using std::pow; static const char* function = "weibull_lpdf"; check_consistent_sizes(function, "Random variable", y, "Shape parameter",