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_ERR_CHECK_SYMMETRIC_HPP
2 #define STAN_MATH_OPENCL_ERR_CHECK_SYMMETRIC_HPP
3 #ifdef STAN_OPENCL
11 #include <vector>
12 namespace stan {
13 namespace math {
24 inline void check_symmetric(const char* function, const char* name,
25  const matrix_cl& y) {
26  if (y.size() == 0)
27  return;
28  check_square(function, name, y);
29  try {
30  int symmetric_flag = 1;
31  matrix_cl symm_flag(1, 1);
32  symm_flag = to_matrix_cl(symmetric_flag);
33  opencl_kernels::check_symmetric(cl::NDRange(y.rows(), y.cols()), y,
34  symm_flag, y.rows(), y.cols(),
36  symmetric_flag = from_matrix_cl<int>(symm_flag);
37  if (!symmetric_flag) {
38  domain_error(function, name, "is not symmetric", "");
39  }
40  } catch (const cl::Error& e) {
41  check_opencl_error("symmetric_check", e);
42  }
43 }
44 
45 } // namespace math
46 } // namespace stan
47 #endif
48 #endif
void check_square(const char *function, const char *name, const matrix_cl &y)
Check if the matrix_cl is square.
The matrix_cl class - allocates memory space on the OpenCL device, functions for transfering matrices...
const double CONSTRAINT_TOLERANCE
The tolerance for checking arithmetic bounds In rank and in simplexes.
Represents a matrix on the OpenCL device.
Definition: matrix_cl.hpp:29
void domain_error(const char *function, const char *name, const T &y, const char *msg1, const char *msg2)
Throw a domain error with a consistently formatted message.
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() .
double e()
Return the base of the natural logarithm.
Definition: constants.hpp:87
matrix_cl to_matrix_cl(const Eigen::Matrix< double, R, C > &src)
Copies the source Eigen matrix to the destination matrix that is stored on the OpenCL device...
Definition: copy.hpp:37
void check_opencl_error(const char *function, const cl::Error &e)
Throws the domain error with specifying the OpenCL error that occured.
void check_symmetric(const char *function, const char *name, const matrix_cl &y)
Check if the matrix_cl is symmetric.

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