Automatic Differentiation
 
Loading...
Searching...
No Matches
check_symmetric.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_OPENCL_KERNELS_CHECK_SYMMETRIC_HPP
2#define STAN_MATH_OPENCL_KERNELS_CHECK_SYMMETRIC_HPP
3#ifdef STAN_OPENCL
4
7#include <string>
8
9namespace stan {
10namespace math {
11namespace opencl_kernels {
12// \cond
13static constexpr const char *is_symmetric_kernel_code = STRINGIFY(
14 // \endcond
29 __kernel void is_symmetric(__global double *A, __global int *flag,
30 unsigned int rows, unsigned int cols,
31 double tolerance) {
32 const int i = get_global_id(0);
33 const int j = get_global_id(1);
34 if (i < rows && j < cols) {
35 double diff = fabs(A(i, j) - A(j, i));
36 if (diff > tolerance) {
37 flag[0] = 0;
38 }
39 }
40 }
41 // \cond
42);
43// \endcond
44
49 "is_symmetric", {indexing_helpers, is_symmetric_kernel_code});
50
51} // namespace opencl_kernels
52} // namespace math
53} // namespace stan
54#endif
55#endif
__kernel void is_symmetric(__global double *A, __global int *flag, unsigned int rows, unsigned int cols, double tolerance)
Check if the matrix_cl is symmetric.
const kernel_cl< in_buffer, out_buffer, int, int, const double > check_symmetric("is_symmetric", {indexing_helpers, is_symmetric_kernel_code})
See the docs for check_symmetric() .
int64_t cols(const T_x &x)
Returns the number of columns in the specified kernel generator expression.
Definition cols.hpp:21
int64_t rows(const T_x &x)
Returns the number of rows in the specified kernel generator expression.
Definition rows.hpp:22
static const std::string indexing_helpers
Defines helper macros for common matrix indexing operations.
Definition helpers.hpp:14
fvar< T > fabs(const fvar< T > &x)
Definition fabs.hpp:15
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
#define STRINGIFY(...)
Definition stringify.hpp:9
Creates functor for kernels.