Skip to content

Commit

Permalink
Update stats.timer in all Krylov methods
Browse files Browse the repository at this point in the history
  • Loading branch information
amontoison committed May 12, 2023
1 parent e2eb7c4 commit fa0da9c
Show file tree
Hide file tree
Showing 33 changed files with 75 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/bicgstab.jl
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ kwargs_bicgstab = (:c, :M, :N, :ldiv, :atol, :rtol, :itmax, :timemax, :verbose,
if rNorm == 0
stats.niter = 0
stats.solved, stats.inconsistent = true, false
stats.timer = ktimer(start_time)
stats.status = "x = 0 is a zero-residual solution"
solver.warm_start = false
return solver
Expand All @@ -204,6 +205,7 @@ kwargs_bicgstab = (:c, :M, :N, :ldiv, :atol, :rtol, :itmax, :timemax, :verbose,
if next_ρ == 0
stats.niter = 0
stats.solved, stats.inconsistent = false, false
stats.timer = ktimer(start_time)
stats.status = "Breakdown bᴴc = 0"
solver.warm_start = false
return solver
Expand Down Expand Up @@ -276,6 +278,7 @@ kwargs_bicgstab = (:c, :M, :N, :ldiv, :atol, :rtol, :itmax, :timemax, :verbose,
stats.niter = iter
stats.solved = solved
stats.inconsistent = false
stats.timer = ktimer(start_time)
stats.status = status
return solver
end
Expand Down
3 changes: 3 additions & 0 deletions src/bilq.jl
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ kwargs_bilq = (:c, :transfer_to_bicg, :atol, :rtol, :itmax, :timemax, :verbose,
stats.niter = 0
stats.solved = true
stats.inconsistent = false
stats.timer = ktimer(start_time)
stats.status = "x = 0 is a zero-residual solution"
solver.warm_start = false
return solver
Expand All @@ -176,6 +177,7 @@ kwargs_bilq = (:c, :transfer_to_bicg, :atol, :rtol, :itmax, :timemax, :verbose,
stats.niter = 0
stats.solved = false
stats.inconsistent = false
stats.timer = ktimer(start_time)
stats.status = "Breakdown bᴴc = 0"
solver.warm_start = false
return solver
Expand Down Expand Up @@ -374,6 +376,7 @@ kwargs_bilq = (:c, :transfer_to_bicg, :atol, :rtol, :itmax, :timemax, :verbose,
stats.niter = iter
stats.solved = solved_lq || solved_cg
stats.inconsistent = false
stats.timer = ktimer(start_time)
stats.status = status
return solver
end
Expand Down
4 changes: 3 additions & 1 deletion src/bilqr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ kwargs_bilqr = (:transfer_to_bicg, :atol, :rtol, :itmax, :timemax, :verbose, :hi
stats.niter = 0
stats.solved_primal = false
stats.solved_dual = false
stats.timer = ktimer(start_time)
stats.status = "Breakdown bᴴc = 0"
solver.warm_start = false
return solver
Expand Down Expand Up @@ -481,9 +482,10 @@ kwargs_bilqr = (:transfer_to_bicg, :atol, :rtol, :itmax, :timemax, :verbose, :hi

# Update stats
stats.niter = iter
stats.status = status
stats.solved_primal = solved_primal
stats.solved_dual = solved_dual
stats.timer = ktimer(start_time)
stats.status = status
return solver
end
end
2 changes: 2 additions & 0 deletions src/cg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ kwargs_cg = (:M, :ldiv, :radius, :linesearch, :atol, :rtol, :itmax, :timemax, :v
if γ == 0
stats.niter = 0
stats.solved, stats.inconsistent = true, false
stats.timer = ktimer(start_time)
stats.status = "x = 0 is a zero-residual solution"
solver.warm_start = false
return solver
Expand Down Expand Up @@ -268,6 +269,7 @@ kwargs_cg = (:M, :ldiv, :radius, :linesearch, :atol, :rtol, :itmax, :timemax, :v
stats.niter = iter
stats.solved = solved
stats.inconsistent = inconsistent
stats.timer = ktimer(start_time)
stats.status = status
return solver
end
Expand Down
2 changes: 2 additions & 0 deletions src/cg_lanczos.jl
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ kwargs_cg_lanczos = (:M, :ldiv, :check_curvature, :atol, :rtol, :itmax, :timemax
stats.solved = true
stats.Anorm = zero(T)
stats.indefinite = false
stats.timer = ktimer(start_time)
stats.status = "x = 0 is a zero-residual solution"
solver.warm_start = false
return solver
Expand Down Expand Up @@ -264,6 +265,7 @@ kwargs_cg_lanczos = (:M, :ldiv, :check_curvature, :atol, :rtol, :itmax, :timemax
stats.solved = solved
stats.Anorm = sqrt(Anorm2)
stats.indefinite = indefinite
stats.timer = ktimer(start_time)
stats.status = status
return solver
end
Expand Down
2 changes: 2 additions & 0 deletions src/cg_lanczos_shift.jl
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ kwargs_cg_lanczos_shift = (:M, :ldiv, :check_curvature, :atol, :rtol, :itmax, :t
if β == 0
stats.niter = 0
stats.solved = true
stats.timer = ktimer(start_time)
stats.status = "x = 0 is a zero-residual solution"
return solver
end
Expand Down Expand Up @@ -269,6 +270,7 @@ kwargs_cg_lanczos_shift = (:M, :ldiv, :check_curvature, :atol, :rtol, :itmax, :t
# Update stats. TODO: Estimate Anorm and Acond.
stats.niter = iter
stats.solved = solved
stats.timer = ktimer(start_time)
stats.status = status
return solver
end
Expand Down
2 changes: 2 additions & 0 deletions src/cgls.jl
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ kwargs_cgls = (:M, :ldiv, :radius, :λ, :atol, :rtol, :itmax, :timemax, :verbose
if bNorm == 0
stats.niter = 0
stats.solved, stats.inconsistent = true, false
stats.timer = ktimer(start_time)
stats.status = "x = 0 is a zero-residual solution"
history && push!(rNorms, zero(T))
history && push!(ArNorms, zero(T))
Expand Down Expand Up @@ -231,6 +232,7 @@ kwargs_cgls = (:M, :ldiv, :radius, :λ, :atol, :rtol, :itmax, :timemax, :verbose
stats.niter = iter
stats.solved = solved
stats.inconsistent = false
stats.timer = ktimer(start_time)
stats.status = status
return solver
end
Expand Down
2 changes: 2 additions & 0 deletions src/cgne.jl
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ kwargs_cgne = (:N, :ldiv, :λ, :atol, :rtol, :itmax, :timemax, :verbose, :histor
if rNorm == 0
stats.niter = 0
stats.solved, stats.inconsistent = true, false
stats.timer = ktimer(start_time)
stats.status = "x = 0 is a zero-residual solution"
return solver
end
Expand Down Expand Up @@ -240,6 +241,7 @@ kwargs_cgne = (:N, :ldiv, :λ, :atol, :rtol, :itmax, :timemax, :verbose, :histor
stats.niter = iter
stats.solved = solved
stats.inconsistent = inconsistent
stats.timer = ktimer(start_time)
stats.status = status
return solver
end
Expand Down
3 changes: 3 additions & 0 deletions src/cgs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ kwargs_cgs = (:c, :M, :N, :ldiv, :atol, :rtol, :itmax, :timemax, :verbose, :hist
if rNorm == 0
stats.niter = 0
stats.solved, stats.inconsistent = true, false
stats.timer = ktimer(start_time)
stats.status = "x = 0 is a zero-residual solution"
solver.warm_start = false
return solver
Expand All @@ -193,6 +194,7 @@ kwargs_cgs = (:c, :M, :N, :ldiv, :atol, :rtol, :itmax, :timemax, :verbose, :hist
if ρ == 0
stats.niter = 0
stats.solved, stats.inconsistent = false, false
stats.timer = ktimer(start_time)
stats.status = "Breakdown bᴴc = 0"
solver.warm_start =false
return solver
Expand Down Expand Up @@ -280,6 +282,7 @@ kwargs_cgs = (:c, :M, :N, :ldiv, :atol, :rtol, :itmax, :timemax, :verbose, :hist
stats.niter = iter
stats.solved = solved
stats.inconsistent = false
stats.timer = ktimer(start_time)
stats.status = status
return solver
end
Expand Down
4 changes: 4 additions & 0 deletions src/cr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ kwargs_cr = (:M, :ldiv, :radius, :linesearch, :γ, :atol, :rtol, :itmax, :timema
if ρ == 0
stats.niter = 0
stats.solved, stats.inconsistent = true, false
stats.timer = ktimer(start_time)
stats.status = "x = 0 is a zero-residual solution"
history && push!(ArNorms, zero(T))
solver.warm_start = false
Expand Down Expand Up @@ -218,6 +219,7 @@ kwargs_cr = (:M, :ldiv, :radius, :linesearch, :γ, :atol, :rtol, :itmax, :timema
(verbose > 0) && @printf(iostream, "nonpositive curvature detected: pᴴAp = %8.1e and rᴴAr = %8.1e\n", pAp, ρ)
stats.solved = solved
stats.inconsistent = false
stats.timer = ktimer(start_time)
stats.status = "nonpositive curvature"
return solver
end
Expand Down Expand Up @@ -382,6 +384,7 @@ kwargs_cr = (:M, :ldiv, :radius, :linesearch, :γ, :atol, :rtol, :itmax, :timema
stats.niter = iter
stats.solved = solved
stats.inconsistent = false
stats.timer = ktimer(start_time)
stats.status = "solver encountered numerical issues"
solver.warm_start = false
return solver
Expand Down Expand Up @@ -411,6 +414,7 @@ kwargs_cr = (:M, :ldiv, :radius, :linesearch, :γ, :atol, :rtol, :itmax, :timema
stats.niter = iter
stats.solved = solved
stats.inconsistent = false
stats.timer = ktimer(start_time)
stats.status = status
return solver
end
Expand Down
2 changes: 2 additions & 0 deletions src/craig.jl
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ kwargs_craig = (:M, :N, :ldiv, :transfer_to_lsqr, :sqd, :λ, :btol, :conlim, :at
if β₁ == 0
stats.niter = 0
stats.solved, stats.inconsistent = true, false
stats.timer = ktimer(start_time)
stats.status = "x = 0 is a zero-residual solution"
return solver
end
Expand Down Expand Up @@ -391,6 +392,7 @@ kwargs_craig = (:M, :N, :ldiv, :transfer_to_lsqr, :sqd, :λ, :btol, :conlim, :at
stats.niter = iter
stats.solved = solved
stats.inconsistent = inconsistent
stats.timer = ktimer(start_time)
stats.status = status
return solver
end
Expand Down
3 changes: 3 additions & 0 deletions src/craigmr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ kwargs_craigmr = (:M, :N, :ldiv, :sqd, :λ, :atol, :rtol, :itmax, :timemax, :ver
stats.solved, stats.inconsistent = true, false
history && push!(rNorms, β)
history && push!(ArNorms, zero(T))
stats.timer = ktimer(start_time)
stats.status = "x = 0 is a zero-residual solution"
return solver
end
Expand Down Expand Up @@ -228,6 +229,7 @@ kwargs_craigmr = (:M, :N, :ldiv, :sqd, :λ, :atol, :rtol, :itmax, :timemax, :ver
stats.solved, stats.inconsistent = true, false
history && push!(rNorms, β)
history && push!(ArNorms, zero(T))
stats.timer = ktimer(start_time)
stats.status = "x = 0 is a minimum least-squares solution"
return solver
end
Expand Down Expand Up @@ -384,6 +386,7 @@ kwargs_craigmr = (:M, :N, :ldiv, :sqd, :λ, :atol, :rtol, :itmax, :timemax, :ver
stats.niter = iter
stats.solved = solved
stats.inconsistent = inconsistent
stats.timer = ktimer(start_time)
stats.status = status
return solver
end
Expand Down
2 changes: 2 additions & 0 deletions src/crls.jl
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ kwargs_crls = (:M, :ldiv, :radius, :λ, :atol, :rtol, :itmax, :timemax, :verbose
if bNorm == 0
stats.niter = 0
stats.solved, stats.inconsistent = true, false
stats.timer = ktimer(start_time)
stats.status = "x = 0 is a zero-residual solution"
history && push!(ArNorms, zero(T))
return solver
Expand Down Expand Up @@ -256,6 +257,7 @@ kwargs_crls = (:M, :ldiv, :radius, :λ, :atol, :rtol, :itmax, :timemax, :verbose
stats.niter = iter
stats.solved = solved
stats.inconsistent = false
stats.timer = ktimer(start_time)
stats.status = status
return solver
end
Expand Down
2 changes: 2 additions & 0 deletions src/crmr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ kwargs_crmr = (:N, :ldiv, :λ, :atol, :rtol, :itmax, :timemax, :verbose, :histor
if bNorm == 0
stats.niter = 0
stats.solved, stats.inconsistent = true, false
stats.timer = ktimer(start_time)
stats.status = "x = 0 is a zero-residual solution"
history && push!(ArNorms, zero(T))
return solver
Expand Down Expand Up @@ -232,6 +233,7 @@ kwargs_crmr = (:N, :ldiv, :λ, :atol, :rtol, :itmax, :timemax, :verbose, :histor
stats.niter = iter
stats.solved = solved
stats.inconsistent = inconsistent
stats.timer = ktimer(start_time)
stats.status = status
return solver
end
Expand Down
2 changes: 2 additions & 0 deletions src/diom.jl
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ kwargs_diom = (:M, :N, :ldiv, :reorthogonalization, :atol, :rtol, :itmax, :timem
if rNorm == 0
stats.niter = 0
stats.solved, stats.inconsistent = true, false
stats.timer = ktimer(start_time)
stats.status = "x = 0 is a zero-residual solution"
solver.warm_start = false
return solver
Expand Down Expand Up @@ -328,6 +329,7 @@ kwargs_diom = (:M, :N, :ldiv, :reorthogonalization, :atol, :rtol, :itmax, :timem
stats.niter = iter
stats.solved = solved
stats.inconsistent = false
stats.timer = ktimer(start_time)
stats.status = status
return solver
end
Expand Down
2 changes: 2 additions & 0 deletions src/dqgmres.jl
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ kwargs_dqgmres = (:M, :N, :ldiv, :reorthogonalization, :atol, :rtol, :itmax, :ti
if rNorm == 0
stats.niter = 0
stats.solved, stats.inconsistent = true, false
stats.timer = ktimer(start_time)
stats.status = "x = 0 is a zero-residual solution"
solver.warm_start = false
return solver
Expand Down Expand Up @@ -330,6 +331,7 @@ kwargs_dqgmres = (:M, :N, :ldiv, :reorthogonalization, :atol, :rtol, :itmax, :ti
stats.niter = iter
stats.solved = solved
stats.inconsistent = false
stats.timer = ktimer(start_time)
stats.status = status
return solver
end
Expand Down
2 changes: 2 additions & 0 deletions src/fgmres.jl
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ kwargs_fgmres = (:M, :N, :ldiv, :restart, :reorthogonalization, :atol, :rtol, :i
if β == 0
stats.niter = 0
stats.solved, stats.inconsistent = true, false
stats.timer = ktimer(start_time)
stats.status = "x = 0 is a zero-residual solution"
solver.warm_start = false
return solver
Expand Down Expand Up @@ -380,6 +381,7 @@ kwargs_fgmres = (:M, :N, :ldiv, :restart, :reorthogonalization, :atol, :rtol, :i
stats.niter = iter
stats.solved = solved
stats.inconsistent = inconsistent
stats.timer = ktimer(start_time)
stats.status = status
return solver
end
Expand Down
2 changes: 2 additions & 0 deletions src/fom.jl
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ kwargs_fom = (:M, :N, :ldiv, :restart, :reorthogonalization, :atol, :rtol, :itma
if β == 0
stats.niter = 0
stats.solved, stats.inconsistent = true, false
stats.timer = ktimer(start_time)
stats.status = "x = 0 is a zero-residual solution"
solver.warm_start = false
return solver
Expand Down Expand Up @@ -360,6 +361,7 @@ kwargs_fom = (:M, :N, :ldiv, :restart, :reorthogonalization, :atol, :rtol, :itma
stats.niter = iter
stats.solved = solved
stats.inconsistent = !solved && breakdown
stats.timer = ktimer(start_time)
stats.status = status
return solver
end
Expand Down
2 changes: 2 additions & 0 deletions src/gmres.jl
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ kwargs_gmres = (:M, :N, :ldiv, :restart, :reorthogonalization, :atol, :rtol, :it
if β == 0
stats.niter = 0
stats.solved, stats.inconsistent = true, false
stats.timer = ktimer(start_time)
stats.status = "x = 0 is a zero-residual solution"
solver.warm_start = false
return solver
Expand Down Expand Up @@ -377,6 +378,7 @@ kwargs_gmres = (:M, :N, :ldiv, :restart, :reorthogonalization, :atol, :rtol, :it
stats.niter = iter
stats.solved = solved
stats.inconsistent = inconsistent
stats.timer = ktimer(start_time)
stats.status = status
return solver
end
Expand Down
1 change: 1 addition & 0 deletions src/gpmr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,7 @@ kwargs_gpmr = (:C, :D, :E, :F, :ldiv, :gsp, :λ, :μ, :reorthogonalization, :ato
stats.niter = iter
stats.solved = solved
stats.inconsistent = inconsistent
stats.timer = ktimer(start_time)
stats.status = status
return solver
end
Expand Down
2 changes: 2 additions & 0 deletions src/lnlq.jl
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ kwargs_lnlq = (:M, :N, :ldiv, :transfer_to_craig, :sqd, :λ, :σ, :utolx, :utoly
stats.solved = true
stats.error_with_bnd = false
history && push!(rNorms, bNorm)
stats.timer = ktimer(start_time)
stats.status = "x = 0 is a zero-residual solution"
return solver
end
Expand Down Expand Up @@ -546,6 +547,7 @@ kwargs_lnlq = (:M, :N, :ldiv, :transfer_to_craig, :sqd, :λ, :σ, :utolx, :utoly
stats.niter = iter
stats.solved = solved_lq || solved_cg
stats.error_with_bnd = complex_error_bnd
stats.timer = ktimer(start_time)
stats.status = status
return solver
end
Expand Down
Loading

0 comments on commit fa0da9c

Please sign in to comment.