Is there a rank revealing qr decomposition?

I am currently looking for a qr decomposition of a matrix A ≈ QR with A being n×m, Q being n×r and A being r×m where r is the rank of A (with respect to some cut-off threshold).
I’ve played around a bit with qr from the LinearAlgebra package, but it seems like it has this functionality.
Also, there already exists a thread regarding this topic from some years ago (/t/rank-revealing-qr-svd-decompositions), however there does not seem to be an answer.

I’m sure it’s not quite what you want, but note that QR with pivoting (qr(A, ColumnNorm())) will reveal the rank though it does compute the whole QR even for low rank matrices.

2 Likes

I looked a little into this in April 2020 (or so; the early phase of Covid). There is a MATLAB routine, but my understanding was that the algorithm was “copyrighted”. I played around a little with it, and thought I had found a way to do it (I wanted one that worked for matrices with eltype being integers and fractions in addition to floats…), but the code was not efficient, and I kind of gave up on it. But I’m interesting in it if there is a good algorithm.

1 Like

If this isn’t acceptable, then there are early-terminating algorithms in GitHub - JuliaLinearAlgebra/LowRankApprox.jl: Fast low-rank matrix approximation in Julia

2 Likes

I could be wrong but looks like LAPACK 3.12 has a new routine GEQP3RK which only computes a truncated QR decomposition. If the atol or rtol criterion is used it will automatically figure out the numerical rank and stop factorization at that point, (The routine itself is more general and can be made to. stop factorization after a prespecified KMAX no of columns), though i don’t think this has been implemented in LinearAlgebra.jl . The release notes for LAPACK 3.12 also mentions this

1 Like

That’s exactly what I was looking for, thank you very much.