1#ifndef STAN_MATH_OPENCL_KERNELS_CHOLESKY_DECOMPOSE_HPP
2#define STAN_MATH_OPENCL_KERNELS_CHOLESKY_DECOMPOSE_HPP
11namespace opencl_kernels {
13static constexpr const char* cholesky_decompose_kernel_code =
STRINGIFY(
34 const int local_index = get_local_id(0);
38 for (
int j = 0; j <
rows; j++) {
39 if (local_index == 0) {
41 for (
int k = 0; k < j; k++) {
42 sum =
sum + A(j, k) * A(j, k);
46 barrier(CLK_LOCAL_MEM_FENCE);
47 if (local_index < j) {
48 A(local_index, j) = 0.0;
49 }
else if (local_index > j) {
51 for (
int k = 0; k < j; k++)
52 sum =
sum + A(local_index, k) * A(j, k);
53 A(local_index, j) = (A(local_index, j) -
sum) / A(j, j);
55 barrier(CLK_LOCAL_MEM_FENCE);
const kernel_cl< in_out_buffer, int > cholesky_decompose("cholesky_decompose", {indexing_helpers, cholesky_decompose_kernel_code})
See the docs for cholesky_decompose() .
int64_t rows(const T_x &x)
Returns the number of rows in the specified kernel generator expression.
static const std::string indexing_helpers
Defines helper macros for common matrix indexing operations.
fvar< T > sqrt(const fvar< T > &x)
auto sum(const std::vector< T > &m)
Return the sum of the entries of the specified standard vector.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
Creates functor for kernels.