Skip to content

Commit

Permalink
Restore the alignment of comments
Browse files Browse the repository at this point in the history
  • Loading branch information
amontoison committed Oct 17, 2024
1 parent 0e62593 commit 2558bfe
Show file tree
Hide file tree
Showing 29 changed files with 190 additions and 190 deletions.
48 changes: 24 additions & 24 deletions src/bicgstab.jl
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,15 @@ kwargs_bicgstab = (:c, :M, :N, :ldiv, :atol, :rtol, :itmax, :timemax, :verbose,
kcopy!(n, r₀, b) # r₀ ← b
end

kfill!(x, zero(FC)) # x₀
kfill!(s, zero(FC)) # s₀
kfill!(v, zero(FC)) # v₀
kfill!(x, zero(FC)) # x₀
kfill!(s, zero(FC)) # s₀
kfill!(v, zero(FC)) # v₀
MisI || mulorldiv!(r, M, r₀, ldiv) # r₀
kcopy!(n, p, r) # p₁
kcopy!(n, p, r) # p₁

α = one(FC) # α₀
ω = one(FC) # ω₀
ρ = one(FC) # ρ₀
α = one(FC) # α₀
ω = one(FC) # ω₀
ρ = one(FC) # ρ₀

# Compute residual norm ‖r₀‖₂.
rNorm = knorm(n, r)
Expand Down Expand Up @@ -206,24 +206,24 @@ kwargs_bicgstab = (:c, :M, :N, :ldiv, :atol, :rtol, :itmax, :timemax, :verbose,
iter = iter + 1
ρ = next_ρ

NisI || mulorldiv!(y, N, p, ldiv) # yₖ = N⁻¹pₖ
mul!(q, A, y) # qₖ = Ayₖ
mulorldiv!(v, M, q, ldiv) # vₖ = M⁻¹qₖ
α = ρ / kdot(n, c, v) # αₖ = ⟨r̅₀,rₖ₋₁⟩ / ⟨r̅₀,vₖ⟩
kcopy!(n, s, r) # sₖ = rₖ₋₁
kaxpy!(n, -α, v, s) # sₖ = sₖ - αₖvₖ
kaxpy!(n, α, y, x) # xₐᵤₓ = xₖ₋₁ + αₖyₖ
NisI || mulorldiv!(z, N, s, ldiv) # zₖ = N⁻¹sₖ
mul!(d, A, z) # dₖ = Azₖ
MisI || mulorldiv!(t, M, d, ldiv) # tₖ = M⁻¹dₖ
NisI || mulorldiv!(y, N, p, ldiv) # yₖ = N⁻¹pₖ
mul!(q, A, y) # qₖ = Ayₖ
mulorldiv!(v, M, q, ldiv) # vₖ = M⁻¹qₖ
α = ρ / kdot(n, c, v) # αₖ = ⟨r̅₀,rₖ₋₁⟩ / ⟨r̅₀,vₖ⟩
kcopy!(n, s, r) # sₖ = rₖ₋₁
kaxpy!(n, -α, v, s) # sₖ = sₖ - αₖvₖ
kaxpy!(n, α, y, x) # xₐᵤₓ = xₖ₋₁ + αₖyₖ
NisI || mulorldiv!(z, N, s, ldiv) # zₖ = N⁻¹sₖ
mul!(d, A, z) # dₖ = Azₖ
MisI || mulorldiv!(t, M, d, ldiv) # tₖ = M⁻¹dₖ
ω = kdot(n, t, s) / kdot(n, t, t) # ⟨tₖ,sₖ⟩ / ⟨tₖ,tₖ⟩
kaxpy!(n, ω, z, x) # xₖ = xₐᵤₓ + ωₖzₖ
kcopy!(n, r, s) # rₖ = sₖ
kaxpy!(n, -ω, t, r) # rₖ = rₖ - ωₖtₖ
next_ρ = kdot(n, c, r) # ρₖ₊₁ = ⟨r̅₀,rₖ⟩
β = (next_ρ / ρ) */ ω) # βₖ₊₁ = (ρₖ₊₁ / ρₖ) * (αₖ / ωₖ)
kaxpy!(n, -ω, v, p) # pₐᵤₓ = pₖ - ωₖvₖ
kaxpby!(n, one(FC), r, β, p) # pₖ₊₁ = rₖ₊₁ + βₖ₊₁pₐᵤₓ
kaxpy!(n, ω, z, x) # xₖ = xₐᵤₓ + ωₖzₖ
kcopy!(n, r, s) # rₖ = sₖ
kaxpy!(n, -ω, t, r) # rₖ = rₖ - ωₖtₖ
next_ρ = kdot(n, c, r) # ρₖ₊₁ = ⟨r̅₀,rₖ⟩
β = (next_ρ / ρ) */ ω) # βₖ₊₁ = (ρₖ₊₁ / ρₖ) * (αₖ / ωₖ)
kaxpy!(n, -ω, v, p) # pₐᵤₓ = pₖ - ωₖvₖ
kaxpby!(n, one(FC), r, β, p) # pₖ₊₁ = rₖ₊₁ + βₖ₊₁pₐᵤₓ

# Compute residual norm ‖rₖ‖₂.
rNorm = knorm(n, r)
Expand Down
10 changes: 5 additions & 5 deletions src/bilq.jl
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,13 @@ kwargs_bilq = (:c, :transfer_to_bicg, :M, :N, :ldiv, :atol, :rtol, :itmax, :time

βₖ = (abs(cᴴb)) # β₁γ₁ = cᴴ(b - Ax₀)
γₖ = cᴴb / βₖ # β₁γ₁ = cᴴ(b - Ax₀)
kfill!(vₖ₋₁, zero(FC)) # v₀ = 0
kfill!(uₖ₋₁, zero(FC)) # u₀ = 0
kfill!(vₖ₋₁, zero(FC)) # v₀ = 0
kfill!(uₖ₋₁, zero(FC)) # u₀ = 0
vₖ .= r₀ ./ βₖ # v₁ = (b - Ax₀) / β₁
uₖ .= c ./ conj(γₖ) # u₁ = c / γ̄₁
cₖ₋₁ = cₖ = -one(T) # Givens cosines used for the LQ factorization of Tₖ
sₖ₋₁ = sₖ = zero(FC) # Givens sines used for the LQ factorization of Tₖ
kfill!(d̅, zero(FC)) # Last column of D̅ₖ = Vₖ(Qₖ)ᴴ
kfill!(d̅, zero(FC)) # Last column of D̅ₖ = Vₖ(Qₖ)ᴴ
ζₖ₋₁ = ζbarₖ = zero(FC) # ζₖ₋₁ and ζbarₖ are the last components of z̅ₖ = (L̅ₖ)⁻¹β₁e₁
ζₖ₋₂ = ηₖ = zero(FC) # ζₖ₋₂ and ηₖ are used to update ζₖ₋₁ and ζbarₖ
δbarₖ₋₁ = δbarₖ = zero(FC) # Coefficients of Lₖ₋₁ and L̅ₖ modified over the course of two iterations
Expand Down Expand Up @@ -239,8 +239,8 @@ kwargs_bilq = (:c, :transfer_to_bicg, :M, :N, :ldiv, :atol, :rtol, :itmax, :time
kaxpy!(n, -conj(αₖ), uₖ, p) # p ← p - ᾱₖ * uₖ

pᴴq = kdot(n, p, q) # pᴴq = ⟨p,q⟩
βₖ₊₁ = (abs(pᴴq)) # βₖ₊₁ = √(|pᴴq|)
γₖ₊₁ = pᴴq / βₖ₊₁ # γₖ₊₁ = pᴴq / βₖ₊₁
βₖ₊₁ = (abs(pᴴq)) # βₖ₊₁ = √(|pᴴq|)
γₖ₊₁ = pᴴq / βₖ₊₁ # γₖ₊₁ = pᴴq / βₖ₊₁

# Update the LQ factorization of Tₖ = L̅ₖQₖ.
# [ α₁ γ₂ 0 • • • 0 ] [ δ₁ 0 • • • • 0 ]
Expand Down
14 changes: 7 additions & 7 deletions src/bilqr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -175,21 +175,21 @@ kwargs_bilqr = (:transfer_to_bicg, :atol, :rtol, :itmax, :timemax, :verbose, :hi
# Set up workspace.
βₖ = (abs(cᴴb)) # β₁γ₁ = (c - Aᴴy₀)ᴴ(b - Ax₀)
γₖ = cᴴb / βₖ # β₁γ₁ = (c - Aᴴy₀)ᴴ(b - Ax₀)
kfill!(vₖ₋₁, zero(FC)) # v₀ = 0
kfill!(uₖ₋₁, zero(FC)) # u₀ = 0
kfill!(vₖ₋₁, zero(FC)) # v₀ = 0
kfill!(uₖ₋₁, zero(FC)) # u₀ = 0
vₖ .= r₀ ./ βₖ # v₁ = (b - Ax₀) / β₁
uₖ .= s₀ ./ conj(γₖ) # u₁ = (c - Aᴴy₀) / γ̄₁
cₖ₋₁ = cₖ = -one(T) # Givens cosines used for the LQ factorization of Tₖ
sₖ₋₁ = sₖ = zero(FC) # Givens sines used for the LQ factorization of Tₖ
kfill!(d̅, zero(FC)) # Last column of D̅ₖ = Vₖ(Qₖ)ᴴ
kfill!(d̅, zero(FC)) # Last column of D̅ₖ = Vₖ(Qₖ)ᴴ
ζₖ₋₁ = ζbarₖ = zero(FC) # ζₖ₋₁ and ζbarₖ are the last components of z̅ₖ = (L̅ₖ)⁻¹β₁e₁
ζₖ₋₂ = ηₖ = zero(FC) # ζₖ₋₂ and ηₖ are used to update ζₖ₋₁ and ζbarₖ
δbarₖ₋₁ = δbarₖ = zero(FC) # Coefficients of Lₖ₋₁ and L̅ₖ modified over the course of two iterations
ψbarₖ₋₁ = ψₖ₋₁ = zero(FC) # ψₖ₋₁ and ψbarₖ are the last components of h̅ₖ = Qₖγ̄₁e₁
norm_vₖ = bNorm / βₖ # ‖vₖ‖ is used for residual norm estimates
ϵₖ₋₃ = λₖ₋₂ = zero(FC) # Components of Lₖ₋₁
kfill!(wₖ₋₃, zero(FC)) # Column k-3 of Wₖ = Uₖ(Lₖ)⁻ᴴ
kfill!(wₖ₋₂, zero(FC)) # Column k-2 of Wₖ = Uₖ(Lₖ)⁻ᴴ
kfill!(wₖ₋₃, zero(FC)) # Column k-3 of Wₖ = Uₖ(Lₖ)⁻ᴴ
kfill!(wₖ₋₂, zero(FC)) # Column k-2 of Wₖ = Uₖ(Lₖ)⁻ᴴ
τₖ = zero(T) # τₖ is used for the dual residual norm estimate

# Stopping criterion.
Expand Down Expand Up @@ -225,8 +225,8 @@ kwargs_bilqr = (:transfer_to_bicg, :atol, :rtol, :itmax, :timemax, :verbose, :hi
kaxpy!(n, -conj(αₖ), uₖ, p) # p ← p - ᾱₖ * uₖ

pᴴq = kdot(n, p, q) # pᴴq = ⟨p,q⟩
βₖ₊₁ = (abs(pᴴq)) # βₖ₊₁ = √(|pᴴq|)
γₖ₊₁ = pᴴq / βₖ₊₁ # γₖ₊₁ = pᴴq / βₖ₊₁
βₖ₊₁ = (abs(pᴴq)) # βₖ₊₁ = √(|pᴴq|)
γₖ₊₁ = pᴴq / βₖ₊₁ # γₖ₊₁ = pᴴq / βₖ₊₁

# Update the LQ factorization of Tₖ = L̅ₖQₖ.
# [ α₁ γ₂ 0 • • • 0 ] [ δ₁ 0 • • • • 0 ]
Expand Down
6 changes: 3 additions & 3 deletions src/car.jl
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ kwargs_car = (:M, :ldiv, :atol, :rtol, :itmax, :timemax, :verbose, :history, :ca
kcopy!(n, s, q) # s ← q
end

mul!(t, A, s) # t₀ = As₀
mul!(t, A, s) # t₀ = As₀
kcopy!(n, u, t) # u₀ = Aq₀
ρ = kdotr(n, t, s) # ρ₀ = ⟨t₀ , s₀⟩

Expand Down Expand Up @@ -201,9 +201,9 @@ kwargs_car = (:M, :ldiv, :atol, :rtol, :itmax, :timemax, :verbose, :history, :ca
solved = resid_decrease_lim || resid_decrease_mach

if !solved
mul!(t, A, s) # tₖ₊₁ = A * sₖ₊₁
mul!(t, A, s) # tₖ₊₁ = A * sₖ₊₁
ρ_next = kdotr(n, t, s) # ρₖ₊₁ = ⟨tₖ₊₁ , sₖ₊₁⟩
β = ρ_next / ρ # βₖ = ρₖ₊₁ / ρₖ
β = ρ_next / ρ # βₖ = ρₖ₊₁ / ρₖ
ρ = ρ_next
kaxpby!(n, one(FC), r, β, p) # pₖ₊₁ = rₖ₊₁ + βₖ * pₖ
kaxpby!(n, one(FC), s, β, q) # qₖ₊₁ = sₖ₊₁ + βₖ * qₖ
Expand Down
18 changes: 9 additions & 9 deletions src/cg_lanczos.jl
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ kwargs_cg_lanczos = (:M, :ldiv, :check_curvature, :atol, :rtol, :itmax, :timemax
kcopy!(n, Mv, b) # Mv ← b
end
MisI || mulorldiv!(v, M, Mv, ldiv) # v₁ = M⁻¹r₀
β = sqrt(kdotr(n, v, Mv)) # β₁ = v₁ᴴ M v₁
β = sqrt(kdotr(n, v, Mv)) # β₁ = v₁ᴴ M v₁
σ = β
rNorm = σ
history && push!(rNorms, rNorm)
Expand Down Expand Up @@ -185,7 +185,7 @@ kwargs_cg_lanczos = (:M, :ldiv, :check_curvature, :atol, :rtol, :itmax, :timemax
while ! (solved || tired || (check_curvature & indefinite) || user_requested_exit || overtimed)
# Form next Lanczos vector.
# βₖ₊₁Mvₖ₊₁ = Avₖ - δₖMvₖ - βₖMvₖ₋₁
mul!(Mv_next, A, v) # Mvₖ₊₁ ← Avₖ
mul!(Mv_next, A, v) # Mvₖ₊₁ ← Avₖ
δ = kdotr(n, v, Mv_next) # δₖ = vₖᴴ A vₖ

# Check curvature. Exit fast if requested.
Expand All @@ -194,25 +194,25 @@ kwargs_cg_lanczos = (:M, :ldiv, :check_curvature, :atol, :rtol, :itmax, :timemax
indefinite |= 0)
(check_curvature & indefinite) && continue

kaxpy!(n, -δ, Mv, Mv_next) # Mvₖ₊₁ ← Mvₖ₊₁ - δₖMvₖ
kaxpy!(n, -δ, Mv, Mv_next) # Mvₖ₊₁ ← Mvₖ₊₁ - δₖMvₖ
if iter > 0
kaxpy!(n, -β, Mv_prev, Mv_next) # Mvₖ₊₁ ← Mvₖ₊₁ - βₖMvₖ₋₁
kcopy!(n, Mv_prev, Mv) # Mvₖ₋₁ ← Mvₖ
kaxpy!(n, -β, Mv_prev, Mv_next) # Mvₖ₊₁ ← Mvₖ₊₁ - βₖMvₖ₋₁
kcopy!(n, Mv_prev, Mv) # Mvₖ₋₁ ← Mvₖ
end
kcopy!(n, Mv, Mv_next) # Mvₖ ← Mvₖ₊₁
MisI || mulorldiv!(v, M, Mv, ldiv) # vₖ₊₁ = M⁻¹ * Mvₖ₊₁
MisI || mulorldiv!(v, M, Mv, ldiv) # vₖ₊₁ = M⁻¹ * Mvₖ₊₁
β = sqrt(kdotr(n, v, Mv)) # βₖ₊₁ = vₖ₊₁ᴴ M vₖ₊₁
kscal!(n, one(FC) / β, v) # vₖ₊₁ ← vₖ₊₁ / βₖ₊₁
MisI || kscal!(n, one(FC) / β, Mv) # Mvₖ₊₁ ← Mvₖ₊₁ / βₖ₊₁
Anorm2 += β_prev^2 + β^2 + δ^2 # Use ‖Tₖ₊₁‖₂ as increasing approximation of ‖A‖₂.
Anorm2 += β_prev^2 + β^2 + δ^2 # Use ‖Tₖ₊₁‖₂ as increasing approximation of ‖A‖₂.
β_prev = β

# Compute next CG iterate.
kaxpy!(n, γ, p, x) # xₖ₊₁ = xₖ + γₖ * pₖ
kaxpy!(n, γ, p, x) # xₖ₊₁ = xₖ + γₖ * pₖ
ω = β * γ
σ = -ω * σ # σₖ₊₁ = - βₖ₊₁ * γₖ * σₖ
ω = ω * ω # ωₖ = (βₖ₊₁ * γₖ)²
kaxpby!(n, σ, v, ω, p) # pₖ₊₁ = σₖ₊₁ * vₖ₊₁ + ωₖ * pₖ
kaxpby!(n, σ, v, ω, p) # pₖ₊₁ = σₖ₊₁ * vₖ₊₁ + ωₖ * pₖ
rNorm = abs(σ) # ‖rₖ₊₁‖_M = |σₖ₊₁| because rₖ₊₁ = σₖ₊₁ * vₖ₊₁ and ‖vₖ₊₁‖_M = 1
history && push!(rNorms, rNorm)
iter = iter + 1
Expand Down
8 changes: 4 additions & 4 deletions src/cg_lanczos_shift.jl
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ kwargs_cg_lanczos_shift = (:M, :ldiv, :check_curvature, :atol, :rtol, :itmax, :t
for i = 1 : nshifts
kfill!(x[i], zero(FC)) # x₀
end
kcopy!(n, Mv, b) # Mv₁ ← b
kcopy!(n, Mv, b) # Mv₁ ← b
MisI || mulorldiv!(v, M, Mv, ldiv) # v₁ = M⁻¹ * Mv₁
β = sqrt(kdotr(n, v, Mv)) # β₁ = v₁ᴴ M v₁
β = sqrt(kdotr(n, v, Mv)) # β₁ = v₁ᴴ M v₁
kfill!(rNorms, β)
if history
for i = 1 : nshifts
Expand Down Expand Up @@ -196,15 +196,15 @@ kwargs_cg_lanczos_shift = (:M, :ldiv, :check_curvature, :atol, :rtol, :itmax, :t
while ! (solved || tired || user_requested_exit || overtimed)
# Form next Lanczos vector.
# βₖ₊₁Mvₖ₊₁ = Avₖ - δₖMvₖ - βₖMvₖ₋₁
mul!(Mv_next, A, v) # Mvₖ₊₁ ← Avₖ
mul!(Mv_next, A, v) # Mvₖ₊₁ ← Avₖ
δ = kdotr(n, v, Mv_next) # δₖ = vₖᴴ A vₖ
kaxpy!(n, -δ, Mv, Mv_next) # Mvₖ₊₁ ← Mvₖ₊₁ - δₖMvₖ
if iter > 0
kaxpy!(n, -β, Mv_prev, Mv_next) # Mvₖ₊₁ ← Mvₖ₊₁ - βₖMvₖ₋₁
kcopy!(n, Mv_prev, Mv) # Mvₖ₋₁ ← Mvₖ
end
kcopy!(n, Mv, Mv_next) # Mvₖ ← Mvₖ₊₁
MisI || mulorldiv!(v, M, Mv, ldiv) # vₖ₊₁ = M⁻¹ * Mvₖ₊₁
MisI || mulorldiv!(v, M, Mv, ldiv) # vₖ₊₁ = M⁻¹ * Mvₖ₊₁
β = sqrt(kdotr(n, v, Mv)) # βₖ₊₁ = vₖ₊₁ᴴ M vₖ₊₁
kscal!(n, one(FC) / β, v) # vₖ₊₁ ← vₖ₊₁ / βₖ₊₁
MisI || kscal!(n, one(FC) / β, Mv) # Mvₖ₊₁ ← Mvₖ₊₁ / βₖ₊₁
Expand Down
14 changes: 7 additions & 7 deletions src/cgls.jl
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ kwargs_cgls = (:M, :ldiv, :radius, :λ, :atol, :rtol, :itmax, :timemax, :verbose
Mq = MisI ? q : solver.Mr

kfill!(x, zero(FC))
kcopy!(m, r, b) # r ← b
bNorm = knorm(m, r) # Marginally faster than norm(b)
kcopy!(m, r, b) # r ← b
bNorm = knorm(m, r) # Marginally faster than norm(b)
if bNorm == 0
stats.niter = 0
stats.solved, stats.inconsistent = true, false
Expand All @@ -160,7 +160,7 @@ kwargs_cgls = (:M, :ldiv, :radius, :λ, :atol, :rtol, :itmax, :timemax, :verbose
end
MisI || mulorldiv!(Mr, M, r, ldiv)
mul!(s, Aᴴ, Mr)
kcopy!(n, p, s) # p ← s
kcopy!(n, p, s) # p ← s
γ = kdotr(n, s, s) # γ = sᴴs
iter = 0
itmax == 0 && (itmax = m + n)
Expand Down Expand Up @@ -194,12 +194,12 @@ kwargs_cgls = (:M, :ldiv, :radius, :λ, :atol, :rtol, :itmax, :timemax, :verbose
on_boundary = true
end

kaxpy!(n, α, p, x) # Faster than x = x + α * p
kaxpy!(m, -α, q, r) # Faster than r = r - α * q
kaxpy!(n, α, p, x) # Faster than x = x + α * p
kaxpy!(m, -α, q, r) # Faster than r = r - α * q
MisI || mulorldiv!(Mr, M, r, ldiv)
mul!(s, Aᴴ, Mr)
λ > 0 && kaxpy!(n, -λ, x, s) # s = A' * r - λ * x
γ_next = kdotr(n, s, s) # γ_next = sᴴs
λ > 0 && kaxpy!(n, -λ, x, s) # s = A' * r - λ * x
γ_next = kdotr(n, s, s) # γ_next = sᴴs
β = γ_next / γ
kaxpby!(n, one(FC), s, β, p) # p = s + βp
γ = γ_next
Expand Down
24 changes: 12 additions & 12 deletions src/cgls_lanczos_shift.jl
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,10 @@ kwargs_cgls_lanczos_shift = (:M, :ldiv, :atol, :rtol, :itmax, :timemax, :verbose
kfill!(x[i], zero(FC)) # x₀
end

kcopy!(m, u, b) # u ← b
kcopy!(m, u, b) # u ← b
kfill!(u_prev, zero(FC))
mul!(v, Aᴴ, u) # v₁ ← Aᴴ * b
β = sqrt(kdotr(n, v, v)) # β₁ = v₁ᵀ M v₁
mul!(v, Aᴴ, u) # v₁ ← Aᴴ * b
β = sqrt(kdotr(n, v, v)) # β₁ = v₁ᵀ M v₁
kfill!(rNorms, β)
if history
for i = 1 : nshifts
Expand Down Expand Up @@ -198,16 +198,16 @@ kwargs_cgls_lanczos_shift = (:M, :ldiv, :atol, :rtol, :itmax, :timemax, :verbose
while ! (solved || tired || user_requested_exit || overtimed)

# Form next Lanczos vector.
mul!(utilde, A, v) # utildeₖ ← Avₖ
δ = kdotr(m, utilde, utilde) # δₖ = vₖᵀAᴴAvₖ
kaxpy!(m, -δ, u, utilde) # uₖ₊₁ = utildeₖ - δₖuₖ - βₖuₖ₋₁
mul!(utilde, A, v) # utildeₖ ← Avₖ
δ = kdotr(m, utilde, utilde) # δₖ = vₖᵀAᴴAvₖ
kaxpy!(m, -δ, u, utilde) # uₖ₊₁ = utildeₖ - δₖuₖ - βₖuₖ₋₁
kaxpy!(m, -β, u_prev, utilde)
mul!(v, Aᴴ, utilde) # vₖ₊₁ = Aᴴuₖ₊₁
β = sqrt(kdotr(n, v, v)) # βₖ₊₁ = vₖ₊₁ᵀ M vₖ₊₁
kscal!(n, one(FC) / β, v) # vₖ₊₁ ← vₖ₊₁ / βₖ₊₁
kscal!(m, one(FC) / β, utilde) # uₖ₊₁ = uₖ₊₁ / βₖ₊₁
kcopy!(m, u_prev, u) # u_prev ← u
kcopy!(m, u, utilde) # u ← utilde
mul!(v, Aᴴ, utilde) # vₖ₊₁ = Aᴴuₖ₊₁
β = sqrt(kdotr(n, v, v)) # βₖ₊₁ = vₖ₊₁ᵀ M vₖ₊₁
kscal!(n, one(FC) / β, v) # vₖ₊₁ ← vₖ₊₁ / βₖ₊₁
kscal!(m, one(FC) / β, utilde) # uₖ₊₁ = uₖ₊₁ / βₖ₊₁
kcopy!(m, u_prev, u) # u_prev ← u
kcopy!(m, u, utilde) # u ← utilde

MisI ||= kdotr(n, v, v))
for i = 1 : nshifts
Expand Down
6 changes: 3 additions & 3 deletions src/cgne.jl
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ kwargs_cgne = (:N, :ldiv, :λ, :atol, :rtol, :itmax, :timemax, :verbose, :histor
kfill!(x, zero(FC))
kcopy!(m, r, b) # r ← b
NisI || mulorldiv!(z, N, r, ldiv)
rNorm = knorm(m, r) # Marginally faster than norm(r)
rNorm = knorm(m, r) # Marginally faster than norm(r)
history && push!(rNorms, rNorm)
if rNorm == 0
stats.niter = 0
Expand Down Expand Up @@ -195,8 +195,8 @@ kwargs_cgne = (:N, :ldiv, :λ, :atol, :rtol, :itmax, :timemax, :verbose, :histor
δ = kdotr(n, p, p) # Faster than dot(p, p)
λ > 0 &&+= λ * kdotr(m, s, s))
α = γ / δ
kaxpy!(n, α, p, x) # Faster than x = x + α * p
kaxpy!(m, -α, q, r) # Faster than r = r - α * q
kaxpy!(n, α, p, x) # Faster than x = x + α * p
kaxpy!(m, -α, q, r) # Faster than r = r - α * q
NisI || mulorldiv!(z, N, r, ldiv)
γ_next = kdotr(m, r, z) # Faster than γ_next = dot(r, z)
β = γ_next / γ
Expand Down
Loading

0 comments on commit 2558bfe

Please sign in to comment.