Automatic Differentiation
 
Loading...
Searching...
No Matches
cholesky_decompose.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_OPENCL_PRIM_CHOLESKY_DECOMPOSE_HPP
2#define STAN_MATH_OPENCL_PRIM_CHOLESKY_DECOMPOSE_HPP
3#ifdef STAN_OPENCL
4
9#include <CL/opencl.hpp>
10#include <algorithm>
11#include <cmath>
12
13namespace stan {
14namespace math {
26 check_symmetric("cholesky_decompose", "A", A);
28 if (res.rows() == 0) {
29 return res;
30 }
32 // check_pos_definite on matrix_cl is check_nan + check_diagonal_zeros
33 check_cl("cholesky_decompose (OpenCL)", "A", res, "not NaN") = !isnan(res);
34 check_cl("cholesky_decompose (OpenCL)", "diagonal of A", diagonal(res),
35 "nonzero")
36 = diagonal(res) != 0.0;
37
38 res.template zeros_strict_tri<matrix_cl_view::Upper>();
39 return res;
40}
41} // namespace math
42} // namespace stan
43
44#endif
45#endif
Represents an arithmetic matrix on the OpenCL device.
Definition matrix_cl.hpp:47
void check_symmetric(const char *function, const char *name, const matrix_cl< T > &y)
Check if the matrix_cl is symmetric.
auto check_cl(const char *function, const char *var_name, T &&y, const char *must_be)
Constructs a check on opencl matrix or expression.
Definition check_cl.hpp:219
auto diagonal(T &&a)
Diagonal of a kernel generator expression.
Definition diagonal.hpp:136
plain_type_t< T > copy_cl(const T &src)
Copies the source matrix to the destination matrix.
Definition copy.hpp:340
void cholesky_decompose(matrix_cl< T > &A)
Performs an in-place computation of the lower-triangular Cholesky factor (i.e., matrix square root) o...
matrix_cl< double > cholesky_decompose(const matrix_cl< double > &A)
Returns the lower-triangular Cholesky factor (i.e., matrix square root) of the specified square,...
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...