The Cholesky decomposition factors a symmetric positive-definite matrix
It is approximately twice as fast as LU decomposition for symmetric positive-definite systems and is numerically stable without pivoting. In this library, it is used primarily by the Unscented Kalman Filter to generate sigma points from the state covariance matrix.
Given
| Operation | Time | Space | Notes |
|---|---|---|---|
| Decomposition | Half the cost of general LU decomposition |
Input: $A = \begin{bmatrix} 4 & 2 \ 2 & 5 \end{bmatrix}$ (symmetric positive-definite).
Compute
| Step | Formula | Value |
|---|---|---|
Result:
Verify: $LL^T = \begin{bmatrix} 2 & 0 \ 1 & 2 \end{bmatrix} \begin{bmatrix} 2 & 1 \ 0 & 2 \end{bmatrix} = \begin{bmatrix} 4 & 2 \ 2 & 5 \end{bmatrix} = A$ ✓
-
Non-positive-definite input. If
$A$ is not positive-definite, a diagonal element under the square root will be negative, producing NaN. Always verify the input or add a small regularization$A + \epsilon I$ . - Numerical precision. In fixed-point arithmetic, the intermediate sums and square root can lose precision. Use float for the decomposition and convert back if needed.
-
Zero diagonal. A zero or near-zero diagonal in
$L$ indicates a singular or nearly singular matrix.
-
$LDL^T$ Decomposition. Avoids the square root by factoring$A = LDL^T$ where$D$ is diagonal. Preferred in fixed-point arithmetic wheresqrtis expensive or imprecise. - Cholesky–Banachiewicz vs Cholesky–Crout. Two orderings of the same algorithm: row-oriented (Banachiewicz, used in this implementation) vs column-oriented (Crout). Performance differs by cache access pattern.
- Incomplete Cholesky. Drops small entries during factorization to produce a sparse approximate factor. Used as a preconditioner for iterative solvers (e.g., conjugate gradient).
-
Rank-1 Update/Downdate. Given the existing factor
$L$ of$A$ , efficiently compute the factor of$A + vv^T$ (or$A - vv^T$ ) in$O(n^2)$ without recomputing from scratch. Central to the square-root UKF. - Block Cholesky. Exploits block structure in large matrices for better cache utilization and parallelism.
-
Sigma point generation — The Unscented Kalman Filter uses Cholesky decomposition of the covariance matrix
$P = LL^T$ to spread sigma points along the principal uncertainty directions. -
Solving symmetric positive-definite systems — Given
$Ax = b$ , compute$L$ , then solve$Ly = b$ (forward substitution) and$L^Tx = y$ (back substitution). Twice as fast as general LU. -
Multivariate normal sampling — To generate
$x \sim \mathcal{N}(\mu, \Sigma)$ , compute$L$ from$\Sigma$ and set$x = \mu + Lz$ where$z \sim \mathcal{N}(0, I)$ . -
Least squares — The normal equations
$A^TAx = A^Tb$ produce a symmetric positive-definite system solvable via Cholesky. - Optimization — Newton-type methods with positive-definite Hessians use Cholesky to compute search directions.
| Algorithm | Relationship |
|---|---|
| Unscented Kalman Filter | Uses Factor to generate sigma points from the covariance matrix |
| Consistency Metrics | Uses Solve for the SPD covariance solve behind NEES/NIS |
| Gaussian Elimination | General-purpose alternative; does not exploit symmetry |
- Golub, G.H. and Van Loan, C.F., Matrix Computations, 4th ed., Johns Hopkins University Press, 2013.
- Press, W.H. et al., Numerical Recipes, 3rd ed., Cambridge University Press, 2007 — Section 2.9.