1 #ifndef STAN_MATH_PRIM_MAT_ERR_CHECK_POS_DEFINITE_HPP 2 #define STAN_MATH_PRIM_MAT_ERR_CHECK_POS_DEFINITE_HPP 32 template <
typename T_y>
34 const Eigen::Matrix<T_y, -1, -1>& y) {
38 domain_error(
function, name,
"is not positive definite.",
"");
40 Eigen::LDLT<Eigen::MatrixXd> cholesky =
value_of_rec(y).ldlt();
41 if (cholesky.info() != Eigen::Success
42 || !cholesky.isPositive()
43 || (cholesky.vectorD().array() <= 0.0).any())
44 domain_error(
function, name,
"is not positive definite.",
"");
60 template <
typename Derived>
62 const Eigen::LDLT<Derived>& cholesky) {
63 if (cholesky.info() != Eigen::Success
64 || !cholesky.isPositive()
65 || !(cholesky.vectorD().array() > 0.0).all())
66 domain_error(
function,
"LDLT decomposition of",
" failed", name);
83 template <
typename Derived>
85 const Eigen::LLT<Derived>& cholesky) {
86 if (cholesky.info() != Eigen::Success
87 || !(cholesky.matrixLLT().diagonal().array() > 0.0).all())
88 domain_error(
function,
"Matrix",
" is not positive definite", name);
double value_of_rec(const fvar< T > &v)
Return the value of the specified variable.
void check_positive_size(const char *function, const char *name, const char *expr, int size)
Check if size is positive.
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 check_symmetric(const char *function, const char *name, const Eigen::Matrix< T_y, Eigen::Dynamic, Eigen::Dynamic > &y)
Check if the specified matrix is symmetric.
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_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.