Automatic Differentiation
 
Loading...
Searching...
No Matches
columns_dot_self.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_OPENCL_PRIM_COLUMNS_DOT_SELF_HPP
2#define STAN_MATH_OPENCL_PRIM_COLUMNS_DOT_SELF_HPP
3#ifdef STAN_OPENCL
9
10namespace stan {
11namespace math {
12
22template <typename T,
23 require_all_kernel_expressions_and_none_scalar_t<T>* = nullptr>
24inline auto columns_dot_self(const T& a) {
25 if (size_zero(a)) {
26 return plain_type_t<T>(constant(0.0, 1, a.cols()));
27 }
29 while (res.rows() > 1) {
30 res = colwise_sum(res).eval();
31 }
32 return res;
33}
34
35} // namespace math
36} // namespace stan
37
38#endif
39#endif
auto constant(const T a, int rows, int cols)
Matrix of repeated values in kernel generator expressions.
Definition constant.hpp:130
auto colwise_sum(T &&a)
Column wise sum - reduction of a kernel generator expression.
bool size_zero(const T &x)
Returns 1 if input is of length 0, returns 0 otherwise.
Definition size_zero.hpp:19
auto columns_dot_self(const T &a)
Returns the dot product of each column of a matrix with itself.
fvar< T > square(const fvar< T > &x)
Definition square.hpp:12
typename plain_type< T >::type plain_type_t
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...