Automatic Differentiation
 
Loading...
Searching...
No Matches
check_ldlt_factor.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_ERR_CHECK_LDLT_FACTOR_HPP
2#define STAN_MATH_PRIM_ERR_CHECK_LDLT_FACTOR_HPP
3
7#include <sstream>
8#include <string>
9
10namespace stan {
11namespace math {
12
24template <typename T>
25inline void check_ldlt_factor(const char* function, const char* name,
26 LDLT_factor<T>& A) {
27 if (!(A.ldlt().info() == Eigen::Success && A.ldlt().isPositive()
28 && (A.ldlt().vectorD().array() > 0).all())) {
29 std::ostringstream msg;
30 msg << "is not positive definite. last conditional variance is ";
31 std::string msg_str(msg.str());
32 auto too_small = A.ldlt().vectorD().tail(1)(0);
33 throw_domain_error(function, name, too_small, msg_str.c_str(), ".");
34 }
35}
36
37} // namespace math
38} // namespace stan
39#endif
LDLT_factor is a structure that holds a matrix of type T and the LDLT of its values.
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_ldlt_factor(const char *function, const char *name, LDLT_factor< T > &A)
Raise domain error if the specified LDLT factor is invalid.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...