Skip to content

Commit 4bdf983

Browse files
committed
Patch the OOP version as well
1 parent 0b4b5b9 commit 4bdf983

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/levenberg.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,18 +274,19 @@ function perform_step!(cache::LevenbergMarquardtCache{false})
274274
end
275275
@unpack u, p, λ, JᵀJ, DᵀD, J = cache
276276

277+
cache.mat_tmp = JᵀJ + λ * DᵀD
277278
# Usual Levenberg-Marquardt step ("velocity").
278-
cache.v = -(JᵀJ + λ * DᵀD) \ (J' * fu1)
279+
cache.v = -cache.mat_tmp \ (J' * fu1)
279280

280281
@unpack v, h, α_geodesic = cache
281282
# Geodesic acceleration (step_size = v + a / 2).
282-
cache.a = -J \ ((2 / h) .* ((f(u .+ h .* v, p) .- fu1) ./ h .- J * v))
283+
cache.a = -cache.mat_tmp \ ((2 / h) .* ((f(u .+ h .* v, p) .- fu1) ./ h .- J * v))
283284
cache.stats.nsolve += 1
284285
cache.stats.nfactors += 1
285286

286287
# Require acceptable steps to satisfy the following condition.
287288
norm_v = norm(v)
288-
if (2 * norm(cache.a) / norm_v) < α_geodesic
289+
if @fastmath((1 + log2(norm(cache.a)) - log2(norm_v))log2(α_geodesic))
289290
cache.δ = v .+ cache.a ./ 2
290291
@unpack δ, loss_old, norm_v_old, v_old, b_uphill = cache
291292
fu_new = f(u .+ δ, p)

0 commit comments

Comments
 (0)