Stan Math Library  2.15.0
reverse mode automatic differentiation
squared_distance.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_SCAL_FUN_SQUARED_DISTANCE_HPP
2 #define STAN_MATH_PRIM_SCAL_FUN_SQUARED_DISTANCE_HPP
3 
6 
7 namespace stan {
8  namespace math {
9 
19  template<typename T1, typename T2>
20  inline typename boost::math::tools::promote_args<T1, T2>::type
21  squared_distance(const T1& x1,
22  const T2& x2) {
23  check_finite("squared_distance", "x1", x1);
24  check_finite("squared_distance", "x2", x2);
25  return square(x1 - x2);
26  }
27  }
28 }
29 #endif
void check_finite(const char *function, const char *name, const T_y &y)
Check if y is finite.
fvar< T > square(const fvar< T > &x)
Definition: square.hpp:14
fvar< T > squared_distance(const Eigen::Matrix< fvar< T >, R, C > &v1, const Eigen::Matrix< double, R, C > &v2)
Returns the squared distance between the specified vectors of the same dimensions.

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