1#ifndef STAN_MATH_REV_FUN_LOG_SUM_EXP_HPP
2#define STAN_MATH_REV_FUN_LOG_SUM_EXP_HPP
67template <
typename T, require_eigen_st<is_var, T>* =
nullptr,
68 require_not_var_matrix_t<T>* =
nullptr>
70 arena_t<
decltype(v)> arena_v = v;
71 arena_t<
decltype(v.val())> arena_v_val = arena_v.val();
76 += res.adj() * (arena_v_val.array().val() - res.val()).exp().matrix();
88template <
typename T, require_var_matrix_t<T>* =
nullptr>
91 x.adj() += res.adj() * (x.val().array().val() - res.val()).exp().matrix();
101template <
typename T, require_std_vector_st<is_var, T>* =
nullptr>
103 return apply_vector_unary<T>::reduce(
log_sum_exp_vd_vari(vari *avi, double b)
log_sum_exp_vv_vari(vari *avi, vari *bvi)
void reverse_pass_callback(F &&functor)
Puts a callback on the autodiff stack to be called in reverse pass.
static constexpr double NEGATIVE_INFTY
Negative infinity.
fvar< T > inv_logit(const fvar< T > &x)
Returns the inverse logit function applied to the argument.
internal::callback_vari< plain_type_t< T >, F > * make_callback_vari(T &&value, F &&functor)
Creates a new vari with given value and a callback that implements the reverse pass (chain).
fvar< T > log_sum_exp(const fvar< T > &x1, const fvar< T > &x2)
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 ...