Skip to content

Commit c25b704

Browse files
authored
Fix of null column error in geqrf! and gerqf! (#42844)
* Fix of null column error in geqrf! and gerqf! * Added tests * Trailing blanks removed * Correct issue number * Adjusted lwork to max(m, 1, Int(real(work[1]))) * Fine tuning
1 parent 017a3af commit c25b704

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

stdlib/LinearAlgebra/src/lapack.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ for (gebrd, gelqf, geqlf, geqrf, geqp3, geqrt, geqrt3, gerqf, getrf, elty, relty
523523
m, n, A, max(1,stride(A,2)), tau, work, lwork, info)
524524
chklapackerror(info[])
525525
if i == 1
526-
lwork = BlasInt(real(work[1]))
526+
lwork = max(BlasInt(1),BlasInt(real(work[1])))
527527
resize!(work, lwork)
528528
end
529529
end
@@ -552,7 +552,7 @@ for (gebrd, gelqf, geqlf, geqrf, geqp3, geqrt, geqrt3, gerqf, getrf, elty, relty
552552
m, n, A, max(1,stride(A,2)), tau, work, lwork, info)
553553
chklapackerror(info[])
554554
if i == 1
555-
lwork = BlasInt(real(work[1]))
555+
lwork = max(BlasInt(m), BlasInt(real(work[1])))
556556
resize!(work, lwork)
557557
end
558558
end

stdlib/LinearAlgebra/test/lapack.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,4 +705,10 @@ end
705705
# # https://github.com/JuliaLang/julia/pull/39845
706706
@test LinearAlgebra.LAPACK.liblapack == "libblastrampoline"
707707

708+
# Issue #42762 https://github.com/JuliaLang/julia/issues/42762
709+
# Tests geqrf! and gerqf! with null column dimensions
710+
a = zeros(2,0), zeros(0)
711+
@test LinearAlgebra.LAPACK.geqrf!(a...) === a
712+
@test LinearAlgebra.LAPACK.gerqf!(a...) === a
713+
708714
end # module TestLAPACK

0 commit comments

Comments
 (0)