1#ifndef STAN_MATH_PRIM_CONSTRAINT_LB_FREE_HPP
2#define STAN_MATH_PRIM_CONSTRAINT_LB_FREE_HPP
28template <
typename T,
typename L, require_not_std_vector_t<T>* =
nullptr,
29 require_stan_scalar_t<L>* =
nullptr>
34 auto&& y_ref =
to_ref(std::forward<T>(y));
35 auto&& lb_ref =
to_ref(std::forward<L>(lb));
38 std::forward<
decltype(lb_ref)>(lb_ref))));
56template <
typename T,
typename L, require_all_eigen_t<T, L>* =
nullptr>
58 auto&& y_ref =
to_ref(std::forward<T>(y));
59 auto&& lb_ref =
to_ref(std::forward<L>(lb));
61 for (Eigen::Index j = 0; j < y.cols(); ++j) {
62 for (Eigen::Index i = 0; i < y.rows(); ++i) {
63 ret.coeffRef(i, j) =
lb_free(y_ref.coeff(i, j), lb_ref.coeff(i, j));
83template <
typename T,
typename L, require_not_std_vector_t<L>* =
nullptr>
84inline auto lb_free(
const std::vector<T> y,
const L& lb) {
85 auto&& lb_ref =
to_ref(lb);
86 std::vector<
decltype(
lb_free(y[0], lb_ref))> ret(y.size());
87 std::transform(y.begin(), y.end(), ret.begin(),
88 [&lb_ref](
auto&& yy) { return lb_free(yy, lb_ref); });
106template <
typename T,
typename L>
107inline auto lb_free(
const std::vector<T> y,
const std::vector<L>& lb) {
108 std::vector<
decltype(
lb_free(y[0], lb[0]))> ret(y.size());
109 std::transform(y.begin(), y.end(), lb.begin(), ret.begin(),
110 [](
auto&& yy,
auto&& lbb) { return lb_free(yy, lbb); });
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.
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 ...
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.
static constexpr double NEGATIVE_INFTY
Negative infinity.
void check_greater_or_equal(const char *function, const char *name, const T_y &y, const T_low &low, Idxs... idxs)
Throw an exception if y is not greater or equal than low.
ref_type_t< T && > to_ref(T &&a)
This evaluates expensive Eigen expressions.
auto lb_free(T &&y, L &&lb)
Return the unconstrained value that produces the specified lower-bound constrained value.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...