Stan Math Library: stan/math/prim/mat/fun/distance.hpp Source File

| Stan Math Library 2.10.0 reverse mode automatic differentiation

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

distance.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_MAT_FUN_DISTANCE_HPP
2 #define STAN_MATH_PRIM_MAT_FUN_DISTANCE_HPP
3
4 #include <stan/math/prim/mat/fun/Eigen.hpp>
5
6 #include <boost/math/tools/promotion.hpp>
7 #include <stan/math/prim/mat/fun/squared_distance.hpp>
8 #include <stan/math/prim/mat/err/check_vector.hpp>
9 #include <stan/math/prim/mat/err/check_matching_sizes.hpp>
10
11 namespace stan {
12 namespace math {
13
23 template<typename T1, int R1, int C1, typename T2, int R2, int C2>
24 inline typename boost::math::tools::promote_args<T1, T2>::type
25 distance(const Eigen::Matrix<T1, R1, C1>& v1,
26 const Eigen::Matrix<T2, R2, C2>& v2) {
27 using std::sqrt;
28 stan::math::check_vector("distance", "v1", v1);
29 stan::math::check_vector("distance", "v2", v2);
30 stan::math::check_matching_sizes("distance",
31 "v1", v1,
32 "v2", v2);
33 return sqrt(squared_distance(v1, v2));
34 }
35 }
36 }
37 #endif
stan::math::sqrt
fvar< T > sqrt(const fvar< T > &x)
Definition: sqrt.hpp:15
stan::math::check_vector
bool check_vector(const char *function, const char *name, const Eigen::Matrix< T, R, C > &x)
Return true if the matrix is either a row vector or column vector.
Definition: check_vector.hpp:34
stan
Definition: log_sum_exp.hpp:8
stan::math::squared_distance
boost::math::tools::promote_args< T1, T2 >::type squared_distance(const Eigen::Matrix< T1, R1, C1 > &v1, const Eigen::Matrix< T2, R2, C2 > &v2)
Returns the squared distance between the specified vectors.
Definition: squared_distance.hpp:22
check_matching_sizes.hpp
squared_distance.hpp
stan::math::check_matching_sizes
bool check_matching_sizes(const char *function, const char *name1, const T_y1 &y1, const char *name2, const T_y2 &y2)
Return true if two structures at the same size.
Definition: check_matching_sizes.hpp:29
Eigen.hpp
check_vector.hpp
stan::math::distance
boost::math::tools::promote_args< T1, T2 >::type distance(const Eigen::Matrix< T1, R1, C1 > &v1, const Eigen::Matrix< T2, R2, C2 > &v2)
Returns the distance between the specified vectors.
Definition: distance.hpp:25

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