Stan Math Library  2.20.0
reverse mode automatic differentiation
dot_self.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_ARR_FUN_DOT_SELF_HPP
2 #define STAN_MATH_PRIM_ARR_FUN_DOT_SELF_HPP
3 
5 #include <vector>
6 #include <cstddef>
7 
8 namespace stan {
9 namespace math {
10 
11 inline double dot_self(const std::vector<double>& x) {
12  double sum = 0.0;
13  for (double i : x)
14  sum += i * i;
15  return sum;
16 }
17 
18 } // namespace math
19 } // namespace stan
20 #endif
fvar< T > sum(const std::vector< fvar< T > > &m)
Return the sum of the entries of the specified standard vector.
Definition: sum.hpp:20
fvar< T > dot_self(const Eigen::Matrix< fvar< T >, R, C > &v)
Definition: dot_self.hpp:13

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