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,
typename Lp,
88template <
typename T,
typename U, require_eigen_t<T>* =
nullptr,
89 require_stan_scalar_t<U>* =
nullptr,
90 require_all_not_st_var<T, U>* =
nullptr>
92 return eval(x.unaryExpr([ub](
auto&& xx) { return ub_constrain(xx, ub); }));
107template <
typename T,
typename U,
typename Lp, require_eigen_t<T>* =
nullptr,
108 require_stan_scalar_t<U>* =
nullptr,
109 require_all_not_st_var<T, U>* =
nullptr,
110 require_convertible_t<return_type_t<T, U>, Lp>* =
nullptr>
113 x.unaryExpr([ub, &lp](
auto&& xx) { return ub_constrain(xx, ub, lp); }));
126template <
typename T,
typename U, require_all_eigen_t<T, U>* =
nullptr,
127 require_all_not_st_var<T, U>* =
nullptr>
130 return eval(x.binaryExpr(
131 ub, [](
auto&& xx,
auto&& ubb) { return ub_constrain(xx, ubb); }));
146template <
typename T,
typename U,
typename Lp,
147 require_all_eigen_t<T, U>* =
nullptr,
148 require_all_not_st_var<T, U>* =
nullptr,
149 require_convertible_t<return_type_t<T, U>, Lp>* =
nullptr>
150inline auto ub_constrain(
const T& x,
const U& ub, Lp& lp) {
152 return eval(x.binaryExpr(
153 ub, [&lp](
auto&& xx,
auto&& ubb) { return ub_constrain(xx, ubb, lp); }));
166template <
typename T,
typename U, require_not_std_vector_t<U>* =
nullptr>
169 for (
size_t i = 0; i < x.size(); ++i) {
187template <
typename T,
typename U,
typename Lp,
190inline auto ub_constrain(
const std::vector<T>& x,
const U& ub, Lp& lp) {
192 for (
size_t i = 0; i < x.size(); ++i) {
208template <
typename T,
typename U>
209inline auto ub_constrain(
const std::vector<T>& x,
const std::vector<U>& ub) {
212 for (
size_t i = 0; i < x.size(); ++i) {
230template <
typename T,
typename U,
typename Lp,
232inline auto ub_constrain(
const std::vector<T>& x,
const std::vector<U>& ub,
236 for (
size_t i = 0; i < x.size(); ++i) {
262template <
bool Jacobian,
typename T,
typename U,
typename Lp,
265 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.
subtraction_< as_operation_cl_t< T_a >, as_operation_cl_t< T_b > > subtract(T_a &&a, T_b &&b)
require_all_t< is_stan_scalar< std::decay_t< Types > >... > require_all_stan_scalar_t
Require all of the types satisfy is_stan_scalar.
require_not_t< is_std_vector< std::decay_t< T > > > require_not_std_vector_t
Require type does not satisfy is_std_vector.
require_all_not_t< is_var< scalar_type_t< std::decay_t< Types > > >... > require_all_not_st_var
Require none of the scalar types satisfy is_var.
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 ...