I'm in the process of trying to convert some Matlab code into Python. There's a statement of the form:

[q,r,e] = qr(A)

which performs a qr-decomposition of A, but then also returns a 'permutation' matrix. The purpose of this is to ensure that the values along r's diagonal are decreasing. I believe this technique is called "qr decomposition with column pivoting" or (equivalently) "qr decomposition with householder reflections".

I have not been able to find an implementation of this within numpy. Does one exist? Or should I come to truly understand this algorithm (prob'ly a good idea regardless) and implement it?