Stan  2.5.0
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations 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 #include <cstddef>
6 #include <cmath>
7 
8 namespace stan {
9  namespace math {
10 
11  inline double dist(const std::vector<double>& x, const std::vector<double>& y) {
12  using std::sqrt;
13  double result = 0;
14  for (size_t i = 0; i < x.size(); ++i) {
15  double diff = x[i] - y[i];
16  result += diff * diff;
17  }
18  return sqrt(result);
19  }
20 
21  }
22 }
23 
24 #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–2014, Stan Development Team.