| Stan Math Library 2.6.3 probability, sampling & optimization

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros
Public Types | Public Member Functions | Public Attributes | List of all members
stan::math::LDLT_factor< stan::math::var, R, C > Class Template Reference

A template specialization of src/stan/math/matrix/LDLT_factor.hpp for stan::math::var which can be used with all the *_ldlt functions. More...

`#include <LDLT_factor.hpp>`

## Public Types
typedef size_t | size_type
typedef stan::math::var | value_type

## Public Member Functions
| LDLT_factor ()
| Default constructor. More...
| LDLT_factor (const Eigen::Matrix< stan::math::var, R, C > &A)
void | compute (const Eigen::Matrix< stan::math::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
stan::math::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...

## Detailed Description

### template<int R, int C>
class stan::math::LDLT_factor< stan::math::var, R, C >

A template specialization of src/stan/math/matrix/LDLT_factor.hpp for stan::math::var which can be used with all the *_ldlt functions.

The usage pattern is:

Eigen::Matrix<T, R, C> A1, A2;
LDLT_factor<T, R, C> ldlt_A1(A1);
LDLT_factor<T, R, C> ldlt_A2;
ldlt_A2.compute(A2);

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

x1 = mdivide_left_ldlt(ldlt_A1, b1);
x2 = mdivide_right_ldlt(b2, ldlt_A2);
d1 = log_determinant_ldlt(ldlt_A1);
d2 = log_determinant_ldlt(ldlt_A2);

Definition at line 45 of file LDLT_factor.hpp.

## Member Typedef Documentation

template<int R, int C>

typedef size_t stan::math::LDLT_factor< stan::math::var, R, C >::size_type

Definition at line 119 of file LDLT_factor.hpp.

template<int R, int C>

typedef stan::math::var stan::math::LDLT_factor< stan::math::var, R, C >::value_type

Definition at line 120 of file LDLT_factor.hpp.

## Constructor & Destructor Documentation

template<int R, int C>

stan::math::LDLT_factor< stan::math::var, R, C >::LDLT_factor | ( |  | ) |
| 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 52 of file LDLT_factor.hpp.

template<int R, int C>

stan::math::LDLT_factor< stan::math::var, R, C >::LDLT_factor | ( | const Eigen::Matrix< stan::math::var, R, C > & | A | ) |
| inline explicit

Definition at line 54 of file LDLT_factor.hpp.

## Member Function Documentation

template<int R, int C>

size_t stan::math::LDLT_factor< stan::math::var, R, C >::cols | ( |  | ) | const
| inline

Definition at line 117 of file LDLT_factor.hpp.

template<int R, int C>

void stan::math::LDLT_factor< stan::math::var, R, C >::compute | ( | const Eigen::Matrix< stan::math::var, R, C > & | A | ) |
| 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.

Parameters

  A | A symmetric positive definite matrix to factorize

Definition at line 67 of file LDLT_factor.hpp.

template<int R, int C>

size_t stan::math::LDLT_factor< stan::math::var, R, C >::rows | ( |  | ) | const
| inline

Definition at line 116 of file LDLT_factor.hpp.

template<int R, int C>
template<typename Rhs >

const Eigen::internal::solve_retval<Eigen::LDLT<Eigen::Matrix<double, R, C> >, Rhs> stan::math::LDLT_factor< stan::math::var, R, C >::solve | ( | const Eigen::MatrixBase< Rhs > & | b | ) | const
| 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.

Parameters

  b | The right handside. Note that this is templated such that Eigen's expression-templating magic can work properly here.

Definition at line 87 of file LDLT_factor.hpp.

template<int R, int C>

bool stan::math::LDLT_factor< stan::math::var, R, C >::success | ( |  | ) | const
| 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 96 of file LDLT_factor.hpp.

template<int R, int C>

Eigen::VectorXd stan::math::LDLT_factor< stan::math::var, R, C >::vectorD | ( |  | ) | const
| 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 112 of file LDLT_factor.hpp.

## Member Data Documentation

template<int R, int C>

stan::math::LDLT_alloc<R, C>* stan::math::LDLT_factor< stan::math::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 130 of file LDLT_factor.hpp.

The documentation for this class was generated from the following file:

- stan/math/rev/mat/fun/LDLT_factor.hpp

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