Skip to content

Commit b0722e3

Browse files
committed
✨ Further allocations improvement
1 parent fdd7bbd commit b0722e3

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/spectrum.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,10 @@ function _spectrum(
247247
end
248248

249249
# Check for convergence
250-
maxResidue =
251-
mapreduce((x, y) -> abs(x - y), max, lanczosFactor, lanczosFactor₋₁) /
252-
max(maximum(abs, lanczosFactor), maximum(abs, lanczosFactor₋₁))
250+
251+
residueNorm = max(maximum(abs, lanczosFactor), maximum(abs, lanczosFactor₋₁))
252+
lanczosFactor₋₁ .-= lanczosFactor
253+
maxResidue = maximum(abs, lanczosFactor₋₁) / residueNorm
253254
if maxResidue <= solver.tol
254255
if solver.verbose > 1
255256
println("spectrum(): solver::Lanczos converged after $(k) iterations")

0 commit comments

Comments
 (0)