Skip to content

Commit e619444

Browse files
Fix reltol type instability in Newton solver
The issue was that reltol could be either a scalar (when adaptive=false) or the value from integrator.opts.reltol (which could be scalar or vector). This runtime branch caused type instability. The fix checks both conditions at once to ensure reltol is only set to eps(eltype(dz)) when it would actually be a scalar, avoiding the type instability when reltol is a vector. Fixes part of issue #2819
1 parent cd924d2 commit e619444

File tree

1 file changed

+3
-3
lines changed
  • lib/OrdinaryDiffEqNonlinearSolve/src

1 file changed

+3
-3
lines changed

lib/OrdinaryDiffEqNonlinearSolve/src/newton.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,10 +246,10 @@ end
246246
update_coefficients!(W, ustep, p, tstep; dtgamma = γW, transform = true)
247247
end
248248

249-
if integrator.opts.adaptive
250-
reltol = integrator.opts.reltol
251-
else
249+
if !integrator.opts.adaptive && !(integrator.opts.reltol isa AbstractArray)
252250
reltol = eps(eltype(dz))
251+
else
252+
reltol = integrator.opts.reltol
253253
end
254254

255255
if is_always_new(nlsolver) || (iter == 1 && new_W)

0 commit comments

Comments
 (0)