1#ifndef STAN_MATH_PRIM_ERR_CHECK_POS_SEMIDEFINITE_HPP
2#define STAN_MATH_PRIM_ERR_CHECK_POS_SEMIDEFINITE_HPP
29template <
typename EigMat, require_matrix_t<EigMat>* =
nullptr>
32 const auto& y_ref =
to_ref(y);
37 if (y_ref.rows() == 1 && !(y_ref(0, 0) >= 0.0)) {
44 LDLT<Matrix<double, Dynamic, Dynamic> > cholesky =
value_of_rec(y_ref).ldlt();
45 if (cholesky.info() != Eigen::Success
46 || (cholesky.vectorD().array() < 0.0).any()) {
61template <
typename Derived>
63 const Eigen::LDLT<Derived>& cholesky) {
64 if (cholesky.info() != Eigen::Success
65 || (cholesky.vectorD().array() < 0.0).any()) {
void check_symmetric(const char *function, const char *name, const matrix_cl< T > &y)
Check if the matrix_cl is symmetric.
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 EigMat &y)
Check if the specified matrix is positive definite.
void throw_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.
ref_type_t< T && > to_ref(T &&a)
This evaluates expensive Eigen expressions.
void check_not_nan(const char *function, const char *name, const T_y &y)
Check if y is not NaN.
void check_positive(const char *function, const char *name, const T_y &y)
Check if y is positive.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...