You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@testset"Convergence rate"begin# Regression test for issue #375: ensures Chebyshev uses correct recurrence u_{k+1} = c + β*u_k# (not the buggy c + β*c). This test verifies convergence happens faster than a simple# Richardson iteration, which would use c + β*c.for T in (Float32, Float64)
# Create a well-conditioned SPD matrix where Chebyshev should converge quickly
n =20
A =Tridiagonal(T.(fill(-1.0, n-1)), T.(fill(2.0, n)), T.(fill(-1.0, n-1)))
b =ones(T, n)
x0 =zeros(T, n)
λ_min, λ_max =approx_eigenvalue_bounds(A)
# Run Chebyshev with enough iterations to converge
x, history =chebyshev!(copy(x0), A, b, λ_min, λ_max,
reltol=T(1e-6), maxiter=50, log=true, initially_zero=true)
# With the correct recurrence relation, Chebyshev should converge in ~log(1/tol) iterations# With the buggy relation (c + β*c), convergence would be much slower# For this well-conditioned problem, we expect convergence in roughly 20-30 iterations@testniters(history) <35# Strict bound to catch regression@test history.isconverged
@testnorm(A * x - b) /norm(b) <T(1e-6)
endend
Activity
giordano commentedon Sep 14, 2026
More direct link:
IterativeSolvers.jl/src/chebyshev.jl
Line 45 in 36844eb
mkitti commentedon Sep 14, 2026
AI evaluation:
Analysis
This is a valid bug in the Chebyshev iteration recurrence relation.
Line 45 contains an error in the search direction update:
Should be:
Why this matters
The Chebyshev acceleration method relies on a specific recurrence relation to construct optimal search directions. The update should combine:
cheb.c: the current preconditioned residualβ * cheb.u: a scaled version of the previous search directionThe current code incorrectly uses
β * cheb.c(the current residual scaled twice), which:This is a straightforward one-character fix that changes
ctouon line 45.From Github Copilot.
mkitti commentedon Sep 14, 2026
AI suggested regression test:
haampie commentedon Sep 14, 2026
I've merged #367, but it looks like more needs to be done.
Fix the Chebyshev iteration recurrence
Fix the Chebyshev iteration recurrence