1#ifndef STAN_MATH_REV_FUN_ELT_MULTIPLY_HPP
2#define STAN_MATH_REV_FUN_ELT_MULTIPLY_HPP
26template <
typename Mat1,
typename Mat2,
27 require_all_matrix_t<Mat1, Mat2>* =
nullptr,
28 require_any_rev_matrix_t<Mat1, Mat2>* =
nullptr>
33 if constexpr (is_autodiff_v<Mat1> && is_autodiff_v<Mat2>) {
38 for (Eigen::Index j = 0; j < arena_m2.cols(); ++j) {
39 for (Eigen::Index i = 0; i < arena_m2.rows(); ++i) {
40 const auto ret_adj = ret.adj().coeffRef(i, j);
41 arena_m1.adj().coeffRef(i, j) += arena_m2.val().coeff(i, j) * ret_adj;
42 arena_m2.adj().coeffRef(i, j) += arena_m1.val().coeff(i, j) * ret_adj;
47 }
else if constexpr (is_autodiff_v<Mat1>) {
52 arena_m1.adj().array() += arena_m2.array() * ret.adj().array();
55 }
else if constexpr (is_autodiff_v<Mat2>) {
60 arena_m2.adj().array() += arena_m1.array() * ret.adj().array();
elt_multiply_< as_operation_cl_t< T_a >, as_operation_cl_t< T_b > > elt_multiply(T_a &&a, T_b &&b)
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.
void check_matching_dims(const char *function, const char *name1, const T1 &y1, const char *name2, const T2 &y2)
Check if the two containers have the same dimensions.
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.
std::conditional_t< is_any_var_matrix< ReturnType, Types... >::value, stan::math::var_value< stan::math::promote_scalar_t< double, plain_type_t< ReturnType > > >, stan::math::promote_scalar_t< stan::math::var_value< double >, plain_type_t< ReturnType > > > return_var_matrix_t
Given an Eigen type and several inputs, determine if a matrix should be var<Matrix> or Matrix<var>.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...