Skip to content

Commit 2690b27

Browse files
Relax method for sigma from Real to Number and order eigenvalues at the end of the computation
1 parent d33e88f commit 2690b27

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/qobj/eigsolve.jl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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))
@@ -309,7 +314,7 @@ Solve for the eigenvalues and eigenvectors of a matrix `A` using the Arnoldi met
309314
function 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

Comments
 (0)