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

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