Stan  2.5.0
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
squared_distance.hpp
Go to the documentation of this file.
1 #ifndef STAN__MATH__MATRIX__SQUARED_DISTANCE_HPP
2 #define STAN__MATH__MATRIX__SQUARED_DISTANCE_HPP
3 
7 
8 namespace stan {
9  namespace math {
10 
20  template<int R1,int C1,int R2, int C2, typename T1, typename T2>
21  inline typename boost::math::tools::promote_args<T1,T2>::type
22  squared_distance(const Eigen::Matrix<T1, R1, C1>& v1,
23  const Eigen::Matrix<T2, R2, C2>& v2) {
24  stan::math::check_vector("squared_distance(%1%)",v1,"v1",(double*)0);
25  stan::math::check_vector("squared_distance(%1%)",v2,"v2",(double*)0);
26  stan::math::check_matching_sizes("squared_distance(%1%)",v1,"v1",
27  v2,"v2",(double*)0);
28  if (v1.rows() != v2.rows())
29  return (v1.transpose()-v2).squaredNorm();
30  else
31  return (v1-v2).squaredNorm();
32  }
33  }
34 }
35 #endif
bool check_vector(const char *function, const Eigen::Matrix< T, R, C > &x, const char *name, T_result *result)
bool check_matching_sizes(const char *function, const T_y1 &y1, const char *name1, const T_y2 &y2, const char *name2, T_result *result)
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.

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