Skip to content

Commit 649a877

Browse files
committed
feat: add bracketing default algorithm
1 parent 9908962 commit 649a877

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

lib/BracketingNonlinearSolve/src/BracketingNonlinearSolve.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ include("falsi.jl")
1919
include("itp.jl")
2020
include("ridder.jl")
2121

22+
# Default Algorithm
23+
function CommonSolve.solve(prob::IntervalNonlinearProblem; kwargs...)
24+
return CommonSolve.solve(prob, ITP(); kwargs...)
25+
end
26+
function CommonSolve.solve(prob::IntervalNonlinearProblem, nothing, args...; kwargs...)
27+
return CommonSolve.solve(prob, ITP(), args...; kwargs...)
28+
end
29+
2230
@setup_workload begin
2331
for T in (Float32, Float64)
2432
prob_brack = IntervalNonlinearProblem{false}(

lib/BracketingNonlinearSolve/test/rootfind_tests.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ end
77
@testitem "Interval Nonlinear Problems" setup=[RootfindingTestSnippet] tags=[:core] begin
88
using ForwardDiff
99

10-
@testset for alg in (Bisection(), Falsi(), Ridder(), Brent(), ITP(), Alefeld())
10+
@testset for alg in (Bisection(), Falsi(), Ridder(), Brent(), ITP(), Alefeld(), nothing)
1111
tspan = (1.0, 20.0)
1212

1313
function g(p)
@@ -52,7 +52,7 @@ end
5252
prob = IntervalNonlinearProblem(quadratic_f, (1.0, 20.0), 2.0)
5353
ϵ = eps(Float64) # least possible tol for all methods
5454

55-
@testset for alg in (Bisection(), Falsi(), ITP())
55+
@testset for alg in (Bisection(), Falsi(), ITP(), nothing)
5656
@testset for abstol in [0.1, 0.01, 0.001, 0.0001, 1e-5, 1e-6, 1e-7]
5757
sol = solve(prob, alg; abstol)
5858
result_tol = abs(sol.u - sqrt(2))
@@ -76,7 +76,7 @@ end
7676
end
7777

7878
@testitem "Flipped Signs and Reversed Tspan" setup=[RootfindingTestSnippet] tags=[:core] begin
79-
@testset for alg in (Alefeld(), Bisection(), Falsi(), Brent(), ITP(), Ridder())
79+
@testset for alg in (Alefeld(), Bisection(), Falsi(), Brent(), ITP(), Ridder(), nothing)
8080
f1(u, p) = u * u - p
8181
f2(u, p) = p - u * u
8282

0 commit comments

Comments
 (0)