Fast and Accurate Symmetric Positive Definite Matrix Inverse Using Cholesky Decomposition

use LAPACK Cholesky to invert real positive definite symmetric matrix; faster more accurate than inv
2.4K Downloads
Updated 18 Feb 2015

View License

We can exploit the structure of a real, positive definite, symmetric matrix by using the Cholesky decomposition to compute the inverse. The standard MATLAB inv function uses LU decomposition which requires twice as many operations as the Cholesky decomposition and is less accurate. Rarely does one need to compute the inverse of a matrix (e.g. when solving a linear system, we should use \), but when it is needed (e.g. least squares or Kalman Filtering applications), the matrix is positive definite and symmetric. Thus, we can speed up and improve the accuracy of the computation by using the Cholesky decomposition. Because the Cholesky decomposition takes half as many operations, the algorithm will decrease run-time by about 50% for large matrices. Accuracy is also improved with some examples showing orders of magnitude improvement (see Felix Govaers's comment).

Cite As

Eric Blake (2024). Fast and Accurate Symmetric Positive Definite Matrix Inverse Using Cholesky Decomposition (https://www.mathworks.com/matlabcentral/fileexchange/34511-fast-and-accurate-symmetric-positive-definite-matrix-inverse-using-cholesky-decomposition), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2011b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.11.0.0

Added more tags.

1.10.0.0

Modified the title and description to acknowledge that numerical accuracy is also improved by using the Cholesky decomposition.

1.9.0.0

Updated test to use larger matrices, and updated description to emphasize the run-time savings on large matrices.

1.8.0.0

Fixed double/float error in invChol_mex.c.

1.7.0.0

Changed the description image.

1.6.0.0

Fixed implicit function declaration warnings, and included support for mac. Also updated the code to throw an error if complex arrays are encountered.

1.5.0.0

Updated the description to be more precise (symmetric positive definite, not symmetric). Compilation and test m-file now runs a test on a large matrix as well as a sequence of smaller matrices.

1.4.0.0

Updated invChol_mex.c comments to support Linux ("/*" instead of "//") as well as improved error catching on inputs. Updated the included m-file to perform compilation on Windows 32 and 64 bit as well as Linux 32 and 64 bit.

1.3.0.0

Updated invChol_mex.c to support float and use mxDuplicateArray instead of memcpy to duplicate the input array.

1.2.0.0

Updated the summary to be more descriptive. We use LAPACK and Cholesky Decomposition.

1.1.0.0

The test matrix must be non-sparse for invChol.

1.0.0.0