MatrixType | the type of the matrix of which we are computing the LL^T Cholesky decomposition |
While the Cholesky decomposition is particularly useful to solve selfadjoint problems like D^*D x = b, for that purpose, we recommend the Cholesky decomposition without square root which is more stable and even faster. Nevertheless, this standard Cholesky decomposition remains useful in many other situations like generalised eigen problems with hermitian matrices.
Note that during the decomposition, only the upper triangular part of A is considered. Therefore, the strict lower part does not have to store correct values.
Public Member Functions | |
void | compute (const MatrixType &matrix) |
bool | isPositiveDefinite (void) const |
LLT (const MatrixType &matrix) | |
Part< MatrixType, LowerTriangular > | matrixL (void) const |
template<typename RhsDerived, typename ResDerived> | |
bool | solve (const MatrixBase< RhsDerived > &b, MatrixBase< ResDerived > *result) const |
template<typename Derived> | |
bool | solveInPlace (MatrixBase< Derived > &bAndX) const |
Protected Attributes | |
bool | m_isPositiveDefinite |
MatrixType | m_matrix |
void compute | ( | const MatrixType & | a | ) | [inline] |
Computes / recomputes the Cholesky decomposition A = LL^* = U^*U of matrix
bool isPositiveDefinite | ( | void | ) | const [inline] |
Part<MatrixType, LowerTriangular> matrixL | ( | void | ) | const [inline] |
bool solve | ( | const MatrixBase< RhsDerived > & | b, | |
MatrixBase< ResDerived > * | result | |||
) | const [inline] |
Computes the solution x of using the current decomposition of A. The result is stored in result
Example:
typedef Matrix<float,Dynamic,2> DataMatrix; // let's generate some samples on the 3D plane of equation z = 2x+3y (with some noise) DataMatrix samples = DataMatrix::Random(12,2); VectorXf elevations = 2*samples.col(0) + 3*samples.col(1) + VectorXf::Random(12)*0.1; // and let's solve samples * [x y]^T = elevations in least square sense: Matrix<float,2,1> xy; (samples.adjoint() * samples).llt().solve((samples.adjoint()*elevations), &xy); cout << xy << endl;
2.02 2.97
bool solveInPlace | ( | MatrixBase< Derived > & | bAndX | ) | const [inline] |
This is the in-place version of solve().
bAndX | represents both the right-hand side matrix b and result x. |