| Stan Math Library 2.11.0 reverse mode automatic differentiation

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

LDLT_factor.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_REV_MAT_FUN_LDLT_FACTOR_HPP
2 #define STAN_MATH_REV_MAT_FUN_LDLT_FACTOR_HPP
3
4 #include <stan/math/rev/core.hpp>
5 #include <stan/math/rev/mat/fun/LDLT_alloc.hpp>
6 #include <stan/math/prim/mat/fun/LDLT_factor.hpp>
7 #include <stan/math/prim/mat/err/check_square.hpp>
8
9 namespace stan {
10 namespace math {
44 template<int R, int C>
45 class LDLT_factor<stan::math::var, R, C> {
46 public:
52 LDLT_factor() : _alloc(new stan::math::LDLT_alloc<R, C>()) {}
53
54 explicit LDLT_factor(const Eigen::Matrix<stan::math::var, R, C> &A)
55 : _alloc(new stan::math::LDLT_alloc<R, C>()) {
56 compute(A);
57 }
58
67 inline void compute(const Eigen::Matrix<stan::math::var, R, C> &A) {
68 stan::math::check_square("comute", "A", A);
69 _alloc->compute(A);
70 }
71
83 template<typename Rhs>
84 inline const
85 Eigen::internal::solve_retval<Eigen::LDLT<Eigen::Matrix<double, R, C> >,
86 Rhs>
87 solve(const Eigen::MatrixBase<Rhs>& b) const {
88 return _alloc->_ldlt.solve(b);
89 }
90
96 inline bool success() const {
97 bool ret;
98 ret = _alloc->N_ != 0;
99 ret = ret && _alloc->_ldlt.info() == Eigen::Success;
100 ret = ret && _alloc->_ldlt.isPositive();
101 ret = ret && (_alloc->_ldlt.vectorD().array() > 0).all();
102 return ret;
103 }
104
112 inline Eigen::VectorXd vectorD() const {
113 return _alloc->_ldlt.vectorD();
114 }
115
116 inline size_t rows() const { return _alloc->N_; }
117 inline size_t cols() const { return _alloc->N_; }
118
119 typedef size_t size_type;
120 typedef stan::math::var value_type;
121
130 stan::math::LDLT_alloc<R, C> *_alloc;
131 };
132 }
133 }
134 #endif
stan::math::LDLT_factor< stan::math::var, R, C >::LDLT_factor
LDLT_factor(const Eigen::Matrix< stan::math::var, R, C > &A)
Definition: LDLT_factor.hpp:54
core.hpp
LDLT_alloc.hpp
stan::math::LDLT_factor< stan::math::var, R, C >::rows
size_t rows() const
Definition: LDLT_factor.hpp:116
stan
Definition: log_sum_exp.hpp:8
stan::math::LDLT_factor< stan::math::var, R, C >::compute
void compute(const Eigen::Matrix< stan::math::var, R, C > &A)
Use the LDLT_factor object to factorize a new matrix.
Definition: LDLT_factor.hpp:67
stan::math::LDLT_factor< stan::math::var, R, C >::size_type
size_t size_type
Definition: LDLT_factor.hpp:119
stan::math::LDLT_factor< stan::math::var, R, C >::_alloc
stan::math::LDLT_alloc< R, C > * _alloc
The LDLT_alloc object actually contains the factorization but is derived from the chainable_alloc cla...
Definition: LDLT_factor.hpp:130
stan::math::LDLT_alloc
This object stores the actual (double typed) LDLT factorization of an Eigen::Matrix along with p...
Definition: LDLT_alloc.hpp:20
stan::math::var
Independent (input) and dependent (output) variables for gradients.
Definition: var.hpp:31
_alloc
mdivide_left_ldlt_alloc< R1, C1, R2, C2 > * _alloc
Definition: mdivide_left_ldlt.hpp:44
stan::math::LDLT_factor
Definition: LDLT_factor.hpp:18
LDLT_factor.hpp
stan::math::LDLT_factor< stan::math::var, R, C >::cols
size_t cols() const
Definition: LDLT_factor.hpp:117
stan::math::LDLT_factor< stan::math::var, R, C >::value_type
stan::math::var value_type
Definition: LDLT_factor.hpp:120
stan::math::LDLT_factor< stan::math::var, R, C >::vectorD
Eigen::VectorXd vectorD() const
The entries of the diagonal matrix D.
Definition: LDLT_factor.hpp:112
stan::math::LDLT_factor< stan::math::var, R, C >::LDLT_factor
LDLT_factor()
Default constructor.
Definition: LDLT_factor.hpp:52
stan::math::LDLT_factor< stan::math::var, R, C >::solve
const Eigen::internal::solve_retval< Eigen::LDLT< Eigen::Matrix< double, R, C > >, Rhs > solve(const Eigen::MatrixBase< Rhs > &b) const
Compute the actual numerical result of inv(A)*b.
Definition: LDLT_factor.hpp:87
stan::math::LDLT_factor< stan::math::var, R, C >::success
bool success() const
Determine whether the most recent factorization succeeded.
Definition: LDLT_factor.hpp:96
stan::math::check_square
bool check_square(const char *function, const char *name, const Eigen::Matrix< T_y, Eigen::Dynamic, Eigen::Dynamic > &y)
Return true if the specified matrix is square.
Definition: check_square.hpp:28
check_square.hpp

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