Skip to content

Commit

Permalink
Update the KrylovSolvers to support the timer in KrylovStats
Browse files Browse the repository at this point in the history
  • Loading branch information
amontoison committed May 12, 2023
1 parent bd3e691 commit e2eb7c4
Showing 1 changed file with 33 additions and 33 deletions.
66 changes: 33 additions & 33 deletions src/krylov_solvers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function MinresSolver(m, n, S; window :: Int=5)
y = S(undef, n)
v = S(undef, 0)
err_vec = zeros(T, window)
stats = SimpleStats(0, false, false, T[], T[], T[], "unknown")
stats = SimpleStats(0, false, false, T[], T[], T[], 0.0, "unknown")
solver = MinresSolver{T,FC,S}(m, n, Δx, x, r1, r2, w1, w2, y, v, err_vec, false, stats)
return solver
end
Expand Down Expand Up @@ -130,7 +130,7 @@ function CgSolver(m, n, S)
p = S(undef, n)
Ap = S(undef, n)
z = S(undef, 0)
stats = SimpleStats(0, false, false, T[], T[], T[], "unknown")
stats = SimpleStats(0, false, false, T[], T[], T[], 0.0, "unknown")
solver = CgSolver{T,FC,S}(m, n, Δx, x, r, p, Ap, z, false, stats)
return solver
end
Expand Down Expand Up @@ -175,7 +175,7 @@ function CrSolver(m, n, S)
q = S(undef, n)
Ar = S(undef, n)
Mq = S(undef, 0)
stats = SimpleStats(0, false, false, T[], T[], T[], "unknown")
stats = SimpleStats(0, false, false, T[], T[], T[], 0.0, "unknown")
solver = CrSolver{T,FC,S}(m, n, Δx, x, r, p, q, Ar, Mq, false, stats)
return solver
end
Expand Down Expand Up @@ -226,7 +226,7 @@ function SymmlqSolver(m, n, S; window :: Int=5)
clist = zeros(T, window)
zlist = zeros(T, window)
sprod = ones(T, window)
stats = SymmlqStats(0, false, T[], Union{T, Missing}[], T[], Union{T, Missing}[], T(NaN), T(NaN), "unknown")
stats = SymmlqStats(0, false, T[], Union{T, Missing}[], T[], Union{T, Missing}[], T(NaN), T(NaN), 0.0, "unknown")
solver = SymmlqSolver{T,FC,S}(m, n, Δx, x, Mvold, Mv, Mv_next, w̅, v, clist, zlist, sprod, false, stats)
return solver
end
Expand Down Expand Up @@ -271,7 +271,7 @@ function CgLanczosSolver(m, n, S)
p = S(undef, n)
Mv_next = S(undef, n)
v = S(undef, 0)
stats = LanczosStats(0, false, T[], false, T(NaN), T(NaN), "unknown")
stats = LanczosStats(0, false, T[], false, T(NaN), T(NaN), 0.0, "unknown")
solver = CgLanczosSolver{T,FC,S}(m, n, Δx, x, Mv, Mv_prev, p, Mv_next, v, false, stats)
return solver
end
Expand Down Expand Up @@ -329,7 +329,7 @@ function CgLanczosShiftSolver(m, n, nshifts, S)
indefinite = BitVector(undef, nshifts)
converged = BitVector(undef, nshifts)
not_cv = BitVector(undef, nshifts)
stats = LanczosShiftStats(0, false, Vector{T}[T[] for i = 1 : nshifts], indefinite, T(NaN), T(NaN), "unknown")
stats = LanczosShiftStats(0, false, Vector{T}[T[] for i = 1 : nshifts], indefinite, T(NaN), T(NaN), 0.0, "unknown")
solver = CgLanczosShiftSolver{T,FC,S}(m, n, nshifts, Mv, Mv_prev, Mv_next, v, x, p, σ, δhat, ω, γ, rNorms, converged, not_cv, stats)
return solver
end
Expand Down Expand Up @@ -376,7 +376,7 @@ function MinresQlpSolver(m, n, S)
x = S(undef, n)
p = S(undef, n)
vₖ = S(undef, 0)
stats = SimpleStats(0, false, false, T[], T[], T[], "unknown")
stats = SimpleStats(0, false, false, T[], T[], T[], 0.0, "unknown")
solver = MinresQlpSolver{T,FC,S}(m, n, Δx, wₖ₋₁, wₖ, M⁻¹vₖ₋₁, M⁻¹vₖ, x, p, vₖ, false, stats)
return solver
end
Expand Down Expand Up @@ -429,7 +429,7 @@ function DqgmresSolver(m, n, memory, S)
c = Vector{T}(undef, memory)
s = Vector{FC}(undef, memory)
H = Vector{FC}(undef, memory+1)
stats = SimpleStats(0, false, false, T[], T[], T[], "unknown")
stats = SimpleStats(0, false, false, T[], T[], T[], 0.0, "unknown")
solver = DqgmresSolver{T,FC,S}(m, n, Δx, x, t, z, w, P, V, c, s, H, false, stats)
return solver
end
Expand Down Expand Up @@ -480,7 +480,7 @@ function DiomSolver(m, n, memory, S)
V = S[S(undef, n) for i = 1 : memory]
L = Vector{FC}(undef, memory-1)
H = Vector{FC}(undef, memory)
stats = SimpleStats(0, false, false, T[], T[], T[], "unknown")
stats = SimpleStats(0, false, false, T[], T[], T[], 0.0, "unknown")
solver = DiomSolver{T,FC,S}(m, n, Δx, x, t, z, w, P, V, L, H, false, stats)
return solver
end
Expand Down Expand Up @@ -529,7 +529,7 @@ function UsymlqSolver(m, n, S)
vₖ₋₁ = S(undef, m)
vₖ = S(undef, m)
q = S(undef, m)
stats = SimpleStats(0, false, false, T[], T[], T[], "unknown")
stats = SimpleStats(0, false, false, T[], T[], T[], 0.0, "unknown")
solver = UsymlqSolver{T,FC,S}(m, n, uₖ₋₁, uₖ, p, Δx, x, d̅, vₖ₋₁, vₖ, q, false, stats)
return solver
end
Expand Down Expand Up @@ -580,7 +580,7 @@ function UsymqrSolver(m, n, S)
uₖ₋₁ = S(undef, n)
uₖ = S(undef, n)
p = S(undef, n)
stats = SimpleStats(0, false, false, T[], T[], T[], "unknown")
stats = SimpleStats(0, false, false, T[], T[], T[], 0.0, "unknown")
solver = UsymqrSolver{T,FC,S}(m, n, vₖ₋₁, vₖ, q, Δx, x, wₖ₋₂, wₖ₋₁, uₖ₋₁, uₖ, p, false, stats)
return solver
end
Expand Down Expand Up @@ -643,7 +643,7 @@ function TricgSolver(m, n, S)
Δy = S(undef, 0)
uₖ = S(undef, 0)
vₖ = S(undef, 0)
stats = SimpleStats(0, false, false, T[], T[], T[], "unknown")
stats = SimpleStats(0, false, false, T[], T[], T[], 0.0, "unknown")
solver = TricgSolver{T,FC,S}(m, n, y, N⁻¹uₖ₋₁, N⁻¹uₖ, p, gy₂ₖ₋₁, gy₂ₖ, x, M⁻¹vₖ₋₁, M⁻¹vₖ, q, gx₂ₖ₋₁, gx₂ₖ, Δx, Δy, uₖ, vₖ, false, stats)
return solver
end
Expand Down Expand Up @@ -714,7 +714,7 @@ function TrimrSolver(m, n, S)
Δy = S(undef, 0)
uₖ = S(undef, 0)
vₖ = S(undef, 0)
stats = SimpleStats(0, false, false, T[], T[], T[], "unknown")
stats = SimpleStats(0, false, false, T[], T[], T[], 0.0, "unknown")
solver = TrimrSolver{T,FC,S}(m, n, y, N⁻¹uₖ₋₁, N⁻¹uₖ, p, gy₂ₖ₋₃, gy₂ₖ₋₂, gy₂ₖ₋₁, gy₂ₖ, x, M⁻¹vₖ₋₁, M⁻¹vₖ, q, gx₂ₖ₋₃, gx₂ₖ₋₂, gx₂ₖ₋₁, gx₂ₖ, Δx, Δy, uₖ, vₖ, false, stats)
return solver
end
Expand Down Expand Up @@ -771,7 +771,7 @@ function TrilqrSolver(m, n, S)
y = S(undef, m)
wₖ₋₃ = S(undef, m)
wₖ₋₂ = S(undef, m)
stats = AdjointStats(0, false, false, T[], T[], "unknown")
stats = AdjointStats(0, false, false, T[], T[], 0.0, "unknown")
solver = TrilqrSolver{T,FC,S}(m, n, uₖ₋₁, uₖ, p, d̅, Δx, x, vₖ₋₁, vₖ, q, Δy, y, wₖ₋₃, wₖ₋₂, false, stats)
return solver
end
Expand Down Expand Up @@ -820,7 +820,7 @@ function CgsSolver(m, n, S)
ts = S(undef, n)
yz = S(undef, 0)
vw = S(undef, 0)
stats = SimpleStats(0, false, false, T[], T[], T[], "unknown")
stats = SimpleStats(0, false, false, T[], T[], T[], 0.0, "unknown")
solver = CgsSolver{T,FC,S}(m, n, Δx, x, r, u, p, q, ts, yz, vw, false, stats)
return solver
end
Expand Down Expand Up @@ -869,7 +869,7 @@ function BicgstabSolver(m, n, S)
qd = S(undef, n)
yz = S(undef, 0)
t = S(undef, 0)
stats = SimpleStats(0, false, false, T[], T[], T[], "unknown")
stats = SimpleStats(0, false, false, T[], T[], T[], 0.0, "unknown")
solver = BicgstabSolver{T,FC,S}(m, n, Δx, x, r, p, v, s, qd, yz, t, false, stats)
return solver
end
Expand Down Expand Up @@ -918,7 +918,7 @@ function BilqSolver(m, n, S)
Δx = S(undef, 0)
x = S(undef, n)
= S(undef, n)
stats = SimpleStats(0, false, false, T[], T[], T[], "unknown")
stats = SimpleStats(0, false, false, T[], T[], T[], 0.0, "unknown")
solver = BilqSolver{T,FC,S}(m, n, uₖ₋₁, uₖ, q, vₖ₋₁, vₖ, p, Δx, x, d̅, false, stats)
return solver
end
Expand Down Expand Up @@ -969,7 +969,7 @@ function QmrSolver(m, n, S)
x = S(undef, n)
wₖ₋₂ = S(undef, n)
wₖ₋₁ = S(undef, n)
stats = SimpleStats(0, false, false, T[], T[], T[], "unknown")
stats = SimpleStats(0, false, false, T[], T[], T[], 0.0, "unknown")
solver = QmrSolver{T,FC,S}(m, n, uₖ₋₁, uₖ, q, vₖ₋₁, vₖ, p, Δx, x, wₖ₋₂, wₖ₋₁, false, stats)
return solver
end
Expand Down Expand Up @@ -1026,7 +1026,7 @@ function BilqrSolver(m, n, S)
= S(undef, n)
wₖ₋₃ = S(undef, n)
wₖ₋₂ = S(undef, n)
stats = AdjointStats(0, false, false, T[], T[], "unknown")
stats = AdjointStats(0, false, false, T[], T[], 0.0, "unknown")
solver = BilqrSolver{T,FC,S}(m, n, uₖ₋₁, uₖ, q, vₖ₋₁, vₖ, p, Δx, x, Δy, y, d̅, wₖ₋₃, wₖ₋₂, false, stats)
return solver
end
Expand Down Expand Up @@ -1068,7 +1068,7 @@ function CglsSolver(m, n, S)
r = S(undef, m)
q = S(undef, m)
Mr = S(undef, 0)
stats = SimpleStats(0, false, false, T[], T[], T[], "unknown")
stats = SimpleStats(0, false, false, T[], T[], T[], 0.0, "unknown")
solver = CglsSolver{T,FC,S}(m, n, x, p, s, r, q, Mr, stats)
return solver
end
Expand Down Expand Up @@ -1114,7 +1114,7 @@ function CrlsSolver(m, n, S)
Ap = S(undef, m)
s = S(undef, m)
Ms = S(undef, 0)
stats = SimpleStats(0, false, false, T[], T[], T[], "unknown")
stats = SimpleStats(0, false, false, T[], T[], T[], 0.0, "unknown")
solver = CrlsSolver{T,FC,S}(m, n, x, p, Ar, q, r, Ap, s, Ms, stats)
return solver
end
Expand Down Expand Up @@ -1158,7 +1158,7 @@ function CgneSolver(m, n, S)
q = S(undef, m)
s = S(undef, 0)
z = S(undef, 0)
stats = SimpleStats(0, false, false, T[], T[], T[], "unknown")
stats = SimpleStats(0, false, false, T[], T[], T[], 0.0, "unknown")
solver = CgneSolver{T,FC,S}(m, n, x, p, Aᴴz, r, q, s, z, stats)
return solver
end
Expand Down Expand Up @@ -1202,7 +1202,7 @@ function CrmrSolver(m, n, S)
q = S(undef, m)
Nq = S(undef, 0)
s = S(undef, 0)
stats = SimpleStats(0, false, false, T[], T[], T[], "unknown")
stats = SimpleStats(0, false, false, T[], T[], T[], 0.0, "unknown")
solver = CrmrSolver{T,FC,S}(m, n, x, p, Aᴴr, r, q, Nq, s, stats)
return solver
end
Expand Down Expand Up @@ -1250,7 +1250,7 @@ function LslqSolver(m, n, S; window :: Int=5)
u = S(undef, 0)
v = S(undef, 0)
err_vec = zeros(T, window)
stats = LSLQStats(0, false, false, T[], T[], T[], false, T[], T[], "unknown")
stats = LSLQStats(0, false, false, T[], T[], T[], false, T[], T[], 0.0, "unknown")
solver = LslqSolver{T,FC,S}(m, n, x, Nv, Aᴴu, w̄, Mu, Av, u, v, err_vec, stats)
return solver
end
Expand Down Expand Up @@ -1298,7 +1298,7 @@ function LsqrSolver(m, n, S; window :: Int=5)
u = S(undef, 0)
v = S(undef, 0)
err_vec = zeros(T, window)
stats = SimpleStats(0, false, false, T[], T[], T[], "unknown")
stats = SimpleStats(0, false, false, T[], T[], T[], 0.0, "unknown")
solver = LsqrSolver{T,FC,S}(m, n, x, Nv, Aᴴu, w, Mu, Av, u, v, err_vec, stats)
return solver
end
Expand Down Expand Up @@ -1348,7 +1348,7 @@ function LsmrSolver(m, n, S; window :: Int=5)
u = S(undef, 0)
v = S(undef, 0)
err_vec = zeros(T, window)
stats = LsmrStats(0, false, false, T[], T[], zero(T), zero(T), zero(T), zero(T), zero(T), "unknown")
stats = LsmrStats(0, false, false, T[], T[], zero(T), zero(T), zero(T), zero(T), zero(T), 0.0, "unknown")
solver = LsmrSolver{T,FC,S}(m, n, x, Nv, Aᴴu, h, hbar, Mu, Av, u, v, err_vec, stats)
return solver
end
Expand Down Expand Up @@ -1398,7 +1398,7 @@ function LnlqSolver(m, n, S)
u = S(undef, 0)
v = S(undef, 0)
q = S(undef, 0)
stats = LNLQStats(0, false, T[], false, T[], T[], "unknown")
stats = LNLQStats(0, false, T[], false, T[], T[], 0.0, "unknown")
solver = LnlqSolver{T,FC,S}(m, n, x, Nv, Aᴴu, y, w̄, Mu, Av, u, v, q, stats)
return solver
end
Expand Down Expand Up @@ -1448,7 +1448,7 @@ function CraigSolver(m, n, S)
u = S(undef, 0)
v = S(undef, 0)
w2 = S(undef, 0)
stats = SimpleStats(0, false, false, T[], T[], T[], "unknown")
stats = SimpleStats(0, false, false, T[], T[], T[], 0.0, "unknown")
solver = CraigSolver{T,FC,S}(m, n, x, Nv, Aᴴu, y, w, Mu, Av, u, v, w2, stats)
return solver
end
Expand Down Expand Up @@ -1502,7 +1502,7 @@ function CraigmrSolver(m, n, S)
u = S(undef, 0)
v = S(undef, 0)
q = S(undef, 0)
stats = SimpleStats(0, false, false, T[], T[], T[], "unknown")
stats = SimpleStats(0, false, false, T[], T[], T[], 0.0, "unknown")
solver = CraigmrSolver{T,FC,S}(m, n, x, Nv, Aᴴu, d, y, Mu, w, wbar, Av, u, v, q, stats)
return solver
end
Expand Down Expand Up @@ -1556,7 +1556,7 @@ function GmresSolver(m, n, memory, S)
s = Vector{FC}(undef, memory)
z = Vector{FC}(undef, memory)
R = Vector{FC}(undef, div(memory * (memory+1), 2))
stats = SimpleStats(0, false, false, T[], T[], T[], "unknown")
stats = SimpleStats(0, false, false, T[], T[], T[], 0.0, "unknown")
solver = GmresSolver{T,FC,S}(m, n, Δx, x, w, p, q, V, c, s, z, R, false, 0, stats)
return solver
end
Expand Down Expand Up @@ -1610,7 +1610,7 @@ function FgmresSolver(m, n, memory, S)
s = Vector{FC}(undef, memory)
z = Vector{FC}(undef, memory)
R = Vector{FC}(undef, div(memory * (memory+1), 2))
stats = SimpleStats(0, false, false, T[], T[], T[], "unknown")
stats = SimpleStats(0, false, false, T[], T[], T[], 0.0, "unknown")
solver = FgmresSolver{T,FC,S}(m, n, Δx, x, w, q, V, Z, c, s, z, R, false, 0, stats)
return solver
end
Expand Down Expand Up @@ -1661,7 +1661,7 @@ function FomSolver(m, n, memory, S)
l = Vector{FC}(undef, memory)
z = Vector{FC}(undef, memory)
U = Vector{FC}(undef, div(memory * (memory+1), 2))
stats = SimpleStats(0, false, false, T[], T[], T[], "unknown")
stats = SimpleStats(0, false, false, T[], T[], T[], 0.0, "unknown")
solver = FomSolver{T,FC,S}(m, n, Δx, x, w, p, q, V, l, z, U, false, stats)
return solver
end
Expand Down Expand Up @@ -1726,7 +1726,7 @@ function GpmrSolver(m, n, memory, S)
gc = Vector{T}(undef, 4 * memory)
zt = Vector{FC}(undef, 2 * memory)
R = Vector{FC}(undef, memory * (2 * memory + 1))
stats = SimpleStats(0, false, false, T[], T[], T[], "unknown")
stats = SimpleStats(0, false, false, T[], T[], T[], 0.0, "unknown")
solver = GpmrSolver{T,FC,S}(m, n, wA, wB, dA, dB, Δx, Δy, x, y, q, p, V, U, gs, gc, zt, R, false, stats)
return solver
end
Expand Down

0 comments on commit e2eb7c4

Please sign in to comment.