1#ifndef STAN_MATH_REV_FUN_COLUMNS_DOT_PRODUCT_HPP
2#define STAN_MATH_REV_FUN_COLUMNS_DOT_PRODUCT_HPP
31template <
typename Mat1,
typename Mat2,
32 require_all_eigen_t<Mat1, Mat2>* =
nullptr,
33 require_any_eigen_vt<is_var, Mat1, Mat2>* =
nullptr>
34inline Eigen::Matrix<return_type_t<Mat1, Mat2>, 1, Mat1::ColsAtCompileTime>
37 Eigen::Matrix<var, 1, Mat1::ColsAtCompileTime> ret(1, v1.cols());
38 for (
size_type j = 0; j < v1.cols(); ++j) {
39 ret.coeffRef(j) =
dot_product(v1.col(j), v2.col(j));
61template <
typename Mat1,
typename Mat2,
62 require_all_matrix_t<Mat1, Mat2>* =
nullptr,
63 require_any_var_matrix_t<Mat1, Mat2>* =
nullptr>
66 using inner_return_t =
decltype(
75 = (arena_v1.val().array() * arena_v2.val().array()).colwise().sum();
79 arena_v1.adj().noalias() += arena_v2.val() * res.adj().asDiagonal();
81 arena_v1.adj() += arena_v2.val() * res.adj().asDiagonal();
84 arena_v2.adj().noalias() += arena_v1.val() * res.adj().asDiagonal();
86 arena_v2.adj() += arena_v1.val() * res.adj().asDiagonal();
95 return_t res = (arena_v1.array() * arena_v2.val().array()).colwise().sum();
99 arena_v2.adj().noalias() += arena_v1 * res.adj().asDiagonal();
101 arena_v2.adj() += arena_v1 * res.adj().asDiagonal();
110 return_t res = (arena_v1.val().array() * arena_v2.array()).colwise().sum();
114 arena_v1.adj().noalias() += arena_v2 * res.adj().asDiagonal();
116 arena_v1.adj() += arena_v2 * res.adj().asDiagonal();
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_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.
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic >::Index size_type
Type for sizes and indexes in an Eigen matrix with double elements.
auto dot_product(const T_a &a, const T_b &b)
Returns the dot product of the specified vectors.
auto columns_dot_product(const T_a &a, const T_b &b)
Returns the dot product of columns of the specified matrices.
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 ...
Metaprogramming struct to detect whether a given type is constant in the mathematical sense (not the ...
Check if a type is a var_value whose value_type is derived from Eigen::EigenBase