All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Groups
LDLT_alloc.hpp
Go to the documentation of this file.
#ifndef STAN_MATH_REV_MAT_FUN_LDLT_ALLOC_HPP
#define STAN_MATH_REV_MAT_FUN_LDLT_ALLOC_HPP
#include <stan/math/prim/mat/fun/Eigen.hpp>
#include <stan/math/rev/core.hpp>
namespace stan {
namespace math {
template<int R, int C>
class LDLT_alloc : public chainable_alloc {
public:
LDLT_alloc() : N_(0) {}
explicit LDLT_alloc(const Eigen::Matrix<var, R, C> &A) : N_(0) {
compute(A);
}
inline void compute(const Eigen::Matrix<var, R, C> &A) {
Eigen::Matrix<double, R, C> Ad(A.rows(), A.cols());
N_ = A.rows();
_variA.resize(A.rows(), A.cols());
for (size_t j = 0; j < N_; j++) {
for (size_t i = 0; i < N_; i++) {
Ad(i, j) = A(i, j).val();
_variA(i, j) = A(i, j).vi_;
}
}
_ldlt.compute(Ad);
}
inline double log_abs_det() const {
return _ldlt.vectorD().array().log().sum();
}
size_t N_;
Eigen::LDLT<Eigen::Matrix<double, R, C> > _ldlt;
Eigen::Matrix<vari*, R, C> _variA;
};
}
}
#endif
core.hpp
stan::math::LDLT_alloc::LDLT_alloc
LDLT_alloc()
Definition: LDLT_alloc.hpp:22
stan::math::LDLT_alloc::N_
size_t N_
Definition: LDLT_alloc.hpp:53
stan::math::LDLT_alloc::_ldlt
Eigen::LDLT< Eigen::Matrix< double, R, C > > _ldlt
Definition: LDLT_alloc.hpp:54
stan::math::LDLT_alloc
This object stores the actual (double typed) LDLT factorization of an Eigen::Matrix<var> along with poi...
Definition: LDLT_alloc.hpp:20
stan::math::LDLT_alloc::LDLT_alloc
LDLT_alloc(const Eigen::Matrix< var, R, C > &A)
Definition: LDLT_alloc.hpp:23
Eigen.hpp
stan::math::LDLT_alloc::_variA
Eigen::Matrix< vari *, R, C > _variA
Definition: LDLT_alloc.hpp:55
stan::math::chainable_alloc
A chainable_alloc is an object which is constructed and destructed normally but the memory lifespan i...
Definition: chainable_alloc.hpp:17
stan::math::LDLT_alloc::log_abs_det
double log_abs_det() const
Compute the log(abs(det(A))). This is just a convenience function.
Definition: LDLT_alloc.hpp:49
stan::math::LDLT_alloc::compute
void compute(const Eigen::Matrix< var, R, C > &A)
Compute the LDLT factorization and store pointers to the vari's of the matrix entries to be used when...
Definition: LDLT_alloc.hpp:32

[ Stan Home Page ] © 2011–2015, Stan Development Team.