LU factorization with complete pivoting.
To compute the LU factorization under default settings:
[L U p q] = lucp(A)
This produces a factorization such that L*U = A(p,q). Vectors p and q permute the rows and columns, respectively.
The pivot tolerance can be controlled:
[L U p q] = lucp(A,tol)
The algorithm will terminate if the absolute value of the pivot is less than tol.
Permutation matrices can be generated:
[L U P Q] = lucp(A,tol,'matrix')
[L U P Q] = lucp(A,tol,'sparse')
The first will generate full permutation matrices P and Q such that L*U = P*A*Q. The second generates sparse P and Q.
If A is sparse, L and U will be sparse. However, no effort is taken to reduce fill in.
This function works on non-square matrices.
Cite As
Nick Henderson (2025). LU factorization with complete pivoting. (https://www.mathworks.com/matlabcentral/fileexchange/27249-lu-factorization-with-complete-pivoting), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxCategories
- MATLAB > Mathematics > Sparse Matrices >
Tags
Acknowledgements
Inspired by: Gauss elimination with complete pivoting, Gaussian Elimination using Complete Pivoting
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.