| Stan Math Library 2.12.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 {
11
45 template<int R, int C>
46 class LDLT_factor<var, R, C> {
47 public:
53 LDLT_factor() : alloc_(new LDLT_alloc<R, C>()) {}
54
55 explicit LDLT_factor(const Eigen::Matrix<var, R, C> &A)
56 : alloc_(new LDLT_alloc<R, C>()) {
57 compute(A);
58 }
59
68 inline void compute(const Eigen::Matrix<var, R, C> &A) {
69 check_square("comute", "A", A);
70 alloc_->compute(A);
71 }
72
84 template<typename Rhs>
85 inline const
86 Eigen::internal::solve_retval<Eigen::LDLT<Eigen::Matrix<double, R, C> >,
87 Rhs>
88 solve(const Eigen::MatrixBase<Rhs>& b) const {
89 return alloc_->ldlt_.solve(b);
90 }
91
97 inline bool success() const {
98 bool ret;
99 ret = alloc_->N_ != 0;
100 ret = ret && alloc_->ldlt_.info() == Eigen::Success;
101 ret = ret && alloc_->ldlt_.isPositive();
102 ret = ret && (alloc_->ldlt_.vectorD().array() > 0).all();
103 return ret;
104 }
105
113 inline Eigen::VectorXd vectorD() const {
114 return alloc_->ldlt_.vectorD();
115 }
116
117 inline size_t rows() const { return alloc_->N_; }
118 inline size_t cols() const { return alloc_->N_; }
119
120 typedef size_t size_type;
121 typedef var value_type;
122
131 LDLT_alloc<R, C> *alloc_;
132 };
133
134 }
135 }
136 #endif
stan::math::LDLT_factor< var, R, C >::LDLT_factor
LDLT_factor(const Eigen::Matrix< var, R, C > &A)
Definition: LDLT_factor.hpp:55
core.hpp
LDLT_alloc.hpp
stan::math::LDLT_factor< var, R, C >::compute
void compute(const Eigen::Matrix< var, R, C > &A)
Use the LDLT_factor object to factorize a new matrix.
Definition: LDLT_factor.hpp:68
stan
Definition: log_sum_exp.hpp:8
stan::math::LDLT_factor< var, R, C >::vectorD
Eigen::VectorXd vectorD() const
The entries of the diagonal matrix D.
Definition: LDLT_factor.hpp:113
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::LDLT_factor< var, R, C >::cols
size_t cols() const
Definition: LDLT_factor.hpp:118
stan::math::var
Independent (input) and dependent (output) variables for gradients.
Definition: var.hpp:30
stan::math::LDLT_factor< var, R, C >::value_type
var value_type
Definition: LDLT_factor.hpp:121
stan::math::LDLT_factor
Definition: LDLT_factor.hpp:13
LDLT_factor.hpp
alloc_
mdivide_left_ldlt_alloc< R1, C1, R2, C2 > * alloc_
Definition: mdivide_left_ldlt.hpp:44
stan::math::LDLT_factor< var, R, C >::size_type
size_t size_type
Definition: LDLT_factor.hpp:120
stan::math::LDLT_factor< var, R, C >::alloc_
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:131
stan::math::LDLT_factor< var, R, C >::success
bool success() const
Determine whether the most recent factorization succeeded.
Definition: LDLT_factor.hpp:97
stan::math::LDLT_factor< var, R, C >::rows
size_t rows() const
Definition: LDLT_factor.hpp:117
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
stan::math::LDLT_factor< var, R, C >::LDLT_factor
LDLT_factor()
Default constructor.
Definition: LDLT_factor.hpp:53
stan::math::LDLT_factor< 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:88
check_square.hpp

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