Skip to content

Commit

Permalink
Add a function knorm_elliptic
Browse files Browse the repository at this point in the history
  • Loading branch information
amontoison committed Oct 17, 2024
1 parent 2558bfe commit 63c0806
Show file tree
Hide file tree
Showing 15 changed files with 46 additions and 44 deletions.
4 changes: 2 additions & 2 deletions src/car.jl
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ kwargs_car = (:M, :ldiv, :atol, :rtol, :itmax, :timemax, :verbose, :history, :ca
history && push!(rNorms, rNorm)

# Compute ‖Ar₀‖
ArNorm = MisI ? knorm(n, s) : sqrt(kdotr(n, r, u))
ArNorm = MisI ? knorm(n, s) : knorm_elliptic(n, r, u)
history && push!(ArNorms, ArNorm)

if rNorm == 0
Expand Down Expand Up @@ -210,7 +210,7 @@ kwargs_car = (:M, :ldiv, :atol, :rtol, :itmax, :timemax, :verbose, :history, :ca
kaxpby!(n, one(FC), t, β, u) # uₖ₊₁ = tₖ₊₁ + βₖ * uₖ

# Compute ‖Arₖ‖
ArNorm = MisI ? knorm(n, s) : sqrt(kdotr(n, r, u))
ArNorm = MisI ? knorm(n, s) : knorm_elliptic(n, r, u)
history && push!(ArNorms, ArNorm)
end

Expand Down
4 changes: 2 additions & 2 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₁
β = knorm_elliptic(n, v, Mv) # β₁ = v₁ᴴ M v₁
σ = β
rNorm = σ
history && push!(rNorms, rNorm)
Expand Down Expand Up @@ -201,7 +201,7 @@ kwargs_cg_lanczos = (:M, :ldiv, :check_curvature, :atol, :rtol, :itmax, :timemax
end
kcopy!(n, Mv, Mv_next) # Mvₖ ← Mvₖ₊₁
MisI || mulorldiv!(v, M, Mv, ldiv) # vₖ₊₁ = M⁻¹ * Mvₖ₊₁
β = sqrt(kdotr(n, v, Mv)) # βₖ₊₁ = vₖ₊₁ᴴ M vₖ₊₁
β = knorm_elliptic(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‖₂.
Expand Down
4 changes: 2 additions & 2 deletions src/cg_lanczos_shift.jl
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ kwargs_cg_lanczos_shift = (:M, :ldiv, :check_curvature, :atol, :rtol, :itmax, :t
end
kcopy!(n, Mv, b) # Mv₁ ← b
MisI || mulorldiv!(v, M, Mv, ldiv) # v₁ = M⁻¹ * Mv₁
β = sqrt(kdotr(n, v, Mv)) # β₁ = v₁ᴴ M v₁
β = knorm_elliptic(n, v, Mv) # β₁ = v₁ᴴ M v₁
kfill!(rNorms, β)
if history
for i = 1 : nshifts
Expand Down Expand Up @@ -205,7 +205,7 @@ kwargs_cg_lanczos_shift = (:M, :ldiv, :check_curvature, :atol, :rtol, :itmax, :t
end
kcopy!(n, Mv, Mv_next) # Mvₖ ← Mvₖ₊₁
MisI || mulorldiv!(v, M, Mv, ldiv) # vₖ₊₁ = M⁻¹ * Mvₖ₊₁
β = sqrt(kdotr(n, v, Mv)) # βₖ₊₁ = vₖ₊₁ᴴ M vₖ₊₁
β = knorm_elliptic(n, v, Mv) # βₖ₊₁ = vₖ₊₁ᴴ M vₖ₊₁
kscal!(n, one(FC) / β, v) # vₖ₊₁ ← vₖ₊₁ / βₖ₊₁
MisI || kscal!(n, one(FC) / β, Mv) # Mvₖ₊₁ ← Mvₖ₊₁ / βₖ₊₁

Expand Down
8 changes: 4 additions & 4 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
β = knorm_elliptic(n, v, v) # β₁ = v₁ᵀ M v₁
kfill!(rNorms, β)
if history
for i = 1 : nshifts
Expand Down Expand Up @@ -203,7 +203,7 @@ kwargs_cgls_lanczos_shift = (:M, :ldiv, :atol, :rtol, :itmax, :timemax, :verbose
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ₖ₊₁
β = knorm_elliptic(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
Expand Down
4 changes: 2 additions & 2 deletions src/cr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ kwargs_cr = (:M, :ldiv, :radius, :linesearch, :γ, :atol, :rtol, :itmax, :timema
mul!(Ar, A, r)
ρ = kdotr(n, r, Ar)

rNorm = sqrt(kdotr(n, r, p)) # ‖r‖
history && push!(rNorms, rNorm) # Values of ‖r‖
rNorm = knorm_elliptic(n, r, p) # ‖r‖
history && push!(rNorms, rNorm) # Values of ‖r‖

if ρ == 0
stats.niter = 0
Expand Down
6 changes: 3 additions & 3 deletions src/craig.jl
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ kwargs_craig = (:M, :N, :ldiv, :transfer_to_lsqr, :sqd, :λ, :btol, :conlim, :at

kcopy!(m, Mu, b) # Mu ← b
MisI || mulorldiv!(u, M, Mu, ldiv)
β₁ = sqrt(kdotr(m, u, Mu))
β₁ = knorm_elliptic(m, u, Mu)
rNorm = β₁
history && push!(rNorms, rNorm)
if β₁ == 0
Expand Down Expand Up @@ -270,7 +270,7 @@ kwargs_craig = (:M, :N, :ldiv, :transfer_to_lsqr, :sqd, :λ, :btol, :conlim, :at
mul!(Aᴴu, Aᴴ, u)
kaxpby!(n, one(FC), Aᴴu, -β, Nv)
NisI || mulorldiv!(v, N, Nv, ldiv)
α = sqrt(kdotr(n, v, Nv))
α = knorm_elliptic(n, v, Nv)
if α == 0
inconsistent = true
continue
Expand Down Expand Up @@ -313,7 +313,7 @@ kwargs_craig = (:M, :N, :ldiv, :transfer_to_lsqr, :sqd, :λ, :btol, :conlim, :at
mul!(Av, A, v)
kaxpby!(m, one(FC), Av, -α, Mu)
MisI || mulorldiv!(u, M, Mu, ldiv)
β = sqrt(kdotr(m, u, Mu))
β = knorm_elliptic(m, u, Mu)
if β 0
kscal!(m, one(FC) / β, u)
MisI || kscal!(m, one(FC) / β, Mu)
Expand Down
8 changes: 4 additions & 4 deletions src/craigmr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ kwargs_craigmr = (:M, :N, :ldiv, :sqd, :λ, :atol, :rtol, :itmax, :timemax, :ver
kfill!(y, zero(FC))
kcopy!(m, Mu, b) # Mu ← b
MisI || mulorldiv!(u, M, Mu, ldiv)
β = sqrt(kdotr(m, u, Mu))
β = knorm_elliptic(m, u, Mu)
if β == 0
stats.niter = 0
stats.solved, stats.inconsistent = true, false
Expand All @@ -210,7 +210,7 @@ kwargs_craigmr = (:M, :N, :ldiv, :sqd, :λ, :atol, :rtol, :itmax, :timemax, :ver
mul!(Aᴴu, Aᴴ, u)
kcopy!(n, Nv, Aᴴu) # Nv ← Aᴴu
NisI || mulorldiv!(v, N, Nv, ldiv)
α = sqrt(kdotr(n, v, Nv))
α = knorm_elliptic(n, v, Nv)
Anorm² = α * α

iter = 0
Expand Down Expand Up @@ -277,7 +277,7 @@ kwargs_craigmr = (:M, :N, :ldiv, :sqd, :λ, :atol, :rtol, :itmax, :timemax, :ver
mul!(Av, A, v)
kaxpby!(m, one(FC), Av, -α, Mu)
MisI || mulorldiv!(u, M, Mu, ldiv)
β = sqrt(kdotr(m, u, Mu))
β = knorm_elliptic(m, u, Mu)
if β 0
kscal!(m, one(FC)/β, u)
MisI || kscal!(m, one(FC)/β, Mu)
Expand Down Expand Up @@ -339,7 +339,7 @@ kwargs_craigmr = (:M, :N, :ldiv, :sqd, :λ, :atol, :rtol, :itmax, :timemax, :ver
mul!(Aᴴu, Aᴴ, u)
kaxpby!(n, one(FC), Aᴴu, -β, Nv)
NisI || mulorldiv!(v, N, Nv, ldiv)
α = sqrt(kdotr(n, v, Nv))
α = knorm_elliptic(n, v, Nv)
Anorm² = Anorm² + α * α # = ‖Lₖ‖
ArNorm = α * β * abs/ρ)
history && push!(ArNorms, ArNorm)
Expand Down
2 changes: 2 additions & 0 deletions src/krylov_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,8 @@ kdotr(n :: Integer, x :: AbstractVector{Complex{T}}, y :: AbstractVector{Complex
knorm(n :: Integer, x :: Vector{T}) where T <: BLAS.BlasFloat = BLAS.nrm2(n, x, 1)
knorm(n :: Integer, x :: AbstractVector{T}) where T <: FloatOrComplex = norm(x)

knorm_elliptic(n :: Integer, x :: AbstractVector{T}, y :: AbstractVector{T}) where T <: FloatOrComplex = (x === y) ? knorm(n, x) : sqrt(kdotr(n, x, y))

kscal!(n :: Integer, s :: T, x :: Vector{T}) where T <: BLAS.BlasFloat = BLAS.scal!(n, s, x, 1)
kscal!(n :: Integer, s :: T, x :: AbstractVector{T}) where T <: FloatOrComplex = (x .*= s)
kscal!(n :: Integer, s :: T, x :: AbstractVector{Complex{T}}) where T <: AbstractFloat = kscal!(n, Complex{T}(s), x)
Expand Down
8 changes: 4 additions & 4 deletions src/lnlq.jl
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ kwargs_lnlq = (:M, :N, :ldiv, :transfer_to_craig, :sqd, :λ, :σ, :utolx, :utoly
# β₁Mu₁ = b.
kcopy!(m, Mu, b) # Mu ← b
MisI || mulorldiv!(u, M, Mu, ldiv) # u₁ = M⁻¹ * Mu₁
βₖ = sqrt(kdotr(m, u, Mu)) # β₁ = ‖u₁‖_M
βₖ = knorm_elliptic(m, u, Mu) # β₁ = ‖u₁‖_M
if βₖ 0
kscal!(m, one(FC) / βₖ, u)
MisI || kscal!(m, one(FC) / βₖ, Mu)
Expand All @@ -238,7 +238,7 @@ kwargs_lnlq = (:M, :N, :ldiv, :transfer_to_craig, :sqd, :λ, :σ, :utolx, :utoly
mul!(Aᴴu, Aᴴ, u)
kcopy!(n, Nv, Aᴴu) # Nv ← Aᴴu
NisI || mulorldiv!(v, N, Nv, ldiv) # v₁ = N⁻¹ * Nv₁
αₖ = sqrt(kdotr(n, v, Nv)) # α₁ = ‖v₁‖_N
αₖ = knorm_elliptic(n, v, Nv) # α₁ = ‖v₁‖_N
if αₖ 0
kscal!(n, one(FC) / αₖ, v)
NisI || kscal!(n, one(FC) / αₖ, Nv)
Expand Down Expand Up @@ -346,7 +346,7 @@ kwargs_lnlq = (:M, :N, :ldiv, :transfer_to_craig, :sqd, :λ, :σ, :utolx, :utoly
mul!(Av, A, v)
kaxpby!(m, one(FC), Av, -αₖ, Mu)
MisI || mulorldiv!(u, M, Mu, ldiv) # uₖ₊₁ = M⁻¹ * Muₖ₊₁
βₖ₊₁ = sqrt(kdotr(m, u, Mu)) # βₖ₊₁ = ‖uₖ₊₁‖_M
βₖ₊₁ = knorm_elliptic(m, u, Mu) # βₖ₊₁ = ‖uₖ₊₁‖_M
if βₖ₊₁ 0
kscal!(m, one(FC) / βₖ₊₁, u)
MisI || kscal!(m, one(FC) / βₖ₊₁, Mu)
Expand All @@ -356,7 +356,7 @@ kwargs_lnlq = (:M, :N, :ldiv, :transfer_to_craig, :sqd, :λ, :σ, :utolx, :utoly
mul!(Aᴴu, Aᴴ, u)
kaxpby!(n, one(FC), Aᴴu, -βₖ₊₁, Nv)
NisI || mulorldiv!(v, N, Nv, ldiv) # vₖ₊₁ = N⁻¹ * Nvₖ₊₁
αₖ₊₁ = sqrt(kdotr(n, v, Nv)) # αₖ₊₁ = ‖vₖ₊₁‖_N
αₖ₊₁ = knorm_elliptic(n, v, Nv) # αₖ₊₁ = ‖vₖ₊₁‖_N
if αₖ₊₁ 0
kscal!(n, one(FC) / αₖ₊₁, v)
NisI || kscal!(n, one(FC) / αₖ₊₁, Nv)
Expand Down
8 changes: 4 additions & 4 deletions src/lslq.jl
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ kwargs_lslq = (:M, :N, :ldiv, :transfer_to_lsqr, :sqd, :λ, :σ, :etol, :utol, :
# β₁ M u₁ = b.
kcopy!(m, Mu, b) # Mu ← b
MisI || mulorldiv!(u, M, Mu, ldiv)
β₁ = sqrt(kdotr(m, u, Mu))
β₁ = knorm_elliptic(m, u, Mu)
if β₁ == 0
stats.niter = 0
stats.solved, stats.inconsistent = true, false
Expand All @@ -246,7 +246,7 @@ kwargs_lslq = (:M, :N, :ldiv, :transfer_to_lsqr, :sqd, :λ, :σ, :etol, :utol, :
mul!(Aᴴu, Aᴴ, u)
kcopy!(n, Nv, Aᴴu) # Nv ← Aᴴu
NisI || mulorldiv!(v, N, Nv, ldiv)
α = sqrt(kdotr(n, v, Nv)) # = α₁
α = knorm_elliptic(n, v, Nv) # = α₁

# Aᴴb = 0 so x = 0 is a minimum least-squares solution
if α == 0
Expand Down Expand Up @@ -326,7 +326,7 @@ kwargs_lslq = (:M, :N, :ldiv, :transfer_to_lsqr, :sqd, :λ, :σ, :etol, :utol, :
mul!(Av, A, v)
kaxpby!(m, one(FC), Av, -α, Mu)
MisI || mulorldiv!(u, M, Mu, ldiv)
β = sqrt(kdotr(m, u, Mu))
β = knorm_elliptic(m, u, Mu)
if β 0
kscal!(m, one(FC)/β, u)
MisI || kscal!(m, one(FC)/β, Mu)
Expand All @@ -335,7 +335,7 @@ kwargs_lslq = (:M, :N, :ldiv, :transfer_to_lsqr, :sqd, :λ, :σ, :etol, :utol, :
mul!(Aᴴu, Aᴴ, u)
kaxpby!(n, one(FC), Aᴴu, -β, Nv)
NisI || mulorldiv!(v, N, Nv, ldiv)
α = sqrt(kdotr(n, v, Nv))
α = knorm_elliptic(n, v, Nv)
if α 0
kscal!(n, one(FC)/α, v)
NisI || kscal!(n, one(FC)/α, Nv)
Expand Down
8 changes: 4 additions & 4 deletions src/lsmr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ kwargs_lsmr = (:M, :N, :ldiv, :sqd, :λ, :radius, :etol, :axtol, :btol, :conlim,
# β₁ M u₁ = b.
kcopy!(m, Mu, b) # Mu ← b
MisI || mulorldiv!(u, M, Mu, ldiv)
β₁ = sqrt(kdotr(m, u, Mu))
β₁ = knorm_elliptic(m, u, Mu)
if β₁ == 0
stats.niter = 0
stats.solved, stats.inconsistent = true, false
Expand All @@ -219,7 +219,7 @@ kwargs_lsmr = (:M, :N, :ldiv, :sqd, :λ, :radius, :etol, :axtol, :btol, :conlim,
mul!(Aᴴu, Aᴴ, u)
kcopy!(n, Nv, Aᴴu) # Nv ← Aᴴu
NisI || mulorldiv!(v, N, Nv, ldiv)
α = sqrt(kdotr(n, v, Nv))
α = knorm_elliptic(n, v, Nv)

ζbar = α * β
αbar = α
Expand Down Expand Up @@ -295,7 +295,7 @@ kwargs_lsmr = (:M, :N, :ldiv, :sqd, :λ, :radius, :etol, :axtol, :btol, :conlim,
mul!(Av, A, v)
kaxpby!(m, one(FC), Av, -α, Mu)
MisI || mulorldiv!(u, M, Mu, ldiv)
β = sqrt(kdotr(m, u, Mu))
β = knorm_elliptic(m, u, Mu)
if β 0
kscal!(m, one(FC)/β, u)
MisI || kscal!(m, one(FC)/β, Mu)
Expand All @@ -304,7 +304,7 @@ kwargs_lsmr = (:M, :N, :ldiv, :sqd, :λ, :radius, :etol, :axtol, :btol, :conlim,
mul!(Aᴴu, Aᴴ, u)
kaxpby!(n, one(FC), Aᴴu, -β, Nv)
NisI || mulorldiv!(v, N, Nv, ldiv)
α = sqrt(kdotr(n, v, Nv))
α = knorm_elliptic(n, v, Nv)
if α 0
kscal!(n, one(FC)/α, v)
NisI || kscal!(n, one(FC)/α, Nv)
Expand Down
6 changes: 3 additions & 3 deletions src/lsqr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ kwargs_lsqr = (:M, :N, :ldiv, :sqd, :λ, :radius, :etol, :axtol, :btol, :conlim,
# β₁ M u₁ = b.
kcopy!(m, Mu, b) # Mu ← b
MisI || mulorldiv!(u, M, Mu, ldiv)
β₁ = sqrt(kdotr(m, u, Mu))
β₁ = knorm_elliptic(m, u, Mu)
if β₁ == 0
stats.niter = 0
stats.solved, stats.inconsistent = true, false
Expand Down Expand Up @@ -283,7 +283,7 @@ kwargs_lsqr = (:M, :N, :ldiv, :sqd, :λ, :radius, :etol, :axtol, :btol, :conlim,
mul!(Av, A, v)
kaxpby!(m, one(FC), Av, -α, Mu)
MisI || mulorldiv!(u, M, Mu, ldiv)
β = sqrt(kdotr(m, u, Mu))
β = knorm_elliptic(m, u, Mu)
if β 0
kscal!(m, one(FC)/β, u)
MisI || kscal!(m, one(FC)/β, Mu)
Expand All @@ -294,7 +294,7 @@ kwargs_lsqr = (:M, :N, :ldiv, :sqd, :λ, :radius, :etol, :axtol, :btol, :conlim,
mul!(Aᴴu, Aᴴ, u)
kaxpby!(n, one(FC), Aᴴu, -β, Nv)
NisI || mulorldiv!(v, N, Nv, ldiv)
α = sqrt(kdotr(n, v, Nv))
α = knorm_elliptic(n, v, Nv)
if α 0
kscal!(n, one(FC)/α, v)
NisI || kscal!(n, one(FC)/α, Nv)
Expand Down
4 changes: 2 additions & 2 deletions src/minres_qlp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ kwargs_minres_qlp = (:M, :ldiv, :λ, :atol, :rtol, :Artol, :itmax, :timemax, :ve

# β₁v₁ = Mb
MisI || mulorldiv!(vₖ, M, M⁻¹vₖ, ldiv)
βₖ = sqrt(kdotr(n, vₖ, M⁻¹vₖ))
βₖ = knorm_elliptic(n, vₖ, M⁻¹vₖ)
if βₖ 0
kscal!(n, one(FC) / βₖ, M⁻¹vₖ)
MisI || kscal!(n, one(FC) / βₖ, vₖ)
Expand Down Expand Up @@ -231,7 +231,7 @@ kwargs_minres_qlp = (:M, :ldiv, :λ, :atol, :rtol, :Artol, :itmax, :timemax, :ve

MisI || mulorldiv!(vₖ₊₁, M, p, ldiv) # βₖ₊₁vₖ₊₁ = MAvₖ - γₖvₖ₋₁ - αₖvₖ

βₖ₊₁ = sqrt(kdotr(m, vₖ₊₁, p))
βₖ₊₁ = knorm_elliptic(m, vₖ₊₁, p)

# βₖ₊₁.ₖ ≠ 0
if βₖ₊₁ > btol
Expand Down
8 changes: 4 additions & 4 deletions src/tricg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ kwargs_tricg = (:M, :N, :ldiv, :spd, :snd, :flip, :τ, :ν, :atol, :rtol, :itmax
# β₁Ev₁ = b ↔ β₁v₁ = Mb
kcopy!(m, M⁻¹vₖ, b₀) # M⁻¹vₖ ← b₀
MisI || mulorldiv!(vₖ, M, M⁻¹vₖ, ldiv)
βₖ = sqrt(kdotr(m, vₖ, M⁻¹vₖ)) # β₁ = ‖v₁‖_E
βₖ = knorm_elliptic(m, vₖ, M⁻¹vₖ) # β₁ = ‖v₁‖_E
if βₖ 0
kscal!(m, one(FC) / βₖ, M⁻¹vₖ)
MisI || kscal!(m, one(FC) / βₖ, vₖ)
Expand All @@ -225,7 +225,7 @@ kwargs_tricg = (:M, :N, :ldiv, :spd, :snd, :flip, :τ, :ν, :atol, :rtol, :itmax
# γ₁Fu₁ = c ↔ γ₁u₁ = Nc
kcopy!(n, N⁻¹uₖ, c₀) # M⁻¹uₖ ← c₀
NisI || mulorldiv!(uₖ, N, N⁻¹uₖ, ldiv)
γₖ = sqrt(kdotr(n, uₖ, N⁻¹uₖ)) # γ₁ = ‖u₁‖_F
γₖ = knorm_elliptic(n, uₖ, N⁻¹uₖ)) # γ₁ = ‖u₁‖_F
if γₖ 0
kscal!(n, one(FC) / γₖ, N⁻¹uₖ)
NisI || kscal!(n, one(FC) / γₖ, uₖ)
Expand Down Expand Up @@ -382,8 +382,8 @@ kwargs_tricg = (:M, :N, :ldiv, :spd, :snd, :flip, :τ, :ν, :atol, :rtol, :itmax
MisI || mulorldiv!(vₖ₊₁, M, q, ldiv) # βₖ₊₁vₖ₊₁ = MAuₖ - γₖvₖ₋₁ - αₖvₖ
NisI || mulorldiv!(uₖ₊₁, N, p, ldiv) # γₖ₊₁uₖ₊₁ = NAᴴvₖ - βₖuₖ₋₁ - ᾱₖuₖ

βₖ₊₁ = sqrt(kdotr(m, vₖ₊₁, q)) # βₖ₊₁ = ‖vₖ₊₁‖_E
γₖ₊₁ = sqrt(kdotr(n, uₖ₊₁, p)) # γₖ₊₁ = ‖uₖ₊₁‖_F
βₖ₊₁ = knorm_elliptic(m, vₖ₊₁, q) # βₖ₊₁ = ‖vₖ₊₁‖_E
γₖ₊₁ = knorm_elliptic(n, uₖ₊₁, p) # γₖ₊₁ = ‖uₖ₊₁‖_F

# βₖ₊₁ ≠ 0
if βₖ₊₁ > btol
Expand Down
8 changes: 4 additions & 4 deletions src/trimr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ kwargs_trimr = (:M, :N, :ldiv, :spd, :snd, :flip, :sp, :τ, :ν, :atol, :rtol, :
# β₁Ev₁ = b ↔ β₁v₁ = Mb
kcopy!(m, M⁻¹vₖ, b₀) # M⁻¹vₖ ← b₀
MisI || mulorldiv!(vₖ, M, M⁻¹vₖ, ldiv)
βₖ = sqrt(kdotr(m, vₖ, M⁻¹vₖ)) # β₁ = ‖v₁‖_E
βₖ = knorm_elliptic(m, vₖ, M⁻¹vₖ) # β₁ = ‖v₁‖_E
if βₖ 0
kscal!(m, one(FC) / βₖ, M⁻¹vₖ)
MisI || kscal!(m, one(FC) / βₖ, vₖ)
Expand All @@ -231,7 +231,7 @@ kwargs_trimr = (:M, :N, :ldiv, :spd, :snd, :flip, :sp, :τ, :ν, :atol, :rtol, :
# γ₁Fu₁ = c ↔ γ₁u₁ = Nc
kcopy!(n, N⁻¹uₖ, c₀) # N⁻¹uₖ ← c₀
NisI || mulorldiv!(uₖ, N, N⁻¹uₖ, ldiv)
γₖ = sqrt(kdotr(n, uₖ, N⁻¹uₖ)) # γ₁ = ‖u₁‖_F
γₖ = knorm_elliptic(n, uₖ, N⁻¹uₖ) # γ₁ = ‖u₁‖_F
if γₖ 0
kscal!(n, one(FC) / γₖ, N⁻¹uₖ)
NisI || kscal!(n, one(FC) / γₖ, uₖ)
Expand Down Expand Up @@ -302,8 +302,8 @@ kwargs_trimr = (:M, :N, :ldiv, :spd, :snd, :flip, :sp, :τ, :ν, :atol, :rtol, :
MisI || mulorldiv!(vₖ₊₁, M, q, ldiv) # βₖ₊₁vₖ₊₁ = MAuₖ - γₖvₖ₋₁ - αₖvₖ
NisI || mulorldiv!(uₖ₊₁, N, p, ldiv) # γₖ₊₁uₖ₊₁ = NAᴴvₖ - βₖuₖ₋₁ - ᾱₖuₖ

βₖ₊₁ = sqrt(kdotr(m, vₖ₊₁, q)) # βₖ₊₁ = ‖vₖ₊₁‖_E
γₖ₊₁ = sqrt(kdotr(n, uₖ₊₁, p)) # γₖ₊₁ = ‖uₖ₊₁‖_F
βₖ₊₁ = knorm_elliptic(m, vₖ₊₁, q) # βₖ₊₁ = ‖vₖ₊₁‖_E
γₖ₊₁ = knorm_elliptic(n, uₖ₊₁, p) # γₖ₊₁ = ‖uₖ₊₁‖_F

# βₖ₊₁ ≠ 0
if βₖ₊₁ > btol
Expand Down

0 comments on commit 63c0806

Please sign in to comment.