Skip to content

Commit 40a9ded

Browse files
committed
try fixing LM for banded jacobian
1 parent b07360f commit 40a9ded

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "NonlinearSolve"
22
uuid = "8913a72c-1f9b-4ce2-8d82-65094dcecaec"
33
authors = ["SciML"]
4-
version = "2.6.0"
4+
version = "2.6.1"
55

66
[deps]
77
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"

src/levenberg.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ function perform_step!(cache::LevenbergMarquardtCache{true, fastls}) where {fast
260260
# Usual Levenberg-Marquardt step ("velocity").
261261
# The following lines do: cache.v = -cache.mat_tmp \ cache.u_tmp
262262
if fastls
263-
cache.mat_tmp[1:length(fu1), :] .= cache.J
263+
copyto!(@view(cache.mat_tmp[1:length(fu1), :]), cache.J)
264264
cache.mat_tmp[(length(fu1) + 1):end, :] .= λ .* cache.DᵀD
265265
cache.rhs_tmp[1:length(fu1)] .= _vec(fu1)
266266
linres = dolinsolve(alg.precs, linsolve; A = cache.mat_tmp,
@@ -299,8 +299,8 @@ function perform_step!(cache::LevenbergMarquardtCache{true, fastls}) where {fast
299299
cache.stats.nfactors += 2
300300

301301
# Require acceptable steps to satisfy the following condition.
302-
norm_v = norm(v)
303-
if 2 * norm(cache.a) α_geodesic * norm_v
302+
norm_v = cache.internalnorm(v)
303+
if 2 * cache.internalnorm(cache.a) α_geodesic * norm_v
304304
_vec(cache.δ) .= _vec(v) .+ _vec(cache.a) ./ 2
305305
@unpack δ, loss_old, norm_v_old, v_old, b_uphill = cache
306306
f(cache.fu_tmp, u .+ δ, p)
@@ -356,7 +356,7 @@ function perform_step!(cache::LevenbergMarquardtCache{false, fastls}) where {fas
356356

357357
# Usual Levenberg-Marquardt step ("velocity").
358358
if fastls
359-
cache.mat_tmp = vcat(J, λ .* cache.DᵀD)
359+
cache.mat_tmp = _vcat(J, λ .* cache.DᵀD)
360360
cache.rhs_tmp[1:length(fu1)] .= -_vec(fu1)
361361
linres = dolinsolve(alg.precs, linsolve; A = cache.mat_tmp,
362362
b = cache.rhs_tmp, linu = _vec(cache.v), p = p, reltol = cache.abstol)
@@ -392,8 +392,8 @@ function perform_step!(cache::LevenbergMarquardtCache{false, fastls}) where {fas
392392
cache.stats.nfactors += 1
393393

394394
# Require acceptable steps to satisfy the following condition.
395-
norm_v = norm(v)
396-
if 2 * norm(cache.a) α_geodesic * norm_v
395+
norm_v = cache.internalnorm(v)
396+
if 2 * cache.internalnorm(cache.a) α_geodesic * norm_v
397397
cache.δ = _restructure(cache.δ, _vec(v) .+ _vec(cache.a) ./ 2)
398398
@unpack δ, loss_old, norm_v_old, v_old, b_uphill = cache
399399
fu_new = f(u .+ δ, p)

0 commit comments

Comments
 (0)