1#ifndef STAN_MATH_OPENCL_KERNELS_GP_EXPONENTIAL_COV_HPP
2#define STAN_MATH_OPENCL_KERNELS_GP_EXPONENTIAL_COV_HPP
10namespace opencl_kernels {
12static constexpr const char* gp_exponential_cov_kernel_code =
STRINGIFY(
25 const __global
double* x, __global
double* res,
const double sigma_sq,
26 const double neg_inv_l,
const int size,
const int element_size) {
27 const int i = get_global_id(0);
28 const int j = get_global_id(1);
32 for (
int k = 0; k < element_size; k++) {
33 double d = x[i * element_size + k] - x[j * element_size + k];
36 double a = sigma_sq *
exp(neg_inv_l *
sqrt(
sum));
37 res[j *
size + i] = a;
38 res[i *
size + j] = a;
40 res[j *
size + i] = sigma_sq;
52const kernel_cl<in_buffer, out_buffer, double, double, int, int>
56static constexpr const char* gp_exponential_cov_cross_kernel_code =
STRINGIFY(
75 const __global
double* x1,
const __global
double* x2,
76 __global
double* res,
const double sigma_sq,
const double neg_inv_l,
77 const int size1,
const int size2,
const int element_size) {
78 const int i = get_global_id(0);
79 const int j = get_global_id(1);
80 if (i < size1 && j < size2) {
82 for (
int k = 0; k < element_size; k++) {
83 double d = x1[i * element_size + k] - x2[j * element_size + k];
86 res[j * size1 + i] = sigma_sq *
exp(neg_inv_l *
sqrt(
sum));
97const kernel_cl<in_buffer, in_buffer, out_buffer, double, double, int, int, int>
99 {gp_exponential_cov_cross_kernel_code});
const kernel_cl< in_buffer, in_buffer, out_buffer, double, double, int, int, int > gp_exponential_cov_cross("gp_exponential_cov_cross", {gp_exponential_cov_cross_kernel_code})
See the docs for gp_exponential_cov_cross() .
const kernel_cl< in_buffer, out_buffer, double, double, int, int > gp_exponential_cov("gp_exponential_cov", {gp_exponential_cov_kernel_code})
See the docs for gp_exponential_cov() .
int64_t size(const T &m)
Returns the size (number of the elements) of a matrix_cl or var_value<matrix_cl<T>>.
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.
fvar< T > exp(const fvar< T > &x)
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...