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(
35 __local
double* row_j) {
36 const int local_index = get_local_id(0);
40 for (
int j = 0; j <
rows; j++) {
41 if (local_index == j) {
43 for (
int k = 0; k < j; k++) {
44 const double a = A(j, k);
53 barrier(CLK_LOCAL_MEM_FENCE);
54 if (local_index < j) {
55 A(local_index, j) = 0.0;
56 }
else if (local_index > j) {
58 for (
int k = 0; k < j; k++)
59 sum += A(local_index, k) * row_j[k];
60 A(local_index, j) = (A(local_index, j) -
sum) / row_j[j];
62 barrier(CLK_LOCAL_MEM_FENCE);
const kernel_cl< in_out_buffer, int, cl::LocalSpaceArg > 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.