[SciPy-dev] QR factorization: modifications
Bart Vandereycken
bart.vandereycken at cs.kuleuven.be
Fri Jun 30 09:25:21 CDT 2006
Hi all,
I've modified the QR routine in scipy.linalg.qr in 3 ways, to make it
faster and more compatible with Matlab.
This is my first patch so any feedback is appreciated... you can find
the files here: http://www.cs.kuleuven.be/~bartvde/scipy/
1) The original method used only one LAPACK-routine (GEQRF) to compute
the R factor, but NOT the (xORGQR and xUNGQR) to compute the Q factor.
This is a huge efficiency loss, see the figure at my site for a
comparison of the old and new qr method.
I included the 2 LAPACK-wrappers in patch_flapack.diff and the new qr
method in patch_qr.diff. (I don't use clapack, so I can't test this.)
The old qr method is still available as qr_old in case you want to
compare the results, use test_qr.py ;-)
2) You can compute economy-sized (as Matlab calls it) or skinny QR
factorizations for tall matrices (more rows than cols). The performance
gain should be obvious now.
3) If you only want the R factor and not the Q, the method stops early
and is 2 times faster.
Testing for test_decompy.py is included in patch_test.diff.
There are 2 new parameters for scipy.decomp.qr:
econ=False: economy size or not
-> Matlab's qr(A,0)
mode='qr': 'qr' or 'r' (or 'qre', qr with Givens rotations, maybe I'll
do this later)
-> Matlab's Q,R=qr(A) or R=qr(A) or Q,R,E=qr(A)
Bart
More information about the Scipy-dev
mailing list