![]() |
Stan Math Library
2.15.0
reverse mode automatic differentiation
|
A template specialization of src/stan/math/matrix/LDLT_factor.hpp for var which can be used with all the *_ldlt functions. More...
#include <LDLT_factor.hpp>
Public Types | |
typedef size_t | size_type |
typedef var | value_type |
Public Member Functions | |
LDLT_factor () | |
Default constructor. More... | |
LDLT_factor (const Eigen::Matrix< var, R, C > &A) | |
void | compute (const Eigen::Matrix< var, R, C > &A) |
Use the LDLT_factor object to factorize a new matrix. More... | |
template<typename Rhs > | |
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. More... | |
bool | success () const |
Determine whether the most recent factorization succeeded. More... | |
Eigen::VectorXd | vectorD () const |
The entries of the diagonal matrix D. More... | |
size_t | rows () const |
size_t | cols () const |
Public Attributes | |
LDLT_alloc< R, C > * | alloc_ |
The LDLT_alloc object actually contains the factorization but is derived from the chainable_alloc class so that it is allocated on the vari stack. More... | |
A template specialization of src/stan/math/matrix/LDLT_factor.hpp for var which can be used with all the *_ldlt functions.
The usage pattern is:
Now, the caller should check that ldlt_A1.success() and ldlt_A2.success() are true or abort accordingly. Alternatively, call check_ldlt_factor(). The behaviour of using an LDLT_factor without success() returning true is undefined.
Note that ldlt_A1 and ldlt_A2 are completely equivalent. They simply demonstrate two different ways to construct the factorization.
Now, the caller can use the LDLT_factor objects as needed. For instance
Definition at line 46 of file LDLT_factor.hpp.
typedef size_t stan::math::LDLT_factor< var, R, C >::size_type |
Definition at line 129 of file LDLT_factor.hpp.
typedef var stan::math::LDLT_factor< var, R, C >::value_type |
Definition at line 130 of file LDLT_factor.hpp.
|
inline |
Default constructor.
The caller MUST call compute() after this. Any calls which use the LDLT_factor without calling compute() run the risk of crashing Stan from within Eigen.
Definition at line 53 of file LDLT_factor.hpp.
|
inlineexplicit |
Definition at line 55 of file LDLT_factor.hpp.
|
inline |
Definition at line 127 of file LDLT_factor.hpp.
|
inline |
Use the LDLT_factor object to factorize a new matrix.
After calling this function, the user should call success() to check that the factorization was successful. If the factorization is not successful, the LDLT_factor is not valid and other functions should not be used.
A | A symmetric positive definite matrix to factorize |
Definition at line 68 of file LDLT_factor.hpp.
|
inline |
Definition at line 126 of file LDLT_factor.hpp.
|
inline |
Compute the actual numerical result of inv(A)*b.
Note that this isn't meant to handle any of the autodiff. This is a convenience function for the actual implementations in mdivide_left_ldlt.
Precondition: success() must return true. If success() returns false, this function runs the risk of crashing Stan from within Eigen.
b | The right handside. Note that this is templated such that Eigen's expression-templating magic can work properly here. |
Definition at line 96 of file LDLT_factor.hpp.
|
inline |
Determine whether the most recent factorization succeeded.
This should always be called after the object is constructed (with a matrix) or after compute() is called.
Definition at line 106 of file LDLT_factor.hpp.
|
inline |
The entries of the diagonal matrix D.
They should be strictly positive for a positive definite matrix.
Precondition: success() must return true. If success() returns false, this function runs the risk of crashing Stan from within Eigen.
Definition at line 122 of file LDLT_factor.hpp.
LDLT_alloc<R, C>* stan::math::LDLT_factor< var, R, C >::alloc_ |
The LDLT_alloc object actually contains the factorization but is derived from the chainable_alloc class so that it is allocated on the vari stack.
This ensures that it's lifespan is longer than the LDLT_factor object which created it. This is needed because the factorization is required during the chain() calls which happen after an LDLT_factor object will most likely have been destroyed.
Definition at line 140 of file LDLT_factor.hpp.