1 #ifndef STAN_MATH_PRIM_MAT_ERR_CHECK_POS_SEMIDEFINITE_HPP 2 #define STAN_MATH_PRIM_MAT_ERR_CHECK_POS_SEMIDEFINITE_HPP 28 template <
typename T_y>
30 const char*
function,
const char* name,
31 const Eigen::Matrix<T_y, Eigen::Dynamic, Eigen::Dynamic>& y) {
35 if (y.rows() == 1 && !(y(0, 0) >= 0.0))
36 domain_error(
function, name,
"is not positive semi-definite.",
"");
41 LDLT<Matrix<double, Dynamic, Dynamic> > cholesky =
value_of_rec(y).ldlt();
42 if (cholesky.info() != Eigen::Success
43 || (cholesky.vectorD().array() < 0.0).any())
44 domain_error(
function, name,
"is not positive semi-definite.",
"");
58 template <
typename Derived>
60 const Eigen::LDLT<Derived>& cholesky) {
61 if (cholesky.info() != Eigen::Success
62 || (cholesky.vectorD().array() < 0.0).any())
63 domain_error(
function, name,
"is not positive semi-definite.",
"");
double value_of_rec(const fvar< T > &v)
Return the value of the specified variable.
void check_pos_semidefinite(const char *function, const char *name, const Eigen::Matrix< T_y, Eigen::Dynamic, Eigen::Dynamic > &y)
Check if the specified matrix is positive definite.
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_symmetric(const char *function, const char *name, const matrix_cl &y)
Check if the matrix_cl is symmetric.