Stan Math Library  2.20.0
reverse mode automatic differentiation
identity.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_OPENCL_IDENTITY_HPP
2 #define STAN_MATH_OPENCL_IDENTITY_HPP
3 #ifdef STAN_OPENCL
7 #include <CL/cl.hpp>
8 
9 namespace stan {
10 namespace math {
11 
20 inline matrix_cl identity(int rows_cols) {
21  matrix_cl A(rows_cols, rows_cols);
22  if (rows_cols == 0) {
23  return A;
24  }
25  try {
26  opencl_kernels::identity(cl::NDRange(A.rows(), A.cols()), A, A.rows(),
27  A.cols());
28  } catch (const cl::Error& e) {
29  check_opencl_error("identity", e);
30  }
31  return A;
32 }
33 } // namespace math
34 } // namespace stan
35 
36 #endif
37 #endif
The matrix_cl class - allocates memory space on the OpenCL device, functions for transfering matrices...
Represents a matrix on the OpenCL device.
Definition: matrix_cl.hpp:29
checking OpenCL error numbers
const kernel_cl< out_buffer, int, int > identity("identity", {indexing_helpers, identity_kernel_code})
See the docs for identity() .
double e()
Return the base of the natural logarithm.
Definition: constants.hpp:87
matrix_cl identity(int rows_cols)
Returns the identity matrix stored on the OpenCL device.
Definition: identity.hpp:20
void check_opencl_error(const char *function, const cl::Error &e)
Throws the domain error with specifying the OpenCL error that occured.

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