#include <vnl_ldl_cholesky.h>
A class to hold the Cholesky decomposition of a positive definite symmetric matrix, using the form A=LDL', where L is lower triangular with ones on the leading diagonal, and D is a diagonal matrix. This differs from vnl_cholesky, which decomposes as A=LL', without a constraint on the diagonal. The advantage of the LDL' form is that it can be efficiently updated. Thus given the decomposition of A, we can compute the decomposition of (A+v.v') in O(n^2) time.
This can be used to solve linear systems, compute determinants and inverses.
To check that the decomposition can be used safely for solving a linear equation it is wise to construct with mode==estimate_condition and check that rcond()>sqrt(machine precision). If this is not the case it might be a good idea to use vnl_svd instead.
Definition at line 31 of file vnl_ldl_cholesky.h.
Public Types | |
| enum | Operation { quiet, verbose, estimate_condition } |
| Modes of computation. See constructor for details. More... | |
Public Member Functions | |
| vnl_ldl_cholesky (vnl_matrix< double > const &M, Operation mode=verbose) | |
| Make cholesky decomposition of M optionally computing the reciprocal condition number. | |
| ~vnl_ldl_cholesky () | |
| vnl_vector< double > | solve (vnl_vector< double > const &b) const |
| Solve LS problem M x = b. | |
| void | solve (vnl_vector< double > const &b, vnl_vector< double > *x) const |
| Solve LS problem M x = b. | |
| void | solve_lx (vnl_vector< double > &y) |
| Solve equation of form Lx=y (in-place). | |
| double | determinant () const |
| Compute determinant. | |
| void | rank1_update (const vnl_vector< double > &v) |
| Compute rank-1 update, ie the decomposition of (M+v.v'). | |
| void | update (const vnl_matrix< double > &W) |
| Multi-rank update, ie the decomposition of (M+W.W'). | |
| vnl_matrix< double > | inverse () const |
| Compute inverse. Not efficient. | |
| const vnl_matrix< double > & | lower_triangle () const |
| Return lower-triangular factor. | |
| vnl_matrix< double > | upper_triangle () const |
| Return upper-triangular factor. | |
| const vnl_vector< double > & | diagonal () const |
| Return elements of diagonal matrix D in LDL'. | |
| double | xt_m_inv_x (const vnl_vector< double > &x) const |
| Efficient computation of x' * inv(M) * x. | |
| double | xt_m_x (const vnl_vector< double > &x) const |
| Efficient computation of x' * M * x. | |
| int | rank_deficiency () const |
| A Success/failure flag. | |
| double | rcond () const |
| Return reciprocal condition number (smallest/largest singular values). | |
| vnl_vector< double > & | nullvector () |
| Return computed nullvector. | |
| vnl_vector< double > const & | nullvector () const |
Protected Attributes | |
| vnl_matrix< double > | L_ |
| Lower triangular matrix. | |
| vnl_vector< double > | d_ |
| Elements of diagonal matrix. | |
| double | rcond_ |
| 1/(condition number). | |
| long | num_dims_rank_def_ |
| vnl_vector< double > | nullvector_ |
Private Member Functions | |
| vnl_ldl_cholesky (vnl_ldl_cholesky const &that) | |
| Copy constructor - privatised to avoid it being used. | |
| vnl_ldl_cholesky & | operator= (vnl_ldl_cholesky const &that) |
| Assignment operator - privatised to avoid it being used. | |
| void | inplace_solve (double *x) const |
| Solve Mx=b, overwriting input vector with the solution. | |
|
|
Modes of computation. See constructor for details.
Definition at line 35 of file vnl_ldl_cholesky.h. |
|
||||||||||||
|
Make cholesky decomposition of M optionally computing the reciprocal condition number. Make cholesky decomposition of M optionally computing the reciprocal condition number. If mode is estimate_condition, the condition number and an approximate nullspace are estimated, at a cost of a factor of (1 + 18/n). Here's a table of 1 + 18/n: n: 3 5 10 50 100 500 1000 slowdown: 7.0 4.6 2.8 1.4 1.18 1.04 1.02 Sqrt of elements of diagonal matrix. Definition at line 28 of file vnl_ldl_cholesky.cxx. |
|
|
Definition at line 43 of file vnl_ldl_cholesky.h. |
|
|
Copy constructor - privatised to avoid it being used.
|
|
|
Compute determinant.
Definition at line 179 of file vnl_ldl_cholesky.cxx. |
|
|
Return elements of diagonal matrix D in LDL'.
Definition at line 80 of file vnl_ldl_cholesky.h. |
|
|
Solve Mx=b, overwriting input vector with the solution. x points to beginning of an n-element vector containing b On exit, x[i] filled with solution vector. Definition at line 100 of file vnl_ldl_cholesky.cxx. |
|
|
Compute inverse. Not efficient. Note that you rarely need the inverse - backsubtitution is faster and less prone to rounding error. Definition at line 251 of file vnl_ldl_cholesky.cxx. |
|
|
Return lower-triangular factor.
Definition at line 74 of file vnl_ldl_cholesky.h. |
|
|
Definition at line 102 of file vnl_ldl_cholesky.h. |
|
|
Return computed nullvector. Not calculated unless Operation mode at construction was estimate_condition. Definition at line 101 of file vnl_ldl_cholesky.h. |
|
|
Assignment operator - privatised to avoid it being used.
|
|
|
Compute rank-1 update, ie the decomposition of (M+v.v'). If the initial state is the decomposition of M, then L and D are updated so that on exit LDL'=M+v.v' Definition at line 193 of file vnl_ldl_cholesky.cxx. |
|
|
A Success/failure flag.
Definition at line 91 of file vnl_ldl_cholesky.h. |
|
|
Return reciprocal condition number (smallest/largest singular values). As long as rcond()>sqrt(precision) the decomposition can be used for solving equations safely. Not calculated unless Operation mode at construction was estimate_condition. Definition at line 97 of file vnl_ldl_cholesky.h. |
|
||||||||||||
|
Solve LS problem M x = b. The right-hand-side vcl_vector x may be b, which will give a fractional increase in speed. Definition at line 160 of file vnl_ldl_cholesky.cxx. |
|
|
Solve LS problem M x = b.
Definition at line 169 of file vnl_ldl_cholesky.cxx. |
|
|
Solve equation of form Lx=y (in-place). x is overwritten with solution Definition at line 90 of file vnl_ldl_cholesky.cxx. |
|
|
Multi-rank update, ie the decomposition of (M+W.W'). If the initial state is the decomposition of M, then L and D are updated so that on exit LDL'=M+W.W' Definition at line 218 of file vnl_ldl_cholesky.cxx. |
|
|
Return upper-triangular factor.
Definition at line 77 of file vnl_ldl_cholesky.h. |
|
|
Efficient computation of x' * inv(M) * x. Useful when M is a covariance matrix! Definition at line 123 of file vnl_ldl_cholesky.cxx. |
|
|
Efficient computation of x' * M * x. Twice as fast as explicitly computing x' * M * x Definition at line 140 of file vnl_ldl_cholesky.cxx. |
|
|
Elements of diagonal matrix.
Definition at line 111 of file vnl_ldl_cholesky.h. |
|
|
Lower triangular matrix.
Definition at line 108 of file vnl_ldl_cholesky.h. |
|
|
Definition at line 116 of file vnl_ldl_cholesky.h. |
|
|
Definition at line 115 of file vnl_ldl_cholesky.h. |
|
|
1/(condition number).
Definition at line 114 of file vnl_ldl_cholesky.h. |
1.4.4