Discussion:
[Numpy-discussion] qr decomposition with column pivoting/qr decomposition with householder reflections
traveller3141
2007-06-22 03:49:43 UTC
Permalink
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?

Thanks,
Steven
Charles R Harris
2007-06-24 23:27:48 UTC
Permalink
Post by traveller3141
I'm in the process of trying to convert some Matlab code into Python.
[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".
There is a qr version in numpy, numpy.linalg.qr, but it only returns the
factors q and r. The underlying lapack routines are {dz}geqrf and {dz}orgqr,
the latter converting the product of Householder reflections into the
orthogonal matrix q. Column pivoting is not used in {dz}geqrf, but it *is*
used in {dz}geqpf. The versions with column pivoting are probably more
accurate and also allow fixing certain columns to the front of the array, a
useful thing in some cases, so I don't know why we chose the first rather
than the second. I suspect the decision was made in Numeric long ago and the
simplest function was chosen. The column pivoting version isn't in scipy
either and it probably should be. If you need it, it shouldn't be hard to
add.

Chuck

Loading...