Allow QR decomposition for zero-row matrices.
Closed this issue · 2 comments
This came up in DynareJulia/FastLapackInterface.jl#39
Currently, Julia allows for QR decomposition of zero-column matrices by skipping the call to LAPACK with a simple conditional [in this line].(
julia/stdlib/LinearAlgebra/src/lapack.jl
Line 456 in 923fe2d
Zero-row matrices are not supported and give an argument error:
LA.qr(zeros(0, 10))
** On entry to DGEQRT parameter number 3 had an illegal value
ERROR: ArgumentError: invalid argument #3 to LAPACK call
Is there a reason for this?
The data type should support these matrices:
import LinearAlgebra as LA
A = Matrix{Float64}(undef, 0, 10)
T = Matrix{Float64}(undef, 0, 0)
qr = LA.QRCompactWY(A, T)
and qr
is as I would expect it.
Would it fix the issue if we changed the condition to
n > 0 && m > 0
so that we go down the LAPACK path only in the LAPACK-valid cases ? If yes, would you be able to submit a PR, together with unit tests?
That would indeed be sufficient. I will prepare a PR until tomorrow evening.
Edit: Will habe to delay for one or two days, other things got in the way. This line has stood for 11 years, so it is not too urgent, I guess 😅