1 #ifndef STAN__MATH__MATRIX__LDLT_FACTOR_HPP
2 #define STAN__MATH__MATRIX__LDLT_FACTOR_HPP
5 #include <boost/shared_ptr.hpp>
15 template<
typename T,
int R,
int C>
55 template<
int R,
int C,
typename T>
59 :
N_(0),
_ldltP(new Eigen::LDLT< Eigen::Matrix<T,R,C> >()) {}
62 :
N_(0),
_ldltP(new Eigen::LDLT< Eigen::Matrix<T,R,C> >())
67 inline void compute(
const Eigen::Matrix<T,R,C> &A) {
75 ret =
_ldltP->info() == Eigen::Success;
76 ret = ret &&
_ldltP->isPositive();
77 ret = ret && (
_ldltP->vectorD().array() > 0).all();
82 return _ldltP->vectorD().array().log().sum();
85 inline void inverse(Eigen::Matrix<T,R,C> &invA)
const {
87 _ldltP->solveInPlace(invA);
90 template<
typename Rhs>
91 inline const Eigen::internal::solve_retval<Eigen::LDLT< Eigen::Matrix<T,R,C> >, Rhs>
92 solve(
const Eigen::MatrixBase<Rhs>& b)
const {
96 inline Eigen::Matrix<T,R,C>
solveRight(
const Eigen::Matrix<T,R,C> &B)
const {
100 inline Eigen::Matrix<T,Eigen::Dynamic,1>
vectorD()
const {
104 inline Eigen::LDLT<Eigen::Matrix<T,R,C> >
matrixLDLT()
const {
105 return _ldltP->matrixLDLT();
108 inline size_t rows()
const {
return N_; }
109 inline size_t cols()
const {
return N_; }
115 boost::shared_ptr< Eigen::LDLT< Eigen::Matrix<T,R,C> > >
_ldltP;
void inverse(Eigen::Matrix< T, R, C > &invA) const
Eigen::Matrix< T, Eigen::Dynamic, 1 > vectorD() const
boost::shared_ptr< Eigen::LDLT< Eigen::Matrix< T, R, C > > > _ldltP
LDLT_factor(const Eigen::Matrix< T, R, C > &A)
Eigen::Matrix< T, C, R > transpose(const Eigen::Matrix< T, R, C > &m)
const Eigen::internal::solve_retval< Eigen::LDLT< Eigen::Matrix< T, R, C > >, Rhs > solve(const Eigen::MatrixBase< Rhs > &b) const
Eigen::LDLT< Eigen::Matrix< T, R, C > > matrixLDLT() const
boost::shared_ptr< Eigen::LDLT< Eigen::Matrix< double, R1, C1 > > > _ldltP
This share_ptr is used to prevent copying the LDLT factorizations for mdivide_left_ldlt(ldltA,b) when ldltA is a LDLT_factor<double>.
void compute(const Eigen::Matrix< T, R, C > &A)
Eigen::Matrix< T, R, C > solveRight(const Eigen::Matrix< T, R, C > &B) const
bool check_square(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 square.