# Is it possible to prevent LUDecomposition from pivoting?

By construction, LUDecomposition performs LU-decomposition with pivoting; i.e., with row permutations (otherwise, the decomposition may not exist). Is it possible to tell Mathematica not to use pivoting in cases when the decomposition can be performed without it?

• It seems LAPACK does not have a no-pivot routine, but MKL does. I can't find an access point within Mathematica, but maybe there is some way to use it. Commented Dec 7, 2017 at 20:38
• This seems to work N@LUDecomposition[SetPrecision[m, Infinity]], but it will be slower than machine precision. Commented Dec 7, 2017 at 20:42
• @MichaelE2 if BLAS has it Mathematica might expose that. Commented Mar 26, 2018 at 8:59
• @b3m2a1, the subset of level-3 BLAS in Mathematica does not have a routine for LU decomposition. Commented Mar 26, 2018 at 9:23
• @MichaelE2 I might be remembering incorrectly, but I believe the exact integer/rational case also uses a pivot strategy, just a different one from the approximate numeric case. Commented Mar 26, 2018 at 13:20

Here's one way to cheat LUDecomposition[]:

BlockRandom[SeedRandom[42]; mat = RandomReal[{1, 2}, {3, 3}]];

{lu, piv, cond} = LUDecomposition[Map[Interval[{#, #}] &, mat, {2}]] /.
Interval -> Mean;

Norm[(LowerTriangularize[lu, -1] + IdentityMatrix[Length[lu]]).
UpperTriangularize[lu] - mat, ∞]
6.66134*10^-16


As another example, let's use this trick to get the Cholesky triangle corresponding to a symmetric positive definite matrix:

mat = N[HilbertMatrix[6]];
lu = First[LUDecomposition[Map[Interval[{#, #}] &, mat, {2}]] /. Interval -> Mean];


Form the Cholesky triangle:

ch1 = DiagonalMatrix[1/Sqrt[Diagonal[lu]]].UpperTriangularize[lu];


Compare with the result of CholeskyDecomposition[]:

Norm[ch1 - CholeskyDecomposition[mat], ∞]
1.15992*10^-13