diff --git a/lib/SimpleNonlinearSolve/src/SimpleNonlinearSolve.jl b/lib/SimpleNonlinearSolve/src/SimpleNonlinearSolve.jl index 85052e5ff..96d76d92e 100644 --- a/lib/SimpleNonlinearSolve/src/SimpleNonlinearSolve.jl +++ b/lib/SimpleNonlinearSolve/src/SimpleNonlinearSolve.jl @@ -64,7 +64,7 @@ import PrecompileTools PrecompileTools.@compile_workload begin for T in (Float32, Float64) prob_no_brack = NonlinearProblem{false}((u, p) -> u .* u .- p, T(0.1), T(2)) - for alg in (SimpleNewtonRaphson, Halley, Broyden, Klement, SimpleTrustRegion, + for alg in (SimpleNewtonRaphson, SimpleHalley, Broyden, Klement, SimpleTrustRegion, SimpleDFSane) solve(prob_no_brack, alg(), abstol = T(1e-2)) end @@ -88,8 +88,7 @@ PrecompileTools.@compile_workload begin end end -# DiffEq styled algorithms -export Bisection, Brent, Broyden, LBroyden, SimpleDFSane, Falsi, Halley, Klement, +export Bisection, Brent, Broyden, LBroyden, SimpleDFSane, Falsi, SimpleHalley, Klement, Ridder, SimpleNewtonRaphson, SimpleTrustRegion, Alefeld, ITP export BatchedBroyden, BatchedSimpleNewtonRaphson, BatchedSimpleDFSane diff --git a/lib/SimpleNonlinearSolve/src/halley.jl b/lib/SimpleNonlinearSolve/src/halley.jl index 9e97a57cd..29cc1e54f 100644 --- a/lib/SimpleNonlinearSolve/src/halley.jl +++ b/lib/SimpleNonlinearSolve/src/halley.jl @@ -1,10 +1,10 @@ """ ```julia -Halley(; chunk_size = Val{0}(), autodiff = Val{true}(), +SimpleHalley(; chunk_size = Val{0}(), autodiff = Val{true}(), diff_type = Val{:forward}) ``` -A low-overhead implementation of Halley's Method. This method is non-allocating on scalar +A low-overhead implementation of SimpleHalley's Method. This method is non-allocating on scalar and static array problems. !!! note @@ -28,8 +28,8 @@ and static array problems. `Val{:forward}` for forward finite differences. For more details on the choices, see the [FiniteDiff.jl](https://github.com/JuliaDiff/FiniteDiff.jl) documentation. """ -struct Halley{CS, AD, FDT} <: AbstractNewtonAlgorithm{CS, AD, FDT} - function Halley(; chunk_size = Val{0}(), autodiff = Val{true}(), +struct SimpleHalley{CS, AD, FDT} <: AbstractNewtonAlgorithm{CS, AD, FDT} + function SimpleHalley(; chunk_size = Val{0}(), autodiff = Val{true}(), diff_type = Val{:forward}) new{SciMLBase._unwrap_val(chunk_size), SciMLBase._unwrap_val(autodiff), SciMLBase._unwrap_val(diff_type)}() @@ -37,7 +37,7 @@ struct Halley{CS, AD, FDT} <: AbstractNewtonAlgorithm{CS, AD, FDT} end function SciMLBase.__solve(prob::NonlinearProblem, - alg::Halley, args...; abstol = nothing, + alg::SimpleHalley, args...; abstol = nothing, reltol = nothing, maxiters = 1000, kwargs...) f = Base.Fix2(prob.f, prob.p) @@ -49,7 +49,7 @@ function SciMLBase.__solve(prob::NonlinearProblem, T = typeof(x) if SciMLBase.isinplace(prob) - error("Halley currently only supports out-of-place nonlinear problems") + error("SimpleHalley currently only supports out-of-place nonlinear problems") end atol = abstol !== nothing ? abstol : diff --git a/lib/SimpleNonlinearSolve/test/basictests.jl b/lib/SimpleNonlinearSolve/test/basictests.jl index 34468be58..027f766ed 100644 --- a/lib/SimpleNonlinearSolve/test/basictests.jl +++ b/lib/SimpleNonlinearSolve/test/basictests.jl @@ -56,10 +56,10 @@ if VERSION >= v"1.7" @test (@ballocated benchmark_scalar(sf, csu0)) == 0 end -# Halley +# SimpleHalley function benchmark_scalar(f, u0) probN = NonlinearProblem{false}(f, u0) - sol = (solve(probN, Halley())) + sol = (solve(probN, SimpleHalley())) end function ff(u, p) @@ -139,7 +139,7 @@ using ForwardDiff f, u0 = (u, p) -> u .* u .- p, @SVector[1.0, 1.0] for alg in (SimpleNewtonRaphson(), LBroyden(), Klement(), SimpleTrustRegion(), - SimpleDFSane(), Halley(), BROYDEN_SOLVERS...) + SimpleDFSane(), SimpleHalley(), BROYDEN_SOLVERS...) g = function (p) probN = NonlinearProblem{false}(f, csu0, p) sol = solve(probN, alg, abstol = 1e-9) @@ -162,7 +162,7 @@ end # Scalar f, u0 = (u, p) -> u * u - p, 1.0 for alg in (SimpleNewtonRaphson(), Klement(), SimpleTrustRegion(), - SimpleDFSane(), Halley(), BROYDEN_SOLVERS..., LBROYDEN_SOLVERS...) + SimpleDFSane(), SimpleHalley(), BROYDEN_SOLVERS..., LBROYDEN_SOLVERS...) g = function (p) probN = NonlinearProblem{false}(f, oftype(p, u0), p) sol = solve(probN, alg) @@ -271,7 +271,7 @@ for alg in [Bisection(), Falsi(), Ridder(), Brent(), ITP()] end for alg in (SimpleNewtonRaphson(), Klement(), SimpleTrustRegion(), - SimpleDFSane(), Halley(), BROYDEN_SOLVERS..., LBROYDEN_SOLVERS...) + SimpleDFSane(), SimpleHalley(), BROYDEN_SOLVERS..., LBROYDEN_SOLVERS...) global g, p g = function (p) probN = NonlinearProblem{false}(f, 0.5, p) @@ -288,7 +288,7 @@ probN = NonlinearProblem(f, u0) for alg in (SimpleNewtonRaphson(), SimpleNewtonRaphson(; autodiff = false), SimpleTrustRegion(), - SimpleTrustRegion(; autodiff = false), Halley(), Halley(; autodiff = false), + SimpleTrustRegion(; autodiff = false), SimpleHalley(), SimpleHalley(; autodiff = false), Klement(), SimpleDFSane(), BROYDEN_SOLVERS..., LBROYDEN_SOLVERS...) sol = solve(probN, alg)