1 #ifndef STAN_MATH_PRIM_MAT_FUN_DOT_SELF_HPP 2 #define STAN_MATH_PRIM_MAT_FUN_DOT_SELF_HPP 3 4 #include <stan/math/prim/mat/fun/Eigen.hpp> 5 #include <stan/math/prim/mat/err/check_vector.hpp> 6 7 namespace stan { 8 namespace math { 9 10 /** 11 * Returns the dot product of the specified vector with itself. 12 * @param v Vector. 13 * @tparam R number of rows or <code>Eigen::Dynamic</code> for dynamic 14 * @tparam C number of rows or <code>Eigen::Dyanmic</code> for dynamic 15 * @throw std::domain_error If v is not vector dimensioned. 16 */ 17 template <int R, int C> dot_self(const Eigen::Matrix<double,R,C> & v)18inline double dot_self(const Eigen::Matrix<double, R, C>& v) { 19 check_vector("dot_self", "v", v); 20 return v.squaredNorm(); 21 } 22 23 } // namespace math 24 } // namespace stan 25 #endif 26