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?
1 Answer
$\begingroup$
$\endgroup$
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
N@LUDecomposition[SetPrecision[m, Infinity]]
, but it will be slower than machine precision. $\endgroup$BLAS
has it Mathematica might expose that. $\endgroup$