Skip to content

Commit

Permalink
Patch the OOP version as well
Browse files Browse the repository at this point in the history
  • Loading branch information
avik-pal committed Oct 3, 2023
1 parent 0b4b5b9 commit 4bdf983
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/levenberg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -274,18 +274,19 @@ function perform_step!(cache::LevenbergMarquardtCache{false})
end
@unpack u, p, λ, JᵀJ, DᵀD, J = cache

cache.mat_tmp = JᵀJ + λ * DᵀD

Check warning on line 277 in src/levenberg.jl

View check run for this annotation

Codecov / codecov/patch

src/levenberg.jl#L277

Added line #L277 was not covered by tests
# Usual Levenberg-Marquardt step ("velocity").
cache.v = -(JᵀJ + λ * DᵀD) \ (J' * fu1)
cache.v = -cache.mat_tmp \ (J' * fu1)

Check warning on line 279 in src/levenberg.jl

View check run for this annotation

Codecov / codecov/patch

src/levenberg.jl#L279

Added line #L279 was not covered by tests

@unpack v, h, α_geodesic = cache
# Geodesic acceleration (step_size = v + a / 2).
cache.a = -J \ ((2 / h) .* ((f(u .+ h .* v, p) .- fu1) ./ h .- J * v))
cache.a = -cache.mat_tmp \ ((2 / h) .* ((f(u .+ h .* v, p) .- fu1) ./ h .- J * v))

Check warning on line 283 in src/levenberg.jl

View check run for this annotation

Codecov / codecov/patch

src/levenberg.jl#L283

Added line #L283 was not covered by tests
cache.stats.nsolve += 1
cache.stats.nfactors += 1

# Require acceptable steps to satisfy the following condition.
norm_v = norm(v)
if (2 * norm(cache.a) / norm_v) < α_geodesic
if @fastmath((1 + log2(norm(cache.a)) - log2(norm_v))log2(α_geodesic))

Check warning on line 289 in src/levenberg.jl

View check run for this annotation

Codecov / codecov/patch

src/levenberg.jl#L289

Added line #L289 was not covered by tests
cache.δ = v .+ cache.a ./ 2
@unpack δ, loss_old, norm_v_old, v_old, b_uphill = cache
fu_new = f(u .+ δ, p)
Expand Down

0 comments on commit 4bdf983

Please sign in to comment.