Automatic Differentiation
 
Loading...
Searching...
No Matches
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
4
12#include <vector>
13
14namespace stan {
15namespace math {
26template <typename T, typename = require_arithmetic_t<T>>
27inline void check_symmetric(const char* function, const char* name,
28 const matrix_cl<T>& y) {
29 if (y.size() == 0) {
30 return;
31 }
32 check_square(function, name, y);
33 try {
34 int symmetric_flag = 1;
35 matrix_cl<int> symm_flag(1, 1);
36 symm_flag = to_matrix_cl(symmetric_flag);
37 opencl_kernels::check_symmetric(cl::NDRange(y.rows(), y.cols()), y,
38 symm_flag, y.rows(), y.cols(),
40 symmetric_flag = from_matrix_cl<int>(symm_flag);
41 if (!symmetric_flag) {
42 throw_domain_error(function, name, "is not symmetric", "");
43 }
44 } catch (const cl::Error& e) {
45 check_opencl_error("symmetric_check", e);
46 }
47}
48
49} // namespace math
50} // namespace stan
51#endif
52#endif
Represents an arithmetic matrix on the OpenCL device.
Definition matrix_cl.hpp:47
void check_symmetric(const char *function, const char *name, const matrix_cl< T > &y)
Check if the matrix_cl is symmetric.
void check_opencl_error(const char *function, const cl::Error &e)
Throws the domain error with specifying the OpenCL error that occurred.
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() .
matrix_cl< scalar_type_t< T > > to_matrix_cl(T &&src)
Copies the source Eigen matrix, std::vector or scalar to the destination matrix that is stored on the...
Definition copy.hpp:45
void check_square(const char *function, const char *name, const T_y &y)
Check if the specified matrix is square.
static constexpr double e()
Return the base of the natural logarithm.
Definition constants.hpp:20
void throw_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 double CONSTRAINT_TOLERANCE
The tolerance for checking arithmetic bounds in rank and in simplexes.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...