Automatic Differentiation
 
Loading...
Searching...
No Matches

◆ ub_constrain() [6/14]

template<typename T , typename U , require_all_stan_scalar_t< T, U > * = nullptr, require_all_not_st_var< T, U > * = nullptr>
auto stan::math::ub_constrain ( const T &  x,
const U &  ub,
std::decay_t< return_type_t< T, U > > &  lp 
)
inline

Return the upper-bounded value for the specified unconstrained scalar and upper bound and increment the specified log probability reference with the log absolute Jacobian determinant of the transform.

Specialization of ub_constrain to apply a matrix of upper bounds elementwise to each input element.

The transform is as specified for ub_constrain(T, double). The log absolute Jacobian determinant is

\( \log | \frac{d}{dx} -\mbox{exp}(x) + U | = \log | -\mbox{exp}(x) + 0 | = x\).

Template Parameters
Ttype of scalar
Utype of upper bound
Stype of log probability
Parameters
[in]xfree scalar
[in]ubupper bound
[in,out]lplog density
Returns
scalar constrained to have upper bound
Template Parameters
TA type inheriting from EigenBase.
UA type inheriting from EigenBase.
Parameters
[in]xunconstrained input
[in]ubupper bound on output
[in,out]lpreference to log probability to increment
Returns
upper-bound constrained value corresponding to inputs

Definition at line 67 of file ub_constrain.hpp.