Skip to content

Prevent runaway QL #183

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "InfiniteLinearAlgebra"
uuid = "cde9dba0-b1de-11e9-2c62-0bab9446c55c"
version = "0.8.2"
version = "0.8.3"

[deps]
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
Expand Down
6 changes: 3 additions & 3 deletions src/infql.jl
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ function initialadaptiveQLblock(A::AbstractMatrix{T}, tol) where T
Ll = ql(A[checkinds:2N,checkinds:2N]).L[2:j-checkinds+1,2:j-checkinds+1]
# compare bottom right sections and stop if desired level of convergence achieved
Lerr = norm(Ll-Ls,2)
if N == maxN
if N >= maxN
error("Reached max. iterations in adaptive QL without convergence to desired tolerance.")
end
Ls = Ll
Expand Down Expand Up @@ -449,7 +449,7 @@ function cache_filldata!(A::AdaptiveQLFactors{T}, inds::UnitRange{Int}) where T
Ll = ql(A.M[checkinds:2N,checkinds:2N]).L[2:j-checkinds+1,2:j-checkinds+1]
# compare bottom right sections and stop if desired level of convergence achieved
Lerr = norm(Ll-Ls,2)
if N == maxN
if N >= maxN
error("Reached max. iterations in adaptive QL without convergence to desired tolerance.")
end
Ls = Ll
Expand All @@ -470,7 +470,7 @@ function cache_filldata!(A::AdaptiveQLTau{T}, inds::UnitRange{Int}) where T
Ll = ql(A.M[checkinds:2N,checkinds:2N]).L[2:j-checkinds+1,2:j-checkinds+1]
# compare bottom right sections and stop if desired level of convergence achieved
Lerr = norm(Ll-Ls,2)
if N == maxN
if N >= maxN
error("Reached max. iterations in adaptive QL without convergence to desired tolerance.")
end
Ls = Ll
Expand Down
6 changes: 5 additions & 1 deletion test/test_infql.jl
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,10 @@ using ArrayLayouts: TriangularLayout, UnknownLayout
@test (L*b)[1:6] == ApplyArray(*,L,b)[1:6] == [0. , -5.25, -7.833333333333333, -2.4166666666666666, -1., 0.]
@test size(ql(A).τ) == (ℵ₀, )
end
@testset "Naive extremely long / infinite loop protection" begin
A = _BandedMatrix(Vcat((((0:∞)))', (((1:∞)).+1/4)', Ones(1,∞)./3), ℵ₀, 1, 1)
@test_throws ErrorException("Reached max. iterations in adaptive QL without convergence to desired tolerance.") ql(A)
end
@testset "Explicit tolerance tests" begin
Asym = LinearAlgebra.SymTridiagonal([[1.,2.]; Fill(3.,∞)], [[1., 2.]; Fill(1.,∞)])
Aplain = LinearAlgebra.Tridiagonal([[1., 2.]; Fill(1.,∞)], [[1.,2.]; Fill(3.,∞)], [[1., 2.]; Fill(1.,∞)])
Expand Down Expand Up @@ -287,4 +291,4 @@ using ArrayLayouts: TriangularLayout, UnknownLayout
Q,L = ql(A)
@test (Q*L)[1:10,1:10] ≈ A[1:10,1:10]
end
end
end
Loading