1 #ifndef STAN__MATH__ERROR_HANDLING__MATRIX__CHECK_POS_DEFINITE_HPP
2 #define STAN__MATH__ERROR_HANDLING__MATRIX__CHECK_POS_DEFINITE_HPP
28 template <
typename T_y,
typename T_result>
30 const Eigen::Matrix<T_y,Eigen::Dynamic,Eigen::Dynamic>& y,
34 std::ostringstream message;
35 message << name <<
" is not positive definite. "
36 << name <<
"(0,0) is %1%.";
37 std::string msg(message.str());
38 return dom_err(
function,y(0,0),name,msg.c_str(),
"",result);
40 for (
int i = 0; i < y.size(); ++i)
43 Eigen::LDLT< Eigen::Matrix<T_y,Eigen::Dynamic,Eigen::Dynamic> > cholesky
45 if (cholesky.info() != Eigen::Success
46 || !cholesky.isPositive()
48 std::ostringstream message;
49 message << name <<
" is not positive definite. "
50 << name <<
"(0,0) is %1%.";
51 std::string msg(message.str());
52 return dom_err(
function,y(0,0),name,msg.c_str(),
"",result);
bool dom_err(const char *function, const T &y, const char *name, const char *error_msg, const T_msg error_msg2, T_result *result)
const double CONSTRAINT_TOLERANCE
The tolerance for checking arithmetic bounds In rank and in simplexes.
bool check_pos_definite(const char *function, const Eigen::Matrix< T_y, Eigen::Dynamic, Eigen::Dynamic > &y, const char *name, T_result *result)
Return true if the specified matrix is positive definite.
bool check_not_nan(const char *function, const T_y &y, const char *name, T_result *result)
Checks if the variable y is nan.