diff --git a/lib/NonlinearSolveBase/src/abstract_types.jl b/lib/NonlinearSolveBase/src/abstract_types.jl index a01aa7afb..3cdb59a1d 100644 --- a/lib/NonlinearSolveBase/src/abstract_types.jl +++ b/lib/NonlinearSolveBase/src/abstract_types.jl @@ -576,7 +576,8 @@ macro internal_caches(cType, internal_cache_names...) $(callbacks_self...) return end - function NonlinearSolveBase.InternalAPI.reinit!(cache::$(cType), args...; kwargs...) + function NonlinearSolveBase.InternalAPI.reinit!( + cache::$(cType), args...; kwargs...) $(reinit_caches...) $(InternalAPI.reinit_self!)(cache, args...; kwargs...) return diff --git a/lib/NonlinearSolveFirstOrder/src/gauss_newton.jl b/lib/NonlinearSolveFirstOrder/src/gauss_newton.jl index e69de29bb..8b1378917 100644 --- a/lib/NonlinearSolveFirstOrder/src/gauss_newton.jl +++ b/lib/NonlinearSolveFirstOrder/src/gauss_newton.jl @@ -0,0 +1 @@ + diff --git a/lib/NonlinearSolveFirstOrder/src/levenberg_marquardt.jl b/lib/NonlinearSolveFirstOrder/src/levenberg_marquardt.jl index e69de29bb..8b1378917 100644 --- a/lib/NonlinearSolveFirstOrder/src/levenberg_marquardt.jl +++ b/lib/NonlinearSolveFirstOrder/src/levenberg_marquardt.jl @@ -0,0 +1 @@ + diff --git a/lib/NonlinearSolveFirstOrder/src/pseudo_transient.jl b/lib/NonlinearSolveFirstOrder/src/pseudo_transient.jl index e69de29bb..8b1378917 100644 --- a/lib/NonlinearSolveFirstOrder/src/pseudo_transient.jl +++ b/lib/NonlinearSolveFirstOrder/src/pseudo_transient.jl @@ -0,0 +1 @@ + diff --git a/lib/NonlinearSolveFirstOrder/src/raphson.jl b/lib/NonlinearSolveFirstOrder/src/raphson.jl index e69de29bb..8b1378917 100644 --- a/lib/NonlinearSolveFirstOrder/src/raphson.jl +++ b/lib/NonlinearSolveFirstOrder/src/raphson.jl @@ -0,0 +1 @@ + diff --git a/lib/NonlinearSolveFirstOrder/src/trust_region.jl b/lib/NonlinearSolveFirstOrder/src/trust_region.jl index e69de29bb..8b1378917 100644 --- a/lib/NonlinearSolveFirstOrder/src/trust_region.jl +++ b/lib/NonlinearSolveFirstOrder/src/trust_region.jl @@ -0,0 +1 @@ + diff --git a/lib/NonlinearSolveQuasiNewton/src/NonlinearSolveQuasiNewton.jl b/lib/NonlinearSolveQuasiNewton/src/NonlinearSolveQuasiNewton.jl index 7068ebc60..aace3b0e8 100644 --- a/lib/NonlinearSolveQuasiNewton/src/NonlinearSolveQuasiNewton.jl +++ b/lib/NonlinearSolveQuasiNewton/src/NonlinearSolveQuasiNewton.jl @@ -7,7 +7,7 @@ using ArrayInterface: ArrayInterface using CommonSolve: CommonSolve using ConcreteStructs: @concrete using DiffEqBase: DiffEqBase # Needed for `init` / `solve` dispatches -using LinearAlgebra: LinearAlgebra, Diagonal, dot, inv, diag +using LinearAlgebra: LinearAlgebra, Diagonal, dot, diag using LinearSolve: LinearSolve # Trigger Linear Solve extension in NonlinearSolveBase using MaybeInplace: @bb using NonlinearSolveBase: NonlinearSolveBase, AbstractNonlinearSolveAlgorithm, diff --git a/lib/NonlinearSolveQuasiNewton/src/broyden.jl b/lib/NonlinearSolveQuasiNewton/src/broyden.jl index 60adc9be5..08570a735 100644 --- a/lib/NonlinearSolveQuasiNewton/src/broyden.jl +++ b/lib/NonlinearSolveQuasiNewton/src/broyden.jl @@ -150,11 +150,13 @@ function InternalAPI.solve!( if cache.rule isa GoodBroydenUpdateRule @bb @. J⁻¹_diag = J⁻¹_diag * cache.dfu * du denom = sum(J⁻¹_diag) - @bb @. J⁻¹_diag = J⁻¹_diag + (du - J⁻¹_diag * cache.dfu) * du * J⁻¹_diag / + @bb @. J⁻¹_diag = J⁻¹_diag + + (du - J⁻¹_diag * cache.dfu) * du * J⁻¹_diag / ifelse(iszero(denom), T(1e-5), denom) else denom = cache.internalnorm(cache.dfu)^2 - @bb @. J⁻¹_diag = J⁻¹_diag + (du - J⁻¹_diag * cache.dfu) * cache.dfu / + @bb @. J⁻¹_diag = J⁻¹_diag + + (du - J⁻¹_diag * cache.dfu) * cache.dfu / ifelse(iszero(denom), T(1e-5), denom) end @bb copyto!(cache.dfu, fu) diff --git a/lib/NonlinearSolveQuasiNewton/src/structure.jl b/lib/NonlinearSolveQuasiNewton/src/structure.jl index 2d5c0baa5..09438289b 100644 --- a/lib/NonlinearSolveQuasiNewton/src/structure.jl +++ b/lib/NonlinearSolveQuasiNewton/src/structure.jl @@ -11,7 +11,7 @@ function NonlinearSolveBase.get_full_jacobian(cache, ::DiagonalStructure, J) end function (::DiagonalStructure)(J::AbstractMatrix; alias::Bool = false) - @assert size(J, 1) == size(J, 2) "Diagonal Jacobian Structure must be square!" + @assert size(J, 1)==size(J, 2) "Diagonal Jacobian Structure must be square!" return LinearAlgebra.diag(J) end (::DiagonalStructure)(J::AbstractVector; alias::Bool = false) = alias ? J : @bb(copy(J)) diff --git a/src/utils.jl b/src/utils.jl index 20602d2db..0a2375ef9 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -26,7 +26,6 @@ end return fx_idx, idx end - """ pickchunksize(x) = pickchunksize(length(x)) pickchunksize(x::Int)