Skip to content

Commit 5b7f4c5

Browse files
authored
Fix eigvals(:::SymTridagonal) with longer off-diagonal vector (#40165)
* Fix eigvals(:::SymTridagonal) with longer off-diagonal vector * Update tridiag.jl * Update lapack.jl * Revert "Update lapack.jl" This reverts commit 5c40476. * Update lapack.jl
1 parent c87d85f commit 5b7f4c5

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

stdlib/LinearAlgebra/src/lapack.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3775,8 +3775,8 @@ for (stev, stebz, stegr, stein, elty) in
37753775
require_one_based_indexing(dv, ev)
37763776
chkstride1(dv, ev)
37773777
n = length(dv)
3778-
if length(ev) != n - 1
3779-
throw(DimensionMismatch("ev has length $(length(ev)) but needs one less than dv's length, $n)"))
3778+
if length(ev) != n - 1 && length(ev) != n
3779+
throw(DimensionMismatch("ev has length $(length(ev)) but needs one less than or equal to dv's length, $n)"))
37803780
end
37813781
Zmat = similar(dv, $elty, (n, job != 'N' ? n : 0))
37823782
work = Vector{$elty}(undef, max(1, 2n-2))

stdlib/LinearAlgebra/test/lapack.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ end
407407
@testset for elty in (Float32, Float64)
408408
d = rand(elty,10)
409409
e = rand(elty,9)
410-
@test_throws DimensionMismatch LAPACK.stev!('U',d,rand(elty,10))
410+
@test_throws DimensionMismatch LAPACK.stev!('U',d,rand(elty,11))
411411
@test_throws DimensionMismatch LAPACK.stebz!('A','B',zero(elty),zero(elty),0,0,-1.,d,rand(elty,10))
412412
@test_throws DimensionMismatch LAPACK.stegr!('N','A',d,rand(elty,11),zero(elty),zero(elty),0,0)
413413
@test_throws DimensionMismatch LAPACK.stein!(d,zeros(elty,10),zeros(elty,10),zeros(BlasInt,10),zeros(BlasInt,10))

stdlib/LinearAlgebra/test/tridiag.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ end
589589
A2 = SymTridiagonal(fill(1.0, 3), fill(-1.0, 2))
590590
F2 = eigen(A2)
591591
test_approx_eq_modphase(F.vectors, F2.vectors)
592-
@test F.values F2.values
592+
@test F.values F2.values eigvals(A) eigvals(A2)
593593
end
594594

595595
@testset "non-commutative algebra (#39701)" begin

0 commit comments

Comments
 (0)