1 #ifndef STAN_MATH_OPENCL_KERNELS_CHOLESKY_DECOMPOSE_HPP 2 #define STAN_MATH_OPENCL_KERNELS_CHOLESKY_DECOMPOSE_HPP 10 namespace opencl_kernels {
12 static const char *cholesky_decompose_kernel_code =
STRINGIFY(
33 const int local_index = get_local_id(0);
37 for (
int j = 0; j <
rows; j++) {
38 if (local_index == 0) {
40 for (
int k = 0; k < j; k++) {
41 sum = sum + A(j, k) * A(j, k);
43 A(j, j) =
sqrt(A(j, j) - sum);
45 barrier(CLK_LOCAL_MEM_FENCE);
46 if (local_index < j) {
47 A(local_index, j) = 0.0;
48 }
else if (local_index > j) {
50 for (
int k = 0; k < j; k++)
51 sum = sum + A(local_index, k) * A(j, k);
52 A(local_index, j) = (A(local_index, j) -
sum) / A(j, j);
54 barrier(CLK_LOCAL_MEM_FENCE);
fvar< T > sum(const std::vector< fvar< T > > &m)
Return the sum of the entries of the specified standard vector.
int rows(const Eigen::Matrix< T, R, C > &m)
Return the number of rows in the specified matrix, vector, or row vector.
fvar< T > sqrt(const fvar< T > &x)
static const char * indexing_helpers
const kernel_cl< in_out_buffer, int > cholesky_decompose("cholesky_decompose", {indexing_helpers, cholesky_decompose_kernel_code})
See the docs for cholesky_decompose() .
Creates functor for kernels.