Stan Math Library  2.20.0
reverse mode automatic differentiation
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 
8 namespace stan {
9 namespace math {
10 namespace opencl_kernels {
11 // \cond
12 static const char *is_symmetric_kernel_code = STRINGIFY(
13  // \endcond
28  __kernel void is_symmetric(__global double *A, __global int *flag,
29  unsigned int rows, unsigned int cols,
30  double tolerance) {
31  const int i = get_global_id(0);
32  const int j = get_global_id(1);
33  if (i < rows && j < cols) {
34  double diff = fabs(A(i, j) - A(j, i));
35  if (diff > tolerance) {
36  flag[0] = 0;
37  }
38  }
39  }
40  // \cond
41 );
42 // \endcond
43 
48  "is_symmetric", {indexing_helpers, is_symmetric_kernel_code});
49 
50 } // namespace opencl_kernels
51 } // namespace math
52 } // namespace stan
53 #endif
54 #endif
int rows(const Eigen::Matrix< T, R, C > &m)
Return the number of rows in the specified matrix, vector, or row vector.
Definition: rows.hpp:20
fvar< T > fabs(const fvar< T > &x)
Definition: fabs.hpp:15
#define STRINGIFY(src)
Definition: kernel_cl.hpp:22
static const char * indexing_helpers
Definition: helpers.hpp:14
__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.
int cols(const Eigen::Matrix< T, R, C > &m)
Return the number of columns in the specified matrix, vector, or row vector.
Definition: cols.hpp:20
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() .
Creates functor for kernels.
Definition: kernel_cl.hpp:201

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