Automatic Differentiation
 
Loading...
Searching...
No Matches
squared_distance.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_FUN_SQUARED_DISTANCE_HPP
2#define STAN_MATH_PRIM_FUN_SQUARED_DISTANCE_HPP
3
9
10namespace stan {
11namespace math {
12
23template <typename Scal1, typename Scal2,
24 require_all_stan_scalar_t<Scal1, Scal2>* = nullptr,
25 require_all_not_var_t<Scal1, Scal2>* = nullptr>
27 const Scal2& x2) {
28 check_finite("squared_distance", "x1", x1);
29 check_finite("squared_distance", "x2", x2);
30 return square(x1 - x2);
31}
32
47template <typename EigVec1, typename EigVec2,
51 const EigVec2& v2) {
52 check_matching_sizes("squared_distance", "v1", v1, "v2", v2);
54 .squaredNorm();
55}
56
57} // namespace math
58} // namespace stan
59
60#endif
require_all_not_t< container_type_check_base< is_eigen, value_type_t, TypeCheck, Check >... > require_all_not_eigen_vt
Require none of the types satisfy is_eigen.
Definition is_eigen.hpp:197
require_all_t< is_eigen_vector< std::decay_t< Types > >... > require_all_eigen_vector_t
Require all of the types satisfy is_eigen_vector.
auto as_column_vector_or_scalar(T &&a)
as_column_vector_or_scalar of a kernel generator expression.
typename return_type< Ts... >::type return_type_t
Convenience type for the return type of the specified template parameters.
void check_matching_sizes(const char *function, const char *name1, const T_y1 &y1, const char *name2, const T_y2 &y2)
Check if two structures at the same size.
void check_finite(const char *function, const char *name, const T_y &y)
Return true if all values in y are finite.
auto squared_distance(const T_a &a, const T_b &b)
Returns the squared distance.
fvar< T > square(const fvar< T > &x)
Definition square.hpp:12
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...