1#ifndef STAN_MATH_OPENCL_REV_ADD_DIAG_HPP 
    2#define STAN_MATH_OPENCL_REV_ADD_DIAG_HPP 
   27template <
typename T_m, 
typename T_a,
 
   28          require_all_nonscalar_prim_or_rev_kernel_expression_t<T_m>* = 
nullptr,
 
   29          require_all_prim_or_rev_kernel_expression_t<T_a>* = 
nullptr,
 
   30          require_any_var_t<T_m, T_a>* = 
nullptr>
 
   31inline auto add_diag(
const T_m& mat, 
const T_a& to_add) {
 
   38    if constexpr (is_autodiff_v<T_m>) {
 
   41    if constexpr (is_autodiff_v<T_a>) {
 
   43        auto& to_add_adj = to_add_arena.adj();
 
   46        auto& to_add_adj = to_add_arena.adj();
 
   47        to_add_adj += to_add_adj + 
sum(
diagonal(res.adj()));
 
auto diagonal(T &&a)
Diagonal of a kernel generator expression.
 
void reverse_pass_callback(F &&functor)
Puts a callback on the autodiff stack to be called in reverse pass.
 
T value_of(const fvar< T > &v)
Return the value of the specified variable.
 
auto add_diag(T_m &&mat, T_a &&to_add)
Returns a Matrix with values added along the main diagonal.
 
auto sum(const std::vector< T > &m)
Return the sum of the entries of the specified standard vector.
 
auto & adjoint_of(const T &x) noexcept
Returns a reference to a variable's adjoint.
 
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 ...
 
Checks if decayed type is a var, fvar, or arithmetic.