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) {
44 = forward_as<var_value<matrix_cl<double>>>(to_add_arena).adj();
47 auto& to_add_adj = forward_as<var_value<double>>(to_add_arena).adj();
48 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.
auto & adjoint_of(const T &x)
Returns a reference to a variable's adjoint.
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.
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 ...
Metaprogramming struct to detect whether a given type is constant in the mathematical sense (not the ...
Checks if decayed type is a var, fvar, or arithmetic.