Automatic Differentiation
 
Loading...
Searching...
No Matches
columns_dot_product.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_FUN_COLUMNS_DOT_PRODUCT_HPP
2#define STAN_MATH_PRIM_FUN_COLUMNS_DOT_PRODUCT_HPP
3
6
7namespace stan {
8namespace math {
9
24template <typename Mat1, typename Mat2,
25 require_all_eigen_t<Mat1, Mat2>* = nullptr,
26 require_all_not_eigen_vt<is_var, Mat1, Mat2>* = nullptr>
27inline auto columns_dot_product(Mat1&& v1, Mat2&& v2) {
28 check_matching_dims("columns_dot_product", "v1", v1, "v2", v2);
29 return make_holder(
30 [](auto&& v1_, auto&& v2_) {
31 return v1_.cwiseProduct(v2_).colwise().sum();
32 },
33 to_ref(std::forward<Mat1>(v1)), to_ref(std::forward<Mat2>(v2)));
34}
35
36} // namespace math
37} // namespace stan
38
39#endif
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.
auto make_holder(F &&func, Args &&... args)
Calls given function with given arguments.
Definition holder.hpp:481
auto sum(const std::vector< T > &m)
Return the sum of the entries of the specified standard vector.
Definition sum.hpp:23
ref_type_t< T && > to_ref(T &&a)
This evaluates expensive Eigen expressions.
Definition to_ref.hpp:18
auto columns_dot_product(const T_a &a, const T_b &b)
Returns the dot product of columns of the specified matrices.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...