1#ifndef STAN_MATH_PRIM_FUN_INVERSE_SPD_HPP
2#define STAN_MATH_PRIM_FUN_INVERSE_SPD_HPP
21template <
typename EigMat>
22inline Eigen::Matrix<value_type_t<EigMat>, Eigen::Dynamic, Eigen::Dynamic>
31 const Eigen::Ref<const plain_type_t<EigMat>>& m_ref = m;
34 LDLT<plain_type_t<EigMat>> ldlt(mmt);
35 if (ldlt.info() != Eigen::Success) {
38 if (!ldlt.isPositive()) {
41 Matrix<Scalar, Dynamic, 1> diag_ldlt = ldlt.vectorD();
42 check_positive(
"inverse_spd",
"matrix not positive definite", diag_ldlt);
45 Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic>::Identity(
void check_symmetric(const char *function, const char *name, const matrix_cl< T > &y)
Check if the matrix_cl is symmetric.
typename value_type< T >::type value_type_t
Helper function for accessing underlying type.
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.
void check_positive(const char *function, const char *name, const T_y &y)
Check if y is positive.
Eigen::Matrix< value_type_t< EigMat >, Eigen::Dynamic, Eigen::Dynamic > inverse_spd(const EigMat &m)
Returns the inverse of the specified symmetric, pos/neg-definite matrix.
typename plain_type< T >::type plain_type_t
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...