Stan Math Library  2.20.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 
7 
8 namespace stan {
9 namespace math {
10 
20 template <typename T1, typename T2>
21 inline typename boost::math::tools::promote_args<T1, T2>::type squared_distance(
22  const T1& x1, const T2& x2) {
23  check_finite("squared_distance", "x1", x1);
24  check_finite("squared_distance", "x2", x2);
25  return square(x1 - x2);
26 }
27 } // namespace math
28 } // namespace stan
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:12
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–2018, Stan Development Team.