How can I find partial pivoting matrix $P$ from $PA=LU$ decomposition if we know $A,L,U$?

Assume that we have this equation

$$PA=LU$$

Where $$A \in \Re^{mxn}$$, $$L \in \Re^{mxn}$$ is a lower triangular matrix and $$U \in \Re^{nxn}$$ is an upper triangular matrix. $$P \in \Re^{mxm}$$ is the partial pivoting matrix.

In this case, $$A,U,L$$ are known. How can I find $$P$$?

Can I take

$$P = LUA^{\dagger}$$

?

• Every algorithm for computing LU decomposition with partial pivoting gives you also $P$ in some way. Why would you do this? – Algebraic Pavel Feb 24 at 0:37
• Because I using Lapack subroutine dgetrf_ , and the P-matrix is not a matrix, it's more like a vector that describe how the P-matrix should be. That's not a problem. The real problem is that the P-vector is one element to short. I think it's a bug inside dgetrf_. Here is an example: github.com/DanielMartensson/EmbeddedLapack/blob/master/… – Daniel Mårtensson Feb 24 at 1:17
• @AlgebraicPavel If you want to contribute with some C-code for solving the pivot matrix, it would be very helpfull for this free library. – Daniel Mårtensson Feb 24 at 1:18
• What do you mean by one element too short? – Algebraic Pavel Feb 24 at 12:11
• @AlgebraicPavel It seems that Lapack solve $A=PLU$ and MATLAB solve $PA=LU$. I have now made so Lapack solve $PA=LU$ :) Just look at the lu.c file from github.com/DanielMartensson/EmbeddedLapack – Daniel Mårtensson Feb 24 at 17:02

1 Answer

Yes, this is correct.

Your problem seems to be that LAPACK doesn't return the pivoting matrix, but a permutation vector. This thread might help: http://icl.cs.utk.edu/lapack-forum/viewtopic.php?f=2&t=1747