Stan Math Library  2.6.3
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros
dist.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_ARR_FUN_DIST_HPP
2 #define STAN_MATH_PRIM_ARR_FUN_DIST_HPP
3 
4 #include <vector>
5 #include <cstddef>
6 #include <cmath>
7 
8 namespace stan {
9  namespace math {
10 
11  inline double dist(const std::vector<double>& x,
12  const std::vector<double>& y) {
13  using std::sqrt;
14  double result = 0;
15  for (size_t i = 0; i < x.size(); ++i) {
16  double diff = x[i] - y[i];
17  result += diff * diff;
18  }
19  return sqrt(result);
20  }
21 
22  }
23 }
24 
25 #endif
fvar< T > sqrt(const fvar< T > &x)
Definition: sqrt.hpp:15
double dist(const std::vector< double > &x, const std::vector< double > &y)
Definition: dist.hpp:11

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