1#ifndef STAN_MATH_PRIM_CONSTRAINT_ORDERED_CONSTRAIN_HPP
2#define STAN_MATH_PRIM_CONSTRAINT_ORDERED_CONSTRAIN_HPP
24template <
typename EigVec, require_eigen_col_vector_t<EigVec>* =
nullptr,
25 require_not_st_var<EigVec>* =
nullptr>
28 Eigen::Index k = x.size();
30 const auto& x_ref =
to_ref(x);
35 for (Eigen::Index i = 1; i < k; ++i) {
36 y.coeffRef(i) = y.coeff(i - 1) +
exp(x_ref.coeff(i));
55template <
typename EigVec,
typename Lp,
59 const auto& x_ref =
to_ref(x);
60 if (
likely(x.size() > 1)) {
61 lp +=
sum(x_ref.tail(x.size() - 1));
78template <
typename T, require_std_vector_t<T>* =
nullptr>
99template <
typename T,
typename Lp, require_std_vector_t<T>* =
nullptr,
100 require_convertible_t<return_type_t<T>, Lp>* =
nullptr>
126template <
bool Jacobian,
typename T,
typename Lp,
129 if constexpr (Jacobian) {
require_t< std::is_convertible< std::decay_t< T >, std::decay_t< S > > > require_convertible_t
Require types T and S satisfies std::is_convertible.
require_t< is_eigen_col_vector< std::decay_t< T > > > require_eigen_col_vector_t
Require type satisfies is_eigen_col_vector.
ref_type_t< T && > to_ref(T &&a)
This evaluates expensive Eigen expressions.
auto sum(const std::vector< T > &m)
Return the sum of the entries of the specified standard vector.
plain_type_t< EigVec > ordered_constrain(const EigVec &x)
Return an increasing ordered vector derived from the specified free vector.
fvar< T > exp(const fvar< T > &x)
typename plain_type< T >::type plain_type_t
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...