Assume that we have this equation


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}$$


  • 1
    $\begingroup$ Every algorithm for computing LU decomposition with partial pivoting gives you also $P$ in some way. Why would you do this? $\endgroup$ – Algebraic Pavel Feb 24 '19 at 0:37
  • $\begingroup$ 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/… $\endgroup$ – Daniel Mårtensson Feb 24 '19 at 1:17
  • $\begingroup$ @AlgebraicPavel If you want to contribute with some C-code for solving the pivot matrix, it would be very helpfull for this free library. $\endgroup$ – Daniel Mårtensson Feb 24 '19 at 1:18
  • $\begingroup$ What do you mean by one element too short? $\endgroup$ – Algebraic Pavel Feb 24 '19 at 12:11
  • $\begingroup$ @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 $\endgroup$ – Daniel Mårtensson Feb 24 '19 at 17:02

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


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.