Automatic Differentiation
 
Loading...
Searching...
No Matches
cholesky_decompose.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_FUN_CHOLESKY_DECOMPOSE_HPP
2#define STAN_MATH_PRIM_FUN_CHOLESKY_DECOMPOSE_HPP
3
7
8#include <cmath>
9
10namespace stan {
11namespace math {
12
29template <typename EigMat, require_eigen_t<EigMat>* = nullptr,
30 require_not_eigen_vt<is_var, EigMat>* = nullptr>
31inline Eigen::Matrix<value_type_t<EigMat>, EigMat::RowsAtCompileTime,
32 EigMat::ColsAtCompileTime>
33cholesky_decompose(const EigMat& m) {
34 const eval_return_type_t<EigMat>& m_eval = m.eval();
35 check_symmetric("cholesky_decompose", "m", m_eval);
36 check_not_nan("cholesky_decompose", "m", m_eval);
37 Eigen::LLT<Eigen::Matrix<value_type_t<EigMat>, EigMat::RowsAtCompileTime,
38 EigMat::ColsAtCompileTime>>
39 llt = m_eval.llt();
40 check_pos_definite("cholesky_decompose", "m", llt);
41 return llt.matrixL();
42}
43
44} // namespace math
45} // namespace stan
46
47#endif
void check_symmetric(const char *function, const char *name, const matrix_cl< T > &y)
Check if the matrix_cl is symmetric.
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,...
void check_pos_definite(const char *function, const char *name, const EigMat &y)
Check if the specified square, symmetric matrix is positive definite.
void check_not_nan(const char *function, const char *name, const T_y &y)
Check if y is not NaN.
typename eval_return_type< T >::type eval_return_type_t
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...