1#ifndef STAN_MATH_REV_FUN_DOT_PRODUCT_HPP
2#define STAN_MATH_REV_FUN_DOT_PRODUCT_HPP
34template <
typename T1,
typename T2, require_all_vector_t<T1, T2>* =
nullptr,
35 require_not_complex_t<return_type_t<T1, T2>>* =
nullptr,
36 require_all_not_std_vector_t<T1, T2>* =
nullptr,
37 require_any_st_var<T1, T2>* =
nullptr>
49 v1_arena.val().dot(v2_arena.val()),
50 [v1_arena, v2_arena](
const auto& vi)
mutable {
51 const auto res_adj = vi.adj();
52 for (Eigen::Index i = 0; i < v1_arena.size(); ++i) {
53 v1_arena.adj().coeffRef(i) += res_adj * v2_arena.val().coeff(i);
54 v2_arena.adj().coeffRef(i) += res_adj * v1_arena.val().coeff(i);
61 [v1_val_arena, v2_arena](
const auto& vi)
mutable {
62 v2_arena.adj().array()
63 += vi.adj() * v1_val_arena.array();
66 arena_t<promote_scalar_t<var, T1>> v1_arena = v1;
67 arena_t<promote_scalar_t<double, T2>> v2_val_arena =
value_of(v2);
69 [v1_arena, v2_val_arena](
const auto& vi)
mutable {
70 v1_arena.adj().array()
71 += vi.adj() * v2_val_arena.array();
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.
void check_matching_sizes(const char *function, const char *name1, const T_y1 &y1, const char *name2, const T_y2 &y2)
Check if two structures at the same size.
auto dot_product(const T_a &a, const T_b &b)
Returns the dot product of the specified vectors.
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 ...