1#ifndef STAN_MATH_PRIM_ERR_IS_POS_DEFINITE_HPP
2#define STAN_MATH_PRIM_ERR_IS_POS_DEFINITE_HPP
26template <
typename EigMat, require_eigen_matrix_dynamic_t<EigMat>* =
nullptr>
28 const auto& y_ref =
to_ref(y);
38 Eigen::LDLT<Eigen::MatrixXd> cholesky =
value_of_rec(y_ref).ldlt();
39 if (cholesky.info() != Eigen::Success || !cholesky.isPositive()
40 || (cholesky.vectorD().array() <= 0.0).any()) {
55template <
typename Derived>
57 return cholesky.info() == Eigen::Success && cholesky.isPositive()
58 && (cholesky.vectorD().array() > 0.0).
all();
70template <
typename Derived>
72 return cholesky.info() == Eigen::Success
73 && (cholesky.matrixLLT().diagonal().array() > 0.0).
all();
double value_of_rec(const fvar< T > &v)
Return the value of the specified variable.
bool is_positive(const T_y &y)
Return true if y is positive.
constexpr bool all(T x)
Return true if all values in the input are true.
bool is_pos_definite(const EigMat &y)
Return true if the matrix is square or if the matrix has non-zero size, or if the matrix is symmetric...
bool is_not_nan(const T_y &y)
Return true if y is not NaN.
ref_type_t< T && > to_ref(T &&a)
This evaluates expensive Eigen expressions.
bool is_symmetric(const EigMat &y)
Return true if the matrix is square, and no element not on the main diagonal is NaN.
const double CONSTRAINT_TOLERANCE
The tolerance for checking arithmetic bounds in rank and in simplexes.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...