JuliaLang / julia

The Julia Programming Language
https://julialang.org/
MIT License
45.48k stars 5.46k forks source link

`schur` fails for zero dimension matrices #36957

Closed andreasvarga closed 3 years ago

andreasvarga commented 4 years ago

The function schur fails for zero dimension matrices:

julia> schur(zeros(0,0),ones(0,0))
 ** On entry to DGGES PMGTL parameter number 15 had an illegal value
ERROR: ArgumentError: invalid argument #15 to LAPACK call
Stacktrace:
 [1] gges!(::Char, ::Char, ::Array{Float64,2}, ::Array{Float64,2}) at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.3\LinearAlgebra\src\lapack.jl:36
 [2] schur! at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.3\LinearAlgebra\src\schur.jl:252 [inlined]
 [3] schur(::Array{Float64,2}, ::Array{Float64,2}) at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.3\LinearAlgebra\src\schur.jl:268   
 [4] top-level scope at REPL[4]:1

The fix is easy: in the function LAPACK.gges! the parameters ldvsl and ldvsr must be set to max(1,n).

andreasvarga commented 4 years ago

I realize this is not a high priority issue. It could be equally be an issue for LAPACK.

StefanKarpinski commented 4 years ago

Reopening since this should work, regardless of whether it's a high priority to fix or not.