1#ifndef STAN_MATH_PRIM_CONSTRAINT_UB_CONSTRAIN_HPP
2#define STAN_MATH_PRIM_CONSTRAINT_UB_CONSTRAIN_HPP
34template <
typename T,
typename U, require_all_stan_scalar_t<T, U>* =
nullptr,
35 require_all_not_st_var<T, U>* =
nullptr>
65template <
typename T,
typename U, require_all_stan_scalar_t<T, U>* =
nullptr,
66 require_all_not_st_var<T, U>* =
nullptr>
87template <
typename T,
typename U, require_eigen_t<T>* =
nullptr,
88 require_stan_scalar_t<U>* =
nullptr,
89 require_all_not_st_var<T, U>* =
nullptr>
91 return eval(x.unaryExpr([ub](
auto&& xx) { return ub_constrain(xx, ub); }));
105template <
typename T,
typename U, require_eigen_t<T>* =
nullptr,
106 require_stan_scalar_t<U>* =
nullptr,
107 require_all_not_st_var<T, U>* =
nullptr>
111 x.unaryExpr([ub, &lp](
auto&& xx) { return ub_constrain(xx, ub, lp); }));
124template <
typename T,
typename U, require_all_eigen_t<T, U>* =
nullptr,
125 require_all_not_st_var<T, U>* =
nullptr>
128 return eval(x.binaryExpr(
129 ub, [](
auto&& xx,
auto&& ubb) { return ub_constrain(xx, ubb); }));
143template <
typename T,
typename U, require_all_eigen_t<T, U>* =
nullptr,
144 require_all_not_st_var<T, U>* =
nullptr>
146 std::decay_t<return_type_t<T, U>>& lp) {
148 return eval(x.binaryExpr(
149 ub, [&lp](
auto&& xx,
auto&& ubb) { return ub_constrain(xx, ubb, lp); }));
162template <
typename T,
typename U, require_not_std_vector_t<U>* =
nullptr>
165 for (
size_t i = 0; i < x.size(); ++i) {
182template <
typename T,
typename U, require_not_std_vector_t<U>* =
nullptr>
186 for (
size_t i = 0; i < x.size(); ++i) {
202template <
typename T,
typename U>
203inline auto ub_constrain(
const std::vector<T>& x,
const std::vector<U>& ub) {
206 for (
size_t i = 0; i < x.size(); ++i) {
223template <
typename T,
typename U>
224inline auto ub_constrain(
const std::vector<T>& x,
const std::vector<U>& ub,
228 for (
size_t i = 0; i < x.size(); ++i) {
252template <
bool Jacobian,
typename T,
typename U>
subtraction_< as_operation_cl_t< T_a >, as_operation_cl_t< T_b > > subtract(T_a &&a, T_b &&b)
typename return_type< Ts... >::type return_type_t
Convenience type for the return type of the specified template parameters.
double value_of_rec(const fvar< T > &v)
Return the value of the specified variable.
T eval(T &&arg)
Inputs which have a plain_type equal to the own time are forwarded unmodified (for Eigen expressions ...
void check_matching_dims(const char *function, const char *name1, const T1 &y1, const char *name2, const T2 &y2)
Check if the two containers have the same dimensions.
auto ub_constrain(T &&x, U &&ub)
Return the upper-bounded value for the specified unconstrained matrix and upper bound.
auto identity_constrain(T &&x, Types &&...)
Returns the result of applying the identity constraint transform to the input.
static constexpr double INFTY
Positive infinity.
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 ...