Stan Math Library  2.20.0
reverse mode automatic differentiation
columns_dot_product.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_MAT_FUN_COLUMNS_DOT_PRODUCT_HPP
2 #define STAN_MATH_PRIM_MAT_FUN_COLUMNS_DOT_PRODUCT_HPP
3 
6 
7 namespace stan {
8 namespace math {
9 
19 template <int R1, int C1, int R2, int C2>
20 inline Eigen::Matrix<double, 1, C1> columns_dot_product(
21  const Eigen::Matrix<double, R1, C1>& v1,
22  const Eigen::Matrix<double, R2, C2>& v2) {
23  check_matching_sizes("columns_dot_product", "v1", v1, "v2", v2);
24  return (v1.transpose() * v2).diagonal();
25 }
26 
27 } // namespace math
28 } // namespace stan
29 #endif
Eigen::Matrix< fvar< T >, 1, C1 > columns_dot_product(const Eigen::Matrix< fvar< T >, R1, C1 > &v1, const Eigen::Matrix< fvar< T >, R2, C2 > &v2)
Eigen::Matrix< T, Eigen::Dynamic, 1 > diagonal(const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &m)
Return a column vector of the diagonal elements of the specified matrix.
Definition: diagonal.hpp:16
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.

     [ Stan Home Page ] © 2011–2018, Stan Development Team.