1#ifndef STAN_MATH_PRIM_CONSTRAINT_POSITIVE_ORDERED_CONSTRAIN_HPP
2#define STAN_MATH_PRIM_CONSTRAINT_POSITIVE_ORDERED_CONSTRAIN_HPP
22template <
typename EigVec, require_eigen_col_vector_t<EigVec>* =
nullptr,
23 require_not_st_var<EigVec>* =
nullptr>
26 Eigen::Index k = x.size();
31 const auto& x_ref =
to_ref(x);
32 y.coeffRef(0) =
exp(x_ref.coeff(0));
33 for (Eigen::Index i = 1; i < k; ++i) {
34 y.coeffRef(i) = y.coeff(i - 1) +
exp(x_ref.coeff(i));
51template <
typename Vec, require_col_vector_t<Vec>* =
nullptr>
53 const auto& x_ref =
to_ref(x);
75template <
bool Jacobian,
typename Vec, require_not_std_vector_t<Vec>* =
nullptr>
102template <
bool Jacobian,
typename T, require_std_vector_t<T>* =
nullptr>
105 return positive_ordered_constrain<Jacobian>(v, lp);
typename return_type< Ts... >::type return_type_t
Convenience type for the return type of the specified template parameters.
ref_type_t< T && > to_ref(T &&a)
This evaluates expensive Eigen expressions.
auto positive_ordered_constrain(const EigVec &x)
Return an increasing positive ordered vector derived from the specified free vector.
auto sum(const std::vector< T > &m)
Return the sum of the entries of the specified standard 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 ...