1#ifndef STAN_MATH_PRIM_CONSTRAINT_UB_FREE_HPP
2#define STAN_MATH_PRIM_CONSTRAINT_UB_FREE_HPP
33template <
typename T,
typename U, require_not_std_vector_t<T>* =
nullptr,
34 require_stan_scalar_t<U>* =
nullptr>
39 auto&& y_ref =
to_ref(std::forward<T>(y));
40 auto&& ub_ref =
to_ref(std::forward<U>(ub));
44 std::forward<
decltype(y_ref)>(y_ref))));
62template <
typename T,
typename U, require_all_eigen_t<T, U>* =
nullptr>
65 auto&& y_ref =
to_ref(std::forward<T>(y));
66 auto&& ub_ref =
to_ref(std::forward<U>(ub));
68 for (Eigen::Index j = 0; j < y.cols(); ++j) {
69 for (Eigen::Index i = 0; i < y.rows(); ++i) {
70 ret.coeffRef(i, j) =
ub_free(y_ref.coeff(i, j), ub_ref.coeff(i, j));
90template <
typename T,
typename U, require_not_std_vector_t<U>* =
nullptr>
91inline auto ub_free(
const std::vector<T> y,
const U& ub) {
92 auto&& ub_ref =
to_ref(ub);
93 std::vector<
decltype(
ub_free(y[0], ub))> ret(y.size());
94 for (Eigen::Index i = 0; i < y.size(); ++i) {
114template <
typename T,
typename U>
115inline auto ub_free(
const std::vector<T> y,
const std::vector<U>& ub) {
117 std::vector<
decltype(
ub_free(y[0], ub[0]))> ret(y.size());
118 for (Eigen::Index i = 0; i < y.size(); ++i) {
subtraction_< as_operation_cl_t< T_a >, as_operation_cl_t< T_b > > subtract(T_a &&a, T_b &&b)
double value_of_rec(const fvar< T > &v)
Return the value of the specified variable.
void check_less_or_equal(const char *function, const char *name, const T_y &y, const T_high &high, Idxs... idxs)
Throw an exception if y is not less than high.
typename promote_scalar_type< std::decay_t< T >, std::decay_t< S > >::type promote_scalar_t
T eval(T &&arg)
Inputs which have a plain_type equal to the own time are forwarded unmodified (for Eigen expressions ...
T value_of(const fvar< T > &v)
Return the value of the specified variable.
fvar< T > log(const fvar< T > &x)
auto identity_free(T &&x, Types &&...)
Returns the result of applying the inverse of the identity constraint transform to the input.
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_free(T &&y, U &&ub)
Return the free scalar that corresponds to the specified upper-bounded value with respect to the spec...
ref_type_t< T && > to_ref(T &&a)
This evaluates expensive Eigen expressions.
static constexpr double INFTY
Positive infinity.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...