I am looking for a way to achieve the PLUR decomposition of a maitrx, as given in this paper here.
The equivalent syntax in Maple is:
LUDecomposition(A, output=['P','L','U1','R'])
as detailed in here.
I 'hope' that works for both numerical and symbolic matrices, just like the one in Maple.
Here is my attempted:
ClearAll[myPLUR];
myPLUR[matrix_] := Module[
{PA, lu, P, L, U, R, x1, x2},
{lu, x1, x2} = LUDecomposition[matrix] // Quiet;
P = Inverse[Part[IdentityMatrix[Length[x1]], x1]];
PA = P.matrix;
R = RowReduce[matrix];
U = UpperTriangularize[lu];
U = U.Transpose[R].Inverse[R.Transpose[R]];
L = matrix.Transpose[R].Transpose[U].Inverse[U.R.Transpose[R].Transpose[U]] // FullSimplify;
FullSimplify[{P, L, U, R}]
];
Original example in the paper:
A = {
{3, 4, -2, 1, -2},
{1, -1, 2, 2, 7},
{4, -3, 4, -3, 2},
{-1, 1, 6, -1, 1}
}
ans = myPLUR[A];
ans[[2]].ans[[3]].ans[[4]] - A // FullSimplify
{{0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}}
ans = myPLUR[A];
ans[[1]].ans[[2]].ans[[3]].ans[[4]] - A // FullSimplify
{{-4, -3, 8, -2, 3}, {2, 5, -4, -1, -9}, {-3, 2, -2, 5, 5}, {5, -4, -2, -2, 1}}
The code with my problem are:
'L' is not lower triangular and 'P' is still not quite right (LUR gives the original matrix, but PLUR cannot).