1#ifndef STAN_MATH_OPENCL_REV_CONSTRAINT_LUB_CONSTRAIN_HPP
2#define STAN_MATH_OPENCL_REV_CONSTRAINT_LUB_CONSTRAIN_HPP
38 typename T_x,
typename T_lb,
typename T_ub,
39 require_all_prim_or_rev_kernel_expression_t<T_x, T_lb, T_ub>* =
nullptr,
40 require_any_var_t<T_x, T_lb, T_ub>* =
nullptr,
41 require_any_not_stan_scalar_t<T_x, T_lb, T_ub>* =
nullptr>
55 auto one_m_inv_logit_x = 1.0 - inv_logit_x;
59 select(lb_inf,
select(ub_inf, res.adj(), -res_adj_exp_x),
60 select(ub_inf, res_adj_exp_x,
94 typename T_x,
typename T_lb,
typename T_ub,
110 std::move(res), [x_arena, lb_arena, ub_arena,
115 auto one_m_inv_logit_x = 1.0 - inv_logit_x;
121 select(lb_inf,
select(ub_inf, res.adj(), lp.adj() - res_adj_exp_x),
122 select(ub_inf, res_adj_exp_x + lp.adj(),
126 + lp.adj() * (1.0 - 2.0 * inv_logit_x))),
130 - one_over_diff * lp.adj())),
134 + one_over_diff * lp.adj())));
Represents an arithmetic matrix on the OpenCL device.
elt_multiply_< as_operation_cl_t< T_a >, as_operation_cl_t< T_b > > elt_multiply(T_a &&a, T_b &&b)
select_< as_operation_cl_t< T_condition >, as_operation_cl_t< T_then >, as_operation_cl_t< T_else > > select(T_condition &&condition, T_then &&then, T_else &&els)
Selection operation on kernel generator expressions.
elt_divide_< as_operation_cl_t< T_a >, as_operation_cl_t< T_b > > elt_divide(T_a &&a, T_b &&b)
expressions_cl< T_expressions... > expressions(T_expressions &&... expressions)
Deduces types for constructing expressions_cl object.
require_all_t< is_prim_or_rev_kernel_expression< std::decay_t< Types > >... > require_all_prim_or_rev_kernel_expression_t
Require type satisfies is_prim_or_rev_kernel_expression.
require_any_not_t< is_stan_scalar< std::decay_t< Types > >... > require_any_not_stan_scalar_t
Require at least one of the types do not satisfy is_stan_scalar.
require_any_t< is_var< std::decay_t< Types > >... > require_any_var_t
Require any of the types satisfy is_var.
adjoint_results_cl< T_results... > adjoint_results(T_results &&... results)
Deduces types for constructing adjoint_results_cl object.
var_value< plain_type_t< T > > make_callback_var(T &&value, F &&functor)
Creates a new var initialized with a callback_vari with a given value and reverse-pass callback funct...
T value_of(const fvar< T > &v)
Return the value of the specified variable.
static constexpr double NEGATIVE_INFTY
Negative infinity.
matrix_cl< double > lub_constrain(const T &x, const L &lb, const U &ub)
Return the lower and upper-bounded matrix derived by transforming the specified free matrix given the...
fvar< T > inv_logit(const fvar< T > &x)
Returns the inverse logit function applied to the argument.
static constexpr double INFTY
Positive infinity.
fvar< T > exp(const fvar< T > &x)
typename internal::arena_type_impl< std::decay_t< T > >::type arena_t
Determines a type that can be used in place of T that does any dynamic allocations on the AD stack.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...