@@ -266,7 +266,12 @@ function _eigsolve(
266266 vals = diag (view (Tₘ, 1 : k, 1 : k))
267267 VR = _schur_right_eigenvectors (Tₘ, k)
268268 mul! (cache1₁ₖ, Vₘ, M (Uₘ * VR))
269- vecs = copy (cache1₁ₖ)
269+
270+ # Order the eigenvalues and eigenvectors
271+ idxs = sortperm (vals, by = sortby, rev = rev)
272+ vals = vals[idxs]
273+ vecs = cache1₁ₖ[:, idxs]
274+
270275 settings. auto_tidyup && tidyup! (vecs)
271276
272277 return EigsolveResult (vals, vecs, type, dimensions, iter, numops, (iter < maxiter))
275280@doc raw """
276281 eigsolve(A::QuantumObject;
277282 v0::Union{Nothing,AbstractVector}=nothing,
278- sigma::Union{Nothing, Real }=nothing,
283+ sigma::Union{Nothing, Number }=nothing,
279284 eigvals::Int = 1,
280285 krylovdim::Int = max(20, 2*k+1),
281286 tol::Real = 1e-8,
@@ -290,7 +295,7 @@ Solve for the eigenvalues and eigenvectors of a matrix `A` using the Arnoldi met
290295# Arguments
291296- `A::QuantumObject`: the [`QuantumObject`](@ref) to solve eigenvalues and eigenvectors.
292297- `v0::Union{Nothing,AbstractVector}`: the initial vector for the Arnoldi method. Default is a random vector.
293- - `sigma::Union{Nothing, Real }`: the shift for the eigenvalue problem. Default is `nothing`.
298+ - `sigma::Union{Nothing, Number }`: the shift for the eigenvalue problem. Default is `nothing`.
294299- `eigvals::Int`: the number of eigenvalues to compute. Default is `1`.
295300- `krylovdim::Int`: the dimension of the Krylov subspace. Default is `max(20, 2*k+1)`.
296301- `tol::Real`: the tolerance for the Arnoldi method. Default is `1e-8`.
@@ -309,7 +314,7 @@ Solve for the eigenvalues and eigenvectors of a matrix `A` using the Arnoldi met
309314function eigsolve (
310315 A:: QuantumObject ;
311316 v0:: Union{Nothing,AbstractVector} = nothing ,
312- sigma:: Union{Nothing,Real } = nothing ,
317+ sigma:: Union{Nothing,Number } = nothing ,
313318 eigvals:: Int = 1 ,
314319 krylovdim:: Int = max (20 , 2 * eigvals + 1 ),
315320 tol:: Real = 1e-8 ,
@@ -341,7 +346,7 @@ function eigsolve(
341346 v0:: Union{Nothing,AbstractVector} = nothing ,
342347 type:: Union{Nothing,Operator,SuperOperator} = nothing ,
343348 dimensions = nothing ,
344- sigma:: Union{Nothing,Real } = nothing ,
349+ sigma:: Union{Nothing,Number } = nothing ,
345350 eigvals:: Int = 1 ,
346351 krylovdim:: Int = max (20 , 2 * eigvals + 1 ),
347352 tol:: Real = 1e-8 ,
0 commit comments