Tidy up eig() return values

This commit is contained in:
Nuwan Yapa 2023-04-07 22:27:40 -04:00
parent a8a7bdb44f
commit 65775cf9be
1 changed files with 2 additions and 1 deletions

View File

@ -131,7 +131,7 @@ end
tolerance = 1e-6
"Wrapper for KrylovKit.eigsolve"
function eig(H::Hamiltonian{T}, levels::Int; resonances = !H.hermitian)::Tuple{Vector{Complex{T}},Any,Any} where {T<:Float}
function eig(H::Hamiltonian{T}, levels::Int; resonances = !H.hermitian)::Tuple{Vector,Vector,KrylovKit.ConvergenceInfo} where {T<:Float}
if H.mode == cpu_tensor
x₀ = rand(Complex{T}, vectorDims(H)...)
elseif H.mode == gpu_cutensor
@ -140,5 +140,6 @@ function eig(H::Hamiltonian{T}, levels::Int; resonances = !H.hermitian)::Tuple{V
end
evals, evecs, info = eigsolve(H, x₀, levels, resonances ? :LI : :SR; ishermitian = H.hermitian, tol = tolerance)
resonances || info.converged < levels && throw(error("Not enough convergence")) # don't check convergence for resonances
if H.hermitian evals = real.(evals) end
return evals, evecs, info
end