Automatic Differentiation
 
Loading...
Searching...
No Matches
squared_distance.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_OPENCL_PRIM_SQUARED_DISTANCE_HPP
2#define STAN_MATH_OPENCL_PRIM_SQUARED_DISTANCE_HPP
3#ifdef STAN_OPENCL
4
11#include <algorithm>
12
13namespace stan {
14namespace math {
15
28template <typename T_a, typename T_b,
29 require_all_kernel_expressions_and_none_scalar_t<T_a, T_b>* = nullptr>
30inline auto squared_distance(const T_a& a, const T_b& b) {
31 const char* function = "squared_distance (OpenCL)";
32 check_vector(function, "a", a);
33 check_vector(function, "b", b);
34 return sum(square(a - b));
35}
36
37} // namespace math
38} // namespace stan
39#endif
40#endif
void check_vector(const char *function, const char *name, const Mat &x)
Check the input is either a row vector or column vector or a matrix with a single row or column.
fvar< T > sum(const std::vector< fvar< T > > &m)
Return the sum of the entries of the specified standard vector.
Definition sum.hpp:22
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 ...
Definition fvar.hpp:9