Efficient QR factorization

Hello,

I’m having some issues with QR factorization in Julia 1.0. I want to efficiently compute the QR factorization of the transpose of a matrix and save only Q. Back in 0.6, there were LAPACK functions that did this efficiently and in-place. Now, it looks like I’m stuck with qr(A').Q.

qr! does not accept transposes or adjoints, and the seemingly efficient LAPACK functions require a tau argument which I’m confused about.

Any help is appreciated.

Back in 0.6 A' made a copy, is that the issue? LAPACK doesn’t support QR on transposes directly it looks like, see dgeqrf. Though I believe it can be recovered from the LQ decomposition, see dgelqf. This would never have been used in previous versions of Julia.

If you wish to wrap this, MatrixFactorizations.jl would be a natural place to make a PR. It already supports QL.

1 Like

Back in 0.6 I could use qrfact!(A')[:Q], which wasn’t ideal but seemed better than what I’m doing at the moment since it was in place.

I suggest you benchmark your code to see if “inplace” operations really give any speedup here. Allocating memory should be really fast compared to actually performing the QR-decomposition. A' in Julia 0.6 is copy(A') in Julia 1.0, so it’s not really “fully” inplace since it does the copying first. But even that copying should be much faster than actually performing the QR decomposition.

3 Likes