From b25eb740fc8632c287b21cdc4ad01010cdc7e1b7 Mon Sep 17 00:00:00 2001 From: Avik Pal Date: Sun, 8 Oct 2023 17:47:06 -0400 Subject: [PATCH] Remove special iszero handling --- src/gaussnewton.jl | 4 +--- src/levenberg.jl | 4 ++-- src/utils.jl | 4 ---- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/gaussnewton.jl b/src/gaussnewton.jl index 973be9288..7c94ec4f3 100644 --- a/src/gaussnewton.jl +++ b/src/gaussnewton.jl @@ -132,9 +132,7 @@ function perform_step!(cache::GaussNewtonCache{false}) cache.u = @. u - cache.du # `u` might not support mutation cache.fu_new = f(cache.u, p) - (cache.internalnorm(cache.fu_new .- cache.fu1) < cache.abstol || - cache.internalnorm(cache.fu_new) < cache.abstol) && - (cache.force_stop = true) + (cache.internalnorm(cache.fu_new) < cache.abstol) && (cache.force_stop = true) cache.fu1 = cache.fu_new cache.stats.nf += 1 cache.stats.njacs += 1 diff --git a/src/levenberg.jl b/src/levenberg.jl index f43eff0a1..426b585fa 100644 --- a/src/levenberg.jl +++ b/src/levenberg.jl @@ -185,7 +185,7 @@ end function perform_step!(cache::LevenbergMarquardtCache{true}) @unpack fu1, f, make_new_J = cache - if _iszero(fu1) + if iszero(fu1) cache.force_stop = true return nothing end @@ -256,7 +256,7 @@ end function perform_step!(cache::LevenbergMarquardtCache{false}) @unpack fu1, f, make_new_J = cache - if _iszero(fu1) + if iszero(fu1) cache.force_stop = true return nothing end diff --git a/src/utils.jl b/src/utils.jl index 9aa2e71bc..bd6a5a036 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -129,10 +129,6 @@ end concrete_jac(_) = nothing concrete_jac(::AbstractNewtonAlgorithm{CJ}) where {CJ} = CJ -# Circumventing https://github.com/SciML/RecursiveArrayTools.jl/issues/277 -_iszero(x) = iszero(x) -_iszero(x::ArrayPartition) = all(_iszero, x.x) - _mutable_zero(x) = zero(x) _mutable_zero(x::SArray) = MArray(x)