From d4cd9cbd3431bd04e7ab3e2afa93729b1b270194 Mon Sep 17 00:00:00 2001 From: stevebronder Date: Tue, 5 Jan 2021 21:55:35 -0700 Subject: [PATCH 01/17] adds val() method for seq_scalar_view and vector_seq_view --- stan/math/prim/meta/scalar_seq_view.hpp | 102 +++++++++++++++--- stan/math/prim/meta/vector_seq_view.hpp | 43 ++++++-- stan/math/prim/prob/bernoulli_cdf.hpp | 6 +- stan/math/prim/prob/bernoulli_lccdf.hpp | 4 +- stan/math/prim/prob/bernoulli_lcdf.hpp | 6 +- stan/math/prim/prob/bernoulli_lpmf.hpp | 8 +- stan/math/prim/prob/beta_binomial_cdf.hpp | 12 +-- stan/math/prim/prob/beta_binomial_lccdf.hpp | 12 +-- stan/math/prim/prob/beta_binomial_lcdf.hpp | 10 +- stan/math/prim/prob/beta_binomial_lpmf.hpp | 20 ++-- stan/math/prim/prob/beta_cdf.hpp | 14 +-- stan/math/prim/prob/beta_lccdf.hpp | 12 +-- stan/math/prim/prob/beta_lcdf.hpp | 12 +-- stan/math/prim/prob/beta_proportion_lccdf.hpp | 12 +-- stan/math/prim/prob/beta_proportion_lcdf.hpp | 12 +-- stan/math/prim/prob/binomial_cdf.hpp | 8 +- stan/math/prim/prob/binomial_lccdf.hpp | 8 +- stan/math/prim/prob/binomial_lcdf.hpp | 8 +- stan/math/prim/prob/binomial_lpmf.hpp | 10 +- stan/math/prim/prob/cauchy_cdf.hpp | 10 +- stan/math/prim/prob/cauchy_lccdf.hpp | 8 +- stan/math/prim/prob/cauchy_lcdf.hpp | 8 +- stan/math/prim/prob/chi_square_cdf.hpp | 10 +- stan/math/prim/prob/chi_square_lccdf.hpp | 10 +- stan/math/prim/prob/chi_square_lcdf.hpp | 10 +- stan/math/prim/prob/dirichlet_lpdf.hpp | 4 +- stan/math/prim/prob/discrete_range_lpmf.hpp | 8 +- .../prim/prob/double_exponential_lccdf.hpp | 6 +- .../prim/prob/double_exponential_lcdf.hpp | 6 +- stan/math/prim/prob/frechet_cdf.hpp | 6 +- stan/math/prim/prob/frechet_lccdf.hpp | 6 +- stan/math/prim/prob/frechet_lcdf.hpp | 6 +- stan/math/prim/prob/gamma_cdf.hpp | 12 +-- stan/math/prim/prob/gamma_lccdf.hpp | 12 +-- stan/math/prim/prob/gamma_lcdf.hpp | 12 +-- stan/math/prim/prob/inv_chi_square_cdf.hpp | 10 +- stan/math/prim/prob/inv_chi_square_lccdf.hpp | 10 +- stan/math/prim/prob/inv_chi_square_lcdf.hpp | 10 +- stan/math/prim/prob/inv_gamma_cdf.hpp | 12 +-- stan/math/prim/prob/inv_gamma_lccdf.hpp | 12 +-- stan/math/prim/prob/inv_gamma_lcdf.hpp | 12 +-- stan/math/prim/prob/logistic_cdf.hpp | 12 +-- stan/math/prim/prob/logistic_lccdf.hpp | 12 +-- stan/math/prim/prob/logistic_lcdf.hpp | 12 +-- stan/math/prim/prob/neg_binomial_2_cdf.hpp | 16 +-- .../prim/prob/neg_binomial_2_log_lpmf.hpp | 4 +- stan/math/prim/prob/neg_binomial_2_lpmf.hpp | 4 +- stan/math/prim/prob/neg_binomial_cdf.hpp | 16 +-- stan/math/prim/prob/neg_binomial_lccdf.hpp | 18 ++-- stan/math/prim/prob/neg_binomial_lcdf.hpp | 18 ++-- stan/math/prim/prob/neg_binomial_lpmf.hpp | 12 +-- stan/math/prim/prob/normal_cdf.hpp | 6 +- stan/math/prim/prob/normal_lccdf.hpp | 6 +- stan/math/prim/prob/normal_lcdf.hpp | 6 +- stan/math/prim/prob/pareto_cdf.hpp | 10 +- .../prim/prob/scaled_inv_chi_square_cdf.hpp | 12 +-- .../prim/prob/scaled_inv_chi_square_lccdf.hpp | 12 +-- .../prim/prob/scaled_inv_chi_square_lcdf.hpp | 12 +-- .../prim/prob/scaled_inv_chi_square_lpdf.hpp | 14 +-- stan/math/prim/prob/std_normal_cdf.hpp | 2 +- stan/math/prim/prob/std_normal_lccdf.hpp | 2 +- stan/math/prim/prob/std_normal_lcdf.hpp | 2 +- stan/math/prim/prob/std_normal_lpdf.hpp | 2 +- stan/math/prim/prob/student_t_cdf.hpp | 12 +-- stan/math/prim/prob/student_t_lccdf.hpp | 12 +-- stan/math/prim/prob/student_t_lcdf.hpp | 12 +-- 66 files changed, 437 insertions(+), 328 deletions(-) diff --git a/stan/math/prim/meta/scalar_seq_view.hpp b/stan/math/prim/meta/scalar_seq_view.hpp index 3ffc4804d6e..b4f3cc168eb 100644 --- a/stan/math/prim/meta/scalar_seq_view.hpp +++ b/stan/math/prim/meta/scalar_seq_view.hpp @@ -5,6 +5,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -21,8 +24,7 @@ template class scalar_seq_view; template -class scalar_seq_view< - C, std::enable_if_t>::value>> { +class scalar_seq_view> { public: template , plain_type_t>> @@ -33,33 +35,109 @@ class scalar_seq_view< * @param i index * @return the element at the specified position in the container */ - decltype(auto) operator[](int i) const { return c_[i]; } - decltype(auto) operator[](int i) { return c_[i]; } + inline auto operator[](size_t i) const { return c_.coeffRef(i); } - int size() const { return c_.size(); } + inline auto size() const noexcept { return c_.size(); } + + template * = nullptr> + inline auto val(size_t i) const { + return c_.coeffRef(i); + } + + template * = nullptr> + inline auto val(size_t i) const { + return c_.coeffRef(i).val(); + } private: ref_type_t c_; }; +template +class scalar_seq_view> { + public: + template , plain_type_t>> + explicit scalar_seq_view(T&& c) : c_(std::forward(c)) {} + + /** \ingroup type_trait + * Segfaults if out of bounds. + * @param i index + * @return the element at the specified position in the container + */ + inline auto operator[](size_t i) const { return c_.val().coeffRef(i); } + + inline auto size() const noexcept { return c_.size(); } + + template * = nullptr> + inline auto val(size_t i) const { + return c_.val().coeffRef(i); + } + + template * = nullptr> + inline auto val(size_t i) const { + return c_.val().coeffRef(i); + } + + private: + std::decay_t c_; +}; + +template +class scalar_seq_view> { + public: + template , plain_type_t>> + explicit scalar_seq_view(T&& c) : c_(std::forward(c)) {} + + /** \ingroup type_trait + * Segfaults if out of bounds. + * @param i index + * @return the element at the specified position in the container + */ + inline auto operator[](size_t i) const { return c_.coeffRef(i); } + inline auto size() const noexcept { return c_.size(); } + + template * = nullptr> + inline auto val(size_t i) const { + return c_.coeffRef(i); + } + + template * = nullptr> + inline auto val(size_t i) const { + return c_.coeffRef(i).val(); + } + + private: + const C& c_; +}; + /** \ingroup type_trait * This specialization handles wrapping a scalar as if it were a sequence. * * @tparam T the scalar type */ template -class scalar_seq_view< - C, std::enable_if_t>::value>> { +class scalar_seq_view> { public: - explicit scalar_seq_view(const C& t) : t_(t) {} + explicit scalar_seq_view(const C& t) noexcept : t_(t) {} + + inline auto operator[](int /* i */) const noexcept { return t_; } + + template * = nullptr> + inline auto val(int /* i */) const noexcept { + return t_; + } - auto& operator[](int /* i */) const { return t_; } - auto& operator[](int /* i */) { return t_; } + template * = nullptr> + inline auto val(int /* i */) const noexcept { + return t_.val(); + } - int size() const { return 1; } + static constexpr auto size() { return 1; } private: - C t_; + std::decay_t t_; }; } // namespace stan #endif diff --git a/stan/math/prim/meta/vector_seq_view.hpp b/stan/math/prim/meta/vector_seq_view.hpp index 292e74b2e52..8d28b72306b 100644 --- a/stan/math/prim/meta/vector_seq_view.hpp +++ b/stan/math/prim/meta/vector_seq_view.hpp @@ -7,6 +7,16 @@ namespace stan { +template * = nullptr> +inline T value_of(T&& x); + +template * = nullptr> +inline auto value_of(const std::vector& x); + +template * = nullptr, + require_not_st_arithmetic* = nullptr> +inline auto value_of(EigMat&& M); + /** \ingroup type_trait * This class provides a low-cost wrapper for situations where you either need * an Eigen Vector or RowVector or a std::vector of them and you want to be @@ -33,11 +43,21 @@ class vector_seq_view {}; * @tparam T the type of the underlying Vector */ template -class vector_seq_view> { +class vector_seq_view> { public: explicit vector_seq_view(const T& m) : m_(m) {} - int size() const { return 1; } - const ref_type_t& operator[](int /* i */) const { return m_; } + static constexpr auto size() { return 1; } + inline const auto& operator[](size_t /* i */) const noexcept { return m_; } + + template * = nullptr> + inline const auto& val(size_t /* i */) const noexcept { + return m_; + } + + template * = nullptr> + inline const auto& val(size_t /* i */) const noexcept { + return m_.val(); + } private: const ref_type_t m_; @@ -57,9 +77,20 @@ class vector_seq_view> { template class vector_seq_view> { public: - explicit vector_seq_view(const T& v) : v_(v) {} - int size() const { return v_.size(); } - const value_type_t& operator[](int i) const { return v_[i]; } + explicit vector_seq_view(const T& v) noexcept : v_(v) {} + inline auto size() const noexcept { return v_.size(); } + + inline const auto& operator[](size_t i) const { return v_[i]; } + + template * = nullptr> + inline const auto& val(size_t i) const { + return v_[i]; + } + + template * = nullptr> + inline const auto& val(size_t i) const { + return value_of(v_[i]); + } private: const T& v_; diff --git a/stan/math/prim/prob/bernoulli_cdf.hpp b/stan/math/prim/prob/bernoulli_cdf.hpp index 4132f539d1a..cf6a28db813 100644 --- a/stan/math/prim/prob/bernoulli_cdf.hpp +++ b/stan/math/prim/prob/bernoulli_cdf.hpp @@ -49,7 +49,7 @@ return_type_t bernoulli_cdf(const T_n& n, const T_prob& theta) { // Explicit return for extreme values // The gradients are technically ill-defined, but treated as zero for (size_t i = 0; i < stan::math::size(n); i++) { - if (value_of(n_vec[i]) < 0) { + if (n_vec.val(i) < 0) { return ops_partials.build(0.0); } } @@ -57,11 +57,11 @@ return_type_t bernoulli_cdf(const T_n& n, const T_prob& theta) { for (size_t i = 0; i < max_size_seq_view; i++) { // Explicit results for extreme values // The gradients are technically ill-defined, but treated as zero - if (value_of(n_vec[i]) >= 1) { + if (n_vec.val(i) >= 1) { continue; } - const T_partials_return Pi = 1 - value_of(theta_vec[i]); + const T_partials_return Pi = 1 - theta_vec.val(i); P *= Pi; diff --git a/stan/math/prim/prob/bernoulli_lccdf.hpp b/stan/math/prim/prob/bernoulli_lccdf.hpp index ecb34c08998..ef3fab1b198 100644 --- a/stan/math/prim/prob/bernoulli_lccdf.hpp +++ b/stan/math/prim/prob/bernoulli_lccdf.hpp @@ -53,7 +53,7 @@ return_type_t bernoulli_lccdf(const T_n& n, const T_prob& theta) { // Explicit return for extreme values // The gradients are technically ill-defined, but treated as zero for (size_t i = 0; i < stan::math::size(n); i++) { - const double n_dbl = value_of(n_vec[i]); + const double n_dbl = n_vec.val(i); if (n_dbl < 0) { return ops_partials.build(0.0); } @@ -63,7 +63,7 @@ return_type_t bernoulli_lccdf(const T_n& n, const T_prob& theta) { } for (size_t i = 0; i < max_size_seq_view; i++) { - const T_partials_return Pi = value_of(theta_vec[i]); + const T_partials_return Pi = theta_vec.val(i); P += log(Pi); diff --git a/stan/math/prim/prob/bernoulli_lcdf.hpp b/stan/math/prim/prob/bernoulli_lcdf.hpp index 114ad2679eb..c9521163d76 100644 --- a/stan/math/prim/prob/bernoulli_lcdf.hpp +++ b/stan/math/prim/prob/bernoulli_lcdf.hpp @@ -53,7 +53,7 @@ return_type_t bernoulli_lcdf(const T_n& n, const T_prob& theta) { // Explicit return for extreme values // The gradients are technically ill-defined, but treated as zero for (size_t i = 0; i < stan::math::size(n); i++) { - if (value_of(n_vec[i]) < 0) { + if (n_vec.val(i) < 0) { return ops_partials.build(NEGATIVE_INFTY); } } @@ -61,11 +61,11 @@ return_type_t bernoulli_lcdf(const T_n& n, const T_prob& theta) { for (size_t i = 0; i < max_size_seq_view; i++) { // Explicit results for extreme values // The gradients are technically ill-defined, but treated as zero - if (value_of(n_vec[i]) >= 1) { + if (n_vec.val(i) >= 1) { continue; } - const T_partials_return Pi = 1 - value_of(theta_vec[i]); + const T_partials_return Pi = 1 - theta_vec.val(i); P += log(Pi); diff --git a/stan/math/prim/prob/bernoulli_lpmf.hpp b/stan/math/prim/prob/bernoulli_lpmf.hpp index c29d701799a..8b5f0669691 100644 --- a/stan/math/prim/prob/bernoulli_lpmf.hpp +++ b/stan/math/prim/prob/bernoulli_lpmf.hpp @@ -60,9 +60,9 @@ return_type_t bernoulli_lpmf(const T_n& n, const T_prob& theta) { if (size(theta) == 1) { size_t sum = 0; for (size_t n = 0; n < N; n++) { - sum += value_of(n_vec[n]); + sum += n_vec.val(n); } - const T_partials_return theta_dbl = value_of(theta_vec[0]); + const T_partials_return theta_dbl = theta_vec.val(0); // avoid nans when sum == N or sum == 0 if (sum == N) { logp += N * log(theta_dbl); @@ -88,8 +88,8 @@ return_type_t bernoulli_lpmf(const T_n& n, const T_prob& theta) { } } else { for (size_t n = 0; n < N; n++) { - const int n_int = value_of(n_vec[n]); - const T_partials_return theta_dbl = value_of(theta_vec[n]); + const int n_int = n_vec.val(n); + const T_partials_return theta_dbl = theta_vec.val(n); if (n_int == 1) { logp += log(theta_dbl); diff --git a/stan/math/prim/prob/beta_binomial_cdf.hpp b/stan/math/prim/prob/beta_binomial_cdf.hpp index 2913ffac839..ab2b90abae0 100644 --- a/stan/math/prim/prob/beta_binomial_cdf.hpp +++ b/stan/math/prim/prob/beta_binomial_cdf.hpp @@ -78,7 +78,7 @@ return_type_t beta_binomial_cdf(const T_n& n, const T_N& N, // Explicit return for extreme values // The gradients are technically ill-defined, but treated as zero for (size_t i = 0; i < stan::math::size(n); i++) { - if (value_of(n_vec[i]) < 0) { + if (n_vec.val(i) < 0) { return ops_partials.build(0.0); } } @@ -86,14 +86,14 @@ return_type_t beta_binomial_cdf(const T_n& n, const T_N& N, for (size_t i = 0; i < max_size_seq_view; i++) { // Explicit results for extreme values // The gradients are technically ill-defined, but treated as zero - if (value_of(n_vec[i]) >= value_of(N_vec[i])) { + if (n_vec.val(i) >= N_vec.val(i)) { continue; } - const T_partials_return n_dbl = value_of(n_vec[i]); - const T_partials_return N_dbl = value_of(N_vec[i]); - const T_partials_return alpha_dbl = value_of(alpha_vec[i]); - const T_partials_return beta_dbl = value_of(beta_vec[i]); + const T_partials_return n_dbl = n_vec.val(i); + const T_partials_return N_dbl = n_vec.val(i); + const T_partials_return alpha_dbl = n_vec.val(i); + const T_partials_return beta_dbl = n_vec.val(i); const T_partials_return N_minus_n = N_dbl - n_dbl; const T_partials_return mu = alpha_dbl + n_dbl + 1; const T_partials_return nu = beta_dbl + N_minus_n - 1; diff --git a/stan/math/prim/prob/beta_binomial_lccdf.hpp b/stan/math/prim/prob/beta_binomial_lccdf.hpp index c1c38c2149f..ec5f4c48ce0 100644 --- a/stan/math/prim/prob/beta_binomial_lccdf.hpp +++ b/stan/math/prim/prob/beta_binomial_lccdf.hpp @@ -80,7 +80,7 @@ return_type_t beta_binomial_lccdf(const T_n& n, const T_N& N, // Explicit return for extreme values // The gradients are technically ill-defined, but treated as zero for (size_t i = 0; i < stan::math::size(n); i++) { - if (value_of(n_vec[i]) < 0) { + if (n_vec.val(i) < 0) { return ops_partials.build(0.0); } } @@ -88,14 +88,14 @@ return_type_t beta_binomial_lccdf(const T_n& n, const T_N& N, for (size_t i = 0; i < max_size_seq_view; i++) { // Explicit results for extreme values // The gradients are technically ill-defined, but treated as neg infinity - if (value_of(n_vec[i]) >= value_of(N_vec[i])) { + if (n_vec.val(i) >= N_vec.val(i)) { return ops_partials.build(negative_infinity()); } - const T_partials_return n_dbl = value_of(n_vec[i]); - const T_partials_return N_dbl = value_of(N_vec[i]); - const T_partials_return alpha_dbl = value_of(alpha_vec[i]); - const T_partials_return beta_dbl = value_of(beta_vec[i]); + const T_partials_return n_dbl = n_vec.val(i); + const T_partials_return N_dbl = n_vec.val(i); + const T_partials_return alpha_dbl = n_vec.val(i); + const T_partials_return beta_dbl = n_vec.val(i); const T_partials_return mu = alpha_dbl + n_dbl + 1; const T_partials_return nu = beta_dbl + N_dbl - n_dbl - 1; const T_partials_return one = 1; diff --git a/stan/math/prim/prob/beta_binomial_lcdf.hpp b/stan/math/prim/prob/beta_binomial_lcdf.hpp index 3179d004efb..16d019b942b 100644 --- a/stan/math/prim/prob/beta_binomial_lcdf.hpp +++ b/stan/math/prim/prob/beta_binomial_lcdf.hpp @@ -80,14 +80,14 @@ return_type_t beta_binomial_lcdf(const T_n& n, const T_N& N, // Explicit return for extreme values // The gradients are technically ill-defined, but treated as neg infinity for (size_t i = 0; i < stan::math::size(n); i++) { - if (value_of(n_vec[i]) < 0) { + if (n_vec.val(i) < 0) { return ops_partials.build(negative_infinity()); } } for (size_t i = 0; i < max_size_seq_view; i++) { - const T_partials_return n_dbl = value_of(n_vec[i]); - const T_partials_return N_dbl = value_of(N_vec[i]); + const T_partials_return n_dbl = n_vec.val(i); + const T_partials_return N_dbl = N_vec.val(i); // Explicit results for extreme values // The gradients are technically ill-defined, but treated as zero @@ -95,8 +95,8 @@ return_type_t beta_binomial_lcdf(const T_n& n, const T_N& N, continue; } - const T_partials_return alpha_dbl = value_of(alpha_vec[i]); - const T_partials_return beta_dbl = value_of(beta_vec[i]); + const T_partials_return alpha_dbl = alpha_vec.val(i); + const T_partials_return beta_dbl = beta_vec.val(i); const T_partials_return N_minus_n = N_dbl - n_dbl; const T_partials_return mu = alpha_dbl + n_dbl + 1; const T_partials_return nu = beta_dbl + N_minus_n - 1; diff --git a/stan/math/prim/prob/beta_binomial_lpmf.hpp b/stan/math/prim/prob/beta_binomial_lpmf.hpp index 55bb9c9cee7..f74968f0b31 100644 --- a/stan/math/prim/prob/beta_binomial_lpmf.hpp +++ b/stan/math/prim/prob/beta_binomial_lpmf.hpp @@ -96,14 +96,14 @@ return_type_t beta_binomial_lpmf(const T_n& n, const T_N& N, VectorBuilder lbeta_denominator( size_alpha_beta); for (size_t i = 0; i < size_alpha_beta; i++) { - lbeta_denominator[i] = lbeta(value_of(alpha_vec[i]), value_of(beta_vec[i])); + lbeta_denominator[i] = lbeta(alpha_vec.val(i), beta_vec.val(i)); } VectorBuilder lbeta_diff( max_size_seq_view); for (size_t i = 0; i < max_size_seq_view; i++) { - lbeta_diff[i] = lbeta(n_vec[i] + value_of(alpha_vec[i]), - N_vec[i] - n_vec[i] + value_of(beta_vec[i])) + lbeta_diff[i] = lbeta(n_vec[i] + alpha_vec.val(i), + N_vec[i] - n_vec[i] + alpha_vec.val(i)) - lbeta_denominator[i]; } @@ -112,7 +112,7 @@ return_type_t beta_binomial_lpmf(const T_n& n, const T_N& N, digamma_n_plus_alpha(max_size(n, alpha)); if (!is_constant_all::value) { for (size_t i = 0; i < max_size(n, alpha); i++) { - digamma_n_plus_alpha[i] = digamma(n_vec[i] + value_of(alpha_vec[i])); + digamma_n_plus_alpha[i] = digamma(n_vec[i] + alpha_vec.val(i)); } } @@ -122,7 +122,7 @@ return_type_t beta_binomial_lpmf(const T_n& n, const T_N& N, if (!is_constant_all::value) { for (size_t i = 0; i < size_alpha_beta; i++) { digamma_alpha_plus_beta[i] - = digamma(value_of(alpha_vec[i]) + value_of(beta_vec[i])); + = digamma(alpha_vec.val(i) + beta_vec.val(i)); } } @@ -132,8 +132,8 @@ return_type_t beta_binomial_lpmf(const T_n& n, const T_N& N, if (!is_constant_all::value) { for (size_t i = 0; i < max_size(N, alpha, beta); i++) { digamma_diff[i] = digamma_alpha_plus_beta[i] - - digamma(N_vec[i] + value_of(alpha_vec[i]) - + value_of(beta_vec[i])); + - digamma(N_vec[i] + alpha_vec.val(i) + + alpha_vec.val(i)); } } @@ -141,13 +141,13 @@ return_type_t beta_binomial_lpmf(const T_n& n, const T_N& N, digamma_alpha(size_alpha); for (size_t i = 0; i < size_alpha; i++) if (!is_constant_all::value) - digamma_alpha[i] = digamma(value_of(alpha_vec[i])); + digamma_alpha[i] = digamma(alpha_vec.val(i)); VectorBuilder::value, T_partials_return, T_size2> digamma_beta(size_beta); for (size_t i = 0; i < size_beta; i++) if (!is_constant_all::value) - digamma_beta[i] = digamma(value_of(beta_vec[i])); + digamma_beta[i] = digamma(alpha_vec.val(i)); for (size_t i = 0; i < max_size_seq_view; i++) { if (include_summand::value) @@ -159,7 +159,7 @@ return_type_t beta_binomial_lpmf(const T_n& n, const T_N& N, += digamma_n_plus_alpha[i] + digamma_diff[i] - digamma_alpha[i]; if (!is_constant_all::value) ops_partials.edge2_.partials_[i] - += digamma(value_of(N_vec[i] - n_vec[i] + beta_vec[i])) + += digamma(N_vec.val(i) - n_vec.val(i) + beta_vec.val(i)) + digamma_diff[i] - digamma_beta[i]; } return ops_partials.build(logp); diff --git a/stan/math/prim/prob/beta_cdf.hpp b/stan/math/prim/prob/beta_cdf.hpp index 67445923fb6..8dd85535781 100644 --- a/stan/math/prim/prob/beta_cdf.hpp +++ b/stan/math/prim/prob/beta_cdf.hpp @@ -67,7 +67,7 @@ return_type_t beta_cdf( // Explicit return for extreme values // The gradients are technically ill-defined, but treated as zero for (size_t i = 0; i < stan::math::size(y); i++) { - if (value_of(y_vec[i]) <= 0) { + if (y_vec.val(i) <= 0) { return ops_partials.build(0.0); } } @@ -77,7 +77,7 @@ return_type_t beta_cdf( digamma_alpha(size_alpha); if (!is_constant_all::value) { for (size_t n = 0; n < size_alpha; n++) { - digamma_alpha[n] = digamma(value_of(alpha_vec[n])); + digamma_alpha[n] = digamma(alpha_vec.val(n)); } } @@ -86,7 +86,7 @@ return_type_t beta_cdf( digamma_beta(size_beta); if (!is_constant_all::value) { for (size_t n = 0; n < size_beta; n++) { - digamma_beta[n] = digamma(value_of(beta_vec[n])); + digamma_beta[n] = digamma(alpha_vec.val(n)); } } @@ -95,12 +95,12 @@ return_type_t beta_cdf( digamma_sum(size_alpha_beta); if (!is_constant_all::value) { for (size_t n = 0; n < size_alpha_beta; n++) { - digamma_sum[n] = digamma(value_of(alpha_vec[n]) + value_of(beta_vec[n])); + digamma_sum[n] = digamma(alpha_vec.val(n) + beta_vec.val(n)); } } for (size_t n = 0; n < N; n++) { - const T_partials_return y_dbl = value_of(y_vec[n]); + const T_partials_return y_dbl = alpha_vec.val(n); // Explicit results for extreme values // The gradients are technically ill-defined, but treated as zero @@ -108,8 +108,8 @@ return_type_t beta_cdf( continue; } - const T_partials_return alpha_dbl = value_of(alpha_vec[n]); - const T_partials_return beta_dbl = value_of(beta_vec[n]); + const T_partials_return alpha_dbl = alpha_vec.val(n); + const T_partials_return beta_dbl = alpha_vec.val(n); const T_partials_return Pn = inc_beta(alpha_dbl, beta_dbl, y_dbl); const T_partials_return inv_Pn = is_constant_all::value ? 0 : inv(Pn); diff --git a/stan/math/prim/prob/beta_lccdf.hpp b/stan/math/prim/prob/beta_lccdf.hpp index 04da2149742..e0061718a7b 100644 --- a/stan/math/prim/prob/beta_lccdf.hpp +++ b/stan/math/prim/prob/beta_lccdf.hpp @@ -84,20 +84,20 @@ return_type_t beta_lccdf( if (!is_constant_all::value) { for (size_t i = 0; i < size_alpha; i++) { - digamma_alpha[i] = digamma(value_of(alpha_vec[i])); + digamma_alpha[i] = digamma(alpha_vec.val(i)); } for (size_t i = 0; i < size_beta; i++) { - digamma_beta[i] = digamma(value_of(beta_vec[i])); + digamma_beta[i] = digamma(alpha_vec.val(i)); } for (size_t i = 0; i < size_alpha_beta; i++) { - digamma_sum[i] = digamma(value_of(alpha_vec[i]) + value_of(beta_vec[i])); + digamma_sum[i] = digamma(alpha_vec.val(i) + beta_vec.val(i)); } } for (size_t n = 0; n < N; n++) { - const T_partials_return y_dbl = value_of(y_vec[n]); - const T_partials_return alpha_dbl = value_of(alpha_vec[n]); - const T_partials_return beta_dbl = value_of(beta_vec[n]); + const T_partials_return y_dbl = y_vec.val(n); + const T_partials_return alpha_dbl = y_vec.val(n); + const T_partials_return beta_dbl = y_vec.val(n); const T_partials_return betafunc_dbl = beta(alpha_dbl, beta_dbl); const T_partials_return Pn = 1.0 - inc_beta(alpha_dbl, beta_dbl, y_dbl); const T_partials_return inv_Pn diff --git a/stan/math/prim/prob/beta_lcdf.hpp b/stan/math/prim/prob/beta_lcdf.hpp index 91aa6fc406e..18119aae318 100644 --- a/stan/math/prim/prob/beta_lcdf.hpp +++ b/stan/math/prim/prob/beta_lcdf.hpp @@ -84,20 +84,20 @@ return_type_t beta_lcdf( if (!is_constant_all::value) { for (size_t i = 0; i < size_alpha; i++) { - digamma_alpha[i] = digamma(value_of(alpha_vec[i])); + digamma_alpha[i] = digamma(alpha_vec.val(i)); } for (size_t i = 0; i < size_beta; i++) { - digamma_beta[i] = digamma(value_of(beta_vec[i])); + digamma_beta[i] = digamma(alpha_vec.val(i)); } for (size_t i = 0; i < size_alpha_beta; i++) { - digamma_sum[i] = digamma(value_of(alpha_vec[i]) + value_of(beta_vec[i])); + digamma_sum[i] = digamma(alpha_vec.val(i) + beta_vec.val(i)); } } for (size_t n = 0; n < N; n++) { - const T_partials_return y_dbl = value_of(y_vec[n]); - const T_partials_return alpha_dbl = value_of(alpha_vec[n]); - const T_partials_return beta_dbl = value_of(beta_vec[n]); + const T_partials_return y_dbl = y_vec.val(n); + const T_partials_return alpha_dbl = y_vec.val(n); + const T_partials_return beta_dbl = y_vec.val(n); const T_partials_return betafunc_dbl = beta(alpha_dbl, beta_dbl); const T_partials_return Pn = inc_beta(alpha_dbl, beta_dbl, y_dbl); const T_partials_return inv_Pn diff --git a/stan/math/prim/prob/beta_proportion_lccdf.hpp b/stan/math/prim/prob/beta_proportion_lccdf.hpp index b0c9883abc7..67c5c674e76 100644 --- a/stan/math/prim/prob/beta_proportion_lccdf.hpp +++ b/stan/math/prim/prob/beta_proportion_lccdf.hpp @@ -88,21 +88,21 @@ return_type_t beta_proportion_lccdf(const T_y& y, if (!is_constant_all::value) { for (size_t i = 0; i < size_mu_kappa; i++) { - const T_partials_return kappa_dbl = value_of(kappa_vec[i]); - const T_partials_return mukappa_dbl = value_of(mu_vec[i]) * kappa_dbl; + const T_partials_return kappa_dbl = kappa_vec.val(i); + const T_partials_return mukappa_dbl = mu_vec.val(i) * kappa_dbl; digamma_mukappa[i] = digamma(mukappa_dbl); digamma_kappa_mukappa[i] = digamma(kappa_dbl - mukappa_dbl); } for (size_t i = 0; i < size_kappa; i++) { - digamma_kappa[i] = digamma(value_of(kappa_vec[i])); + digamma_kappa[i] = digamma(kappa_vec.val(i)); } } for (size_t n = 0; n < N; n++) { - const T_partials_return y_dbl = value_of(y_vec[n]); - const T_partials_return mu_dbl = value_of(mu_vec[n]); - const T_partials_return kappa_dbl = value_of(kappa_vec[n]); + const T_partials_return y_dbl = y_vec.val(n); + const T_partials_return mu_dbl = mu_vec.val(n); + const T_partials_return kappa_dbl = kappa_vec.val(n); const T_partials_return mukappa_dbl = mu_dbl * kappa_dbl; const T_partials_return kappa_mukappa_dbl = kappa_dbl - mukappa_dbl; const T_partials_return betafunc_dbl = beta(mukappa_dbl, kappa_mukappa_dbl); diff --git a/stan/math/prim/prob/beta_proportion_lcdf.hpp b/stan/math/prim/prob/beta_proportion_lcdf.hpp index 095fe831005..2675b604ad1 100644 --- a/stan/math/prim/prob/beta_proportion_lcdf.hpp +++ b/stan/math/prim/prob/beta_proportion_lcdf.hpp @@ -89,20 +89,20 @@ return_type_t beta_proportion_lcdf(const T_y& y, if (!is_constant_all::value) { for (size_t i = 0; i < size_mu_kappa; i++) { - const T_partials_return kappa_dbl = value_of(kappa_vec[i]); - const T_partials_return mukappa_dbl = value_of(mu_vec[i]) * kappa_dbl; + const T_partials_return kappa_dbl = kappa_vec.val(i); + const T_partials_return mukappa_dbl = mu_vec.val(i) * kappa_dbl; digamma_mukappa[i] = digamma(mukappa_dbl); digamma_kappa_mukappa[i] = digamma(kappa_dbl - mukappa_dbl); } for (size_t i = 0; i < size_kappa; i++) { - digamma_kappa[i] = digamma(value_of(kappa_vec[i])); + digamma_kappa[i] = digamma(kappa_vec.val(i)); } } for (size_t n = 0; n < N; n++) { - const T_partials_return y_dbl = value_of(y_vec[n]); - const T_partials_return mu_dbl = value_of(mu_vec[n]); - const T_partials_return kappa_dbl = value_of(kappa_vec[n]); + const T_partials_return y_dbl = y_vec.val(n); + const T_partials_return mu_dbl = mu_vec.val(n); + const T_partials_return kappa_dbl = kappa_vec.val(n); const T_partials_return mukappa_dbl = mu_dbl * kappa_dbl; const T_partials_return kappa_mukappa_dbl = kappa_dbl - mukappa_dbl; const T_partials_return betafunc_dbl = beta(mukappa_dbl, kappa_mukappa_dbl); diff --git a/stan/math/prim/prob/binomial_cdf.hpp b/stan/math/prim/prob/binomial_cdf.hpp index 8604b0d5826..8eed0a013a8 100644 --- a/stan/math/prim/prob/binomial_cdf.hpp +++ b/stan/math/prim/prob/binomial_cdf.hpp @@ -67,14 +67,14 @@ return_type_t binomial_cdf(const T_n& n, const T_N& N, // Explicit return for extreme values // The gradients are technically ill-defined, but treated as zero for (size_t i = 0; i < stan::math::size(n); i++) { - if (value_of(n_vec[i]) < 0) { + if (n_vec.val(i) < 0) { return ops_partials.build(0.0); } } for (size_t i = 0; i < max_size_seq_view; i++) { - const T_partials_return n_dbl = value_of(n_vec[i]); - const T_partials_return N_dbl = value_of(N_vec[i]); + const T_partials_return n_dbl = n_vec.val(i); + const T_partials_return N_dbl = N_vec.val(i); // Explicit results for extreme values // The gradients are technically ill-defined, but treated as zero @@ -82,7 +82,7 @@ return_type_t binomial_cdf(const T_n& n, const T_N& N, continue; } - const T_partials_return theta_dbl = value_of(theta_vec[i]); + const T_partials_return theta_dbl = theta_vec.val(i); const T_partials_return Pi = inc_beta(N_dbl - n_dbl, n_dbl + 1, 1 - theta_dbl); diff --git a/stan/math/prim/prob/binomial_lccdf.hpp b/stan/math/prim/prob/binomial_lccdf.hpp index 622c6ab16fd..9e033d25d7b 100644 --- a/stan/math/prim/prob/binomial_lccdf.hpp +++ b/stan/math/prim/prob/binomial_lccdf.hpp @@ -71,14 +71,14 @@ return_type_t binomial_lccdf(const T_n& n, const T_N& N, // The gradients are technically ill-defined, // but treated as negative infinity for (size_t i = 0; i < stan::math::size(n); i++) { - if (value_of(n_vec[i]) < 0) { + if (n_vec.val(i) < 0) { return ops_partials.build(0.0); } } for (size_t i = 0; i < max_size_seq_view; i++) { - const T_partials_return n_dbl = value_of(n_vec[i]); - const T_partials_return N_dbl = value_of(N_vec[i]); + const T_partials_return n_dbl = n_vec.val(i); + const T_partials_return N_dbl = N_vec.val(i); // Explicit results for extreme values // The gradients are technically ill-defined, but treated as zero @@ -86,7 +86,7 @@ return_type_t binomial_lccdf(const T_n& n, const T_N& N, return ops_partials.build(NEGATIVE_INFTY); } - const T_partials_return theta_dbl = value_of(theta_vec[i]); + const T_partials_return theta_dbl = theta_vec.val(i); const T_partials_return Pi = 1.0 - inc_beta(N_dbl - n_dbl, n_dbl + 1, 1 - theta_dbl); diff --git a/stan/math/prim/prob/binomial_lcdf.hpp b/stan/math/prim/prob/binomial_lcdf.hpp index 3d1482e4468..44b9bee7d12 100644 --- a/stan/math/prim/prob/binomial_lcdf.hpp +++ b/stan/math/prim/prob/binomial_lcdf.hpp @@ -71,14 +71,14 @@ return_type_t binomial_lcdf(const T_n& n, const T_N& N, // The gradients are technically ill-defined, // but treated as negative infinity for (size_t i = 0; i < stan::math::size(n); i++) { - if (value_of(n_vec[i]) < 0) { + if (n_vec.val(i) < 0) { return ops_partials.build(NEGATIVE_INFTY); } } for (size_t i = 0; i < max_size_seq_view; i++) { - const T_partials_return n_dbl = value_of(n_vec[i]); - const T_partials_return N_dbl = value_of(N_vec[i]); + const T_partials_return n_dbl = n_vec.val(i); + const T_partials_return N_dbl = N_vec.val(i); // Explicit results for extreme values // The gradients are technically ill-defined, but treated as zero @@ -86,7 +86,7 @@ return_type_t binomial_lcdf(const T_n& n, const T_N& N, continue; } - const T_partials_return theta_dbl = value_of(theta_vec[i]); + const T_partials_return theta_dbl = theta_vec.val(i); const T_partials_return Pi = inc_beta(N_dbl - n_dbl, n_dbl + 1, 1 - theta_dbl); diff --git a/stan/math/prim/prob/binomial_lpmf.hpp b/stan/math/prim/prob/binomial_lpmf.hpp index 4dba3bdcb06..e6c0ba9a711 100644 --- a/stan/math/prim/prob/binomial_lpmf.hpp +++ b/stan/math/prim/prob/binomial_lpmf.hpp @@ -72,7 +72,7 @@ return_type_t binomial_lpmf(const T_n& n, const T_N& N, VectorBuilder log1m_theta(size_theta); for (size_t i = 0; i < size_theta; ++i) { - log1m_theta[i] = log1m(value_of(theta_vec[i])); + log1m_theta[i] = log1m(theta_vec.val(i)); } if (include_summand::value) { @@ -86,9 +86,9 @@ return_type_t binomial_lpmf(const T_n& n, const T_N& N, if (n_vec[i] == 0) { logp += N_vec[i] * log1m_theta[i]; } else if (n_vec[i] == N_vec[i]) { - logp += n_vec[i] * log(value_of(theta_vec[i])); + logp += n_vec[i] * log(theta_vec.val(i)); } else { - logp += n_vec[i] * log(value_of(theta_vec[i])) + logp += n_vec[i] * log(theta_vec.val(i)) + (N_vec[i] - n_vec[i]) * log1m_theta[i]; } } @@ -102,7 +102,7 @@ return_type_t binomial_lpmf(const T_n& n, const T_N& N, sum_n += n_vec[i]; sum_N += N_vec[i]; } - const T_partials_return theta_dbl = value_of(theta_vec[0]); + const T_partials_return theta_dbl = theta_vec.val(0); if (sum_N != 0) { if (sum_n == 0) { ops_partials.edge1_.partials_[0] -= sum_N / (1.0 - theta_dbl); @@ -115,7 +115,7 @@ return_type_t binomial_lpmf(const T_n& n, const T_N& N, } } else { for (size_t i = 0; i < max_size_seq_view; ++i) { - const T_partials_return theta_dbl = value_of(theta_vec[i]); + const T_partials_return theta_dbl = theta_vec.val(i); if (N_vec[i] != 0) { if (n_vec[i] == 0) { ops_partials.edge1_.partials_[i] -= N_vec[i] / (1.0 - theta_dbl); diff --git a/stan/math/prim/prob/cauchy_cdf.hpp b/stan/math/prim/prob/cauchy_cdf.hpp index 0bdc33806b7..648b803307a 100644 --- a/stan/math/prim/prob/cauchy_cdf.hpp +++ b/stan/math/prim/prob/cauchy_cdf.hpp @@ -62,7 +62,7 @@ return_type_t cauchy_cdf(const T_y& y, const T_loc& mu, // Explicit return for extreme values // The gradients are technically ill-defined, but treated as zero for (size_t i = 0; i < stan::math::size(y); i++) { - if (value_of(y_vec[i]) == NEGATIVE_INFTY) { + if (y_vec.val(i) == NEGATIVE_INFTY) { return ops_partials.build(0.0); } } @@ -70,13 +70,13 @@ return_type_t cauchy_cdf(const T_y& y, const T_loc& mu, for (size_t n = 0; n < N; n++) { // Explicit results for extreme values // The gradients are technically ill-defined, but treated as zero - if (value_of(y_vec[n]) == INFTY) { + if (y_vec.val(n) == INFTY) { continue; } - const T_partials_return y_dbl = value_of(y_vec[n]); - const T_partials_return mu_dbl = value_of(mu_vec[n]); - const T_partials_return sigma_inv_dbl = 1.0 / value_of(sigma_vec[n]); + const T_partials_return y_dbl = y_vec.val(n); + const T_partials_return mu_dbl = mu_vec.val(n); + const T_partials_return sigma_inv_dbl = 1.0 / sigma_vec.val(n); const T_partials_return z = (y_dbl - mu_dbl) * sigma_inv_dbl; diff --git a/stan/math/prim/prob/cauchy_lccdf.hpp b/stan/math/prim/prob/cauchy_lccdf.hpp index cf932ebcfa4..9f3a754340e 100644 --- a/stan/math/prim/prob/cauchy_lccdf.hpp +++ b/stan/math/prim/prob/cauchy_lccdf.hpp @@ -62,10 +62,10 @@ return_type_t cauchy_lccdf(const T_y& y, const T_loc& mu, size_t N = max_size(y, mu, sigma); for (size_t n = 0; n < N; n++) { - const T_partials_return y_dbl = value_of(y_vec[n]); - const T_partials_return mu_dbl = value_of(mu_vec[n]); - const T_partials_return sigma_inv_dbl = 1.0 / value_of(sigma_vec[n]); - const T_partials_return sigma_dbl = value_of(sigma_vec[n]); + const T_partials_return y_dbl = y_vec.val(n); + const T_partials_return mu_dbl = mu_vec.val(n); + const T_partials_return sigma_inv_dbl = 1.0 / sigma_vec.val(n); + const T_partials_return sigma_dbl = sigma_vec.val(n); const T_partials_return z = (y_dbl - mu_dbl) * sigma_inv_dbl; const T_partials_return Pn = 0.5 - atan(z) / pi(); diff --git a/stan/math/prim/prob/cauchy_lcdf.hpp b/stan/math/prim/prob/cauchy_lcdf.hpp index 24a83fd0b56..14c139efa17 100644 --- a/stan/math/prim/prob/cauchy_lcdf.hpp +++ b/stan/math/prim/prob/cauchy_lcdf.hpp @@ -62,10 +62,10 @@ return_type_t cauchy_lcdf(const T_y& y, const T_loc& mu, size_t N = max_size(y, mu, sigma); for (size_t n = 0; n < N; n++) { - const T_partials_return y_dbl = value_of(y_vec[n]); - const T_partials_return mu_dbl = value_of(mu_vec[n]); - const T_partials_return sigma_inv_dbl = 1.0 / value_of(sigma_vec[n]); - const T_partials_return sigma_dbl = value_of(sigma_vec[n]); + const T_partials_return y_dbl = y_vec.val(n); + const T_partials_return mu_dbl = mu_vec.val(n); + const T_partials_return sigma_inv_dbl = 1.0 / sigma_vec.val(n); + const T_partials_return sigma_dbl = sigma_vec.val(n); const T_partials_return z = (y_dbl - mu_dbl) * sigma_inv_dbl; diff --git a/stan/math/prim/prob/chi_square_cdf.hpp b/stan/math/prim/prob/chi_square_cdf.hpp index 755b7a6ad39..1a5869dec2b 100644 --- a/stan/math/prim/prob/chi_square_cdf.hpp +++ b/stan/math/prim/prob/chi_square_cdf.hpp @@ -62,7 +62,7 @@ return_type_t chi_square_cdf(const T_y& y, const T_dof& nu) { // Explicit return for extreme values // The gradients are technically ill-defined, but treated as zero for (size_t i = 0; i < stan::math::size(y); i++) { - if (value_of(y_vec[i]) == 0) { + if (y_vec.val(i) == 0) { return ops_partials.build(0.0); } } @@ -74,7 +74,7 @@ return_type_t chi_square_cdf(const T_y& y, const T_dof& nu) { if (!is_constant_all::value) { for (size_t i = 0; i < stan::math::size(nu); i++) { - const T_partials_return alpha_dbl = value_of(nu_vec[i]) * 0.5; + const T_partials_return alpha_dbl = nu_vec.val(i) * 0.5; gamma_vec[i] = tgamma(alpha_dbl); digamma_vec[i] = digamma(alpha_dbl); } @@ -83,12 +83,12 @@ return_type_t chi_square_cdf(const T_y& y, const T_dof& nu) { for (size_t n = 0; n < N; n++) { // Explicit results for extreme values // The gradients are technically ill-defined, but treated as zero - if (value_of(y_vec[n]) == INFTY) { + if (y_vec.val(n) == INFTY) { continue; } - const T_partials_return y_dbl = value_of(y_vec[n]); - const T_partials_return alpha_dbl = value_of(nu_vec[n]) * 0.5; + const T_partials_return y_dbl = y_vec.val(n); + const T_partials_return alpha_dbl = nu_vec.val(n) * 0.5; const T_partials_return beta_dbl = 0.5; const T_partials_return Pn = gamma_p(alpha_dbl, beta_dbl * y_dbl); diff --git a/stan/math/prim/prob/chi_square_lccdf.hpp b/stan/math/prim/prob/chi_square_lccdf.hpp index 575b38ff5f5..63d8f3adcbc 100644 --- a/stan/math/prim/prob/chi_square_lccdf.hpp +++ b/stan/math/prim/prob/chi_square_lccdf.hpp @@ -64,7 +64,7 @@ return_type_t chi_square_lccdf(const T_y& y, const T_dof& nu) { // Explicit return for extreme values // The gradients are technically ill-defined, but treated as zero for (size_t i = 0; i < stan::math::size(y); i++) { - if (value_of(y_vec[i]) == 0) { + if (y_vec.val(i) == 0) { return ops_partials.build(0.0); } } @@ -76,7 +76,7 @@ return_type_t chi_square_lccdf(const T_y& y, const T_dof& nu) { if (!is_constant_all::value) { for (size_t i = 0; i < stan::math::size(nu); i++) { - const T_partials_return alpha_dbl = value_of(nu_vec[i]) * 0.5; + const T_partials_return alpha_dbl = nu_vec.val(i) * 0.5; gamma_vec[i] = tgamma(alpha_dbl); digamma_vec[i] = digamma(alpha_dbl); } @@ -85,12 +85,12 @@ return_type_t chi_square_lccdf(const T_y& y, const T_dof& nu) { for (size_t n = 0; n < N; n++) { // Explicit results for extreme values // The gradients are technically ill-defined, but treated as zero - if (value_of(y_vec[n]) == INFTY) { + if (y_vec.val(n) == INFTY) { return ops_partials.build(negative_infinity()); } - const T_partials_return y_dbl = value_of(y_vec[n]); - const T_partials_return alpha_dbl = value_of(nu_vec[n]) * 0.5; + const T_partials_return y_dbl = y_vec.val(n); + const T_partials_return alpha_dbl = nu_vec.val(n) * 0.5; const T_partials_return beta_dbl = 0.5; const T_partials_return Pn = gamma_q(alpha_dbl, beta_dbl * y_dbl); diff --git a/stan/math/prim/prob/chi_square_lcdf.hpp b/stan/math/prim/prob/chi_square_lcdf.hpp index c6d8bacd5e1..ff6da8c33ef 100644 --- a/stan/math/prim/prob/chi_square_lcdf.hpp +++ b/stan/math/prim/prob/chi_square_lcdf.hpp @@ -64,7 +64,7 @@ return_type_t chi_square_lcdf(const T_y& y, const T_dof& nu) { // Explicit return for extreme values // The gradients are technically ill-defined, but treated as zero for (size_t i = 0; i < stan::math::size(y); i++) { - if (value_of(y_vec[i]) == 0) { + if (y_vec.val(i) == 0) { return ops_partials.build(negative_infinity()); } } @@ -76,7 +76,7 @@ return_type_t chi_square_lcdf(const T_y& y, const T_dof& nu) { if (!is_constant_all::value) { for (size_t i = 0; i < stan::math::size(nu); i++) { - const T_partials_return alpha_dbl = value_of(nu_vec[i]) * 0.5; + const T_partials_return alpha_dbl = nu_vec.val(i) * 0.5; gamma_vec[i] = tgamma(alpha_dbl); digamma_vec[i] = digamma(alpha_dbl); } @@ -85,12 +85,12 @@ return_type_t chi_square_lcdf(const T_y& y, const T_dof& nu) { for (size_t n = 0; n < N; n++) { // Explicit results for extreme values // The gradients are technically ill-defined, but treated as zero - if (value_of(y_vec[n]) == INFTY) { + if (y_vec.val(n) == INFTY) { return ops_partials.build(0.0); } - const T_partials_return y_dbl = value_of(y_vec[n]); - const T_partials_return alpha_dbl = value_of(nu_vec[n]) * 0.5; + const T_partials_return y_dbl = y_vec.val(n); + const T_partials_return alpha_dbl = nu_vec.val(n) * 0.5; const T_partials_return beta_dbl = 0.5; const T_partials_return Pn = gamma_p(alpha_dbl, beta_dbl * y_dbl); diff --git a/stan/math/prim/prob/dirichlet_lpdf.hpp b/stan/math/prim/prob/dirichlet_lpdf.hpp index 266c520433e..88ed478ee57 100644 --- a/stan/math/prim/prob/dirichlet_lpdf.hpp +++ b/stan/math/prim/prob/dirichlet_lpdf.hpp @@ -80,11 +80,11 @@ return_type_t dirichlet_lpdf(const T_prob& theta, T_partials_array theta_dbl(t_size, t_length); for (size_t t = 0; t < t_length; t++) { - theta_dbl.col(t) = value_of(theta_vec[t]); + theta_dbl.col(t) = theta_vec.val(t); } T_partials_array alpha_dbl(t_size, t_length); for (size_t t = 0; t < t_length; t++) { - alpha_dbl.col(t) = value_of(alpha_vec[t]); + alpha_dbl.col(t) = alpha_vec.val(t); } T_partials_return lp(0.0); diff --git a/stan/math/prim/prob/discrete_range_lpmf.hpp b/stan/math/prim/prob/discrete_range_lpmf.hpp index a8014715369..a07a8031dda 100644 --- a/stan/math/prim/prob/discrete_range_lpmf.hpp +++ b/stan/math/prim/prob/discrete_range_lpmf.hpp @@ -65,8 +65,8 @@ double discrete_range_lpmf(const T_y& y, const T_lower& lower, size_t N = max_size(y, lower, upper); for (size_t n = 0; n < N; ++n) { - const double y_dbl = value_of(y_vec[n]); - if (y_dbl < value_of(lower_vec[n]) || y_dbl > value_of(upper_vec[n])) { + const double y_dbl = y_vec.val(n); + if (y_dbl < lower_vec.val(n) || y_dbl > upper_vec.val(n)) { return LOG_ZERO; } } @@ -75,8 +75,8 @@ double discrete_range_lpmf(const T_y& y, const T_lower& lower, size_lower_upper); for (size_t i = 0; i < size_lower_upper; i++) { - const double lower_dbl = value_of(lower_vec[i]); - const double upper_dbl = value_of(upper_vec[i]); + const double lower_dbl = lower_vec.val(i); + const double upper_dbl = upper_vec.val(i); log_upper_minus_lower[i] = log(upper_dbl - lower_dbl + 1); } diff --git a/stan/math/prim/prob/double_exponential_lccdf.hpp b/stan/math/prim/prob/double_exponential_lccdf.hpp index 99357df1700..1326f7dd59c 100644 --- a/stan/math/prim/prob/double_exponential_lccdf.hpp +++ b/stan/math/prim/prob/double_exponential_lccdf.hpp @@ -66,12 +66,12 @@ return_type_t double_exponential_lccdf( VectorBuilder inv_sigma(size_sigma); for (size_t i = 0; i < size_sigma; i++) { - inv_sigma[i] = inv(value_of(sigma_vec[i])); + inv_sigma[i] = inv(sigma_vec.val(i)); } for (size_t n = 0; n < N; n++) { - const T_partials_return y_dbl = value_of(y_vec[n]); - const T_partials_return mu_dbl = value_of(mu_vec[n]); + const T_partials_return y_dbl = y_vec.val(n); + const T_partials_return mu_dbl = mu_vec.val(n); const T_partials_return scaled_diff = (y_dbl - mu_dbl) * inv_sigma[n]; const T_partials_return rep_deriv diff --git a/stan/math/prim/prob/double_exponential_lcdf.hpp b/stan/math/prim/prob/double_exponential_lcdf.hpp index d84263e9455..734cdfc0a6c 100644 --- a/stan/math/prim/prob/double_exponential_lcdf.hpp +++ b/stan/math/prim/prob/double_exponential_lcdf.hpp @@ -65,12 +65,12 @@ return_type_t double_exponential_lcdf( VectorBuilder inv_sigma(size_sigma); for (size_t i = 0; i < size_sigma; i++) { - inv_sigma[i] = inv(value_of(sigma_vec[i])); + inv_sigma[i] = inv(sigma_vec.val(i)); } for (size_t n = 0; n < N; n++) { - const T_partials_return y_dbl = value_of(y_vec[n]); - const T_partials_return mu_dbl = value_of(mu_vec[n]); + const T_partials_return y_dbl = y_vec.val(n); + const T_partials_return mu_dbl = mu_vec.val(n); const T_partials_return scaled_diff = (y_dbl - mu_dbl) * inv_sigma[n]; const T_partials_return rep_deriv diff --git a/stan/math/prim/prob/frechet_cdf.hpp b/stan/math/prim/prob/frechet_cdf.hpp index de7ea5fb678..b45052a07bb 100644 --- a/stan/math/prim/prob/frechet_cdf.hpp +++ b/stan/math/prim/prob/frechet_cdf.hpp @@ -54,9 +54,9 @@ return_type_t frechet_cdf(const T_y& y, size_t N = max_size(y_ref, sigma_ref, alpha_ref); for (size_t n = 0; n < N; n++) { - const T_partials_return y_dbl = value_of(y_vec[n]); - const T_partials_return sigma_dbl = value_of(sigma_vec[n]); - const T_partials_return alpha_dbl = value_of(alpha_vec[n]); + const T_partials_return y_dbl = y_vec.val(n); + const T_partials_return sigma_dbl = sigma_vec.val(n); + const T_partials_return alpha_dbl = alpha_vec.val(n); const T_partials_return pow_n = pow(sigma_dbl / y_dbl, alpha_dbl); const T_partials_return cdf_n = exp(-pow_n); diff --git a/stan/math/prim/prob/frechet_lccdf.hpp b/stan/math/prim/prob/frechet_lccdf.hpp index 2f8510a0065..67d69ecd5df 100644 --- a/stan/math/prim/prob/frechet_lccdf.hpp +++ b/stan/math/prim/prob/frechet_lccdf.hpp @@ -52,9 +52,9 @@ return_type_t frechet_lccdf(const T_y& y, size_t N = max_size(y_ref, sigma_ref, alpha_ref); for (size_t n = 0; n < N; n++) { - const T_partials_return y_dbl = value_of(y_vec[n]); - const T_partials_return sigma_dbl = value_of(sigma_vec[n]); - const T_partials_return alpha_dbl = value_of(alpha_vec[n]); + const T_partials_return y_dbl = y_vec.val(n); + const T_partials_return sigma_dbl = sigma_vec.val(n); + const T_partials_return alpha_dbl = alpha_vec.val(n); const T_partials_return pow_n = pow(sigma_dbl / y_dbl, alpha_dbl); const T_partials_return exp_n = exp(-pow_n); diff --git a/stan/math/prim/prob/frechet_lcdf.hpp b/stan/math/prim/prob/frechet_lcdf.hpp index 26b7fe581c7..74e86e5c7c7 100644 --- a/stan/math/prim/prob/frechet_lcdf.hpp +++ b/stan/math/prim/prob/frechet_lcdf.hpp @@ -51,9 +51,9 @@ return_type_t frechet_lcdf(const T_y& y, scalar_seq_view alpha_vec(alpha_ref); size_t N = max_size(y_ref, sigma_ref, alpha_ref); for (size_t n = 0; n < N; n++) { - const T_partials_return y_dbl = value_of(y_vec[n]); - const T_partials_return sigma_dbl = value_of(sigma_vec[n]); - const T_partials_return alpha_dbl = value_of(alpha_vec[n]); + const T_partials_return y_dbl = y_vec.val(n); + const T_partials_return sigma_dbl = sigma_vec.val(n); + const T_partials_return alpha_dbl = alpha_vec.val(n); const T_partials_return pow_n = pow(sigma_dbl / y_dbl, alpha_dbl); cdf_log -= pow_n; diff --git a/stan/math/prim/prob/gamma_cdf.hpp b/stan/math/prim/prob/gamma_cdf.hpp index 344fa170cd8..a7f0d791b4f 100644 --- a/stan/math/prim/prob/gamma_cdf.hpp +++ b/stan/math/prim/prob/gamma_cdf.hpp @@ -71,7 +71,7 @@ return_type_t gamma_cdf(const T_y& y, // Explicit return for extreme values // The gradients are technically ill-defined, but treated as zero for (size_t i = 0; i < stan::math::size(y); i++) { - if (value_of(y_vec[i]) == 0) { + if (y_vec.val(i) == 0) { return ops_partials.build(0.0); } } @@ -86,7 +86,7 @@ return_type_t gamma_cdf(const T_y& y, if (!is_constant_all::value) { for (size_t i = 0; i < stan::math::size(alpha); i++) { - const T_partials_return alpha_dbl = value_of(alpha_vec[i]); + const T_partials_return alpha_dbl = alpha_vec.val(i); gamma_vec[i] = tgamma(alpha_dbl); digamma_vec[i] = digamma(alpha_dbl); } @@ -95,13 +95,13 @@ return_type_t gamma_cdf(const T_y& y, for (size_t n = 0; n < N; n++) { // Explicit results for extreme values // The gradients are technically ill-defined, but treated as zero - if (value_of(y_vec[n]) == INFTY) { + if (y_vec.val(n) == INFTY) { continue; } - const T_partials_return y_dbl = value_of(y_vec[n]); - const T_partials_return alpha_dbl = value_of(alpha_vec[n]); - const T_partials_return beta_dbl = value_of(beta_vec[n]); + 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 Pn = gamma_p(alpha_dbl, beta_dbl * y_dbl); diff --git a/stan/math/prim/prob/gamma_lccdf.hpp b/stan/math/prim/prob/gamma_lccdf.hpp index 469a289723d..22b637603bb 100644 --- a/stan/math/prim/prob/gamma_lccdf.hpp +++ b/stan/math/prim/prob/gamma_lccdf.hpp @@ -57,7 +57,7 @@ return_type_t gamma_lccdf(const T_y& y, // Explicit return for extreme values // The gradients are technically ill-defined, but treated as zero for (size_t i = 0; i < stan::math::size(y); i++) { - if (value_of(y_vec[i]) == 0) { + if (y_vec.val(i) == 0) { return ops_partials.build(0.0); } } @@ -69,7 +69,7 @@ return_type_t gamma_lccdf(const T_y& y, if (!is_constant_all::value) { for (size_t i = 0; i < stan::math::size(alpha); i++) { - const T_partials_return alpha_dbl = value_of(alpha_vec[i]); + const T_partials_return alpha_dbl = alpha_vec.val(i); gamma_vec[i] = tgamma(alpha_dbl); digamma_vec[i] = digamma(alpha_dbl); } @@ -78,13 +78,13 @@ return_type_t gamma_lccdf(const T_y& y, for (size_t n = 0; n < N; n++) { // Explicit results for extreme values // The gradients are technically ill-defined, but treated as zero - if (value_of(y_vec[n]) == INFTY) { + if (y_vec.val(n) == INFTY) { return ops_partials.build(negative_infinity()); } - const T_partials_return y_dbl = value_of(y_vec[n]); - const T_partials_return alpha_dbl = value_of(alpha_vec[n]); - const T_partials_return beta_dbl = value_of(beta_vec[n]); + 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 Pn = gamma_q(alpha_dbl, beta_dbl * y_dbl); diff --git a/stan/math/prim/prob/gamma_lcdf.hpp b/stan/math/prim/prob/gamma_lcdf.hpp index d8d30af42ef..22746d6520f 100644 --- a/stan/math/prim/prob/gamma_lcdf.hpp +++ b/stan/math/prim/prob/gamma_lcdf.hpp @@ -57,7 +57,7 @@ return_type_t gamma_lcdf(const T_y& y, // Explicit return for extreme values // The gradients are technically ill-defined, but treated as zero for (size_t i = 0; i < stan::math::size(y); i++) { - if (value_of(y_vec[i]) == 0) { + if (y_vec.val(i) == 0) { return ops_partials.build(negative_infinity()); } } @@ -69,7 +69,7 @@ return_type_t gamma_lcdf(const T_y& y, if (!is_constant_all::value) { for (size_t i = 0; i < stan::math::size(alpha); i++) { - const T_partials_return alpha_dbl = value_of(alpha_vec[i]); + const T_partials_return alpha_dbl = alpha_vec.val(i); gamma_vec[i] = tgamma(alpha_dbl); digamma_vec[i] = digamma(alpha_dbl); } @@ -78,13 +78,13 @@ return_type_t gamma_lcdf(const T_y& y, for (size_t n = 0; n < N; n++) { // Explicit results for extreme values // The gradients are technically ill-defined, but treated as zero - if (value_of(y_vec[n]) == INFTY) { + if (y_vec.val(n) == INFTY) { return ops_partials.build(0.0); } - const T_partials_return y_dbl = value_of(y_vec[n]); - const T_partials_return alpha_dbl = value_of(alpha_vec[n]); - const T_partials_return beta_dbl = value_of(beta_vec[n]); + 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 Pn = gamma_p(alpha_dbl, beta_dbl * y_dbl); diff --git a/stan/math/prim/prob/inv_chi_square_cdf.hpp b/stan/math/prim/prob/inv_chi_square_cdf.hpp index 717efcbba62..2bf30712d2b 100644 --- a/stan/math/prim/prob/inv_chi_square_cdf.hpp +++ b/stan/math/prim/prob/inv_chi_square_cdf.hpp @@ -62,7 +62,7 @@ return_type_t inv_chi_square_cdf(const T_y& y, const T_dof& nu) { // Explicit return for extreme values // The gradients are technically ill-defined, but treated as zero for (size_t i = 0; i < stan::math::size(y); i++) { - if (value_of(y_vec[i]) == 0) { + if (y_vec.val(i) == 0) { return ops_partials.build(0.0); } } @@ -74,7 +74,7 @@ return_type_t inv_chi_square_cdf(const T_y& y, const T_dof& nu) { if (!is_constant_all::value) { for (size_t i = 0; i < stan::math::size(nu); i++) { - const T_partials_return nu_dbl = value_of(nu_vec[i]); + const T_partials_return nu_dbl = nu_vec.val(i); gamma_vec[i] = tgamma(0.5 * nu_dbl); digamma_vec[i] = digamma(0.5 * nu_dbl); } @@ -83,13 +83,13 @@ return_type_t inv_chi_square_cdf(const T_y& y, const T_dof& nu) { for (size_t n = 0; n < N; n++) { // Explicit results for extreme values // The gradients are technically ill-defined, but treated as zero - if (value_of(y_vec[n]) == INFTY) { + if (y_vec.val(n) == INFTY) { continue; } - const T_partials_return y_dbl = value_of(y_vec[n]); + const T_partials_return y_dbl = y_vec.val(n); const T_partials_return y_inv_dbl = 1.0 / y_dbl; - const T_partials_return nu_dbl = value_of(nu_vec[n]); + const T_partials_return nu_dbl = nu_vec.val(n); const T_partials_return Pn = gamma_q(0.5 * nu_dbl, 0.5 * y_inv_dbl); diff --git a/stan/math/prim/prob/inv_chi_square_lccdf.hpp b/stan/math/prim/prob/inv_chi_square_lccdf.hpp index f5ce9ef7497..c3e069bbbfb 100644 --- a/stan/math/prim/prob/inv_chi_square_lccdf.hpp +++ b/stan/math/prim/prob/inv_chi_square_lccdf.hpp @@ -64,7 +64,7 @@ return_type_t inv_chi_square_lccdf(const T_y& y, const T_dof& nu) { // Explicit return for extreme values // The gradients are technically ill-defined, but treated as zero for (size_t i = 0; i < stan::math::size(y); i++) { - if (value_of(y_vec[i]) == 0) { + if (y_vec.val(i) == 0) { return ops_partials.build(0.0); } } @@ -76,7 +76,7 @@ return_type_t inv_chi_square_lccdf(const T_y& y, const T_dof& nu) { if (!is_constant_all::value) { for (size_t i = 0; i < stan::math::size(nu); i++) { - const T_partials_return nu_dbl = value_of(nu_vec[i]); + const T_partials_return nu_dbl = nu_vec.val(i); gamma_vec[i] = tgamma(0.5 * nu_dbl); digamma_vec[i] = digamma(0.5 * nu_dbl); } @@ -85,13 +85,13 @@ return_type_t inv_chi_square_lccdf(const T_y& y, const T_dof& nu) { for (size_t n = 0; n < N; n++) { // Explicit results for extreme values // The gradients are technically ill-defined, but treated as zero - if (value_of(y_vec[n]) == INFTY) { + if (y_vec.val(n) == INFTY) { return ops_partials.build(negative_infinity()); } - const T_partials_return y_dbl = value_of(y_vec[n]); + const T_partials_return y_dbl = y_vec.val(n); const T_partials_return y_inv_dbl = 1.0 / y_dbl; - const T_partials_return nu_dbl = value_of(nu_vec[n]); + const T_partials_return nu_dbl = nu_vec.val(n); const T_partials_return Pn = gamma_p(0.5 * nu_dbl, 0.5 * y_inv_dbl); diff --git a/stan/math/prim/prob/inv_chi_square_lcdf.hpp b/stan/math/prim/prob/inv_chi_square_lcdf.hpp index 4dd4f3749f5..96ef9700dad 100644 --- a/stan/math/prim/prob/inv_chi_square_lcdf.hpp +++ b/stan/math/prim/prob/inv_chi_square_lcdf.hpp @@ -64,7 +64,7 @@ return_type_t inv_chi_square_lcdf(const T_y& y, const T_dof& nu) { // Explicit return for extreme values // The gradients are technically ill-defined, but treated as zero for (size_t i = 0; i < stan::math::size(y); i++) { - if (value_of(y_vec[i]) == 0) { + if (y_vec.val(i) == 0) { return ops_partials.build(negative_infinity()); } } @@ -76,7 +76,7 @@ return_type_t inv_chi_square_lcdf(const T_y& y, const T_dof& nu) { if (!is_constant_all::value) { for (size_t i = 0; i < stan::math::size(nu); i++) { - const T_partials_return nu_dbl = value_of(nu_vec[i]); + const T_partials_return nu_dbl = nu_vec.val(i); gamma_vec[i] = tgamma(0.5 * nu_dbl); digamma_vec[i] = digamma(0.5 * nu_dbl); } @@ -85,13 +85,13 @@ return_type_t inv_chi_square_lcdf(const T_y& y, const T_dof& nu) { for (size_t n = 0; n < N; n++) { // Explicit results for extreme values // The gradients are technically ill-defined, but treated as zero - if (value_of(y_vec[n]) == INFTY) { + if (y_vec.val(n) == INFTY) { continue; } - const T_partials_return y_dbl = value_of(y_vec[n]); + const T_partials_return y_dbl = y_vec.val(n); const T_partials_return y_inv_dbl = 1.0 / y_dbl; - const T_partials_return nu_dbl = value_of(nu_vec[n]); + const T_partials_return nu_dbl = nu_vec.val(n); const T_partials_return Pn = gamma_q(0.5 * nu_dbl, 0.5 * y_inv_dbl); diff --git a/stan/math/prim/prob/inv_gamma_cdf.hpp b/stan/math/prim/prob/inv_gamma_cdf.hpp index 148a685f417..66a5019c0b5 100644 --- a/stan/math/prim/prob/inv_gamma_cdf.hpp +++ b/stan/math/prim/prob/inv_gamma_cdf.hpp @@ -73,7 +73,7 @@ return_type_t inv_gamma_cdf(const T_y& y, // Explicit return for extreme values // The gradients are technically ill-defined, but treated as zero for (size_t i = 0; i < stan::math::size(y); i++) { - if (value_of(y_vec[i]) == 0) { + if (y_vec.val(i) == 0) { return ops_partials.build(0.0); } } @@ -85,7 +85,7 @@ return_type_t inv_gamma_cdf(const T_y& y, if (!is_constant_all::value) { for (size_t i = 0; i < stan::math::size(alpha); i++) { - const T_partials_return alpha_dbl = value_of(alpha_vec[i]); + const T_partials_return alpha_dbl = alpha_vec.val(i); gamma_vec[i] = tgamma(alpha_dbl); digamma_vec[i] = digamma(alpha_dbl); } @@ -94,14 +94,14 @@ return_type_t inv_gamma_cdf(const T_y& y, for (size_t n = 0; n < N; n++) { // Explicit results for extreme values // The gradients are technically ill-defined, but treated as zero - if (value_of(y_vec[n]) == INFTY) { + if (y_vec.val(n) == INFTY) { continue; } - const T_partials_return y_dbl = value_of(y_vec[n]); + const T_partials_return y_dbl = y_vec.val(n); const T_partials_return y_inv_dbl = 1.0 / y_dbl; - const T_partials_return alpha_dbl = value_of(alpha_vec[n]); - const T_partials_return beta_dbl = value_of(beta_vec[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 Pn = gamma_q(alpha_dbl, beta_dbl * y_inv_dbl); diff --git a/stan/math/prim/prob/inv_gamma_lccdf.hpp b/stan/math/prim/prob/inv_gamma_lccdf.hpp index 1073a2ac7d1..5f4ec4730db 100644 --- a/stan/math/prim/prob/inv_gamma_lccdf.hpp +++ b/stan/math/prim/prob/inv_gamma_lccdf.hpp @@ -59,7 +59,7 @@ return_type_t inv_gamma_lccdf(const T_y& y, // Explicit return for extreme values // The gradients are technically ill-defined, but treated as zero for (size_t i = 0; i < stan::math::size(y); i++) { - if (value_of(y_vec[i]) == 0) { + if (y_vec.val(i) == 0) { return ops_partials.build(0.0); } } @@ -71,7 +71,7 @@ return_type_t inv_gamma_lccdf(const T_y& y, if (!is_constant_all::value) { for (size_t i = 0; i < stan::math::size(alpha); i++) { - const T_partials_return alpha_dbl = value_of(alpha_vec[i]); + const T_partials_return alpha_dbl = alpha_vec.val(i); gamma_vec[i] = tgamma(alpha_dbl); digamma_vec[i] = digamma(alpha_dbl); } @@ -80,14 +80,14 @@ return_type_t inv_gamma_lccdf(const T_y& y, for (size_t n = 0; n < N; n++) { // Explicit results for extreme values // The gradients are technically ill-defined, but treated as zero - if (value_of(y_vec[n]) == INFTY) { + if (y_vec.val(n) == INFTY) { return ops_partials.build(negative_infinity()); } - const T_partials_return y_dbl = value_of(y_vec[n]); + const T_partials_return y_dbl = y_vec.val(n); const T_partials_return y_inv_dbl = 1.0 / y_dbl; - const T_partials_return alpha_dbl = value_of(alpha_vec[n]); - const T_partials_return beta_dbl = value_of(beta_vec[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 Pn = gamma_p(alpha_dbl, beta_dbl * y_inv_dbl); diff --git a/stan/math/prim/prob/inv_gamma_lcdf.hpp b/stan/math/prim/prob/inv_gamma_lcdf.hpp index fdd1dcd5dce..048dd7eabda 100644 --- a/stan/math/prim/prob/inv_gamma_lcdf.hpp +++ b/stan/math/prim/prob/inv_gamma_lcdf.hpp @@ -59,7 +59,7 @@ return_type_t inv_gamma_lcdf(const T_y& y, // Explicit return for extreme values // The gradients are technically ill-defined, but treated as zero for (size_t i = 0; i < stan::math::size(y); i++) { - if (value_of(y_vec[i]) == 0) { + if (y_vec.val(i) == 0) { return ops_partials.build(negative_infinity()); } } @@ -71,7 +71,7 @@ return_type_t inv_gamma_lcdf(const T_y& y, if (!is_constant_all::value) { for (size_t i = 0; i < stan::math::size(alpha); i++) { - const T_partials_return alpha_dbl = value_of(alpha_vec[i]); + const T_partials_return alpha_dbl = alpha_vec.val(i); gamma_vec[i] = tgamma(alpha_dbl); digamma_vec[i] = digamma(alpha_dbl); } @@ -80,14 +80,14 @@ return_type_t inv_gamma_lcdf(const T_y& y, for (size_t n = 0; n < N; n++) { // Explicit results for extreme values // The gradients are technically ill-defined, but treated as zero - if (value_of(y_vec[n]) == INFTY) { + if (y_vec.val(n) == INFTY) { continue; } - const T_partials_return y_dbl = value_of(y_vec[n]); + const T_partials_return y_dbl = y_vec.val(n); const T_partials_return y_inv_dbl = 1.0 / y_dbl; - const T_partials_return alpha_dbl = value_of(alpha_vec[n]); - const T_partials_return beta_dbl = value_of(beta_vec[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 Pn = gamma_q(alpha_dbl, beta_dbl * y_inv_dbl); diff --git a/stan/math/prim/prob/logistic_cdf.hpp b/stan/math/prim/prob/logistic_cdf.hpp index 7cde6668e17..fffeb23e883 100644 --- a/stan/math/prim/prob/logistic_cdf.hpp +++ b/stan/math/prim/prob/logistic_cdf.hpp @@ -51,7 +51,7 @@ return_type_t logistic_cdf(const T_y& y, const T_loc& mu, // Explicit return for extreme values // The gradients are technically ill-defined, but treated as zero for (size_t i = 0; i < stan::math::size(y); i++) { - if (value_of(y_vec[i]) == NEGATIVE_INFTY) { + if (y_vec.val(i) == NEGATIVE_INFTY) { return ops_partials.build(0.0); } } @@ -59,14 +59,14 @@ return_type_t logistic_cdf(const T_y& y, const T_loc& mu, for (size_t n = 0; n < N; n++) { // Explicit results for extreme values // The gradients are technically ill-defined, but treated as zero - if (value_of(y_vec[n]) == INFTY) { + if (y_vec.val(n) == INFTY) { continue; } - const T_partials_return y_dbl = value_of(y_vec[n]); - const T_partials_return mu_dbl = value_of(mu_vec[n]); - const T_partials_return sigma_dbl = value_of(sigma_vec[n]); - const T_partials_return sigma_inv_vec = 1.0 / value_of(sigma_vec[n]); + const T_partials_return y_dbl = y_vec.val(n); + const T_partials_return mu_dbl = mu_vec.val(n); + const T_partials_return sigma_dbl = sigma_vec.val(n); + const T_partials_return sigma_inv_vec = 1.0 / sigma_vec.val(n); const T_partials_return Pn = 1.0 / (1.0 + exp(-(y_dbl - mu_dbl) * sigma_inv_vec)); diff --git a/stan/math/prim/prob/logistic_lccdf.hpp b/stan/math/prim/prob/logistic_lccdf.hpp index 0318461c39e..3325273b2c0 100644 --- a/stan/math/prim/prob/logistic_lccdf.hpp +++ b/stan/math/prim/prob/logistic_lccdf.hpp @@ -52,7 +52,7 @@ return_type_t logistic_lccdf(const T_y& y, const T_loc& mu, // Explicit return for extreme values // The gradients are technically ill-defined, but treated as zero for (size_t i = 0; i < stan::math::size(y); i++) { - if (value_of(y_vec[i]) == NEGATIVE_INFTY) { + if (y_vec.val(i) == NEGATIVE_INFTY) { return ops_partials.build(0.0); } } @@ -60,14 +60,14 @@ return_type_t logistic_lccdf(const T_y& y, const T_loc& mu, for (size_t n = 0; n < N; n++) { // Explicit results for extreme values // The gradients are technically ill-defined, but treated as zero - if (value_of(y_vec[n]) == INFTY) { + if (y_vec.val(n) == INFTY) { return ops_partials.build(negative_infinity()); } - const T_partials_return y_dbl = value_of(y_vec[n]); - const T_partials_return mu_dbl = value_of(mu_vec[n]); - const T_partials_return sigma_dbl = value_of(sigma_vec[n]); - const T_partials_return sigma_inv_vec = 1.0 / value_of(sigma_vec[n]); + const T_partials_return y_dbl = y_vec.val(n); + const T_partials_return mu_dbl = mu_vec.val(n); + const T_partials_return sigma_dbl = sigma_vec.val(n); + const T_partials_return sigma_inv_vec = 1.0 / sigma_vec.val(n); const T_partials_return Pn = 1.0 - 1.0 / (1.0 + exp(-(y_dbl - mu_dbl) * sigma_inv_vec)); diff --git a/stan/math/prim/prob/logistic_lcdf.hpp b/stan/math/prim/prob/logistic_lcdf.hpp index 93dd9dd43b0..397e2e88d40 100644 --- a/stan/math/prim/prob/logistic_lcdf.hpp +++ b/stan/math/prim/prob/logistic_lcdf.hpp @@ -52,7 +52,7 @@ return_type_t logistic_lcdf(const T_y& y, const T_loc& mu, // Explicit return for extreme values // The gradients are technically ill-defined, but treated as zero for (size_t i = 0; i < stan::math::size(y); i++) { - if (value_of(y_vec[i]) == NEGATIVE_INFTY) { + if (y_vec.val(i) == NEGATIVE_INFTY) { return ops_partials.build(NEGATIVE_INFTY); } } @@ -60,14 +60,14 @@ return_type_t logistic_lcdf(const T_y& y, const T_loc& mu, for (size_t n = 0; n < N; n++) { // Explicit results for extreme values // The gradients are technically ill-defined, but treated as zero - if (value_of(y_vec[n]) == INFTY) { + if (y_vec.val(n) == INFTY) { continue; } - const T_partials_return y_dbl = value_of(y_vec[n]); - const T_partials_return mu_dbl = value_of(mu_vec[n]); - const T_partials_return sigma_dbl = value_of(sigma_vec[n]); - const T_partials_return sigma_inv_vec = 1.0 / value_of(sigma_vec[n]); + const T_partials_return y_dbl = y_vec.val(n); + const T_partials_return mu_dbl = mu_vec.val(n); + const T_partials_return sigma_dbl = sigma_vec.val(n); + const T_partials_return sigma_inv_vec = 1.0 / sigma_vec.val(n); const T_partials_return Pn = 1.0 / (1.0 + exp(-(y_dbl - mu_dbl) * sigma_inv_vec)); diff --git a/stan/math/prim/prob/neg_binomial_2_cdf.hpp b/stan/math/prim/prob/neg_binomial_2_cdf.hpp index da0d6afcf3c..c7a7a8127f2 100644 --- a/stan/math/prim/prob/neg_binomial_2_cdf.hpp +++ b/stan/math/prim/prob/neg_binomial_2_cdf.hpp @@ -55,7 +55,7 @@ return_type_t neg_binomial_2_cdf( // Explicit return for extreme values // The gradients are technically ill-defined, but treated as zero for (size_t i = 0; i < stan::math::size(n); i++) { - if (value_of(n_vec[i]) < 0) { + if (n_vec.val(i) < 0) { return ops_partials.build(0.0); } } @@ -69,11 +69,11 @@ return_type_t neg_binomial_2_cdf( if (!is_constant_all::value) { for (size_t i = 0; i < size_phi; i++) { - digamma_phi_vec[i] = digamma(value_of(phi_vec[i])); + digamma_phi_vec[i] = digamma(phi_vec.val(i)); } for (size_t i = 0; i < size_n_phi; i++) { - const T_partials_return n_dbl = value_of(n_vec[i]); - const T_partials_return phi_dbl = value_of(phi_vec[i]); + const T_partials_return n_dbl = n_vec.val(i); + const T_partials_return phi_dbl = phi_vec.val(i); digamma_sum_vec[i] = digamma(n_dbl + phi_dbl + 1); } } @@ -81,13 +81,13 @@ return_type_t neg_binomial_2_cdf( for (size_t i = 0; i < max_size_seq_view; i++) { // Explicit results for extreme values // The gradients are technically ill-defined, but treated as zero - if (value_of(n_vec[i]) == std::numeric_limits::max()) { + if (n_vec.val(i) == std::numeric_limits::max()) { return ops_partials.build(1.0); } - const T_partials_return n_dbl_p1 = value_of(n_vec[i]) + 1; - const T_partials_return mu_dbl = value_of(mu_vec[i]); - const T_partials_return phi_dbl = value_of(phi_vec[i]); + const T_partials_return n_dbl_p1 = n_vec.val(i) + 1; + const T_partials_return mu_dbl = mu_vec.val(i); + const T_partials_return phi_dbl = phi_vec.val(i); const T_partials_return inv_mu_plus_phi = inv(mu_dbl + phi_dbl); const T_partials_return p_dbl = phi_dbl * inv_mu_plus_phi; const T_partials_return d_dbl = square(inv_mu_plus_phi); 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 e9659e94ab3..96c2a38f730 100644 --- a/stan/math/prim/prob/neg_binomial_2_log_lpmf.hpp +++ b/stan/math/prim/prob/neg_binomial_2_log_lpmf.hpp @@ -66,13 +66,13 @@ return_type_t neg_binomial_2_log_lpmf( VectorBuilder eta_val(size_eta); for (size_t i = 0; i < size_eta; ++i) { - eta_val[i] = value_of(eta_vec[i]); + eta_val[i] = eta_vec.val(i); } VectorBuilder phi_val(size_phi); VectorBuilder log_phi(size_phi); for (size_t i = 0; i < size_phi; ++i) { - phi_val[i] = value_of(phi_vec[i]); + phi_val[i] = phi_vec.val(i); log_phi[i] = log(phi_val[i]); } diff --git a/stan/math/prim/prob/neg_binomial_2_lpmf.hpp b/stan/math/prim/prob/neg_binomial_2_lpmf.hpp index d9787117ed0..67e51c2892b 100644 --- a/stan/math/prim/prob/neg_binomial_2_lpmf.hpp +++ b/stan/math/prim/prob/neg_binomial_2_lpmf.hpp @@ -61,13 +61,13 @@ return_type_t neg_binomial_2_lpmf( VectorBuilder mu_val(size_mu); for (size_t i = 0; i < size_mu; ++i) { - mu_val[i] = value_of(mu_vec[i]); + mu_val[i] = mu_vec.val(i); } VectorBuilder phi_val(size_phi); VectorBuilder log_phi(size_phi); for (size_t i = 0; i < size_phi; ++i) { - phi_val[i] = value_of(phi_vec[i]); + phi_val[i] = phi_vec.val(i); log_phi[i] = log(phi_val[i]); } diff --git a/stan/math/prim/prob/neg_binomial_cdf.hpp b/stan/math/prim/prob/neg_binomial_cdf.hpp index 6c00f3d96ff..2fb53c5e1ef 100644 --- a/stan/math/prim/prob/neg_binomial_cdf.hpp +++ b/stan/math/prim/prob/neg_binomial_cdf.hpp @@ -55,7 +55,7 @@ return_type_t neg_binomial_cdf(const T_n& n, // Explicit return for extreme values // The gradients are technically ill-defined, but treated as zero for (size_t i = 0; i < stan::math::size(n); i++) { - if (value_of(n_vec[i]) < 0) { + if (n_vec.val(i) < 0) { return ops_partials.build(0.0); } } @@ -68,11 +68,11 @@ return_type_t neg_binomial_cdf(const T_n& n, if (!is_constant_all::value) { for (size_t i = 0; i < size_alpha; i++) { - digamma_alpha_vec[i] = digamma(value_of(alpha_vec[i])); + digamma_alpha_vec[i] = digamma(alpha_vec.val(i)); } for (size_t i = 0; i < size_n_alpha; i++) { - const T_partials_return n_dbl = value_of(n_vec[i]); - const T_partials_return alpha_dbl = value_of(alpha_vec[i]); + const T_partials_return n_dbl = n_vec.val(i); + const T_partials_return alpha_dbl = alpha_vec.val(i); digamma_sum_vec[i] = digamma(n_dbl + alpha_dbl + 1); } } @@ -80,13 +80,13 @@ return_type_t neg_binomial_cdf(const T_n& n, for (size_t i = 0; i < max_size_seq_view; i++) { // Explicit results for extreme values // The gradients are technically ill-defined, but treated as zero - if (value_of(n_vec[i]) == std::numeric_limits::max()) { + if (n_vec.val(i) == std::numeric_limits::max()) { return ops_partials.build(1.0); } - const T_partials_return n_dbl = value_of(n_vec[i]); - const T_partials_return alpha_dbl = value_of(alpha_vec[i]); - const T_partials_return beta_dbl = value_of(beta_vec[i]); + const T_partials_return n_dbl = n_vec.val(i); + const T_partials_return alpha_dbl = alpha_vec.val(i); + const T_partials_return beta_dbl = beta_vec.val(i); const T_partials_return inv_beta_p1 = inv(beta_dbl + 1); const T_partials_return p_dbl = beta_dbl * inv_beta_p1; const T_partials_return d_dbl = square(inv_beta_p1); diff --git a/stan/math/prim/prob/neg_binomial_lccdf.hpp b/stan/math/prim/prob/neg_binomial_lccdf.hpp index 88d1a9713d6..88d0bdf5735 100644 --- a/stan/math/prim/prob/neg_binomial_lccdf.hpp +++ b/stan/math/prim/prob/neg_binomial_lccdf.hpp @@ -60,7 +60,7 @@ return_type_t neg_binomial_lccdf( // Explicit return for extreme values // The gradients are technically ill-defined, but treated as zero for (size_t i = 0; i < size_n; i++) { - if (value_of(n_vec[i]) < 0) { + if (n_vec.val(i) < 0) { return ops_partials.build(0.0); } } @@ -75,14 +75,14 @@ return_type_t neg_binomial_lccdf( if (!is_constant_all::value) { for (size_t i = 0; i < size_n; i++) { - digammaN_vec[i] = digamma(value_of(n_vec[i]) + 1); + digammaN_vec[i] = digamma(n_vec.val(i) + 1); } for (size_t i = 0; i < size_alpha; i++) { - digammaAlpha_vec[i] = digamma(value_of(alpha_vec[i])); + digammaAlpha_vec[i] = digamma(alpha_vec.val(i)); } for (size_t i = 0; i < size_n_alpha; i++) { - const T_partials_return n_dbl = value_of(n_vec[i]); - const T_partials_return alpha_dbl = value_of(alpha_vec[i]); + const T_partials_return n_dbl = n_vec.val(i); + const T_partials_return alpha_dbl = alpha_vec.val(i); digammaSum_vec[i] = digamma(n_dbl + alpha_dbl + 1); } } @@ -90,13 +90,13 @@ return_type_t neg_binomial_lccdf( for (size_t i = 0; i < max_size_seq_view; i++) { // Explicit results for extreme values // The gradients are technically ill-defined, but treated as zero - if (value_of(n_vec[i]) == std::numeric_limits::max()) { + if (n_vec.val(i) == std::numeric_limits::max()) { return ops_partials.build(negative_infinity()); } - const T_partials_return n_dbl = value_of(n_vec[i]); - const T_partials_return alpha_dbl = value_of(alpha_vec[i]); - const T_partials_return beta_dbl = value_of(beta_vec[i]); + const T_partials_return n_dbl = n_vec.val(i); + const T_partials_return alpha_dbl = alpha_vec.val(i); + const T_partials_return beta_dbl = beta_vec.val(i); const T_partials_return inv_beta_p1 = inv(beta_dbl + 1); const T_partials_return p_dbl = beta_dbl * inv_beta_p1; const T_partials_return d_dbl = square(inv_beta_p1); diff --git a/stan/math/prim/prob/neg_binomial_lcdf.hpp b/stan/math/prim/prob/neg_binomial_lcdf.hpp index e0e9d6098fd..526e611a7c5 100644 --- a/stan/math/prim/prob/neg_binomial_lcdf.hpp +++ b/stan/math/prim/prob/neg_binomial_lcdf.hpp @@ -60,7 +60,7 @@ return_type_t neg_binomial_lcdf( // Explicit return for extreme values // The gradients are technically ill-defined, but treated as zero for (size_t i = 0; i < size_n; i++) { - if (value_of(n_vec[i]) < 0) { + if (n_vec.val(i) < 0) { return ops_partials.build(negative_infinity()); } } @@ -75,14 +75,14 @@ return_type_t neg_binomial_lcdf( if (!is_constant_all::value) { for (size_t i = 0; i < size_n; i++) { - digammaN_vec[i] = digamma(value_of(n_vec[i]) + 1); + digammaN_vec[i] = digamma(n_vec.val(i) + 1); } for (size_t i = 0; i < size_alpha; i++) { - digammaAlpha_vec[i] = digamma(value_of(alpha_vec[i])); + digammaAlpha_vec[i] = digamma(alpha_vec.val(i)); } for (size_t i = 0; i < size_n_alpha; i++) { - const T_partials_return n_dbl = value_of(n_vec[i]); - const T_partials_return alpha_dbl = value_of(alpha_vec[i]); + const T_partials_return n_dbl = n_vec.val(i); + const T_partials_return alpha_dbl = alpha_vec.val(i); digammaSum_vec[i] = digamma(n_dbl + alpha_dbl + 1); } } @@ -90,13 +90,13 @@ return_type_t neg_binomial_lcdf( for (size_t i = 0; i < max_size_seq_view; i++) { // Explicit results for extreme values // The gradients are technically ill-defined, but treated as zero - if (value_of(n_vec[i]) == std::numeric_limits::max()) { + if (n_vec.val(i) == std::numeric_limits::max()) { return ops_partials.build(0.0); } - const T_partials_return n_dbl = value_of(n_vec[i]); - const T_partials_return alpha_dbl = value_of(alpha_vec[i]); - const T_partials_return beta_dbl = value_of(beta_vec[i]); + const T_partials_return n_dbl = n_vec.val(i); + const T_partials_return alpha_dbl = alpha_vec.val(i); + const T_partials_return beta_dbl = beta_vec.val(i); const T_partials_return inv_beta_p1 = inv(beta_dbl + 1); const T_partials_return p_dbl = beta_dbl * inv_beta_p1; const T_partials_return d_dbl = square(inv_beta_p1); diff --git a/stan/math/prim/prob/neg_binomial_lpmf.hpp b/stan/math/prim/prob/neg_binomial_lpmf.hpp index 573d0f5a4f4..c206f5a2da9 100644 --- a/stan/math/prim/prob/neg_binomial_lpmf.hpp +++ b/stan/math/prim/prob/neg_binomial_lpmf.hpp @@ -70,14 +70,14 @@ return_type_t neg_binomial_lpmf(const T_n& n, digamma_alpha(size_alpha); if (!is_constant_all::value) { for (size_t i = 0; i < size_alpha; ++i) { - digamma_alpha[i] = digamma(value_of(alpha_vec[i])); + digamma_alpha[i] = digamma(alpha_vec.val(i)); } } VectorBuilder log1p_inv_beta(size_beta); VectorBuilder log1p_beta(size_beta); for (size_t i = 0; i < size_beta; ++i) { - const T_partials_return beta_dbl = value_of(beta_vec[i]); + const T_partials_return beta_dbl = beta_vec.val(i); log1p_inv_beta[i] = log1p(inv(beta_dbl)); log1p_beta[i] = log1p(beta_dbl); } @@ -87,16 +87,16 @@ return_type_t neg_binomial_lpmf(const T_n& n, lambda_m_alpha_over_1p_beta(size_alpha_beta); if (!is_constant_all::value) { for (size_t i = 0; i < size_alpha_beta; ++i) { - const T_partials_return alpha_dbl = value_of(alpha_vec[i]); - const T_partials_return beta_dbl = value_of(beta_vec[i]); + const T_partials_return alpha_dbl = alpha_vec.val(i); + const T_partials_return beta_dbl = beta_vec.val(i); lambda_m_alpha_over_1p_beta[i] = alpha_dbl / beta_dbl - alpha_dbl / (1 + beta_dbl); } } for (size_t i = 0; i < max_size_seq_view; i++) { - const T_partials_return alpha_dbl = value_of(alpha_vec[i]); - const T_partials_return beta_dbl = value_of(beta_vec[i]); + const T_partials_return alpha_dbl = alpha_vec.val(i); + const T_partials_return beta_dbl = beta_vec.val(i); if (include_summand::value) { if (n_vec[i] != 0) { diff --git a/stan/math/prim/prob/normal_cdf.hpp b/stan/math/prim/prob/normal_cdf.hpp index 65bccb157b4..10101f34ca0 100644 --- a/stan/math/prim/prob/normal_cdf.hpp +++ b/stan/math/prim/prob/normal_cdf.hpp @@ -64,9 +64,9 @@ inline return_type_t normal_cdf(const T_y& y, size_t N = max_size(y, mu, sigma); for (size_t n = 0; n < N; n++) { - const T_partials_return y_dbl = value_of(y_vec[n]); - const T_partials_return mu_dbl = value_of(mu_vec[n]); - const T_partials_return sigma_dbl = value_of(sigma_vec[n]); + const T_partials_return y_dbl = y_vec.val(n); + const T_partials_return mu_dbl = mu_vec.val(n); + const T_partials_return sigma_dbl = sigma_vec.val(n); const T_partials_return scaled_diff = (y_dbl - mu_dbl) / (sigma_dbl * SQRT_TWO); T_partials_return cdf_n; diff --git a/stan/math/prim/prob/normal_lccdf.hpp b/stan/math/prim/prob/normal_lccdf.hpp index 9432ecec0a6..77adca6b17f 100644 --- a/stan/math/prim/prob/normal_lccdf.hpp +++ b/stan/math/prim/prob/normal_lccdf.hpp @@ -51,9 +51,9 @@ inline return_type_t normal_lccdf(const T_y& y, size_t N = max_size(y, mu, sigma); for (size_t n = 0; n < N; n++) { - const T_partials_return y_dbl = value_of(y_vec[n]); - const T_partials_return mu_dbl = value_of(mu_vec[n]); - const T_partials_return sigma_dbl = value_of(sigma_vec[n]); + const T_partials_return y_dbl = y_vec.val(n); + const T_partials_return mu_dbl = mu_vec.val(n); + const T_partials_return sigma_dbl = sigma_vec.val(n); const T_partials_return scaled_diff = (y_dbl - mu_dbl) / (sigma_dbl * SQRT_TWO); diff --git a/stan/math/prim/prob/normal_lcdf.hpp b/stan/math/prim/prob/normal_lcdf.hpp index bf6a945931f..7ed13334b80 100644 --- a/stan/math/prim/prob/normal_lcdf.hpp +++ b/stan/math/prim/prob/normal_lcdf.hpp @@ -57,9 +57,9 @@ inline return_type_t normal_lcdf(const T_y& y, size_t N = max_size(y, mu, sigma); for (size_t n = 0; n < N; n++) { - const T_partials_return y_dbl = value_of(y_vec[n]); - const T_partials_return mu_dbl = value_of(mu_vec[n]); - const T_partials_return sigma_dbl = value_of(sigma_vec[n]); + const T_partials_return y_dbl = y_vec.val(n); + const T_partials_return mu_dbl = mu_vec.val(n); + const T_partials_return sigma_dbl = sigma_vec.val(n); const T_partials_return scaled_diff = (y_dbl - mu_dbl) / (sigma_dbl * SQRT_TWO); diff --git a/stan/math/prim/prob/pareto_cdf.hpp b/stan/math/prim/prob/pareto_cdf.hpp index 42dee552279..d4e29caf945 100644 --- a/stan/math/prim/prob/pareto_cdf.hpp +++ b/stan/math/prim/prob/pareto_cdf.hpp @@ -53,7 +53,7 @@ return_type_t pareto_cdf(const T_y& y, // Explicit return for extreme values // The gradients are technically ill-defined, but treated as zero for (size_t i = 0; i < stan::math::size(y); i++) { - if (value_of(y_vec[i]) < value_of(y_min_vec[i])) { + if (y_vec.val(i) < y_min_vec.val(i)) { return ops_partials.build(0.0); } } @@ -61,14 +61,14 @@ return_type_t pareto_cdf(const T_y& y, for (size_t n = 0; n < N; n++) { // Explicit results for extreme values // The gradients are technically ill-defined, but treated as zero - if (value_of(y_vec[n]) == INFTY) { + if (y_vec.val(n) == INFTY) { continue; } const T_partials_return log_dbl - = log(value_of(y_min_vec[n]) / value_of(y_vec[n])); - const T_partials_return y_min_inv_dbl = 1.0 / value_of(y_min_vec[n]); - const T_partials_return alpha_dbl = value_of(alpha_vec[n]); + = log(y_min_vec.val(n) / y_vec.val(n)); + const T_partials_return y_min_inv_dbl = 1.0 / y_vec.val(n); + const T_partials_return alpha_dbl = y_vec.val(n); const T_partials_return Pn = 1.0 - exp(alpha_dbl * log_dbl); 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 f4a65ab2b3c..30caf205456 100644 --- a/stan/math/prim/prob/scaled_inv_chi_square_cdf.hpp +++ b/stan/math/prim/prob/scaled_inv_chi_square_cdf.hpp @@ -71,7 +71,7 @@ return_type_t scaled_inv_chi_square_cdf(const T_y& y, // Explicit return for extreme values // The gradients are technically ill-defined, but treated as zero for (size_t i = 0; i < stan::math::size(y); i++) { - if (value_of(y_vec[i]) == 0) { + if (y_vec.val(i) == 0) { return ops_partials.build(0.0); } } @@ -83,7 +83,7 @@ return_type_t scaled_inv_chi_square_cdf(const T_y& y, if (!is_constant_all::value) { for (size_t i = 0; i < stan::math::size(nu); i++) { - const T_partials_return half_nu_dbl = 0.5 * value_of(nu_vec[i]); + const T_partials_return half_nu_dbl = 0.5 * nu_vec.val(i); gamma_vec[i] = tgamma(half_nu_dbl); digamma_vec[i] = digamma(half_nu_dbl); } @@ -92,14 +92,14 @@ return_type_t scaled_inv_chi_square_cdf(const T_y& y, for (size_t n = 0; n < N; n++) { // Explicit results for extreme values // The gradients are technically ill-defined, but treated as zero - if (value_of(y_vec[n]) == INFTY) { + if (y_vec.val(n) == INFTY) { continue; } - const T_partials_return y_dbl = value_of(y_vec[n]); + const T_partials_return y_dbl = y_vec.val(n); const T_partials_return y_inv_dbl = 1.0 / y_dbl; - const T_partials_return half_nu_dbl = 0.5 * value_of(nu_vec[n]); - const T_partials_return s_dbl = value_of(s_vec[n]); + const T_partials_return half_nu_dbl = 0.5 * nu_vec.val(n); + const T_partials_return s_dbl = s_vec.val(n); const T_partials_return half_s2_overx_dbl = 0.5 * s_dbl * s_dbl * y_inv_dbl; const T_partials_return half_nu_s2_overx_dbl = 2.0 * half_nu_dbl * half_s2_overx_dbl; 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 79e2a78dbb6..d0826784c3a 100644 --- a/stan/math/prim/prob/scaled_inv_chi_square_lccdf.hpp +++ b/stan/math/prim/prob/scaled_inv_chi_square_lccdf.hpp @@ -57,7 +57,7 @@ return_type_t scaled_inv_chi_square_lccdf( // Explicit return for extreme values // The gradients are technically ill-defined, but treated as zero for (size_t i = 0; i < stan::math::size(y); i++) { - if (value_of(y_vec[i]) == 0) { + if (y_vec.val(i) == 0) { return ops_partials.build(0.0); } } @@ -69,7 +69,7 @@ return_type_t scaled_inv_chi_square_lccdf( if (!is_constant_all::value) { for (size_t i = 0; i < stan::math::size(nu); i++) { - const T_partials_return half_nu_dbl = 0.5 * value_of(nu_vec[i]); + const T_partials_return half_nu_dbl = 0.5 * nu_vec.val(i); gamma_vec[i] = tgamma(half_nu_dbl); digamma_vec[i] = digamma(half_nu_dbl); } @@ -78,14 +78,14 @@ return_type_t scaled_inv_chi_square_lccdf( for (size_t n = 0; n < N; n++) { // Explicit results for extreme values // The gradients are technically ill-defined, but treated as zero - if (value_of(y_vec[n]) == INFTY) { + if (y_vec.val(n) == INFTY) { return ops_partials.build(negative_infinity()); } - const T_partials_return y_dbl = value_of(y_vec[n]); + const T_partials_return y_dbl = y_vec.val(n); const T_partials_return y_inv_dbl = 1.0 / y_dbl; - const T_partials_return half_nu_dbl = 0.5 * value_of(nu_vec[n]); - const T_partials_return s_dbl = value_of(s_vec[n]); + const T_partials_return half_nu_dbl = 0.5 * nu_vec.val(n); + const T_partials_return s_dbl = s_vec.val(n); const T_partials_return half_s2_overx_dbl = 0.5 * s_dbl * s_dbl * y_inv_dbl; const T_partials_return half_nu_s2_overx_dbl = 2.0 * half_nu_dbl * half_s2_overx_dbl; 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 3e81a71b730..0b71388b491 100644 --- a/stan/math/prim/prob/scaled_inv_chi_square_lcdf.hpp +++ b/stan/math/prim/prob/scaled_inv_chi_square_lcdf.hpp @@ -57,7 +57,7 @@ return_type_t scaled_inv_chi_square_lcdf( // Explicit return for extreme values // The gradients are technically ill-defined, but treated as zero for (size_t i = 0; i < stan::math::size(y); i++) { - if (value_of(y_vec[i]) == 0) { + if (y_vec.val(i) == 0) { return ops_partials.build(negative_infinity()); } } @@ -69,7 +69,7 @@ return_type_t scaled_inv_chi_square_lcdf( if (!is_constant_all::value) { for (size_t i = 0; i < stan::math::size(nu); i++) { - const T_partials_return half_nu_dbl = 0.5 * value_of(nu_vec[i]); + const T_partials_return half_nu_dbl = 0.5 * nu_vec.val(i); gamma_vec[i] = tgamma(half_nu_dbl); digamma_vec[i] = digamma(half_nu_dbl); } @@ -78,14 +78,14 @@ return_type_t scaled_inv_chi_square_lcdf( for (size_t n = 0; n < N; n++) { // Explicit results for extreme values // The gradients are technically ill-defined, but treated as zero - if (value_of(y_vec[n]) == INFTY) { + if (y_vec.val(n) == INFTY) { continue; } - const T_partials_return y_dbl = value_of(y_vec[n]); + const T_partials_return y_dbl = y_vec.val(n); const T_partials_return y_inv_dbl = 1.0 / y_dbl; - const T_partials_return half_nu_dbl = 0.5 * value_of(nu_vec[n]); - const T_partials_return s_dbl = value_of(s_vec[n]); + const T_partials_return half_nu_dbl = 0.5 * nu_vec.val(n); + const T_partials_return s_dbl = s_vec.val(n); const T_partials_return half_s2_overx_dbl = 0.5 * s_dbl * s_dbl * y_inv_dbl; const T_partials_return half_nu_s2_overx_dbl = 2.0 * half_nu_dbl * half_s2_overx_dbl; 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 9fe954fd8d4..33cbfacde8c 100644 --- a/stan/math/prim/prob/scaled_inv_chi_square_lpdf.hpp +++ b/stan/math/prim/prob/scaled_inv_chi_square_lpdf.hpp @@ -78,7 +78,7 @@ return_type_t scaled_inv_chi_square_lpdf( size_t N = max_size(y, nu, s); for (size_t n = 0; n < N; n++) { - if (value_of(y_vec[n]) <= 0) { + if (y_vec.val(n) <= 0) { return LOG_ZERO; } } @@ -88,7 +88,7 @@ return_type_t scaled_inv_chi_square_lpdf( half_nu(size(nu)); for (size_t i = 0; i < stan::math::size(nu); i++) { if (include_summand::value) { - half_nu[i] = 0.5 * value_of(nu_vec[i]); + half_nu[i] = 0.5 * nu_vec.val(i); } } @@ -97,7 +97,7 @@ return_type_t scaled_inv_chi_square_lpdf( log_y(size(y)); for (size_t i = 0; i < stan::math::size(y); i++) { if (include_summand::value) { - log_y[i] = log(value_of(y_vec[i])); + log_y[i] = log(y_vec.val(i)); } } @@ -106,7 +106,7 @@ return_type_t scaled_inv_chi_square_lpdf( inv_y(size(y)); for (size_t i = 0; i < stan::math::size(y); i++) { if (include_summand::value) { - inv_y[i] = 1.0 / value_of(y_vec[i]); + inv_y[i] = 1.0 / y_vec.val(i); } } @@ -115,7 +115,7 @@ return_type_t scaled_inv_chi_square_lpdf( log_s(size(s)); for (size_t i = 0; i < stan::math::size(s); i++) { if (include_summand::value) { - log_s[i] = log(value_of(s_vec[i])); + log_s[i] = log(s_vec.val(i)); } } @@ -138,8 +138,8 @@ return_type_t scaled_inv_chi_square_lpdf( } for (size_t n = 0; n < N; n++) { - const T_partials_return s_dbl = value_of(s_vec[n]); - const T_partials_return nu_dbl = value_of(nu_vec[n]); + const T_partials_return s_dbl = s_vec.val(n); + const T_partials_return nu_dbl = nu_vec.val(n); if (include_summand::value) { logp += half_nu[n] * log_half_nu[n] - lgamma_half_nu[n]; } diff --git a/stan/math/prim/prob/std_normal_cdf.hpp b/stan/math/prim/prob/std_normal_cdf.hpp index 9d27a001290..8686917793e 100644 --- a/stan/math/prim/prob/std_normal_cdf.hpp +++ b/stan/math/prim/prob/std_normal_cdf.hpp @@ -46,7 +46,7 @@ inline return_type_t std_normal_cdf(const T_y& y) { size_t N = stan::math::size(y); for (size_t n = 0; n < N; n++) { - const T_partials_return y_dbl = value_of(y_vec[n]); + const T_partials_return y_dbl = y_vec.val(n); const T_partials_return scaled_y = y_dbl * INV_SQRT_TWO; T_partials_return cdf_n; if (y_dbl < -37.5) { diff --git a/stan/math/prim/prob/std_normal_lccdf.hpp b/stan/math/prim/prob/std_normal_lccdf.hpp index dcc93bba370..de8152df115 100644 --- a/stan/math/prim/prob/std_normal_lccdf.hpp +++ b/stan/math/prim/prob/std_normal_lccdf.hpp @@ -38,7 +38,7 @@ inline return_type_t std_normal_lccdf(const T_y& y) { size_t N = stan::math::size(y); for (size_t n = 0; n < N; n++) { - const T_partials_return y_dbl = value_of(y_vec[n]); + const T_partials_return y_dbl = y_vec.val(n); const T_partials_return scaled_y = y_dbl * INV_SQRT_TWO; T_partials_return one_m_erf; diff --git a/stan/math/prim/prob/std_normal_lcdf.hpp b/stan/math/prim/prob/std_normal_lcdf.hpp index 0defa6ec96d..ec1b93c9efb 100644 --- a/stan/math/prim/prob/std_normal_lcdf.hpp +++ b/stan/math/prim/prob/std_normal_lcdf.hpp @@ -43,7 +43,7 @@ inline return_type_t std_normal_lcdf(const T_y& y) { size_t N = stan::math::size(y); for (size_t n = 0; n < N; n++) { - const T_partials_return y_dbl = value_of(y_vec[n]); + const T_partials_return y_dbl = y_vec.val(n); const T_partials_return scaled_y = y_dbl * INV_SQRT_TWO; const T_partials_return x2 = square(scaled_y); diff --git a/stan/math/prim/prob/std_normal_lpdf.hpp b/stan/math/prim/prob/std_normal_lpdf.hpp index 05d34d7b8b7..fdc29232157 100644 --- a/stan/math/prim/prob/std_normal_lpdf.hpp +++ b/stan/math/prim/prob/std_normal_lpdf.hpp @@ -49,7 +49,7 @@ return_type_t std_normal_lpdf(const T_y& y) { size_t N = stan::math::size(y); for (size_t n = 0; n < N; n++) { - const T_partials_return y_val = value_of(y_vec[n]); + const T_partials_return y_val = y_vec.val(n); logp += y_val * y_val; if (!is_constant_all::value) { ops_partials.edge1_.partials_[n] -= y_val; diff --git a/stan/math/prim/prob/student_t_cdf.hpp b/stan/math/prim/prob/student_t_cdf.hpp index cef582b6c4a..d5a6d634a36 100644 --- a/stan/math/prim/prob/student_t_cdf.hpp +++ b/stan/math/prim/prob/student_t_cdf.hpp @@ -56,7 +56,7 @@ return_type_t student_t_cdf(const T_y& y, // Explicit return for extreme values // The gradients are technically ill-defined, but treated as zero for (size_t i = 0; i < stan::math::size(y); i++) { - if (value_of(y_vec[i]) == NEGATIVE_INFTY) { + if (y_vec.val(i) == NEGATIVE_INFTY) { return ops_partials.build(0.0); } } @@ -74,7 +74,7 @@ return_type_t student_t_cdf(const T_y& y, digammaHalf = digamma(0.5); for (size_t i = 0; i < stan::math::size(nu); i++) { - const T_partials_return nu_dbl = value_of(nu_vec[i]); + const T_partials_return nu_dbl = nu_vec.val(i); digammaNu_vec[i] = digamma(0.5 * nu_dbl); digammaNuPlusHalf_vec[i] = digamma(0.5 + 0.5 * nu_dbl); @@ -84,14 +84,14 @@ return_type_t student_t_cdf(const T_y& y, for (size_t n = 0; n < N; n++) { // Explicit results for extreme values // The gradients are technically ill-defined, but treated as zero - if (value_of(y_vec[n]) == INFTY) { + if (y_vec.val(n) == INFTY) { continue; } - const T_partials_return sigma_inv = 1.0 / value_of(sigma_vec[n]); + const T_partials_return sigma_inv = 1.0 / y_vec.val(n); const T_partials_return t - = (value_of(y_vec[n]) - value_of(mu_vec[n])) * sigma_inv; - const T_partials_return nu_dbl = value_of(nu_vec[n]); + = (y_vec.val(n) - mu_vec.val(n)) * sigma_inv; + const T_partials_return nu_dbl = y_vec.val(n); const T_partials_return q = nu_dbl / (t * t); const T_partials_return r = 1.0 / (1.0 + q); const T_partials_return J = 2 * r * r * q / t; diff --git a/stan/math/prim/prob/student_t_lccdf.hpp b/stan/math/prim/prob/student_t_lccdf.hpp index bef0bbda65f..4502e64a819 100644 --- a/stan/math/prim/prob/student_t_lccdf.hpp +++ b/stan/math/prim/prob/student_t_lccdf.hpp @@ -56,7 +56,7 @@ return_type_t student_t_lccdf( // Explicit return for extreme values // The gradients are technically ill-defined, but treated as zero for (size_t i = 0; i < stan::math::size(y); i++) { - if (value_of(y_vec[i]) == NEGATIVE_INFTY) { + if (y_vec.val(i) == NEGATIVE_INFTY) { return ops_partials.build(0.0); } } @@ -74,7 +74,7 @@ return_type_t student_t_lccdf( digammaHalf = digamma(0.5); for (size_t i = 0; i < stan::math::size(nu); i++) { - const T_partials_return nu_dbl = value_of(nu_vec[i]); + const T_partials_return nu_dbl = nu_vec.val(i); digammaNu_vec[i] = digamma(0.5 * nu_dbl); digammaNuPlusHalf_vec[i] = digamma(0.5 + 0.5 * nu_dbl); @@ -84,14 +84,14 @@ return_type_t student_t_lccdf( for (size_t n = 0; n < N; n++) { // Explicit results for extreme values // The gradients are technically ill-defined, but treated as zero - if (value_of(y_vec[n]) == INFTY) { + if (y_vec.val(n) == INFTY) { return ops_partials.build(negative_infinity()); } - const T_partials_return sigma_inv = 1.0 / value_of(sigma_vec[n]); + const T_partials_return sigma_inv = 1.0 / y_vec.val(n); const T_partials_return t - = (value_of(y_vec[n]) - value_of(mu_vec[n])) * sigma_inv; - const T_partials_return nu_dbl = value_of(nu_vec[n]); + = (y_vec.val(n) - mu_vec.val(n)) * sigma_inv; + const T_partials_return nu_dbl = y_vec.val(n); const T_partials_return q = nu_dbl / (t * t); const T_partials_return r = 1.0 / (1.0 + q); const T_partials_return J = 2 * r * r * q / t; diff --git a/stan/math/prim/prob/student_t_lcdf.hpp b/stan/math/prim/prob/student_t_lcdf.hpp index 0c99251dbf9..d65e6df6d57 100644 --- a/stan/math/prim/prob/student_t_lcdf.hpp +++ b/stan/math/prim/prob/student_t_lcdf.hpp @@ -58,7 +58,7 @@ return_type_t student_t_lcdf(const T_y& y, // Explicit return for extreme values // The gradients are technically ill-defined, but treated as zero for (size_t i = 0; i < stan::math::size(y); i++) { - if (value_of(y_vec[i]) == NEGATIVE_INFTY) { + if (y_vec.val(i) == NEGATIVE_INFTY) { return ops_partials.build(negative_infinity()); } } @@ -76,7 +76,7 @@ return_type_t student_t_lcdf(const T_y& y, digammaHalf = digamma(0.5); for (size_t i = 0; i < stan::math::size(nu); i++) { - const T_partials_return nu_dbl = value_of(nu_vec[i]); + const T_partials_return nu_dbl = nu_vec.val(i); digammaNu_vec[i] = digamma(0.5 * nu_dbl); digammaNuPlusHalf_vec[i] = digamma(0.5 + 0.5 * nu_dbl); @@ -86,14 +86,14 @@ return_type_t student_t_lcdf(const T_y& y, for (size_t n = 0; n < N; n++) { // Explicit results for extreme values // The gradients are technically ill-defined, but treated as zero - if (value_of(y_vec[n]) == INFTY) { + if (y_vec.val(n) == INFTY) { continue; } - const T_partials_return sigma_inv = 1.0 / value_of(sigma_vec[n]); + const T_partials_return sigma_inv = 1.0 / y_vec.val(n); const T_partials_return t - = (value_of(y_vec[n]) - value_of(mu_vec[n])) * sigma_inv; - const T_partials_return nu_dbl = value_of(nu_vec[n]); + = (y_vec.val(n) - mu_vec.val(n)) * sigma_inv; + const T_partials_return nu_dbl = y_vec.val(n); const T_partials_return q = nu_dbl / (t * t); const T_partials_return r = 1.0 / (1.0 + q); const T_partials_return J = 2 * r * r * q / t; From 27ec9292afe8d332a6cd7fa2a7b9b57e2822c3bd Mon Sep 17 00:00:00 2001 From: stevebronder Date: Wed, 6 Jan 2021 00:28:17 -0700 Subject: [PATCH 02/17] add tests for var scalar and vector seq views --- stan/math/prim/err/check_bounded.hpp | 1 + stan/math/prim/err/check_greater.hpp | 1 + stan/math/prim/err/check_greater_or_equal.hpp | 1 + stan/math/prim/err/check_less.hpp | 1 + stan/math/prim/err/check_less_or_equal.hpp | 1 + stan/math/prim/err/is_less_or_equal.hpp | 1 + stan/math/prim/fun.hpp | 2 + .../prim/fun/poisson_binomial_log_probs.hpp | 1 + .../prim/{meta => fun}/scalar_seq_view.hpp | 16 ++-- .../prim/{meta => fun}/vector_seq_view.hpp | 27 +++--- stan/math/prim/meta.hpp | 2 - stan/math/prim/prob/bernoulli_cdf.hpp | 1 + stan/math/prim/prob/bernoulli_lccdf.hpp | 1 + stan/math/prim/prob/bernoulli_lcdf.hpp | 1 + .../prim/prob/bernoulli_logit_glm_rng.hpp | 1 + stan/math/prim/prob/bernoulli_logit_rng.hpp | 1 + stan/math/prim/prob/bernoulli_lpmf.hpp | 1 + stan/math/prim/prob/bernoulli_rng.hpp | 1 + stan/math/prim/prob/beta_binomial_cdf.hpp | 1 + stan/math/prim/prob/beta_binomial_lccdf.hpp | 1 + stan/math/prim/prob/beta_binomial_lcdf.hpp | 1 + stan/math/prim/prob/beta_binomial_lpmf.hpp | 1 + stan/math/prim/prob/beta_cdf.hpp | 1 + stan/math/prim/prob/beta_lccdf.hpp | 1 + stan/math/prim/prob/beta_lcdf.hpp | 1 + stan/math/prim/prob/beta_proportion_lccdf.hpp | 1 + stan/math/prim/prob/beta_proportion_lcdf.hpp | 1 + stan/math/prim/prob/beta_proportion_rng.hpp | 1 + stan/math/prim/prob/beta_rng.hpp | 1 + stan/math/prim/prob/binomial_cdf.hpp | 1 + stan/math/prim/prob/binomial_lccdf.hpp | 1 + stan/math/prim/prob/binomial_lcdf.hpp | 1 + stan/math/prim/prob/binomial_lpmf.hpp | 1 + stan/math/prim/prob/binomial_rng.hpp | 1 + .../prim/prob/categorical_logit_glm_lpmf.hpp | 1 + stan/math/prim/prob/cauchy_cdf.hpp | 1 + stan/math/prim/prob/cauchy_lccdf.hpp | 1 + stan/math/prim/prob/cauchy_lcdf.hpp | 1 + stan/math/prim/prob/cauchy_rng.hpp | 1 + stan/math/prim/prob/chi_square_cdf.hpp | 1 + stan/math/prim/prob/chi_square_lccdf.hpp | 1 + stan/math/prim/prob/chi_square_lcdf.hpp | 1 + stan/math/prim/prob/chi_square_rng.hpp | 1 + stan/math/prim/prob/dirichlet_lpdf.hpp | 1 + stan/math/prim/prob/discrete_range_cdf.hpp | 1 + stan/math/prim/prob/discrete_range_lccdf.hpp | 1 + stan/math/prim/prob/discrete_range_lcdf.hpp | 1 + stan/math/prim/prob/discrete_range_lpmf.hpp | 1 + stan/math/prim/prob/discrete_range_rng.hpp | 1 + .../prim/prob/double_exponential_lccdf.hpp | 1 + .../prim/prob/double_exponential_lcdf.hpp | 1 + .../math/prim/prob/double_exponential_rng.hpp | 1 + stan/math/prim/prob/exp_mod_normal_lccdf.hpp | 1 + stan/math/prim/prob/exp_mod_normal_lcdf.hpp | 1 + stan/math/prim/prob/exp_mod_normal_rng.hpp | 1 + stan/math/prim/prob/exponential_rng.hpp | 1 + stan/math/prim/prob/frechet_cdf.hpp | 1 + stan/math/prim/prob/frechet_lccdf.hpp | 1 + stan/math/prim/prob/frechet_lcdf.hpp | 1 + stan/math/prim/prob/frechet_rng.hpp | 1 + stan/math/prim/prob/gamma_cdf.hpp | 1 + stan/math/prim/prob/gamma_lccdf.hpp | 1 + stan/math/prim/prob/gamma_lcdf.hpp | 1 + stan/math/prim/prob/gamma_lpdf.hpp | 1 + stan/math/prim/prob/gamma_rng.hpp | 1 + stan/math/prim/prob/gumbel_rng.hpp | 1 + stan/math/prim/prob/hypergeometric_lpmf.hpp | 1 + stan/math/prim/prob/inv_chi_square_cdf.hpp | 1 + stan/math/prim/prob/inv_chi_square_lccdf.hpp | 1 + stan/math/prim/prob/inv_chi_square_lcdf.hpp | 1 + stan/math/prim/prob/inv_chi_square_rng.hpp | 1 + stan/math/prim/prob/inv_gamma_cdf.hpp | 1 + stan/math/prim/prob/inv_gamma_lccdf.hpp | 1 + stan/math/prim/prob/inv_gamma_lcdf.hpp | 1 + stan/math/prim/prob/inv_gamma_rng.hpp | 1 + stan/math/prim/prob/logistic_cdf.hpp | 1 + stan/math/prim/prob/logistic_lccdf.hpp | 1 + stan/math/prim/prob/logistic_lcdf.hpp | 1 + stan/math/prim/prob/logistic_rng.hpp | 1 + stan/math/prim/prob/lognormal_rng.hpp | 1 + .../prim/prob/multi_normal_cholesky_lpdf.hpp | 1 + .../prim/prob/multi_normal_cholesky_rng.hpp | 1 + stan/math/prim/prob/multi_normal_lpdf.hpp | 1 + .../math/prim/prob/multi_normal_prec_lpdf.hpp | 1 + stan/math/prim/prob/multi_normal_prec_rng.hpp | 1 + stan/math/prim/prob/multi_normal_rng.hpp | 1 + stan/math/prim/prob/multi_student_t_lpdf.hpp | 1 + stan/math/prim/prob/multi_student_t_rng.hpp | 1 + stan/math/prim/prob/neg_binomial_2_cdf.hpp | 1 + stan/math/prim/prob/neg_binomial_2_lccdf.hpp | 1 + stan/math/prim/prob/neg_binomial_2_lcdf.hpp | 1 + .../prim/prob/neg_binomial_2_log_glm_lpmf.hpp | 1 + .../prim/prob/neg_binomial_2_log_lpmf.hpp | 1 + .../math/prim/prob/neg_binomial_2_log_rng.hpp | 1 + stan/math/prim/prob/neg_binomial_2_lpmf.hpp | 1 + stan/math/prim/prob/neg_binomial_2_rng.hpp | 1 + stan/math/prim/prob/neg_binomial_cdf.hpp | 1 + stan/math/prim/prob/neg_binomial_lccdf.hpp | 1 + stan/math/prim/prob/neg_binomial_lcdf.hpp | 1 + stan/math/prim/prob/neg_binomial_lpmf.hpp | 1 + stan/math/prim/prob/neg_binomial_rng.hpp | 1 + stan/math/prim/prob/normal_cdf.hpp | 1 + stan/math/prim/prob/normal_lccdf.hpp | 1 + stan/math/prim/prob/normal_lcdf.hpp | 1 + stan/math/prim/prob/normal_rng.hpp | 1 + .../prim/prob/ordered_logistic_glm_lpmf.hpp | 1 + stan/math/prim/prob/ordered_logistic_lpmf.hpp | 2 + stan/math/prim/prob/ordered_probit_lpmf.hpp | 2 + stan/math/prim/prob/pareto_cdf.hpp | 1 + stan/math/prim/prob/pareto_rng.hpp | 1 + stan/math/prim/prob/pareto_type_2_rng.hpp | 1 + .../math/prim/prob/poisson_binomial_lccdf.hpp | 2 + stan/math/prim/prob/poisson_binomial_lcdf.hpp | 2 + stan/math/prim/prob/poisson_binomial_lpmf.hpp | 2 + stan/math/prim/prob/poisson_log_lpmf.hpp | 1 + stan/math/prim/prob/poisson_log_rng.hpp | 1 + stan/math/prim/prob/poisson_lpmf.hpp | 1 + stan/math/prim/prob/poisson_rng.hpp | 1 + stan/math/prim/prob/rayleigh_rng.hpp | 1 + .../prim/prob/scaled_inv_chi_square_cdf.hpp | 1 + .../prim/prob/scaled_inv_chi_square_lccdf.hpp | 1 + .../prim/prob/scaled_inv_chi_square_lcdf.hpp | 1 + .../prim/prob/scaled_inv_chi_square_lpdf.hpp | 1 + .../prim/prob/scaled_inv_chi_square_rng.hpp | 1 + stan/math/prim/prob/skew_normal_rng.hpp | 1 + stan/math/prim/prob/std_normal_cdf.hpp | 1 + stan/math/prim/prob/std_normal_lccdf.hpp | 1 + stan/math/prim/prob/std_normal_lcdf.hpp | 1 + stan/math/prim/prob/std_normal_lpdf.hpp | 1 + stan/math/prim/prob/student_t_cdf.hpp | 1 + stan/math/prim/prob/student_t_lccdf.hpp | 1 + stan/math/prim/prob/student_t_lcdf.hpp | 1 + stan/math/prim/prob/student_t_rng.hpp | 1 + stan/math/prim/prob/uniform_rng.hpp | 1 + stan/math/prim/prob/von_mises_rng.hpp | 1 + stan/math/prim/prob/weibull_rng.hpp | 1 + stan/math/prim/prob/wiener_lpdf.hpp | 1 + stan/math/rev/meta/is_rev_matrix.hpp | 3 +- .../math/rev/meta/scalar_seq_view_test.cpp | 84 +++++++++++++++++++ .../math/rev/meta/vector_seq_view_test.cpp | 30 +++++++ 140 files changed, 271 insertions(+), 31 deletions(-) rename stan/math/prim/{meta => fun}/scalar_seq_view.hpp (87%) rename stan/math/prim/{meta => fun}/vector_seq_view.hpp (82%) create mode 100644 test/unit/math/rev/meta/scalar_seq_view_test.cpp create mode 100644 test/unit/math/rev/meta/vector_seq_view_test.cpp diff --git a/stan/math/prim/err/check_bounded.hpp b/stan/math/prim/err/check_bounded.hpp index fa7c7cd5587..5bd82130316 100644 --- a/stan/math/prim/err/check_bounded.hpp +++ b/stan/math/prim/err/check_bounded.hpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/err/check_greater.hpp b/stan/math/prim/err/check_greater.hpp index a146dd35c5b..b5b0b92ed14 100644 --- a/stan/math/prim/err/check_greater.hpp +++ b/stan/math/prim/err/check_greater.hpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/err/check_greater_or_equal.hpp b/stan/math/prim/err/check_greater_or_equal.hpp index a070f4bd451..37560a0a4ed 100644 --- a/stan/math/prim/err/check_greater_or_equal.hpp +++ b/stan/math/prim/err/check_greater_or_equal.hpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/err/check_less.hpp b/stan/math/prim/err/check_less.hpp index 56ac704dd6f..92f0d88eadf 100644 --- a/stan/math/prim/err/check_less.hpp +++ b/stan/math/prim/err/check_less.hpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/err/check_less_or_equal.hpp b/stan/math/prim/err/check_less_or_equal.hpp index 534e467e077..112db46a47b 100644 --- a/stan/math/prim/err/check_less_or_equal.hpp +++ b/stan/math/prim/err/check_less_or_equal.hpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/err/is_less_or_equal.hpp b/stan/math/prim/err/is_less_or_equal.hpp index 8aa47e52512..8344e3c32e6 100644 --- a/stan/math/prim/err/is_less_or_equal.hpp +++ b/stan/math/prim/err/is_less_or_equal.hpp @@ -3,6 +3,7 @@ #include #include +#include #include #include diff --git a/stan/math/prim/fun.hpp b/stan/math/prim/fun.hpp index ef110d5fa34..3104d23e6b3 100644 --- a/stan/math/prim/fun.hpp +++ b/stan/math/prim/fun.hpp @@ -278,6 +278,7 @@ #include #include #include +#include #include #include #include @@ -336,6 +337,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/fun/poisson_binomial_log_probs.hpp b/stan/math/prim/fun/poisson_binomial_log_probs.hpp index 3c7fe1f9235..f9143d27178 100644 --- a/stan/math/prim/fun/poisson_binomial_log_probs.hpp +++ b/stan/math/prim/fun/poisson_binomial_log_probs.hpp @@ -6,6 +6,7 @@ #include #include #include +#include namespace stan { namespace math { diff --git a/stan/math/prim/meta/scalar_seq_view.hpp b/stan/math/prim/fun/scalar_seq_view.hpp similarity index 87% rename from stan/math/prim/meta/scalar_seq_view.hpp rename to stan/math/prim/fun/scalar_seq_view.hpp index b4f3cc168eb..3990b8e165a 100644 --- a/stan/math/prim/meta/scalar_seq_view.hpp +++ b/stan/math/prim/fun/scalar_seq_view.hpp @@ -1,14 +1,8 @@ #ifndef STAN_MATH_PRIM_META_SCALAR_SEQ_VIEW_HPP #define STAN_MATH_PRIM_META_SCALAR_SEQ_VIEW_HPP -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include #include #include @@ -95,17 +89,17 @@ class scalar_seq_view> { * @param i index * @return the element at the specified position in the container */ - inline auto operator[](size_t i) const { return c_.coeffRef(i); } + inline auto operator[](size_t i) const { return c_[i]; } inline auto size() const noexcept { return c_.size(); } template * = nullptr> inline auto val(size_t i) const { - return c_.coeffRef(i); + return c_[i]; } template * = nullptr> inline auto val(size_t i) const { - return c_.coeffRef(i).val(); + return c_[i].val(); } private: diff --git a/stan/math/prim/meta/vector_seq_view.hpp b/stan/math/prim/fun/vector_seq_view.hpp similarity index 82% rename from stan/math/prim/meta/vector_seq_view.hpp rename to stan/math/prim/fun/vector_seq_view.hpp index 8d28b72306b..6d66f684544 100644 --- a/stan/math/prim/meta/vector_seq_view.hpp +++ b/stan/math/prim/fun/vector_seq_view.hpp @@ -1,5 +1,5 @@ -#ifndef STAN_MATH_PRIM_META_vector_SEQ_VIEW_HPP -#define STAN_MATH_PRIM_META_vector_SEQ_VIEW_HPP +#ifndef STAN_MATH_PRIM_META_VECTOR_SEQ_VIEW_HPP +#define STAN_MATH_PRIM_META_VECTOR_SEQ_VIEW_HPP #include #include @@ -7,16 +7,6 @@ namespace stan { -template * = nullptr> -inline T value_of(T&& x); - -template * = nullptr> -inline auto value_of(const std::vector& x); - -template * = nullptr, - require_not_st_arithmetic* = nullptr> -inline auto value_of(EigMat&& M); - /** \ingroup type_trait * This class provides a low-cost wrapper for situations where you either need * an Eigen Vector or RowVector or a std::vector of them and you want to be @@ -29,7 +19,7 @@ inline auto value_of(EigMat&& M); * @tparam T the wrapped type, either a Vector or std::vector of them. */ template -class vector_seq_view {}; +class vector_seq_view; /** \ingroup type_trait * This class provides a low-cost wrapper for situations where you either need @@ -55,7 +45,7 @@ class vector_seq_view> { } template * = nullptr> - inline const auto& val(size_t /* i */) const noexcept { + inline auto val(size_t /* i */) const noexcept { return m_.val(); } @@ -63,6 +53,11 @@ class vector_seq_view> { const ref_type_t m_; }; +namespace internal { + template + using is_matrix_or_std_vector = math::disjunction, is_std_vector>; +} + /** \ingroup type_trait * This class provides a low-cost wrapper for situations where you either need * an Eigen Vector or RowVector or a std::vector of them and you want to be @@ -75,7 +70,7 @@ class vector_seq_view> { * @tparam S the type inside of the std::vector */ template -class vector_seq_view> { +class vector_seq_view> { public: explicit vector_seq_view(const T& v) noexcept : v_(v) {} inline auto size() const noexcept { return v_.size(); } @@ -88,7 +83,7 @@ class vector_seq_view> { } template * = nullptr> - inline const auto& val(size_t i) const { + inline auto val(size_t i) const { return value_of(v_[i]); } diff --git a/stan/math/prim/meta.hpp b/stan/math/prim/meta.hpp index e5142b07299..c13fc5b8bec 100644 --- a/stan/math/prim/meta.hpp +++ b/stan/math/prim/meta.hpp @@ -225,13 +225,11 @@ #include #include #include -#include #include #include #include #include #include -#include #include #include #include diff --git a/stan/math/prim/prob/bernoulli_cdf.hpp b/stan/math/prim/prob/bernoulli_cdf.hpp index cf6a28db813..ed3d1d9a39c 100644 --- a/stan/math/prim/prob/bernoulli_cdf.hpp +++ b/stan/math/prim/prob/bernoulli_cdf.hpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/bernoulli_lccdf.hpp b/stan/math/prim/prob/bernoulli_lccdf.hpp index ef3fab1b198..0017779ea54 100644 --- a/stan/math/prim/prob/bernoulli_lccdf.hpp +++ b/stan/math/prim/prob/bernoulli_lccdf.hpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/bernoulli_lcdf.hpp b/stan/math/prim/prob/bernoulli_lcdf.hpp index c9521163d76..78c51fc8074 100644 --- a/stan/math/prim/prob/bernoulli_lcdf.hpp +++ b/stan/math/prim/prob/bernoulli_lcdf.hpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/bernoulli_logit_glm_rng.hpp b/stan/math/prim/prob/bernoulli_logit_glm_rng.hpp index 54377cad1f2..4d5e724e4b2 100644 --- a/stan/math/prim/prob/bernoulli_logit_glm_rng.hpp +++ b/stan/math/prim/prob/bernoulli_logit_glm_rng.hpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/bernoulli_logit_rng.hpp b/stan/math/prim/prob/bernoulli_logit_rng.hpp index 7cc493ef018..662657149a7 100644 --- a/stan/math/prim/prob/bernoulli_logit_rng.hpp +++ b/stan/math/prim/prob/bernoulli_logit_rng.hpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/bernoulli_lpmf.hpp b/stan/math/prim/prob/bernoulli_lpmf.hpp index 8b5f0669691..4e5876f7359 100644 --- a/stan/math/prim/prob/bernoulli_lpmf.hpp +++ b/stan/math/prim/prob/bernoulli_lpmf.hpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/bernoulli_rng.hpp b/stan/math/prim/prob/bernoulli_rng.hpp index 9e588953712..7051bd3e015 100644 --- a/stan/math/prim/prob/bernoulli_rng.hpp +++ b/stan/math/prim/prob/bernoulli_rng.hpp @@ -3,6 +3,7 @@ #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/beta_binomial_cdf.hpp b/stan/math/prim/prob/beta_binomial_cdf.hpp index ab2b90abae0..5104bbe5763 100644 --- a/stan/math/prim/prob/beta_binomial_cdf.hpp +++ b/stan/math/prim/prob/beta_binomial_cdf.hpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/beta_binomial_lccdf.hpp b/stan/math/prim/prob/beta_binomial_lccdf.hpp index ec5f4c48ce0..0ccdd696249 100644 --- a/stan/math/prim/prob/beta_binomial_lccdf.hpp +++ b/stan/math/prim/prob/beta_binomial_lccdf.hpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/beta_binomial_lcdf.hpp b/stan/math/prim/prob/beta_binomial_lcdf.hpp index 16d019b942b..500db7aac2b 100644 --- a/stan/math/prim/prob/beta_binomial_lcdf.hpp +++ b/stan/math/prim/prob/beta_binomial_lcdf.hpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/beta_binomial_lpmf.hpp b/stan/math/prim/prob/beta_binomial_lpmf.hpp index f74968f0b31..601a4ca1a9c 100644 --- a/stan/math/prim/prob/beta_binomial_lpmf.hpp +++ b/stan/math/prim/prob/beta_binomial_lpmf.hpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/beta_cdf.hpp b/stan/math/prim/prob/beta_cdf.hpp index 8dd85535781..3b9de67016c 100644 --- a/stan/math/prim/prob/beta_cdf.hpp +++ b/stan/math/prim/prob/beta_cdf.hpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/beta_lccdf.hpp b/stan/math/prim/prob/beta_lccdf.hpp index e0061718a7b..e6dfcdacdf2 100644 --- a/stan/math/prim/prob/beta_lccdf.hpp +++ b/stan/math/prim/prob/beta_lccdf.hpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/beta_lcdf.hpp b/stan/math/prim/prob/beta_lcdf.hpp index 18119aae318..f4580a71105 100644 --- a/stan/math/prim/prob/beta_lcdf.hpp +++ b/stan/math/prim/prob/beta_lcdf.hpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/beta_proportion_lccdf.hpp b/stan/math/prim/prob/beta_proportion_lccdf.hpp index 67c5c674e76..c4b554dc127 100644 --- a/stan/math/prim/prob/beta_proportion_lccdf.hpp +++ b/stan/math/prim/prob/beta_proportion_lccdf.hpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/beta_proportion_lcdf.hpp b/stan/math/prim/prob/beta_proportion_lcdf.hpp index 2675b604ad1..5a5f27ffc26 100644 --- a/stan/math/prim/prob/beta_proportion_lcdf.hpp +++ b/stan/math/prim/prob/beta_proportion_lcdf.hpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/beta_proportion_rng.hpp b/stan/math/prim/prob/beta_proportion_rng.hpp index 6b21d319025..f5a01f68b38 100644 --- a/stan/math/prim/prob/beta_proportion_rng.hpp +++ b/stan/math/prim/prob/beta_proportion_rng.hpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include diff --git a/stan/math/prim/prob/beta_rng.hpp b/stan/math/prim/prob/beta_rng.hpp index f0ddeb2530c..d31c104dbea 100644 --- a/stan/math/prim/prob/beta_rng.hpp +++ b/stan/math/prim/prob/beta_rng.hpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/binomial_cdf.hpp b/stan/math/prim/prob/binomial_cdf.hpp index 8eed0a013a8..384a4fe2ca7 100644 --- a/stan/math/prim/prob/binomial_cdf.hpp +++ b/stan/math/prim/prob/binomial_cdf.hpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/binomial_lccdf.hpp b/stan/math/prim/prob/binomial_lccdf.hpp index 9e033d25d7b..b375708f98c 100644 --- a/stan/math/prim/prob/binomial_lccdf.hpp +++ b/stan/math/prim/prob/binomial_lccdf.hpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/binomial_lcdf.hpp b/stan/math/prim/prob/binomial_lcdf.hpp index 44b9bee7d12..0f34ef177e2 100644 --- a/stan/math/prim/prob/binomial_lcdf.hpp +++ b/stan/math/prim/prob/binomial_lcdf.hpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/binomial_lpmf.hpp b/stan/math/prim/prob/binomial_lpmf.hpp index e6c0ba9a711..440aeabdc68 100644 --- a/stan/math/prim/prob/binomial_lpmf.hpp +++ b/stan/math/prim/prob/binomial_lpmf.hpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/binomial_rng.hpp b/stan/math/prim/prob/binomial_rng.hpp index 4fbb9117420..fb4a05cb73d 100644 --- a/stan/math/prim/prob/binomial_rng.hpp +++ b/stan/math/prim/prob/binomial_rng.hpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include diff --git a/stan/math/prim/prob/categorical_logit_glm_lpmf.hpp b/stan/math/prim/prob/categorical_logit_glm_lpmf.hpp index 7f0c4d5e55e..f25ea745e4f 100644 --- a/stan/math/prim/prob/categorical_logit_glm_lpmf.hpp +++ b/stan/math/prim/prob/categorical_logit_glm_lpmf.hpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/cauchy_cdf.hpp b/stan/math/prim/prob/cauchy_cdf.hpp index 648b803307a..1d24626bfa4 100644 --- a/stan/math/prim/prob/cauchy_cdf.hpp +++ b/stan/math/prim/prob/cauchy_cdf.hpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/cauchy_lccdf.hpp b/stan/math/prim/prob/cauchy_lccdf.hpp index 9f3a754340e..e13faccdf8b 100644 --- a/stan/math/prim/prob/cauchy_lccdf.hpp +++ b/stan/math/prim/prob/cauchy_lccdf.hpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/cauchy_lcdf.hpp b/stan/math/prim/prob/cauchy_lcdf.hpp index 14c139efa17..306cfc6be65 100644 --- a/stan/math/prim/prob/cauchy_lcdf.hpp +++ b/stan/math/prim/prob/cauchy_lcdf.hpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/cauchy_rng.hpp b/stan/math/prim/prob/cauchy_rng.hpp index dbeb096ca26..3a53abfa0d0 100644 --- a/stan/math/prim/prob/cauchy_rng.hpp +++ b/stan/math/prim/prob/cauchy_rng.hpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include diff --git a/stan/math/prim/prob/chi_square_cdf.hpp b/stan/math/prim/prob/chi_square_cdf.hpp index 1a5869dec2b..ea439f86bf6 100644 --- a/stan/math/prim/prob/chi_square_cdf.hpp +++ b/stan/math/prim/prob/chi_square_cdf.hpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/chi_square_lccdf.hpp b/stan/math/prim/prob/chi_square_lccdf.hpp index 63d8f3adcbc..8347406a373 100644 --- a/stan/math/prim/prob/chi_square_lccdf.hpp +++ b/stan/math/prim/prob/chi_square_lccdf.hpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/chi_square_lcdf.hpp b/stan/math/prim/prob/chi_square_lcdf.hpp index ff6da8c33ef..dc7c196a454 100644 --- a/stan/math/prim/prob/chi_square_lcdf.hpp +++ b/stan/math/prim/prob/chi_square_lcdf.hpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/chi_square_rng.hpp b/stan/math/prim/prob/chi_square_rng.hpp index 79e62998d75..16c3f122eb0 100644 --- a/stan/math/prim/prob/chi_square_rng.hpp +++ b/stan/math/prim/prob/chi_square_rng.hpp @@ -3,6 +3,7 @@ #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/dirichlet_lpdf.hpp b/stan/math/prim/prob/dirichlet_lpdf.hpp index 88ed478ee57..c3f26c569fe 100644 --- a/stan/math/prim/prob/dirichlet_lpdf.hpp +++ b/stan/math/prim/prob/dirichlet_lpdf.hpp @@ -8,6 +8,7 @@ #include #include #include +#include #include namespace stan { diff --git a/stan/math/prim/prob/discrete_range_cdf.hpp b/stan/math/prim/prob/discrete_range_cdf.hpp index 776bc94a86a..f3672237339 100644 --- a/stan/math/prim/prob/discrete_range_cdf.hpp +++ b/stan/math/prim/prob/discrete_range_cdf.hpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include diff --git a/stan/math/prim/prob/discrete_range_lccdf.hpp b/stan/math/prim/prob/discrete_range_lccdf.hpp index ac2fae5a0fe..d58736fec1a 100644 --- a/stan/math/prim/prob/discrete_range_lccdf.hpp +++ b/stan/math/prim/prob/discrete_range_lccdf.hpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include diff --git a/stan/math/prim/prob/discrete_range_lcdf.hpp b/stan/math/prim/prob/discrete_range_lcdf.hpp index 2f937d1a71a..aa7d75fb7ca 100644 --- a/stan/math/prim/prob/discrete_range_lcdf.hpp +++ b/stan/math/prim/prob/discrete_range_lcdf.hpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include diff --git a/stan/math/prim/prob/discrete_range_lpmf.hpp b/stan/math/prim/prob/discrete_range_lpmf.hpp index a07a8031dda..df153064672 100644 --- a/stan/math/prim/prob/discrete_range_lpmf.hpp +++ b/stan/math/prim/prob/discrete_range_lpmf.hpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/discrete_range_rng.hpp b/stan/math/prim/prob/discrete_range_rng.hpp index adb976e5451..9f0bbb1f514 100644 --- a/stan/math/prim/prob/discrete_range_rng.hpp +++ b/stan/math/prim/prob/discrete_range_rng.hpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include diff --git a/stan/math/prim/prob/double_exponential_lccdf.hpp b/stan/math/prim/prob/double_exponential_lccdf.hpp index 1326f7dd59c..03f02915a9c 100644 --- a/stan/math/prim/prob/double_exponential_lccdf.hpp +++ b/stan/math/prim/prob/double_exponential_lccdf.hpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/double_exponential_lcdf.hpp b/stan/math/prim/prob/double_exponential_lcdf.hpp index 734cdfc0a6c..f2b642dc9f7 100644 --- a/stan/math/prim/prob/double_exponential_lcdf.hpp +++ b/stan/math/prim/prob/double_exponential_lcdf.hpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/double_exponential_rng.hpp b/stan/math/prim/prob/double_exponential_rng.hpp index 763569d8102..856ccc946b4 100644 --- a/stan/math/prim/prob/double_exponential_rng.hpp +++ b/stan/math/prim/prob/double_exponential_rng.hpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/exp_mod_normal_lccdf.hpp b/stan/math/prim/prob/exp_mod_normal_lccdf.hpp index b2b3171d3b2..aa212c551dc 100644 --- a/stan/math/prim/prob/exp_mod_normal_lccdf.hpp +++ b/stan/math/prim/prob/exp_mod_normal_lccdf.hpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/exp_mod_normal_lcdf.hpp b/stan/math/prim/prob/exp_mod_normal_lcdf.hpp index 431c745aeac..7291b0ba45d 100644 --- a/stan/math/prim/prob/exp_mod_normal_lcdf.hpp +++ b/stan/math/prim/prob/exp_mod_normal_lcdf.hpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/exp_mod_normal_rng.hpp b/stan/math/prim/prob/exp_mod_normal_rng.hpp index 2037a1ae741..07c4cffde2b 100644 --- a/stan/math/prim/prob/exp_mod_normal_rng.hpp +++ b/stan/math/prim/prob/exp_mod_normal_rng.hpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/exponential_rng.hpp b/stan/math/prim/prob/exponential_rng.hpp index e11f28fa8bf..981067e3d79 100644 --- a/stan/math/prim/prob/exponential_rng.hpp +++ b/stan/math/prim/prob/exponential_rng.hpp @@ -3,6 +3,7 @@ #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/frechet_cdf.hpp b/stan/math/prim/prob/frechet_cdf.hpp index b45052a07bb..3379e3519ae 100644 --- a/stan/math/prim/prob/frechet_cdf.hpp +++ b/stan/math/prim/prob/frechet_cdf.hpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/frechet_lccdf.hpp b/stan/math/prim/prob/frechet_lccdf.hpp index 67d69ecd5df..c362c3d7021 100644 --- a/stan/math/prim/prob/frechet_lccdf.hpp +++ b/stan/math/prim/prob/frechet_lccdf.hpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/frechet_lcdf.hpp b/stan/math/prim/prob/frechet_lcdf.hpp index 74e86e5c7c7..65995b31629 100644 --- a/stan/math/prim/prob/frechet_lcdf.hpp +++ b/stan/math/prim/prob/frechet_lcdf.hpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/frechet_rng.hpp b/stan/math/prim/prob/frechet_rng.hpp index 0fcfe774c60..6cb91bc25e1 100644 --- a/stan/math/prim/prob/frechet_rng.hpp +++ b/stan/math/prim/prob/frechet_rng.hpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include diff --git a/stan/math/prim/prob/gamma_cdf.hpp b/stan/math/prim/prob/gamma_cdf.hpp index a7f0d791b4f..2918ebb9f22 100644 --- a/stan/math/prim/prob/gamma_cdf.hpp +++ b/stan/math/prim/prob/gamma_cdf.hpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/gamma_lccdf.hpp b/stan/math/prim/prob/gamma_lccdf.hpp index 22b637603bb..12fbd24a9f2 100644 --- a/stan/math/prim/prob/gamma_lccdf.hpp +++ b/stan/math/prim/prob/gamma_lccdf.hpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/gamma_lcdf.hpp b/stan/math/prim/prob/gamma_lcdf.hpp index 22746d6520f..b40c75bc7f3 100644 --- a/stan/math/prim/prob/gamma_lcdf.hpp +++ b/stan/math/prim/prob/gamma_lcdf.hpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/gamma_lpdf.hpp b/stan/math/prim/prob/gamma_lpdf.hpp index 351c41dcbcc..662fea8329a 100644 --- a/stan/math/prim/prob/gamma_lpdf.hpp +++ b/stan/math/prim/prob/gamma_lpdf.hpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/gamma_rng.hpp b/stan/math/prim/prob/gamma_rng.hpp index 9fa42ffaf31..7a1ac651b18 100644 --- a/stan/math/prim/prob/gamma_rng.hpp +++ b/stan/math/prim/prob/gamma_rng.hpp @@ -3,6 +3,7 @@ #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/gumbel_rng.hpp b/stan/math/prim/prob/gumbel_rng.hpp index 1d2cac0bb23..ff8b6ca4db1 100644 --- a/stan/math/prim/prob/gumbel_rng.hpp +++ b/stan/math/prim/prob/gumbel_rng.hpp @@ -3,6 +3,7 @@ #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/hypergeometric_lpmf.hpp b/stan/math/prim/prob/hypergeometric_lpmf.hpp index cba7fbe09c4..876b387caef 100644 --- a/stan/math/prim/prob/hypergeometric_lpmf.hpp +++ b/stan/math/prim/prob/hypergeometric_lpmf.hpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include diff --git a/stan/math/prim/prob/inv_chi_square_cdf.hpp b/stan/math/prim/prob/inv_chi_square_cdf.hpp index 2bf30712d2b..1f1ff29c386 100644 --- a/stan/math/prim/prob/inv_chi_square_cdf.hpp +++ b/stan/math/prim/prob/inv_chi_square_cdf.hpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/inv_chi_square_lccdf.hpp b/stan/math/prim/prob/inv_chi_square_lccdf.hpp index c3e069bbbfb..394e7956f97 100644 --- a/stan/math/prim/prob/inv_chi_square_lccdf.hpp +++ b/stan/math/prim/prob/inv_chi_square_lccdf.hpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/inv_chi_square_lcdf.hpp b/stan/math/prim/prob/inv_chi_square_lcdf.hpp index 96ef9700dad..abd879cb2c6 100644 --- a/stan/math/prim/prob/inv_chi_square_lcdf.hpp +++ b/stan/math/prim/prob/inv_chi_square_lcdf.hpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/inv_chi_square_rng.hpp b/stan/math/prim/prob/inv_chi_square_rng.hpp index fc06d978840..b43b3c990b6 100644 --- a/stan/math/prim/prob/inv_chi_square_rng.hpp +++ b/stan/math/prim/prob/inv_chi_square_rng.hpp @@ -3,6 +3,7 @@ #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/inv_gamma_cdf.hpp b/stan/math/prim/prob/inv_gamma_cdf.hpp index 66a5019c0b5..89271caa42d 100644 --- a/stan/math/prim/prob/inv_gamma_cdf.hpp +++ b/stan/math/prim/prob/inv_gamma_cdf.hpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/inv_gamma_lccdf.hpp b/stan/math/prim/prob/inv_gamma_lccdf.hpp index 5f4ec4730db..22212e5adff 100644 --- a/stan/math/prim/prob/inv_gamma_lccdf.hpp +++ b/stan/math/prim/prob/inv_gamma_lccdf.hpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/inv_gamma_lcdf.hpp b/stan/math/prim/prob/inv_gamma_lcdf.hpp index 048dd7eabda..27e6800b444 100644 --- a/stan/math/prim/prob/inv_gamma_lcdf.hpp +++ b/stan/math/prim/prob/inv_gamma_lcdf.hpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/inv_gamma_rng.hpp b/stan/math/prim/prob/inv_gamma_rng.hpp index a5b6896d952..6923a934a00 100644 --- a/stan/math/prim/prob/inv_gamma_rng.hpp +++ b/stan/math/prim/prob/inv_gamma_rng.hpp @@ -3,6 +3,7 @@ #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/logistic_cdf.hpp b/stan/math/prim/prob/logistic_cdf.hpp index fffeb23e883..06af4fa7d26 100644 --- a/stan/math/prim/prob/logistic_cdf.hpp +++ b/stan/math/prim/prob/logistic_cdf.hpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/logistic_lccdf.hpp b/stan/math/prim/prob/logistic_lccdf.hpp index 3325273b2c0..e4822eadcdc 100644 --- a/stan/math/prim/prob/logistic_lccdf.hpp +++ b/stan/math/prim/prob/logistic_lccdf.hpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/logistic_lcdf.hpp b/stan/math/prim/prob/logistic_lcdf.hpp index 397e2e88d40..a438b35c74f 100644 --- a/stan/math/prim/prob/logistic_lcdf.hpp +++ b/stan/math/prim/prob/logistic_lcdf.hpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/logistic_rng.hpp b/stan/math/prim/prob/logistic_rng.hpp index aaf6182599d..ffb3315d09d 100644 --- a/stan/math/prim/prob/logistic_rng.hpp +++ b/stan/math/prim/prob/logistic_rng.hpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/lognormal_rng.hpp b/stan/math/prim/prob/lognormal_rng.hpp index 5ffc4647b45..d6e9c600bff 100644 --- a/stan/math/prim/prob/lognormal_rng.hpp +++ b/stan/math/prim/prob/lognormal_rng.hpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include diff --git a/stan/math/prim/prob/multi_normal_cholesky_lpdf.hpp b/stan/math/prim/prob/multi_normal_cholesky_lpdf.hpp index e8017dcf29f..f08bc298863 100644 --- a/stan/math/prim/prob/multi_normal_cholesky_lpdf.hpp +++ b/stan/math/prim/prob/multi_normal_cholesky_lpdf.hpp @@ -11,6 +11,7 @@ #include #include #include +#include #include namespace stan { diff --git a/stan/math/prim/prob/multi_normal_cholesky_rng.hpp b/stan/math/prim/prob/multi_normal_cholesky_rng.hpp index 070b58ea5c5..43b568da11c 100644 --- a/stan/math/prim/prob/multi_normal_cholesky_rng.hpp +++ b/stan/math/prim/prob/multi_normal_cholesky_rng.hpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include diff --git a/stan/math/prim/prob/multi_normal_lpdf.hpp b/stan/math/prim/prob/multi_normal_lpdf.hpp index 6d7a25afa23..3c32e574799 100644 --- a/stan/math/prim/prob/multi_normal_lpdf.hpp +++ b/stan/math/prim/prob/multi_normal_lpdf.hpp @@ -9,6 +9,7 @@ #include #include #include +#include namespace stan { namespace math { diff --git a/stan/math/prim/prob/multi_normal_prec_lpdf.hpp b/stan/math/prim/prob/multi_normal_prec_lpdf.hpp index 9a4b8f3f829..88bf3cb1a68 100644 --- a/stan/math/prim/prob/multi_normal_prec_lpdf.hpp +++ b/stan/math/prim/prob/multi_normal_prec_lpdf.hpp @@ -10,6 +10,7 @@ #include #include #include +#include namespace stan { namespace math { diff --git a/stan/math/prim/prob/multi_normal_prec_rng.hpp b/stan/math/prim/prob/multi_normal_prec_rng.hpp index bddbf21fa6d..5f4cd70d37e 100644 --- a/stan/math/prim/prob/multi_normal_prec_rng.hpp +++ b/stan/math/prim/prob/multi_normal_prec_rng.hpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include diff --git a/stan/math/prim/prob/multi_normal_rng.hpp b/stan/math/prim/prob/multi_normal_rng.hpp index 506c49e06b5..5ce93db8fb4 100644 --- a/stan/math/prim/prob/multi_normal_rng.hpp +++ b/stan/math/prim/prob/multi_normal_rng.hpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include diff --git a/stan/math/prim/prob/multi_student_t_lpdf.hpp b/stan/math/prim/prob/multi_student_t_lpdf.hpp index 1457d5fe4f1..d8b1f8ea245 100644 --- a/stan/math/prim/prob/multi_student_t_lpdf.hpp +++ b/stan/math/prim/prob/multi_student_t_lpdf.hpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/multi_student_t_rng.hpp b/stan/math/prim/prob/multi_student_t_rng.hpp index cd140e1c35b..3bc8148f6d4 100644 --- a/stan/math/prim/prob/multi_student_t_rng.hpp +++ b/stan/math/prim/prob/multi_student_t_rng.hpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/neg_binomial_2_cdf.hpp b/stan/math/prim/prob/neg_binomial_2_cdf.hpp index c7a7a8127f2..ecf85cb91ee 100644 --- a/stan/math/prim/prob/neg_binomial_2_cdf.hpp +++ b/stan/math/prim/prob/neg_binomial_2_cdf.hpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/neg_binomial_2_lccdf.hpp b/stan/math/prim/prob/neg_binomial_2_lccdf.hpp index 8c6aa3ee2f5..d7575ba64b8 100644 --- a/stan/math/prim/prob/neg_binomial_2_lccdf.hpp +++ b/stan/math/prim/prob/neg_binomial_2_lccdf.hpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include diff --git a/stan/math/prim/prob/neg_binomial_2_lcdf.hpp b/stan/math/prim/prob/neg_binomial_2_lcdf.hpp index bde70938ba8..fa0a1302994 100644 --- a/stan/math/prim/prob/neg_binomial_2_lcdf.hpp +++ b/stan/math/prim/prob/neg_binomial_2_lcdf.hpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include 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 46efda70494..1a3ec82d68f 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 @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include 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 96c2a38f730..b950b84420c 100644 --- a/stan/math/prim/prob/neg_binomial_2_log_lpmf.hpp +++ b/stan/math/prim/prob/neg_binomial_2_log_lpmf.hpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/neg_binomial_2_log_rng.hpp b/stan/math/prim/prob/neg_binomial_2_log_rng.hpp index 89f8f8de229..7cfa3b068cd 100644 --- a/stan/math/prim/prob/neg_binomial_2_log_rng.hpp +++ b/stan/math/prim/prob/neg_binomial_2_log_rng.hpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/neg_binomial_2_lpmf.hpp b/stan/math/prim/prob/neg_binomial_2_lpmf.hpp index 67e51c2892b..474aed2fabc 100644 --- a/stan/math/prim/prob/neg_binomial_2_lpmf.hpp +++ b/stan/math/prim/prob/neg_binomial_2_lpmf.hpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/neg_binomial_2_rng.hpp b/stan/math/prim/prob/neg_binomial_2_rng.hpp index 92f58121a47..8c23c634471 100644 --- a/stan/math/prim/prob/neg_binomial_2_rng.hpp +++ b/stan/math/prim/prob/neg_binomial_2_rng.hpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/neg_binomial_cdf.hpp b/stan/math/prim/prob/neg_binomial_cdf.hpp index 2fb53c5e1ef..835c7689bc3 100644 --- a/stan/math/prim/prob/neg_binomial_cdf.hpp +++ b/stan/math/prim/prob/neg_binomial_cdf.hpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/neg_binomial_lccdf.hpp b/stan/math/prim/prob/neg_binomial_lccdf.hpp index 88d0bdf5735..a9536686468 100644 --- a/stan/math/prim/prob/neg_binomial_lccdf.hpp +++ b/stan/math/prim/prob/neg_binomial_lccdf.hpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/neg_binomial_lcdf.hpp b/stan/math/prim/prob/neg_binomial_lcdf.hpp index 526e611a7c5..0f4d8052158 100644 --- a/stan/math/prim/prob/neg_binomial_lcdf.hpp +++ b/stan/math/prim/prob/neg_binomial_lcdf.hpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/neg_binomial_lpmf.hpp b/stan/math/prim/prob/neg_binomial_lpmf.hpp index c206f5a2da9..6be061c99a2 100644 --- a/stan/math/prim/prob/neg_binomial_lpmf.hpp +++ b/stan/math/prim/prob/neg_binomial_lpmf.hpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/neg_binomial_rng.hpp b/stan/math/prim/prob/neg_binomial_rng.hpp index c8b527dcc23..0eb772092c6 100644 --- a/stan/math/prim/prob/neg_binomial_rng.hpp +++ b/stan/math/prim/prob/neg_binomial_rng.hpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/normal_cdf.hpp b/stan/math/prim/prob/normal_cdf.hpp index 10101f34ca0..87aae2a87a9 100644 --- a/stan/math/prim/prob/normal_cdf.hpp +++ b/stan/math/prim/prob/normal_cdf.hpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/normal_lccdf.hpp b/stan/math/prim/prob/normal_lccdf.hpp index 77adca6b17f..85f3fc1ea95 100644 --- a/stan/math/prim/prob/normal_lccdf.hpp +++ b/stan/math/prim/prob/normal_lccdf.hpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/normal_lcdf.hpp b/stan/math/prim/prob/normal_lcdf.hpp index 7ed13334b80..6df6dda05a6 100644 --- a/stan/math/prim/prob/normal_lcdf.hpp +++ b/stan/math/prim/prob/normal_lcdf.hpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/normal_rng.hpp b/stan/math/prim/prob/normal_rng.hpp index 9356d9c9aea..65536fd93d1 100644 --- a/stan/math/prim/prob/normal_rng.hpp +++ b/stan/math/prim/prob/normal_rng.hpp @@ -3,6 +3,7 @@ #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/ordered_logistic_glm_lpmf.hpp b/stan/math/prim/prob/ordered_logistic_glm_lpmf.hpp index dc6e44a5e6a..0f3416a1b69 100644 --- a/stan/math/prim/prob/ordered_logistic_glm_lpmf.hpp +++ b/stan/math/prim/prob/ordered_logistic_glm_lpmf.hpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/ordered_logistic_lpmf.hpp b/stan/math/prim/prob/ordered_logistic_lpmf.hpp index 6f524f5a0d9..611ab5fdd48 100644 --- a/stan/math/prim/prob/ordered_logistic_lpmf.hpp +++ b/stan/math/prim/prob/ordered_logistic_lpmf.hpp @@ -8,9 +8,11 @@ #include #include #include +#include #include #include #include +#include #include #include diff --git a/stan/math/prim/prob/ordered_probit_lpmf.hpp b/stan/math/prim/prob/ordered_probit_lpmf.hpp index 586f7a323be..b7a89401737 100644 --- a/stan/math/prim/prob/ordered_probit_lpmf.hpp +++ b/stan/math/prim/prob/ordered_probit_lpmf.hpp @@ -7,9 +7,11 @@ #include #include #include +#include #include #include #include +#include #include #include diff --git a/stan/math/prim/prob/pareto_cdf.hpp b/stan/math/prim/prob/pareto_cdf.hpp index d4e29caf945..4703896e2eb 100644 --- a/stan/math/prim/prob/pareto_cdf.hpp +++ b/stan/math/prim/prob/pareto_cdf.hpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/pareto_rng.hpp b/stan/math/prim/prob/pareto_rng.hpp index 679db6e08ad..6cbb121d001 100644 --- a/stan/math/prim/prob/pareto_rng.hpp +++ b/stan/math/prim/prob/pareto_rng.hpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/pareto_type_2_rng.hpp b/stan/math/prim/prob/pareto_type_2_rng.hpp index 9d2c283e5c4..a1ab4af97d4 100644 --- a/stan/math/prim/prob/pareto_type_2_rng.hpp +++ b/stan/math/prim/prob/pareto_type_2_rng.hpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/poisson_binomial_lccdf.hpp b/stan/math/prim/prob/poisson_binomial_lccdf.hpp index 690af125529..c2320956c4d 100644 --- a/stan/math/prim/prob/poisson_binomial_lccdf.hpp +++ b/stan/math/prim/prob/poisson_binomial_lccdf.hpp @@ -10,10 +10,12 @@ #include #include #include +#include #include #include #include #include +#include namespace stan { namespace math { diff --git a/stan/math/prim/prob/poisson_binomial_lcdf.hpp b/stan/math/prim/prob/poisson_binomial_lcdf.hpp index 065dddcb9ba..6dc9b30b1d6 100644 --- a/stan/math/prim/prob/poisson_binomial_lcdf.hpp +++ b/stan/math/prim/prob/poisson_binomial_lcdf.hpp @@ -9,10 +9,12 @@ #include #include #include +#include #include #include #include #include +#include namespace stan { namespace math { diff --git a/stan/math/prim/prob/poisson_binomial_lpmf.hpp b/stan/math/prim/prob/poisson_binomial_lpmf.hpp index 52cd4efccfb..c4d35a4f307 100644 --- a/stan/math/prim/prob/poisson_binomial_lpmf.hpp +++ b/stan/math/prim/prob/poisson_binomial_lpmf.hpp @@ -4,7 +4,9 @@ #include #include #include +#include #include +#include namespace stan { namespace math { diff --git a/stan/math/prim/prob/poisson_log_lpmf.hpp b/stan/math/prim/prob/poisson_log_lpmf.hpp index 4f1a393c46e..089e2b036e9 100644 --- a/stan/math/prim/prob/poisson_log_lpmf.hpp +++ b/stan/math/prim/prob/poisson_log_lpmf.hpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/poisson_log_rng.hpp b/stan/math/prim/prob/poisson_log_rng.hpp index 3a6b731774a..8e7a8daa7dc 100644 --- a/stan/math/prim/prob/poisson_log_rng.hpp +++ b/stan/math/prim/prob/poisson_log_rng.hpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/poisson_lpmf.hpp b/stan/math/prim/prob/poisson_lpmf.hpp index f78420a5002..7ab5e0ec325 100644 --- a/stan/math/prim/prob/poisson_lpmf.hpp +++ b/stan/math/prim/prob/poisson_lpmf.hpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/poisson_rng.hpp b/stan/math/prim/prob/poisson_rng.hpp index 352a6d3897b..7ec96d678b1 100644 --- a/stan/math/prim/prob/poisson_rng.hpp +++ b/stan/math/prim/prob/poisson_rng.hpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/rayleigh_rng.hpp b/stan/math/prim/prob/rayleigh_rng.hpp index af551c0e0bf..58868567273 100644 --- a/stan/math/prim/prob/rayleigh_rng.hpp +++ b/stan/math/prim/prob/rayleigh_rng.hpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include 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 30caf205456..f441852d649 100644 --- a/stan/math/prim/prob/scaled_inv_chi_square_cdf.hpp +++ b/stan/math/prim/prob/scaled_inv_chi_square_cdf.hpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include 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 d0826784c3a..83b31549806 100644 --- a/stan/math/prim/prob/scaled_inv_chi_square_lccdf.hpp +++ b/stan/math/prim/prob/scaled_inv_chi_square_lccdf.hpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include 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 0b71388b491..c25413b2831 100644 --- a/stan/math/prim/prob/scaled_inv_chi_square_lcdf.hpp +++ b/stan/math/prim/prob/scaled_inv_chi_square_lcdf.hpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include 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 33cbfacde8c..5187e4b03f5 100644 --- a/stan/math/prim/prob/scaled_inv_chi_square_lpdf.hpp +++ b/stan/math/prim/prob/scaled_inv_chi_square_lpdf.hpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/scaled_inv_chi_square_rng.hpp b/stan/math/prim/prob/scaled_inv_chi_square_rng.hpp index 2eaa46a4c41..1b3abcb9776 100644 --- a/stan/math/prim/prob/scaled_inv_chi_square_rng.hpp +++ b/stan/math/prim/prob/scaled_inv_chi_square_rng.hpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/skew_normal_rng.hpp b/stan/math/prim/prob/skew_normal_rng.hpp index eb69c646c5f..6758a6bcd69 100644 --- a/stan/math/prim/prob/skew_normal_rng.hpp +++ b/stan/math/prim/prob/skew_normal_rng.hpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/std_normal_cdf.hpp b/stan/math/prim/prob/std_normal_cdf.hpp index 8686917793e..bd812c58117 100644 --- a/stan/math/prim/prob/std_normal_cdf.hpp +++ b/stan/math/prim/prob/std_normal_cdf.hpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/std_normal_lccdf.hpp b/stan/math/prim/prob/std_normal_lccdf.hpp index de8152df115..a08af1ae461 100644 --- a/stan/math/prim/prob/std_normal_lccdf.hpp +++ b/stan/math/prim/prob/std_normal_lccdf.hpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/std_normal_lcdf.hpp b/stan/math/prim/prob/std_normal_lcdf.hpp index ec1b93c9efb..ca68f1245b0 100644 --- a/stan/math/prim/prob/std_normal_lcdf.hpp +++ b/stan/math/prim/prob/std_normal_lcdf.hpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/std_normal_lpdf.hpp b/stan/math/prim/prob/std_normal_lpdf.hpp index fdc29232157..bfbcf590146 100644 --- a/stan/math/prim/prob/std_normal_lpdf.hpp +++ b/stan/math/prim/prob/std_normal_lpdf.hpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/student_t_cdf.hpp b/stan/math/prim/prob/student_t_cdf.hpp index d5a6d634a36..0df5bb749c2 100644 --- a/stan/math/prim/prob/student_t_cdf.hpp +++ b/stan/math/prim/prob/student_t_cdf.hpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/student_t_lccdf.hpp b/stan/math/prim/prob/student_t_lccdf.hpp index 4502e64a819..ad678fdf632 100644 --- a/stan/math/prim/prob/student_t_lccdf.hpp +++ b/stan/math/prim/prob/student_t_lccdf.hpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/student_t_lcdf.hpp b/stan/math/prim/prob/student_t_lcdf.hpp index d65e6df6d57..e23e9ad630b 100644 --- a/stan/math/prim/prob/student_t_lcdf.hpp +++ b/stan/math/prim/prob/student_t_lcdf.hpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/student_t_rng.hpp b/stan/math/prim/prob/student_t_rng.hpp index bda4e2f416d..c47c8d2672e 100644 --- a/stan/math/prim/prob/student_t_rng.hpp +++ b/stan/math/prim/prob/student_t_rng.hpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include diff --git a/stan/math/prim/prob/uniform_rng.hpp b/stan/math/prim/prob/uniform_rng.hpp index d04376e8bf4..b2591c1245b 100644 --- a/stan/math/prim/prob/uniform_rng.hpp +++ b/stan/math/prim/prob/uniform_rng.hpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/von_mises_rng.hpp b/stan/math/prim/prob/von_mises_rng.hpp index 3055d4313b7..da51770c18f 100644 --- a/stan/math/prim/prob/von_mises_rng.hpp +++ b/stan/math/prim/prob/von_mises_rng.hpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/prim/prob/weibull_rng.hpp b/stan/math/prim/prob/weibull_rng.hpp index d90913e605b..3ae4dc64a6a 100644 --- a/stan/math/prim/prob/weibull_rng.hpp +++ b/stan/math/prim/prob/weibull_rng.hpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include diff --git a/stan/math/prim/prob/wiener_lpdf.hpp b/stan/math/prim/prob/wiener_lpdf.hpp index 61e65ba77d7..90446a30479 100644 --- a/stan/math/prim/prob/wiener_lpdf.hpp +++ b/stan/math/prim/prob/wiener_lpdf.hpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include diff --git a/stan/math/rev/meta/is_rev_matrix.hpp b/stan/math/rev/meta/is_rev_matrix.hpp index 066cb7ef667..1020d38a897 100644 --- a/stan/math/rev/meta/is_rev_matrix.hpp +++ b/stan/math/rev/meta/is_rev_matrix.hpp @@ -18,8 +18,7 @@ namespace stan { */ template struct is_rev_matrix< - T, require_all_t>, - math::disjunction, is_eigen>>>> + T, require_all_t>, math::disjunction, is_eigen>>, is_eigen>>> : std::true_type {}; /** \ingroup type_trait diff --git a/test/unit/math/rev/meta/scalar_seq_view_test.cpp b/test/unit/math/rev/meta/scalar_seq_view_test.cpp new file mode 100644 index 00000000000..bb2636d8d21 --- /dev/null +++ b/test/unit/math/rev/meta/scalar_seq_view_test.cpp @@ -0,0 +1,84 @@ +#include +#include +#include + +TEST(MathMetaRev, ScalarSeqViewvar) { + using stan::scalar_seq_view; + using stan::math::var; + var d = 10; + scalar_seq_view sv(d); + EXPECT_FLOAT_EQ(d.val(), sv.val(0)); + EXPECT_FLOAT_EQ(d.val(), sv.val(12)); + + const var d_const = 10; + scalar_seq_view sv_const(d_const); + EXPECT_FLOAT_EQ(d_const.val(), sv_const.val(0)); + EXPECT_FLOAT_EQ(d_const.val(), sv_const.val(12)); + + const var& d_const_ref = 10; + scalar_seq_view sv_const_ref(d_const); + EXPECT_FLOAT_EQ(d_const_ref.val(), sv_const_ref.val(0)); + EXPECT_FLOAT_EQ(d_const_ref.val(), sv_const_ref.val(12)); + + EXPECT_EQ(1, sv.size()); +} + +TEST(MathMetaRev, ScalarSeqViewArrayVarVal) { + using stan::scalar_seq_view; + using std::vector; + using stan::math::var; + vector v; + v.push_back(2.2); + v.push_back(0.0001); + scalar_seq_view > sv(v); + EXPECT_FLOAT_EQ(v[0].val(), sv.val(0)); + EXPECT_FLOAT_EQ(v[1].val(), sv.val(1)); + + const vector v_const{2.2, 0.001}; + scalar_seq_view > sv_const(v_const); + EXPECT_FLOAT_EQ(v_const[0].val(), sv_const.val(0)); + EXPECT_FLOAT_EQ(v_const[1].val(), sv_const.val(1)); + + const vector& v_const_ref{2.2, 0.001}; + scalar_seq_view > sv_const_ref(v_const_ref); + EXPECT_FLOAT_EQ(v_const_ref[0].val(), sv_const_ref.val(0)); + EXPECT_FLOAT_EQ(v_const_ref[1].val(), sv_const_ref.val(1)); + + EXPECT_EQ(v.size(), sv.size()); +} + +template +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)); + EXPECT_FLOAT_EQ(v.val()(1), sv.val(1)); + EXPECT_FLOAT_EQ(v.val()(2), sv.val(2)); + EXPECT_FLOAT_EQ(v.val()(3), sv.val(3)); + + EXPECT_EQ(v.size(), sv.size()); +} + +TEST(MathMetaRev, ScalarSeqViewVectorVar) { + using stan::math::var; + Eigen::Matrix A = Eigen::VectorXd(4); + expect_scalar_seq_view_value(A); +} + +TEST(MathMetaRev, ScalarSeqViewRowVectorVar) { + using stan::math::var; + Eigen::Matrix A = Eigen::RowVectorXd(4); + expect_scalar_seq_view_value(A); +} + +TEST(MathMetaRev, VarScalarSeqViewVector) { + using stan::math::var_value; + var_value> A = Eigen::VectorXd(4); + expect_scalar_seq_view_value(A); +} + +TEST(MathMetaRev, VarScalarSeqViewRowVector) { + using stan::math::var_value; + var_value> A = Eigen::RowVectorXd(4); + expect_scalar_seq_view_value(A); +} diff --git a/test/unit/math/rev/meta/vector_seq_view_test.cpp b/test/unit/math/rev/meta/vector_seq_view_test.cpp new file mode 100644 index 00000000000..6886c708169 --- /dev/null +++ b/test/unit/math/rev/meta/vector_seq_view_test.cpp @@ -0,0 +1,30 @@ +#include +#include +#include + +template +void test_vec_seq_var(const T& m1) { + using stan::math::var; + using stan::vector_seq_view; + vector_seq_view vsv(m1); + EXPECT_FLOAT_EQ(m1.val()(1), vsv.val(12)(1)); + + std::vector> v; + v.push_back(m1); + v.push_back(m1.reverse()); + vector_seq_view>> vsv_vec(v); + EXPECT_FLOAT_EQ(m1.val()(0), vsv_vec.val(0)[0]); + EXPECT_FLOAT_EQ(m1.val()(0), vsv_vec.val(1)[3]); + EXPECT_FLOAT_EQ(m1.val()(2), vsv_vec.val(1)[1]); + EXPECT_FLOAT_EQ(m1.val()(2), vsv_vec.val(0)[2]); + +} +TEST(MathMetaRev, VectorSeqViewVar) { + Eigen::Matrix values = Eigen::Matrix::Random(4); + Eigen::Matrix A = values; + test_vec_seq_var(A); + test_vec_seq_var(A.transpose()); + stan::math::var_value> B = values; + test_vec_seq_var(B); + test_vec_seq_var(B.transpose()); +} From 3a5b8f43bce6898fe6c99b03c4fd059f7f38bab9 Mon Sep 17 00:00:00 2001 From: Stan Jenkins Date: Wed, 6 Jan 2021 07:35:47 +0000 Subject: [PATCH 03/17] [Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.04.1 (tags/RELEASE_600/final) --- stan/math/prim/fun/scalar_seq_view.hpp | 2 +- stan/math/prim/fun/vector_seq_view.hpp | 8 +++++--- stan/math/prim/prob/beta_binomial_lpmf.hpp | 9 ++++----- stan/math/prim/prob/pareto_cdf.hpp | 3 +-- stan/math/prim/prob/student_t_cdf.hpp | 3 +-- stan/math/prim/prob/student_t_lccdf.hpp | 3 +-- stan/math/prim/prob/student_t_lcdf.hpp | 3 +-- stan/math/rev/meta/is_rev_matrix.hpp | 7 +++++-- test/unit/math/rev/meta/scalar_seq_view_test.cpp | 8 ++++---- test/unit/math/rev/meta/vector_seq_view_test.cpp | 3 +-- 10 files changed, 24 insertions(+), 25 deletions(-) diff --git a/stan/math/prim/fun/scalar_seq_view.hpp b/stan/math/prim/fun/scalar_seq_view.hpp index 3990b8e165a..b2a1ceed962 100644 --- a/stan/math/prim/fun/scalar_seq_view.hpp +++ b/stan/math/prim/fun/scalar_seq_view.hpp @@ -124,7 +124,7 @@ class scalar_seq_view> { } template * = nullptr> - inline auto val(int /* i */) const noexcept { + inline auto val(int /* i */) const noexcept { return t_.val(); } diff --git a/stan/math/prim/fun/vector_seq_view.hpp b/stan/math/prim/fun/vector_seq_view.hpp index 6d66f684544..4972ecec064 100644 --- a/stan/math/prim/fun/vector_seq_view.hpp +++ b/stan/math/prim/fun/vector_seq_view.hpp @@ -54,8 +54,9 @@ class vector_seq_view> { }; namespace internal { - template - using is_matrix_or_std_vector = math::disjunction, is_std_vector>; +template +using is_matrix_or_std_vector + = math::disjunction, is_std_vector>; } /** \ingroup type_trait @@ -70,7 +71,8 @@ namespace internal { * @tparam S the type inside of the std::vector */ template -class vector_seq_view> { +class vector_seq_view< + T, require_std_vector_vt> { public: explicit vector_seq_view(const T& v) noexcept : v_(v) {} inline auto size() const noexcept { return v_.size(); } diff --git a/stan/math/prim/prob/beta_binomial_lpmf.hpp b/stan/math/prim/prob/beta_binomial_lpmf.hpp index 601a4ca1a9c..51dafeffc03 100644 --- a/stan/math/prim/prob/beta_binomial_lpmf.hpp +++ b/stan/math/prim/prob/beta_binomial_lpmf.hpp @@ -122,8 +122,7 @@ return_type_t beta_binomial_lpmf(const T_n& n, const T_N& N, digamma_alpha_plus_beta(size_alpha_beta); if (!is_constant_all::value) { for (size_t i = 0; i < size_alpha_beta; i++) { - digamma_alpha_plus_beta[i] - = digamma(alpha_vec.val(i) + beta_vec.val(i)); + digamma_alpha_plus_beta[i] = digamma(alpha_vec.val(i) + beta_vec.val(i)); } } @@ -132,9 +131,9 @@ return_type_t beta_binomial_lpmf(const T_n& n, const T_N& N, digamma_diff(max_size(N, alpha, beta)); if (!is_constant_all::value) { for (size_t i = 0; i < max_size(N, alpha, beta); i++) { - digamma_diff[i] = digamma_alpha_plus_beta[i] - - digamma(N_vec[i] + alpha_vec.val(i) - + alpha_vec.val(i)); + digamma_diff[i] + = digamma_alpha_plus_beta[i] + - digamma(N_vec[i] + alpha_vec.val(i) + alpha_vec.val(i)); } } diff --git a/stan/math/prim/prob/pareto_cdf.hpp b/stan/math/prim/prob/pareto_cdf.hpp index 4703896e2eb..abe2fef6fbd 100644 --- a/stan/math/prim/prob/pareto_cdf.hpp +++ b/stan/math/prim/prob/pareto_cdf.hpp @@ -66,8 +66,7 @@ return_type_t pareto_cdf(const T_y& y, continue; } - const T_partials_return log_dbl - = log(y_min_vec.val(n) / y_vec.val(n)); + const T_partials_return log_dbl = log(y_min_vec.val(n) / y_vec.val(n)); const T_partials_return y_min_inv_dbl = 1.0 / y_vec.val(n); const T_partials_return alpha_dbl = y_vec.val(n); diff --git a/stan/math/prim/prob/student_t_cdf.hpp b/stan/math/prim/prob/student_t_cdf.hpp index 0df5bb749c2..3556e667a07 100644 --- a/stan/math/prim/prob/student_t_cdf.hpp +++ b/stan/math/prim/prob/student_t_cdf.hpp @@ -90,8 +90,7 @@ return_type_t student_t_cdf(const T_y& y, } const T_partials_return sigma_inv = 1.0 / y_vec.val(n); - const T_partials_return t - = (y_vec.val(n) - mu_vec.val(n)) * sigma_inv; + const T_partials_return t = (y_vec.val(n) - mu_vec.val(n)) * sigma_inv; const T_partials_return nu_dbl = y_vec.val(n); const T_partials_return q = nu_dbl / (t * t); const T_partials_return r = 1.0 / (1.0 + q); diff --git a/stan/math/prim/prob/student_t_lccdf.hpp b/stan/math/prim/prob/student_t_lccdf.hpp index ad678fdf632..74940cd9330 100644 --- a/stan/math/prim/prob/student_t_lccdf.hpp +++ b/stan/math/prim/prob/student_t_lccdf.hpp @@ -90,8 +90,7 @@ return_type_t student_t_lccdf( } const T_partials_return sigma_inv = 1.0 / y_vec.val(n); - const T_partials_return t - = (y_vec.val(n) - mu_vec.val(n)) * sigma_inv; + const T_partials_return t = (y_vec.val(n) - mu_vec.val(n)) * sigma_inv; const T_partials_return nu_dbl = y_vec.val(n); const T_partials_return q = nu_dbl / (t * t); const T_partials_return r = 1.0 / (1.0 + q); diff --git a/stan/math/prim/prob/student_t_lcdf.hpp b/stan/math/prim/prob/student_t_lcdf.hpp index e23e9ad630b..343d1540802 100644 --- a/stan/math/prim/prob/student_t_lcdf.hpp +++ b/stan/math/prim/prob/student_t_lcdf.hpp @@ -92,8 +92,7 @@ return_type_t student_t_lcdf(const T_y& y, } const T_partials_return sigma_inv = 1.0 / y_vec.val(n); - const T_partials_return t - = (y_vec.val(n) - mu_vec.val(n)) * sigma_inv; + const T_partials_return t = (y_vec.val(n) - mu_vec.val(n)) * sigma_inv; const T_partials_return nu_dbl = y_vec.val(n); const T_partials_return q = nu_dbl / (t * t); const T_partials_return r = 1.0 / (1.0 + q); diff --git a/stan/math/rev/meta/is_rev_matrix.hpp b/stan/math/rev/meta/is_rev_matrix.hpp index 1020d38a897..9588f47798b 100644 --- a/stan/math/rev/meta/is_rev_matrix.hpp +++ b/stan/math/rev/meta/is_rev_matrix.hpp @@ -18,8 +18,11 @@ namespace stan { */ template struct is_rev_matrix< - T, require_all_t>, math::disjunction, is_eigen>>, is_eigen>>> - : std::true_type {}; + T, + require_all_t>, + math::disjunction< + math::conjunction, is_eigen>>, + is_eigen>>> : std::true_type {}; /** \ingroup type_trait * Defines a static member named value which is defined to be true diff --git a/test/unit/math/rev/meta/scalar_seq_view_test.cpp b/test/unit/math/rev/meta/scalar_seq_view_test.cpp index bb2636d8d21..cee1184afe4 100644 --- a/test/unit/math/rev/meta/scalar_seq_view_test.cpp +++ b/test/unit/math/rev/meta/scalar_seq_view_test.cpp @@ -25,22 +25,22 @@ TEST(MathMetaRev, ScalarSeqViewvar) { TEST(MathMetaRev, ScalarSeqViewArrayVarVal) { using stan::scalar_seq_view; - using std::vector; using stan::math::var; + using std::vector; vector v; v.push_back(2.2); v.push_back(0.0001); - scalar_seq_view > sv(v); + scalar_seq_view> sv(v); EXPECT_FLOAT_EQ(v[0].val(), sv.val(0)); EXPECT_FLOAT_EQ(v[1].val(), sv.val(1)); const vector v_const{2.2, 0.001}; - scalar_seq_view > sv_const(v_const); + scalar_seq_view> sv_const(v_const); EXPECT_FLOAT_EQ(v_const[0].val(), sv_const.val(0)); EXPECT_FLOAT_EQ(v_const[1].val(), sv_const.val(1)); const vector& v_const_ref{2.2, 0.001}; - scalar_seq_view > sv_const_ref(v_const_ref); + scalar_seq_view> sv_const_ref(v_const_ref); EXPECT_FLOAT_EQ(v_const_ref[0].val(), sv_const_ref.val(0)); EXPECT_FLOAT_EQ(v_const_ref[1].val(), sv_const_ref.val(1)); diff --git a/test/unit/math/rev/meta/vector_seq_view_test.cpp b/test/unit/math/rev/meta/vector_seq_view_test.cpp index 6886c708169..f753fa84637 100644 --- a/test/unit/math/rev/meta/vector_seq_view_test.cpp +++ b/test/unit/math/rev/meta/vector_seq_view_test.cpp @@ -4,8 +4,8 @@ template void test_vec_seq_var(const T& m1) { - using stan::math::var; using stan::vector_seq_view; + using stan::math::var; vector_seq_view vsv(m1); EXPECT_FLOAT_EQ(m1.val()(1), vsv.val(12)(1)); @@ -17,7 +17,6 @@ void test_vec_seq_var(const T& m1) { EXPECT_FLOAT_EQ(m1.val()(0), vsv_vec.val(1)[3]); EXPECT_FLOAT_EQ(m1.val()(2), vsv_vec.val(1)[1]); EXPECT_FLOAT_EQ(m1.val()(2), vsv_vec.val(0)[2]); - } TEST(MathMetaRev, VectorSeqViewVar) { Eigen::Matrix values = Eigen::Matrix::Random(4); From 9ad9f114f71a21216ef8aa044aeac626fffd8a55 Mon Sep 17 00:00:00 2001 From: stevebronder Date: Wed, 6 Jan 2021 00:37:46 -0700 Subject: [PATCH 04/17] fix header guards --- stan/math/prim/fun/scalar_seq_view.hpp | 14 +++++++------- stan/math/prim/fun/vector_seq_view.hpp | 10 +++++----- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/stan/math/prim/fun/scalar_seq_view.hpp b/stan/math/prim/fun/scalar_seq_view.hpp index b2a1ceed962..fa6564dfba7 100644 --- a/stan/math/prim/fun/scalar_seq_view.hpp +++ b/stan/math/prim/fun/scalar_seq_view.hpp @@ -1,5 +1,5 @@ -#ifndef STAN_MATH_PRIM_META_SCALAR_SEQ_VIEW_HPP -#define STAN_MATH_PRIM_META_SCALAR_SEQ_VIEW_HPP +#ifndef STAN_MATH_PRIM_FUN_SCALAR_SEQ_VIEW_HPP +#define STAN_MATH_PRIM_FUN_SCALAR_SEQ_VIEW_HPP #include #include @@ -7,7 +7,7 @@ #include namespace stan { -/** \ingroup type_trait +/** * scalar_seq_view provides a uniform sequence-like wrapper around either a * scalar or a sequence of scalars. * @@ -24,7 +24,7 @@ class scalar_seq_view> { typename = require_same_t, plain_type_t>> explicit scalar_seq_view(T&& c) : c_(std::forward(c)) {} - /** \ingroup type_trait + /** * Segfaults if out of bounds. * @param i index * @return the element at the specified position in the container @@ -54,7 +54,7 @@ class scalar_seq_view> { typename = require_same_t, plain_type_t>> explicit scalar_seq_view(T&& c) : c_(std::forward(c)) {} - /** \ingroup type_trait + /** * Segfaults if out of bounds. * @param i index * @return the element at the specified position in the container @@ -84,7 +84,7 @@ class scalar_seq_view> { typename = require_same_t, plain_type_t>> explicit scalar_seq_view(T&& c) : c_(std::forward(c)) {} - /** \ingroup type_trait + /** * Segfaults if out of bounds. * @param i index * @return the element at the specified position in the container @@ -106,7 +106,7 @@ class scalar_seq_view> { const C& c_; }; -/** \ingroup type_trait +/** * This specialization handles wrapping a scalar as if it were a sequence. * * @tparam T the scalar type diff --git a/stan/math/prim/fun/vector_seq_view.hpp b/stan/math/prim/fun/vector_seq_view.hpp index 4972ecec064..95db7344d20 100644 --- a/stan/math/prim/fun/vector_seq_view.hpp +++ b/stan/math/prim/fun/vector_seq_view.hpp @@ -1,5 +1,5 @@ -#ifndef STAN_MATH_PRIM_META_VECTOR_SEQ_VIEW_HPP -#define STAN_MATH_PRIM_META_VECTOR_SEQ_VIEW_HPP +#ifndef STAN_MATH_PRIM_FUN_VECTOR_SEQ_VIEW_HPP +#define STAN_MATH_PRIM_FUN_VECTOR_SEQ_VIEW_HPP #include #include @@ -7,7 +7,7 @@ namespace stan { -/** \ingroup type_trait +/** * This class provides a low-cost wrapper for situations where you either need * an Eigen Vector or RowVector or a std::vector of them and you want to be * agnostic between those two options. This is similar to scalar_seq_view but @@ -21,7 +21,7 @@ namespace stan { template class vector_seq_view; -/** \ingroup type_trait +/** * This class provides a low-cost wrapper for situations where you either need * an Eigen Vector or RowVector or a std::vector of them and you want to be * agnostic between those two options. This is similar to scalar_seq_view but @@ -59,7 +59,7 @@ using is_matrix_or_std_vector = math::disjunction, is_std_vector>; } -/** \ingroup type_trait +/** * This class provides a low-cost wrapper for situations where you either need * an Eigen Vector or RowVector or a std::vector of them and you want to be * agnostic between those two options. This is similar to scalar_seq_view but From ed5998c54b91f1012d0de0e5e3ec219024149530 Mon Sep 17 00:00:00 2001 From: stevebronder Date: Wed, 6 Jan 2021 02:06:37 -0700 Subject: [PATCH 05/17] add data() member for pointer access --- stan/math/prim/fun/scalar_seq_view.hpp | 9 ++++++++- stan/math/prim/prob/ordered_logistic_lpmf.hpp | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/stan/math/prim/fun/scalar_seq_view.hpp b/stan/math/prim/fun/scalar_seq_view.hpp index fa6564dfba7..bfcd410ef54 100644 --- a/stan/math/prim/fun/scalar_seq_view.hpp +++ b/stan/math/prim/fun/scalar_seq_view.hpp @@ -33,8 +33,11 @@ class scalar_seq_view> { inline auto size() const noexcept { return c_.size(); } + inline const auto& data() const noexcept { return c_.data(); } + inline auto& data() noexcept { return c_.data(); } + template * = nullptr> - inline auto val(size_t i) const { + inline const auto val(size_t i) const { return c_.coeffRef(i); } @@ -91,6 +94,8 @@ class scalar_seq_view> { */ inline auto operator[](size_t i) const { return c_[i]; } inline auto size() const noexcept { return c_.size(); } + inline const auto& data() const noexcept { return c_.data(); } + inline auto& data() noexcept { return c_.data(); } template * = nullptr> inline auto val(size_t i) const { @@ -129,6 +134,8 @@ class scalar_seq_view> { } static constexpr auto size() { return 1; } + inline const auto& data() const noexcept { return &c_; } + inline auto& data() noexcept { return &c_; } private: std::decay_t t_; diff --git a/stan/math/prim/prob/ordered_logistic_lpmf.hpp b/stan/math/prim/prob/ordered_logistic_lpmf.hpp index 611ab5fdd48..c8a72900713 100644 --- a/stan/math/prim/prob/ordered_logistic_lpmf.hpp +++ b/stan/math/prim/prob/ordered_logistic_lpmf.hpp @@ -144,7 +144,7 @@ return_type_t ordered_logistic_lpmf(const T_y& y, if (is_vector::value) { Eigen::Map, Eigen::Dynamic, 1>> y_vec( - &y_seq[0], y_seq.size()); + y_seq.data(), y_seq.size()); auto log1m_exp_cuts_diff = log1m_exp(cut1 - cut2); logp = y_vec.cwiseEqual(1) .select(m_log_1p_exp_cut1, From 81ad0bfce04670004aa405ed8a4c42f4a095fd51 Mon Sep 17 00:00:00 2001 From: stevebronder Date: Wed, 6 Jan 2021 10:51:42 -0700 Subject: [PATCH 06/17] fix c_ to t_ in scalar version of scalar sequence view --- stan/math/prim/fun/scalar_seq_view.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stan/math/prim/fun/scalar_seq_view.hpp b/stan/math/prim/fun/scalar_seq_view.hpp index bfcd410ef54..6bad73ada99 100644 --- a/stan/math/prim/fun/scalar_seq_view.hpp +++ b/stan/math/prim/fun/scalar_seq_view.hpp @@ -134,8 +134,8 @@ class scalar_seq_view> { } static constexpr auto size() { return 1; } - inline const auto& data() const noexcept { return &c_; } - inline auto& data() noexcept { return &c_; } + inline const auto& data() const noexcept { return &t_; } + inline auto& data() noexcept { return &t_; } private: std::decay_t t_; From b1b62c99e02299985a82847c1ecc928da4c34b56 Mon Sep 17 00:00:00 2001 From: stevebronder Date: Wed, 6 Jan 2021 12:07:36 -0700 Subject: [PATCH 07/17] add data() member to seq_scalar_view --- stan/math/prim/fun/scalar_seq_view.hpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/stan/math/prim/fun/scalar_seq_view.hpp b/stan/math/prim/fun/scalar_seq_view.hpp index 6bad73ada99..65263a6036d 100644 --- a/stan/math/prim/fun/scalar_seq_view.hpp +++ b/stan/math/prim/fun/scalar_seq_view.hpp @@ -33,8 +33,8 @@ class scalar_seq_view> { inline auto size() const noexcept { return c_.size(); } - inline const auto& data() const noexcept { return c_.data(); } - inline auto& data() noexcept { return c_.data(); } + inline const value_type_t* data() const noexcept { return c_.data(); } + inline value_type_t* data() noexcept { return c_.data(); } template * = nullptr> inline const auto val(size_t i) const { @@ -63,6 +63,8 @@ class scalar_seq_view> { * @return the element at the specified position in the container */ inline auto operator[](size_t i) const { return c_.val().coeffRef(i); } + inline const auto* data() const noexcept { return c_.vi_; } + inline auto* data() noexcept { return c_.vi_; } inline auto size() const noexcept { return c_.size(); } @@ -94,8 +96,7 @@ class scalar_seq_view> { */ inline auto operator[](size_t i) const { return c_[i]; } inline auto size() const noexcept { return c_.size(); } - inline const auto& data() const noexcept { return c_.data(); } - inline auto& data() noexcept { return c_.data(); } + inline const auto* data() const noexcept { return c_.data(); } template * = nullptr> inline auto val(size_t i) const { @@ -124,21 +125,21 @@ class scalar_seq_view> { inline auto operator[](int /* i */) const noexcept { return t_; } template * = nullptr> - inline auto val(int /* i */) const noexcept { + inline const auto& val(int /* i */) const noexcept { return t_; } template * = nullptr> - inline auto val(int /* i */) const noexcept { + inline auto& val(int /* i */) const noexcept { return t_.val(); } static constexpr auto size() { return 1; } - inline const auto& data() const noexcept { return &t_; } - inline auto& data() noexcept { return &t_; } + inline const auto* data() const noexcept { return &t_; } + inline auto* data() noexcept { return &t_; } private: - std::decay_t t_; + std::decay_t t_; }; } // namespace stan #endif From 3e2e0d2955f45804280d38e1427ca89161240038 Mon Sep 17 00:00:00 2001 From: Stan Jenkins Date: Wed, 6 Jan 2021 19:08:22 +0000 Subject: [PATCH 08/17] [Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.04.1 (tags/RELEASE_600/final) --- stan/math/prim/fun/scalar_seq_view.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stan/math/prim/fun/scalar_seq_view.hpp b/stan/math/prim/fun/scalar_seq_view.hpp index 65263a6036d..caf6a9fa5fd 100644 --- a/stan/math/prim/fun/scalar_seq_view.hpp +++ b/stan/math/prim/fun/scalar_seq_view.hpp @@ -139,7 +139,7 @@ class scalar_seq_view> { inline auto* data() noexcept { return &t_; } private: - std::decay_t t_; + std::decay_t t_; }; } // namespace stan #endif From 7b70621dfd95ebd084041570c6416ca49fe88204 Mon Sep 17 00:00:00 2001 From: stevebronder Date: Wed, 6 Jan 2021 15:16:25 -0700 Subject: [PATCH 09/17] use decltype(auto) for val() *_seq_view classes --- stan/math/prim/fun/scalar_seq_view.hpp | 20 ++++++++++---------- stan/math/prim/fun/vector_seq_view.hpp | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/stan/math/prim/fun/scalar_seq_view.hpp b/stan/math/prim/fun/scalar_seq_view.hpp index caf6a9fa5fd..cf9b123330b 100644 --- a/stan/math/prim/fun/scalar_seq_view.hpp +++ b/stan/math/prim/fun/scalar_seq_view.hpp @@ -37,12 +37,12 @@ class scalar_seq_view> { inline value_type_t* data() noexcept { return c_.data(); } template * = nullptr> - inline const auto val(size_t i) const { + inline decltype(auto) val(size_t i) const { return c_.coeffRef(i); } template * = nullptr> - inline auto val(size_t i) const { + inline decltype(auto) val(size_t i) const { return c_.coeffRef(i).val(); } @@ -68,13 +68,13 @@ class scalar_seq_view> { inline auto size() const noexcept { return c_.size(); } - template * = nullptr> + template * = nullptr> inline auto val(size_t i) const { return c_.val().coeffRef(i); } template * = nullptr> - inline auto val(size_t i) const { + inline auto& val(size_t i) { return c_.val().coeffRef(i); } @@ -99,12 +99,12 @@ class scalar_seq_view> { inline const auto* data() const noexcept { return c_.data(); } template * = nullptr> - inline auto val(size_t i) const { + inline decltype(auto) val(size_t i) const { return c_[i]; } template * = nullptr> - inline auto val(size_t i) const { + inline decltype(auto) val(size_t i) const { return c_[i].val(); } @@ -122,15 +122,15 @@ class scalar_seq_view> { public: explicit scalar_seq_view(const C& t) noexcept : t_(t) {} - inline auto operator[](int /* i */) const noexcept { return t_; } + inline decltype(auto) operator[](int /* i */) const noexcept { return t_; } template * = nullptr> - inline const auto& val(int /* i */) const noexcept { + inline decltype(auto) val(int /* i */) const noexcept { return t_; } template * = nullptr> - inline auto& val(int /* i */) const noexcept { + inline decltype(auto) val(int /* i */) const noexcept { return t_.val(); } @@ -139,7 +139,7 @@ class scalar_seq_view> { inline auto* data() noexcept { return &t_; } private: - std::decay_t t_; + std::decay_t t_; }; } // namespace stan #endif diff --git a/stan/math/prim/fun/vector_seq_view.hpp b/stan/math/prim/fun/vector_seq_view.hpp index 95db7344d20..44903ca3db5 100644 --- a/stan/math/prim/fun/vector_seq_view.hpp +++ b/stan/math/prim/fun/vector_seq_view.hpp @@ -77,10 +77,10 @@ class vector_seq_view< explicit vector_seq_view(const T& v) noexcept : v_(v) {} inline auto size() const noexcept { return v_.size(); } - inline const auto& operator[](size_t i) const { return v_[i]; } + inline decltype(auto) operator[](size_t i) const { return v_[i]; } template * = nullptr> - inline const auto& val(size_t i) const { + inline decltype(auto) val(size_t i) const { return v_[i]; } From 822180f9cd3173f053883748ef875194f93e751a Mon Sep 17 00:00:00 2001 From: Stan Jenkins Date: Wed, 6 Jan 2021 23:03:34 +0000 Subject: [PATCH 10/17] [Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.04.1 (tags/RELEASE_600/final) --- stan/math/prim/fun/scalar_seq_view.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stan/math/prim/fun/scalar_seq_view.hpp b/stan/math/prim/fun/scalar_seq_view.hpp index cf9b123330b..66c89f22e53 100644 --- a/stan/math/prim/fun/scalar_seq_view.hpp +++ b/stan/math/prim/fun/scalar_seq_view.hpp @@ -139,7 +139,7 @@ class scalar_seq_view> { inline auto* data() noexcept { return &t_; } private: - std::decay_t t_; + std::decay_t t_; }; } // namespace stan #endif From 9ff9d2f22da049bb5280c81228f38fcd81a2063b Mon Sep 17 00:00:00 2001 From: stevebronder Date: Wed, 6 Jan 2021 18:55:06 -0700 Subject: [PATCH 11/17] update tests to move from meta to fun in prim for seq views --- stan/math/prim/fun/scalar_seq_view.hpp | 35 ++++++++++++++++++- .../{meta => fun}/scalar_seq_view_test.cpp | 2 +- .../{meta => fun}/vector_seq_view_test.cpp | 2 +- .../{meta => fun}/scalar_seq_view_test.cpp | 0 .../{meta => fun}/vector_seq_view_test.cpp | 0 5 files changed, 36 insertions(+), 3 deletions(-) rename test/unit/math/prim/{meta => fun}/scalar_seq_view_test.cpp (98%) rename test/unit/math/prim/{meta => fun}/vector_seq_view_test.cpp (94%) rename test/unit/math/rev/{meta => fun}/scalar_seq_view_test.cpp (100%) rename test/unit/math/rev/{meta => fun}/vector_seq_view_test.cpp (100%) diff --git a/stan/math/prim/fun/scalar_seq_view.hpp b/stan/math/prim/fun/scalar_seq_view.hpp index 66c89f22e53..123c1f685ea 100644 --- a/stan/math/prim/fun/scalar_seq_view.hpp +++ b/stan/math/prim/fun/scalar_seq_view.hpp @@ -112,6 +112,39 @@ class scalar_seq_view> { const C& c_; }; +template +class scalar_seq_view>> { + public: + template , plain_type_t>> + explicit scalar_seq_view(const T& c) : c_(c) {} + + /** + * Segfaults if out of bounds. + * @param i index + * @return the element at the specified position in the container + */ + inline auto operator[](size_t i) const { return c_[i]; } + inline auto size() const noexcept { + static_assert(1, "Cannot Return Size of scalar_seq_view with pointer type"); + } + inline const auto* data() const noexcept { return &c_[0]; } + + template * = nullptr> + inline decltype(auto) val(size_t i) const { + return c_[i]; + } + + template * = nullptr> + inline decltype(auto) val(size_t i) const { + return c_[i].val(); + } + + private: + const C& c_; +}; + + /** * This specialization handles wrapping a scalar as if it were a sequence. * @@ -139,7 +172,7 @@ class scalar_seq_view> { inline auto* data() noexcept { return &t_; } private: - std::decay_t t_; + std::decay_t t_; }; } // namespace stan #endif diff --git a/test/unit/math/prim/meta/scalar_seq_view_test.cpp b/test/unit/math/prim/fun/scalar_seq_view_test.cpp similarity index 98% rename from test/unit/math/prim/meta/scalar_seq_view_test.cpp rename to test/unit/math/prim/fun/scalar_seq_view_test.cpp index 9cd0781b3b6..92f0052958b 100644 --- a/test/unit/math/prim/meta/scalar_seq_view_test.cpp +++ b/test/unit/math/prim/fun/scalar_seq_view_test.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include diff --git a/test/unit/math/prim/meta/vector_seq_view_test.cpp b/test/unit/math/prim/fun/vector_seq_view_test.cpp similarity index 94% rename from test/unit/math/prim/meta/vector_seq_view_test.cpp rename to test/unit/math/prim/fun/vector_seq_view_test.cpp index 22fd7a1ea39..ca56eb8a818 100644 --- a/test/unit/math/prim/meta/vector_seq_view_test.cpp +++ b/test/unit/math/prim/fun/vector_seq_view_test.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include diff --git a/test/unit/math/rev/meta/scalar_seq_view_test.cpp b/test/unit/math/rev/fun/scalar_seq_view_test.cpp similarity index 100% rename from test/unit/math/rev/meta/scalar_seq_view_test.cpp rename to test/unit/math/rev/fun/scalar_seq_view_test.cpp diff --git a/test/unit/math/rev/meta/vector_seq_view_test.cpp b/test/unit/math/rev/fun/vector_seq_view_test.cpp similarity index 100% rename from test/unit/math/rev/meta/vector_seq_view_test.cpp rename to test/unit/math/rev/fun/vector_seq_view_test.cpp From eac53e59ad3ff283948a4ea172ac91991ec437bc Mon Sep 17 00:00:00 2001 From: Stan Jenkins Date: Thu, 7 Jan 2021 01:59:44 +0000 Subject: [PATCH 12/17] [Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.04.1 (tags/RELEASE_600/final) --- stan/math/prim/fun/scalar_seq_view.hpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/stan/math/prim/fun/scalar_seq_view.hpp b/stan/math/prim/fun/scalar_seq_view.hpp index 123c1f685ea..f5263037714 100644 --- a/stan/math/prim/fun/scalar_seq_view.hpp +++ b/stan/math/prim/fun/scalar_seq_view.hpp @@ -144,7 +144,6 @@ class scalar_seq_view>> { const C& c_; }; - /** * This specialization handles wrapping a scalar as if it were a sequence. * @@ -172,7 +171,7 @@ class scalar_seq_view> { inline auto* data() noexcept { return &t_; } private: - std::decay_t t_; + std::decay_t t_; }; } // namespace stan #endif From 5142e99324e6e6cf7d74f74d49908e319e45ee4f Mon Sep 17 00:00:00 2001 From: stevebronder Date: Wed, 6 Jan 2021 20:08:14 -0700 Subject: [PATCH 13/17] fix glm for accessing pointer to data --- stan/math/prim/prob/ordered_logistic_glm_lpmf.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stan/math/prim/prob/ordered_logistic_glm_lpmf.hpp b/stan/math/prim/prob/ordered_logistic_glm_lpmf.hpp index 0f3416a1b69..f71b68547d4 100644 --- a/stan/math/prim/prob/ordered_logistic_glm_lpmf.hpp +++ b/stan/math/prim/prob/ordered_logistic_glm_lpmf.hpp @@ -131,7 +131,7 @@ return_type_t ordered_logistic_glm_lpmf( T_partials_return logp(0); if (is_vector::value) { - Eigen::Map> y_vec(&y_seq[0], + Eigen::Map> y_vec(y_seq.data(), y_seq.size()); logp = y_vec.cwiseEqual(1) .select(m_log_1p_exp_cut1, From 70a6546baeecebd16b3f3d5cbcae5e35d136c517 Mon Sep 17 00:00:00 2001 From: stevebronder Date: Wed, 6 Jan 2021 21:57:26 -0700 Subject: [PATCH 14/17] fix beta dist --- stan/math/prim/prob/beta_binomial_cdf.hpp | 6 +++--- stan/math/prim/prob/beta_binomial_lpmf.hpp | 8 ++++---- stan/math/prim/prob/beta_cdf.hpp | 6 +++--- stan/math/prim/prob/beta_lccdf.hpp | 6 +++--- stan/math/prim/prob/beta_lcdf.hpp | 6 +++--- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/stan/math/prim/prob/beta_binomial_cdf.hpp b/stan/math/prim/prob/beta_binomial_cdf.hpp index 5104bbe5763..41bb221fc3f 100644 --- a/stan/math/prim/prob/beta_binomial_cdf.hpp +++ b/stan/math/prim/prob/beta_binomial_cdf.hpp @@ -92,9 +92,9 @@ return_type_t beta_binomial_cdf(const T_n& n, const T_N& N, } const T_partials_return n_dbl = n_vec.val(i); - const T_partials_return N_dbl = n_vec.val(i); - const T_partials_return alpha_dbl = n_vec.val(i); - const T_partials_return beta_dbl = n_vec.val(i); + const T_partials_return N_dbl = N_vec.val(i); + const T_partials_return alpha_dbl = alpha_vec.val(i); + const T_partials_return beta_dbl = beta_vec.val(i); const T_partials_return N_minus_n = N_dbl - n_dbl; const T_partials_return mu = alpha_dbl + n_dbl + 1; const T_partials_return nu = beta_dbl + N_minus_n - 1; diff --git a/stan/math/prim/prob/beta_binomial_lpmf.hpp b/stan/math/prim/prob/beta_binomial_lpmf.hpp index 51dafeffc03..27552933c61 100644 --- a/stan/math/prim/prob/beta_binomial_lpmf.hpp +++ b/stan/math/prim/prob/beta_binomial_lpmf.hpp @@ -104,7 +104,7 @@ return_type_t beta_binomial_lpmf(const T_n& n, const T_N& N, max_size_seq_view); for (size_t i = 0; i < max_size_seq_view; i++) { lbeta_diff[i] = lbeta(n_vec[i] + alpha_vec.val(i), - N_vec[i] - n_vec[i] + alpha_vec.val(i)) + N_vec[i] - n_vec[i] + beta_vec.val(i)) - lbeta_denominator[i]; } @@ -113,7 +113,7 @@ return_type_t beta_binomial_lpmf(const T_n& n, const T_N& N, digamma_n_plus_alpha(max_size(n, alpha)); if (!is_constant_all::value) { for (size_t i = 0; i < max_size(n, alpha); i++) { - digamma_n_plus_alpha[i] = digamma(n_vec[i] + alpha_vec.val(i)); + digamma_n_plus_alpha[i] = digamma(n_vec.val(i) + alpha_vec.val(i)); } } @@ -133,7 +133,7 @@ return_type_t beta_binomial_lpmf(const T_n& n, const T_N& N, for (size_t i = 0; i < max_size(N, alpha, beta); i++) { digamma_diff[i] = digamma_alpha_plus_beta[i] - - digamma(N_vec[i] + alpha_vec.val(i) + alpha_vec.val(i)); + - digamma(N_vec.val(i) + alpha_vec.val(i) + beta_vec.val(i)); } } @@ -147,7 +147,7 @@ return_type_t beta_binomial_lpmf(const T_n& n, const T_N& N, digamma_beta(size_beta); for (size_t i = 0; i < size_beta; i++) if (!is_constant_all::value) - digamma_beta[i] = digamma(alpha_vec.val(i)); + digamma_beta[i] = digamma(beta_vec.val(i)); for (size_t i = 0; i < max_size_seq_view; i++) { if (include_summand::value) diff --git a/stan/math/prim/prob/beta_cdf.hpp b/stan/math/prim/prob/beta_cdf.hpp index 3b9de67016c..d5ce66e8a9c 100644 --- a/stan/math/prim/prob/beta_cdf.hpp +++ b/stan/math/prim/prob/beta_cdf.hpp @@ -87,7 +87,7 @@ return_type_t beta_cdf( digamma_beta(size_beta); if (!is_constant_all::value) { for (size_t n = 0; n < size_beta; n++) { - digamma_beta[n] = digamma(alpha_vec.val(n)); + digamma_beta[n] = digamma(beta_vec.val(n)); } } @@ -101,7 +101,7 @@ return_type_t beta_cdf( } for (size_t n = 0; n < N; n++) { - const T_partials_return y_dbl = alpha_vec.val(n); + const T_partials_return y_dbl = y_vec.val(n); // Explicit results for extreme values // The gradients are technically ill-defined, but treated as zero @@ -110,7 +110,7 @@ return_type_t beta_cdf( } const T_partials_return alpha_dbl = alpha_vec.val(n); - const T_partials_return beta_dbl = alpha_vec.val(n); + const T_partials_return beta_dbl = beta_vec.val(n); const T_partials_return Pn = inc_beta(alpha_dbl, beta_dbl, y_dbl); const T_partials_return inv_Pn = is_constant_all::value ? 0 : inv(Pn); diff --git a/stan/math/prim/prob/beta_lccdf.hpp b/stan/math/prim/prob/beta_lccdf.hpp index e6dfcdacdf2..bdb51607cb5 100644 --- a/stan/math/prim/prob/beta_lccdf.hpp +++ b/stan/math/prim/prob/beta_lccdf.hpp @@ -88,7 +88,7 @@ return_type_t beta_lccdf( digamma_alpha[i] = digamma(alpha_vec.val(i)); } for (size_t i = 0; i < size_beta; i++) { - digamma_beta[i] = digamma(alpha_vec.val(i)); + digamma_beta[i] = digamma(beta_vec.val(i)); } for (size_t i = 0; i < size_alpha_beta; i++) { digamma_sum[i] = digamma(alpha_vec.val(i) + beta_vec.val(i)); @@ -97,8 +97,8 @@ return_type_t beta_lccdf( for (size_t n = 0; n < N; n++) { const T_partials_return y_dbl = y_vec.val(n); - const T_partials_return alpha_dbl = y_vec.val(n); - const T_partials_return beta_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 betafunc_dbl = beta(alpha_dbl, beta_dbl); const T_partials_return Pn = 1.0 - inc_beta(alpha_dbl, beta_dbl, y_dbl); const T_partials_return inv_Pn diff --git a/stan/math/prim/prob/beta_lcdf.hpp b/stan/math/prim/prob/beta_lcdf.hpp index f4580a71105..d92144daa0a 100644 --- a/stan/math/prim/prob/beta_lcdf.hpp +++ b/stan/math/prim/prob/beta_lcdf.hpp @@ -88,7 +88,7 @@ return_type_t beta_lcdf( digamma_alpha[i] = digamma(alpha_vec.val(i)); } for (size_t i = 0; i < size_beta; i++) { - digamma_beta[i] = digamma(alpha_vec.val(i)); + digamma_beta[i] = digamma(beta_vec.val(i)); } for (size_t i = 0; i < size_alpha_beta; i++) { digamma_sum[i] = digamma(alpha_vec.val(i) + beta_vec.val(i)); @@ -97,8 +97,8 @@ return_type_t beta_lcdf( for (size_t n = 0; n < N; n++) { const T_partials_return y_dbl = y_vec.val(n); - const T_partials_return alpha_dbl = y_vec.val(n); - const T_partials_return beta_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 betafunc_dbl = beta(alpha_dbl, beta_dbl); const T_partials_return Pn = inc_beta(alpha_dbl, beta_dbl, y_dbl); const T_partials_return inv_Pn From 15f8500225420f6c2d78bf938dfe126c910c6bbc Mon Sep 17 00:00:00 2001 From: stevebronder Date: Wed, 6 Jan 2021 22:18:50 -0700 Subject: [PATCH 15/17] update student and pareto --- stan/math/prim/prob/pareto_cdf.hpp | 4 ++-- stan/math/prim/prob/student_t_cdf.hpp | 4 ++-- stan/math/prim/prob/student_t_lccdf.hpp | 4 ++-- stan/math/prim/prob/student_t_lcdf.hpp | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/stan/math/prim/prob/pareto_cdf.hpp b/stan/math/prim/prob/pareto_cdf.hpp index abe2fef6fbd..d39585f2271 100644 --- a/stan/math/prim/prob/pareto_cdf.hpp +++ b/stan/math/prim/prob/pareto_cdf.hpp @@ -67,8 +67,8 @@ return_type_t pareto_cdf(const T_y& y, } const T_partials_return log_dbl = log(y_min_vec.val(n) / y_vec.val(n)); - const T_partials_return y_min_inv_dbl = 1.0 / y_vec.val(n); - const T_partials_return alpha_dbl = y_vec.val(n); + const T_partials_return y_min_inv_dbl = 1.0 / y_min_vec.val(n); + const T_partials_return alpha_dbl = alpha_vec.val(n); const T_partials_return Pn = 1.0 - exp(alpha_dbl * log_dbl); diff --git a/stan/math/prim/prob/student_t_cdf.hpp b/stan/math/prim/prob/student_t_cdf.hpp index 3556e667a07..38232b2ea0a 100644 --- a/stan/math/prim/prob/student_t_cdf.hpp +++ b/stan/math/prim/prob/student_t_cdf.hpp @@ -89,9 +89,9 @@ return_type_t student_t_cdf(const T_y& y, continue; } - const T_partials_return sigma_inv = 1.0 / y_vec.val(n); + const T_partials_return sigma_inv = 1.0 / sigma_vec.val(n); const T_partials_return t = (y_vec.val(n) - mu_vec.val(n)) * sigma_inv; - const T_partials_return nu_dbl = y_vec.val(n); + const T_partials_return nu_dbl = nu_vec.val(n); const T_partials_return q = nu_dbl / (t * t); const T_partials_return r = 1.0 / (1.0 + q); const T_partials_return J = 2 * r * r * q / t; diff --git a/stan/math/prim/prob/student_t_lccdf.hpp b/stan/math/prim/prob/student_t_lccdf.hpp index 74940cd9330..5c9e39865d2 100644 --- a/stan/math/prim/prob/student_t_lccdf.hpp +++ b/stan/math/prim/prob/student_t_lccdf.hpp @@ -89,9 +89,9 @@ return_type_t student_t_lccdf( return ops_partials.build(negative_infinity()); } - const T_partials_return sigma_inv = 1.0 / y_vec.val(n); + const T_partials_return sigma_inv = 1.0 / sigma_vec.val(n); const T_partials_return t = (y_vec.val(n) - mu_vec.val(n)) * sigma_inv; - const T_partials_return nu_dbl = y_vec.val(n); + const T_partials_return nu_dbl = nu_vec.val(n); const T_partials_return q = nu_dbl / (t * t); const T_partials_return r = 1.0 / (1.0 + q); const T_partials_return J = 2 * r * r * q / t; diff --git a/stan/math/prim/prob/student_t_lcdf.hpp b/stan/math/prim/prob/student_t_lcdf.hpp index 343d1540802..401e938cc5b 100644 --- a/stan/math/prim/prob/student_t_lcdf.hpp +++ b/stan/math/prim/prob/student_t_lcdf.hpp @@ -91,9 +91,9 @@ return_type_t student_t_lcdf(const T_y& y, continue; } - const T_partials_return sigma_inv = 1.0 / y_vec.val(n); + const T_partials_return sigma_inv = 1.0 / sigma_vec.val(n); const T_partials_return t = (y_vec.val(n) - mu_vec.val(n)) * sigma_inv; - const T_partials_return nu_dbl = y_vec.val(n); + const T_partials_return nu_dbl = nu_vec.val(n); const T_partials_return q = nu_dbl / (t * t); const T_partials_return r = 1.0 / (1.0 + q); const T_partials_return J = 2 * r * r * q / t; From f61f1040053d674c3f34f7bfdc37081b2aea366a Mon Sep 17 00:00:00 2001 From: stevebronder Date: Wed, 6 Jan 2021 22:36:50 -0700 Subject: [PATCH 16/17] fix binomial --- stan/math/prim/prob/beta_binomial_lccdf.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/stan/math/prim/prob/beta_binomial_lccdf.hpp b/stan/math/prim/prob/beta_binomial_lccdf.hpp index 0ccdd696249..4e8d95fab79 100644 --- a/stan/math/prim/prob/beta_binomial_lccdf.hpp +++ b/stan/math/prim/prob/beta_binomial_lccdf.hpp @@ -94,9 +94,9 @@ return_type_t beta_binomial_lccdf(const T_n& n, const T_N& N, } const T_partials_return n_dbl = n_vec.val(i); - const T_partials_return N_dbl = n_vec.val(i); - const T_partials_return alpha_dbl = n_vec.val(i); - const T_partials_return beta_dbl = n_vec.val(i); + const T_partials_return N_dbl = N_vec.val(i); + const T_partials_return alpha_dbl = alpha_vec.val(i); + const T_partials_return beta_dbl = beta_vec.val(i); const T_partials_return mu = alpha_dbl + n_dbl + 1; const T_partials_return nu = beta_dbl + N_dbl - n_dbl - 1; const T_partials_return one = 1; From d7124dff41dfeb7bc5fb58816d4658b21c8fdd78 Mon Sep 17 00:00:00 2001 From: Ben Date: Thu, 7 Jan 2021 08:24:18 -0500 Subject: [PATCH 17/17] Added size tests to vector sequence view (Issue #2101) --- test/unit/math/prim/fun/vector_seq_view_test.cpp | 2 ++ test/unit/math/rev/fun/vector_seq_view_test.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/test/unit/math/prim/fun/vector_seq_view_test.cpp b/test/unit/math/prim/fun/vector_seq_view_test.cpp index ca56eb8a818..f2b92b028e4 100644 --- a/test/unit/math/prim/fun/vector_seq_view_test.cpp +++ b/test/unit/math/prim/fun/vector_seq_view_test.cpp @@ -12,6 +12,7 @@ TEST(MathMetaPrim, VectorSeqView) { vector_seq_view vsv(m1); EXPECT_FLOAT_EQ(m1(1), vsv[12](1)); + EXPECT_EQ(vsv.size(), 1); vector v; v.push_back(m1); @@ -21,4 +22,5 @@ TEST(MathMetaPrim, VectorSeqView) { EXPECT_FLOAT_EQ(m1(0), vsv_vec[1][3]); EXPECT_FLOAT_EQ(m1(2), vsv_vec[1][1]); EXPECT_FLOAT_EQ(m1(2), vsv_vec[0][2]); + EXPECT_EQ(vsv_vec.size(), 2); } 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 f753fa84637..17fb4c98580 100644 --- a/test/unit/math/rev/fun/vector_seq_view_test.cpp +++ b/test/unit/math/rev/fun/vector_seq_view_test.cpp @@ -8,6 +8,7 @@ void test_vec_seq_var(const T& m1) { using stan::math::var; vector_seq_view vsv(m1); EXPECT_FLOAT_EQ(m1.val()(1), vsv.val(12)(1)); + EXPECT_EQ(vsv.size(), 1); std::vector> v; v.push_back(m1); @@ -17,6 +18,7 @@ void test_vec_seq_var(const T& m1) { EXPECT_FLOAT_EQ(m1.val()(0), vsv_vec.val(1)[3]); EXPECT_FLOAT_EQ(m1.val()(2), vsv_vec.val(1)[1]); EXPECT_FLOAT_EQ(m1.val()(2), vsv_vec.val(0)[2]); + EXPECT_EQ(vsv_vec.size(), 2); } TEST(MathMetaRev, VectorSeqViewVar) { Eigen::Matrix values = Eigen::Matrix::Random(4);