-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LinearAlgebra: specialize is{hermitian,symmetric} for {Sym,}Tridiagonal #41037
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some simplifications.
stdlib/LinearAlgebra/src/tridiag.jl
Outdated
ishermitian(S::SymTridiagonal{<:Real}) = true | ||
ishermitian(S::SymTridiagonal{<:Complex}) = all(x -> imag(x) == 0, S.dv) && all(x -> imag(x) == 0, S.ev) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ishermitian(S::SymTridiagonal{<:Real}) = true | |
ishermitian(S::SymTridiagonal{<:Complex}) = all(x -> imag(x) == 0, S.dv) && all(x -> imag(x) == 0, S.ev) | |
ishermitian(S::SymTridiagonal) = isreal(S.dv) && isreal(S.ev) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clearer, but slightly slower (by ~50ns) on my machine with S = SymTridiagonal(rand(100) .+ 0im, rand(100) .+ 0im)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what isreal
is good for, and we use it even internally in LinearAlgebra
for that purpose.
…nal) SymTridiagonal allows `dv` and `ev` to have the same length, in which case the last element of `ev` isn't part of the matrix. Thus it doesn't matter, and should be ignored when checking if `ev` is real. Thanks to @sostock for pointing this out in JuliaLang#41037 (comment)
No description provided.