Skip to content

Commit fce5537

Browse files
committed
📝 Implement @ytdHuang's suggestions
1 parent eb1722f commit fce5537

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

src/spectrum.jl

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,12 @@ A solver which solves [`spectrum`](@ref) by using a non-symmetric Lanczos varian
3333
The nonsymmetric Lanczos algorithm is adapted from Algorithm 6.6 in [Saad2011](https://www-users.cse.umn.edu/~saad/eig_book_2ndEd.pdf).
3434
The running estimate is updated via a [Wallis-Euler recursion](https://en.wikipedia.org/wiki/Continued_fraction).
3535
"""
36-
struct Lanczos{T<:Real,IT<:Int} <: SpectrumSolver
37-
tol::T
38-
maxiter::IT
39-
verbose::IT
36+
Base.@kwdef struct Lanczos{T<:Real,IT<:Int} <: SpectrumSolver
37+
tol::T = 1e-8
38+
maxiter::IT = 5000
39+
verbose::IT = 0
4040
end
4141

42-
Lanczos(; tol = 1e-8, maxiter = 5000, verbose = 0) = Lanczos(tol, maxiter, verbose)
43-
4442
@doc raw"""
4543
spectrum(H::QuantumObject,
4644
ωlist::AbstractVector,
@@ -166,7 +164,6 @@ function _spectrum(
166164
A::QuantumObject{Operator},
167165
B::QuantumObject{Operator},
168166
solver::Lanczos;
169-
kwargs...,
170167
)
171168
check_dimensions(L, A, B)
172169

@@ -283,12 +280,10 @@ function _spectrum(
283280
B₋₁ .= Bₖ
284281
end
285282

286-
if solver.verbose > 0
287-
if maxResidue > solver.tol
288-
println("spectrum(): maxiter = $(solver.maxiter) reached before convergence!")
289-
println("spectrum(): Max residue = $maxResidue")
290-
println("spectrum(): Consider increasing maxiter and/or tol")
291-
end
283+
if solver.verbose > 0 && maxResidue > solver.tol
284+
println("spectrum(): maxiter = $(solver.maxiter) reached before convergence!")
285+
println("spectrum(): Max residue = $maxResidue")
286+
println("spectrum(): Consider increasing maxiter and/or tol")
292287
end
293288

294289
# Restore the norm

0 commit comments

Comments
 (0)