Skip to content
This repository was archived by the owner on May 15, 2025. It is now read-only.

Commit 9737208

Browse files
Merge pull request #86 from SciML/simplehally
Halley -> SimpleHalley
2 parents 354bb89 + 2107cd7 commit 9737208

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

src/SimpleNonlinearSolve.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ import PrecompileTools
6464
PrecompileTools.@compile_workload begin
6565
for T in (Float32, Float64)
6666
prob_no_brack = NonlinearProblem{false}((u, p) -> u .* u .- p, T(0.1), T(2))
67-
for alg in (SimpleNewtonRaphson, Halley, Broyden, Klement, SimpleTrustRegion,
67+
for alg in (SimpleNewtonRaphson, SimpleHalley, Broyden, Klement, SimpleTrustRegion,
6868
SimpleDFSane)
6969
solve(prob_no_brack, alg(), abstol = T(1e-2))
7070
end
@@ -88,8 +88,7 @@ PrecompileTools.@compile_workload begin
8888
end
8989
end
9090

91-
# DiffEq styled algorithms
92-
export Bisection, Brent, Broyden, LBroyden, SimpleDFSane, Falsi, Halley, Klement,
91+
export Bisection, Brent, Broyden, LBroyden, SimpleDFSane, Falsi, SimpleHalley, Klement,
9392
Ridder, SimpleNewtonRaphson, SimpleTrustRegion, Alefeld, ITP
9493
export BatchedBroyden, BatchedSimpleNewtonRaphson, BatchedSimpleDFSane
9594

src/halley.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
"""
22
```julia
3-
Halley(; chunk_size = Val{0}(), autodiff = Val{true}(),
3+
SimpleHalley(; chunk_size = Val{0}(), autodiff = Val{true}(),
44
diff_type = Val{:forward})
55
```
66
7-
A low-overhead implementation of Halley's Method. This method is non-allocating on scalar
7+
A low-overhead implementation of SimpleHalley's Method. This method is non-allocating on scalar
88
and static array problems.
99
1010
!!! note
@@ -28,16 +28,16 @@ and static array problems.
2828
`Val{:forward}` for forward finite differences. For more details on the choices, see the
2929
[FiniteDiff.jl](https://github.com/JuliaDiff/FiniteDiff.jl) documentation.
3030
"""
31-
struct Halley{CS, AD, FDT} <: AbstractNewtonAlgorithm{CS, AD, FDT}
32-
function Halley(; chunk_size = Val{0}(), autodiff = Val{true}(),
31+
struct SimpleHalley{CS, AD, FDT} <: AbstractNewtonAlgorithm{CS, AD, FDT}
32+
function SimpleHalley(; chunk_size = Val{0}(), autodiff = Val{true}(),
3333
diff_type = Val{:forward})
3434
new{SciMLBase._unwrap_val(chunk_size), SciMLBase._unwrap_val(autodiff),
3535
SciMLBase._unwrap_val(diff_type)}()
3636
end
3737
end
3838

3939
function SciMLBase.__solve(prob::NonlinearProblem,
40-
alg::Halley, args...; abstol = nothing,
40+
alg::SimpleHalley, args...; abstol = nothing,
4141
reltol = nothing,
4242
maxiters = 1000, kwargs...)
4343
f = Base.Fix2(prob.f, prob.p)
@@ -49,7 +49,7 @@ function SciMLBase.__solve(prob::NonlinearProblem,
4949
T = typeof(x)
5050

5151
if SciMLBase.isinplace(prob)
52-
error("Halley currently only supports out-of-place nonlinear problems")
52+
error("SimpleHalley currently only supports out-of-place nonlinear problems")
5353
end
5454

5555
atol = abstol !== nothing ? abstol :

test/basictests.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ if VERSION >= v"1.7"
5656
@test (@ballocated benchmark_scalar(sf, csu0)) == 0
5757
end
5858

59-
# Halley
59+
# SimpleHalley
6060
function benchmark_scalar(f, u0)
6161
probN = NonlinearProblem{false}(f, u0)
62-
sol = (solve(probN, Halley()))
62+
sol = (solve(probN, SimpleHalley()))
6363
end
6464

6565
function ff(u, p)
@@ -139,7 +139,7 @@ using ForwardDiff
139139
f, u0 = (u, p) -> u .* u .- p, @SVector[1.0, 1.0]
140140

141141
for alg in (SimpleNewtonRaphson(), LBroyden(), Klement(), SimpleTrustRegion(),
142-
SimpleDFSane(), Halley(), BROYDEN_SOLVERS...)
142+
SimpleDFSane(), SimpleHalley(), BROYDEN_SOLVERS...)
143143
g = function (p)
144144
probN = NonlinearProblem{false}(f, csu0, p)
145145
sol = solve(probN, alg, abstol = 1e-9)
@@ -162,7 +162,7 @@ end
162162
# Scalar
163163
f, u0 = (u, p) -> u * u - p, 1.0
164164
for alg in (SimpleNewtonRaphson(), Klement(), SimpleTrustRegion(),
165-
SimpleDFSane(), Halley(), BROYDEN_SOLVERS..., LBROYDEN_SOLVERS...)
165+
SimpleDFSane(), SimpleHalley(), BROYDEN_SOLVERS..., LBROYDEN_SOLVERS...)
166166
g = function (p)
167167
probN = NonlinearProblem{false}(f, oftype(p, u0), p)
168168
sol = solve(probN, alg)
@@ -271,7 +271,7 @@ for alg in [Bisection(), Falsi(), Ridder(), Brent(), ITP()]
271271
end
272272

273273
for alg in (SimpleNewtonRaphson(), Klement(), SimpleTrustRegion(),
274-
SimpleDFSane(), Halley(), BROYDEN_SOLVERS..., LBROYDEN_SOLVERS...)
274+
SimpleDFSane(), SimpleHalley(), BROYDEN_SOLVERS..., LBROYDEN_SOLVERS...)
275275
global g, p
276276
g = function (p)
277277
probN = NonlinearProblem{false}(f, 0.5, p)
@@ -288,7 +288,7 @@ probN = NonlinearProblem(f, u0)
288288

289289
for alg in (SimpleNewtonRaphson(), SimpleNewtonRaphson(; autodiff = false),
290290
SimpleTrustRegion(),
291-
SimpleTrustRegion(; autodiff = false), Halley(), Halley(; autodiff = false),
291+
SimpleTrustRegion(; autodiff = false), SimpleHalley(), SimpleHalley(; autodiff = false),
292292
Klement(), SimpleDFSane(),
293293
BROYDEN_SOLVERS..., LBROYDEN_SOLVERS...)
294294
sol = solve(probN, alg)

0 commit comments

Comments
 (0)