Stan Math Library: stan/math/prim/arr/fun/dist.hpp Source File

| Stan Math Library 2.10.0 reverse mode automatic differentiation

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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
stan::math::sqrt
fvar< T > sqrt(const fvar< T > &x)
Definition: sqrt.hpp:15
stan
Definition: log_sum_exp.hpp:8
stan::math::dist
double dist(const std::vector< double > &x, const std::vector< double > &y)
Definition: dist.hpp:11

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