1 #ifndef STAN_MATH_PRIM_MAT_ERR_CHECK_POS_DEFINITE_HPP 2 #define STAN_MATH_PRIM_MAT_ERR_CHECK_POS_DEFINITE_HPP 27 template <
typename T_y>
29 const Eigen::Matrix<T_y, -1, -1>& y) {
33 domain_error(
function, name,
"is not positive definite.",
"");
35 Eigen::LDLT<Eigen::MatrixXd> cholesky =
value_of_rec(y).ldlt();
36 if (cholesky.info() != Eigen::Success || !cholesky.isPositive()
37 || (cholesky.vectorD().array() <= 0.0).any())
38 domain_error(
function, name,
"is not positive definite.",
"");
52 template <
typename Derived>
54 const Eigen::LDLT<Derived>& cholesky) {
55 if (cholesky.info() != Eigen::Success || !cholesky.isPositive()
56 || !(cholesky.vectorD().array() > 0.0).all())
57 domain_error(
function,
"LDLT decomposition of",
" failed", name);
71 template <
typename Derived>
73 const Eigen::LLT<Derived>& cholesky) {
74 if (cholesky.info() != Eigen::Success
75 || !(cholesky.matrixLLT().diagonal().array() > 0.0).all())
76 domain_error(
function,
"Matrix",
" is not positive definite", name);
double value_of_rec(const fvar< T > &v)
Return the value of the specified variable.
const double CONSTRAINT_TOLERANCE
The tolerance for checking arithmetic bounds In rank and in simplexes.
void check_not_nan(const char *function, const char *name, const T_y &y)
Check if y is not NaN.
void domain_error(const char *function, const char *name, const T &y, const char *msg1, const char *msg2)
Throw a domain error with a consistently formatted message.
void check_positive(const char *function, const char *name, const T_y &y)
Check if y is positive.
void check_pos_definite(const char *function, const char *name, const Eigen::Matrix< T_y, -1, -1 > &y)
Check if the specified square, symmetric matrix is positive definite.
void check_symmetric(const char *function, const char *name, const matrix_cl &y)
Check if the matrix_cl is symmetric.