Stan Math Library  2.20.0
reverse mode automatic differentiation
copy_triangular.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_OPENCL_KERNELS_COPY_TRIANGULAR_HPP
2 #define STAN_MATH_OPENCL_KERNELS_COPY_TRIANGULAR_HPP
3 #ifdef STAN_OPENCL
4 
7 
8 namespace stan {
9 namespace math {
10 namespace opencl_kernels {
11 // \cond
12 static const char *copy_triangular_kernel_code = STRINGIFY(
13  // \endcond
33  __kernel void copy_triangular(__global double *A, __global double *B,
34  unsigned int rows, unsigned int cols,
35  unsigned int lower_upper) {
36  int i = get_global_id(0);
37  int j = get_global_id(1);
38  if (i < rows && j < cols) {
39  if (!lower_upper && j <= i) {
40  A(i, j) = B(i, j);
41  } else if (!lower_upper) {
42  A(i, j) = 0;
43  } else if (lower_upper && j >= i) {
44  A(i, j) = B(i, j);
45  } else if (lower_upper && j < i) {
46  A(i, j) = 0;
47  }
48  }
49  }
50  // \cond
51 );
52 // \endcond
53 
58  copy_triangular("copy_triangular",
59  {indexing_helpers, copy_triangular_kernel_code});
60 
61 } // namespace opencl_kernels
62 } // namespace math
63 } // namespace stan
64 #endif
65 #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
#define STRINGIFY(src)
Definition: kernel_cl.hpp:22
static const char * indexing_helpers
Definition: helpers.hpp:14
const kernel_cl< out_buffer, in_buffer, int, int, TriangularViewCL > copy_triangular("copy_triangular", {indexing_helpers, copy_triangular_kernel_code})
See the docs for copy_triangular() .
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
Creates functor for kernels.
Definition: kernel_cl.hpp:201

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