@@ -209,21 +209,22 @@ function perform_step!(cache::LevenbergMarquardtCache{true})
209
209
210
210
# Usual Levenberg-Marquardt step ("velocity").
211
211
# The following lines do: cache.v = -cache.mat_tmp \ cache.u_tmp
212
- mul! (cache. u_tmp, J' , fu1)
212
+ mul! (_vec ( cache. u_tmp) , J' , _vec ( fu1) )
213
213
@. cache. mat_tmp = JᵀJ + λ * DᵀD
214
214
linres = dolinsolve (alg. precs, linsolve; A = __maybe_symmetric (cache. mat_tmp),
215
215
b = _vec (cache. u_tmp), linu = _vec (cache. du), p = p, reltol = cache. abstol)
216
216
cache. linsolve = linres. cache
217
- @. cache. v = - cache. du
217
+ _vec ( cache. v) . = .- _vec ( cache. du)
218
218
219
219
# Geodesic acceleration (step_size = v + a / 2).
220
220
@unpack v, α_geodesic, h = cache
221
- f (cache. fu_tmp, u .+ h .* v, p)
221
+ _vec (cache. du) .= _vec (u) .+ h .* _vec (v)
222
+ f (cache. fu_tmp, cache. du, p)
222
223
223
224
# The following lines do: cache.a = -J \ cache.fu_tmp
224
- mul! (cache. Jv, J, v )
225
+ mul! (_vec ( cache. Jv) , J, _vec (v) )
225
226
@. cache. fu_tmp = (2 / h) * ((cache. fu_tmp - fu1) / h - cache. Jv)
226
- mul! (cache. u_tmp, J' , cache. fu_tmp)
227
+ mul! (_vec ( cache. u_tmp) , J' , _vec ( cache. fu_tmp) )
227
228
# NOTE: Don't pass `A` in again, since we want to reuse the previous solve
228
229
linres = dolinsolve (alg. precs, linsolve; b = _vec (cache. u_tmp),
229
230
linu = _vec (cache. du), p = p, reltol = cache. abstol)
@@ -235,7 +236,7 @@ function perform_step!(cache::LevenbergMarquardtCache{true})
235
236
# Require acceptable steps to satisfy the following condition.
236
237
norm_v = norm (v)
237
238
if 2 * norm (cache. a) ≤ α_geodesic * norm_v
238
- @. cache. δ = v + cache. a / 2
239
+ _vec ( cache. δ) . = _vec (v) .+ _vec ( cache. a) . / 2
239
240
@unpack δ, loss_old, norm_v_old, v_old, b_uphill = cache
240
241
f (cache. fu_tmp, u .+ δ, p)
241
242
cache. stats. nf += 1
@@ -251,7 +252,7 @@ function perform_step!(cache::LevenbergMarquardtCache{true})
251
252
return nothing
252
253
end
253
254
cache. fu1 .= cache. fu_tmp
254
- cache. v_old .= v
255
+ _vec ( cache. v_old) .= _vec (v)
255
256
cache. norm_v_old = norm_v
256
257
cache. loss_old = loss
257
258
cache. λ_factor = 1 / cache. damping_decrease_factor
0 commit comments