diff --git a/stdlib/LinearAlgebra/src/tridiag.jl b/stdlib/LinearAlgebra/src/tridiag.jl index 41e038ec2e1b1..99de21d4bd76d 100644 --- a/stdlib/LinearAlgebra/src/tridiag.jl +++ b/stdlib/LinearAlgebra/src/tridiag.jl @@ -170,7 +170,7 @@ adjoint(S::SymTridiagonal) = Adjoint(S) Base.copy(S::Adjoint{<:Any,<:SymTridiagonal}) = SymTridiagonal(map(x -> copy.(adjoint.(x)), (S.parent.dv, S.parent.ev))...) Base.copy(S::Transpose{<:Any,<:SymTridiagonal}) = SymTridiagonal(map(x -> copy.(transpose.(x)), (S.parent.dv, S.parent.ev))...) -ishermitian(S::SymTridiagonal) = isreal(S.dv) && isreal(S.ev) +ishermitian(S::SymTridiagonal) = isreal(S.dv) && isreal(@view S.ev[begin:length(S.dv) - 1]) issymmetric(S::SymTridiagonal) = true function diag(M::SymTridiagonal{<:Number}, n::Integer=0) diff --git a/stdlib/LinearAlgebra/test/tridiag.jl b/stdlib/LinearAlgebra/test/tridiag.jl index 7da5fc85c0296..079c7aa0d5a91 100644 --- a/stdlib/LinearAlgebra/test/tridiag.jl +++ b/stdlib/LinearAlgebra/test/tridiag.jl @@ -632,6 +632,12 @@ end @test !ishermitian(A) # complex + # https://github.com/JuliaLang/julia/pull/41037#discussion_r645524081 + S = SymTridiagonal(randn(5) .+ 0im, randn(5) .+ 0im) + S.ev[end] = im + @test issymmetric(S) + @test ishermitian(S) + S = SymTridiagonal(randn(5) .+ 1im, randn(4) .+ 1im) @test issymmetric(S) @test !ishermitian(S)