It seems like the function
qr doesn’t take keywords argument to return an economy-sized factorization.
In this thread qr(A; full=false) no longer available? · Issue #27397 · JuliaLang/julia · GitHub they say that the internal representation is efficient so it shouldn’t be a problem. But when it comes to do matrix multiplications with the Q factor I get weird performances.
Here is an example:
function fun1() A = randn(10000, 500) B = randn(10000, 500) Q, R = qr(A) return Q * B end function fun2() A = randn(10000, 500) B = randn(500, 500) Q, R = qr(A) return Q * B end
fun2 should use the thin QR when evaluating the product
Q * B.
But when we time the functions
using BenchmarkTools @btime fun1(); @btime fun2();
we find that
fun2 is as slow as
fun1, or even slower because there are more allocations.
So my question would be: how to take advantage of the thin QR decomposition to get better performances?
Side note: If I try to do the multiplication with
Q[:, 1:500] * B it is even slower (actually it takes forever – not sure what’s happening here).