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

Commit 2c2737a

Browse files
committed
minor arg fix
1 parent e4b2b4f commit 2c2737a

File tree

5 files changed

+15
-18
lines changed

5 files changed

+15
-18
lines changed

src/bisection.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ function Bisection(; exact_left = false, exact_right = false)
2020
end
2121

2222
function SciMLBase.solve(prob::IntervalNonlinearProblem, alg::Bisection, args...;
23-
maxiters = 1000, abstol = nothing,
23+
maxiters = 1000, abstol = min(eps(prob.tspan[1]), eps(prob.tspan[2])),
2424
kwargs...)
2525
f = Base.Fix2(prob.f, prob.p)
2626
left, right = prob.tspan
2727
fl, fr = f(left), f(right)
28-
atol = abstol !== nothing ? abstol : min(eps(left), eps(right))
28+
#atol = abstol
2929
if iszero(fl)
3030
return SciMLBase.build_solution(prob, alg, left, fl;
3131
retcode = ReturnCode.ExactSolutionLeft, left = left,
@@ -46,7 +46,7 @@ function SciMLBase.solve(prob::IntervalNonlinearProblem, alg::Bisection, args...
4646
retcode = ReturnCode.FloatingPointLimit,
4747
left = left, right = right)
4848
fm = f(mid)
49-
if abs((right - left) / 2) < atol
49+
if abs((right - left) / 2) < abstol
5050
return SciMLBase.build_solution(prob, alg, mid, fm;
5151
retcode = ReturnCode.Success,
5252
left = left, right = right)
@@ -73,7 +73,7 @@ function SciMLBase.solve(prob::IntervalNonlinearProblem, alg::Bisection, args...
7373
retcode = ReturnCode.FloatingPointLimit,
7474
left = left, right = right)
7575
fm = f(mid)
76-
if abs((right - left) / 2) < atol
76+
if abs((right - left) / 2) < abstol
7777
return SciMLBase.build_solution(prob, alg, mid, fm;
7878
retcode = ReturnCode.Success,
7979
left = left, right = right)

src/brent.jl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@ A non-allocating Brent method
77
struct Brent <: AbstractBracketingAlgorithm end
88

99
function SciMLBase.solve(prob::IntervalNonlinearProblem, alg::Brent, args...;
10-
maxiters = 1000, abstol = nothing,
10+
maxiters = 1000, abstol = min(eps(prob.tspan[1]), eps(prob.tspan[2])),
1111
kwargs...)
1212
f = Base.Fix2(prob.f, prob.p)
1313
a, b = prob.tspan
1414
fa, fb = f(a), f(b)
1515
ϵ = eps(convert(typeof(fa), 1.0))
16-
atol = abstol !== nothing ? abstol : min(eps(a), eps(b))
1716

1817
if iszero(fa)
1918
return SciMLBase.build_solution(prob, alg, a, fa;
@@ -65,7 +64,7 @@ function SciMLBase.solve(prob::IntervalNonlinearProblem, alg::Brent, args...;
6564
cond = false
6665
end
6766
fs = f(s)
68-
if abs((b - a) / 2) < atol
67+
if abs((b - a) / 2) < abstol
6968
return SciMLBase.build_solution(prob, alg, s, fs;
7069
retcode = ReturnCode.Success,
7170
left = a, right = b)
@@ -109,7 +108,7 @@ function SciMLBase.solve(prob::IntervalNonlinearProblem, alg::Brent, args...;
109108
left = a, right = b)
110109
end
111110
fc = f(c)
112-
if abs((b - a) / 2) < atol
111+
if abs((b - a) / 2) < abstol
113112
return SciMLBase.build_solution(prob, alg, c, fc;
114113
retcode = ReturnCode.Success,
115114
left = a, right = b)

src/falsi.jl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@
44
struct Falsi <: AbstractBracketingAlgorithm end
55

66
function SciMLBase.solve(prob::IntervalNonlinearProblem, alg::Falsi, args...;
7-
maxiters = 1000, abstol = nothing,
7+
maxiters = 1000, abstol = min(eps(prob.tspan[1]), eps(prob.tspan[2])),
88
kwargs...)
99
f = Base.Fix2(prob.f, prob.p)
1010
left, right = prob.tspan
1111
fl, fr = f(left), f(right)
12-
atol = abstol !== nothing ? abstol : min(eps(left), eps(right))
1312

1413
if iszero(fl)
1514
return SciMLBase.build_solution(prob, alg, left, fl;
@@ -37,7 +36,7 @@ function SciMLBase.solve(prob::IntervalNonlinearProblem, alg::Falsi, args...;
3736
break
3837
end
3938
fm = f(mid)
40-
if abs((right - left) / 2) < atol
39+
if abs((right - left) / 2) < abstol
4140
return SciMLBase.build_solution(prob, alg, mid, fm;
4241
retcode = ReturnCode.Success,
4342
left = left, right = right)
@@ -64,7 +63,7 @@ function SciMLBase.solve(prob::IntervalNonlinearProblem, alg::Falsi, args...;
6463
retcode = ReturnCode.FloatingPointLimit,
6564
left = left, right = right)
6665
fm = f(mid)
67-
if abs((right - left) / 2) < atol
66+
if abs((right - left) / 2) < abstol
6867
return SciMLBase.build_solution(prob, alg, mid, fm;
6968
retcode = ReturnCode.Success,
7069
left = left, right = right)

src/itp.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,12 @@ struct ITP{T} <: AbstractBracketingAlgorithm
5959
end
6060

6161
function SciMLBase.solve(prob::IntervalNonlinearProblem, alg::ITP,
62-
args...; abstol = nothing,
62+
args...; abstol = min(eps(prob.tspan[1]), eps(prob.tspan[2])),
6363
maxiters = 1000, kwargs...)
6464
f = Base.Fix2(prob.f, prob.p)
6565
left, right = prob.tspan # a and b
6666
fl, fr = f(left), f(right)
67-
ϵ = abstol !== nothing ? abstol : min(eps(left), eps(right))
67+
ϵ = abstol
6868
if iszero(fl)
6969
return SciMLBase.build_solution(prob, alg, left, fl;
7070
retcode = ReturnCode.ExactSolutionLeft, left = left,

src/ridder.jl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@ A non-allocating ridder method
77
struct Ridder <: AbstractBracketingAlgorithm end
88

99
function SciMLBase.solve(prob::IntervalNonlinearProblem, alg::Ridder, args...;
10-
maxiters = 1000, abstol = nothing,
10+
maxiters = 1000, abstol = min(eps(prob.tspan[1]), eps(prob.tspan[2])),
1111
kwargs...)
1212
f = Base.Fix2(prob.f, prob.p)
1313
left, right = prob.tspan
1414
fl, fr = f(left), f(right)
15-
atol = abstol !== nothing ? abstol : min(eps(left), eps(right))
1615

1716
if iszero(fl)
1817
return SciMLBase.build_solution(prob, alg, left, fl;
@@ -42,7 +41,7 @@ function SciMLBase.solve(prob::IntervalNonlinearProblem, alg::Ridder, args...;
4241
x = mid + (mid - left) * sign(fl - fr) * fm / s
4342
fx = f(x)
4443
xo = x
45-
if abs((right - left) / 2) < atol
44+
if abs((right - left) / 2) < abstol
4645
return SciMLBase.build_solution(prob, alg, mid, fm;
4746
retcode = ReturnCode.Success,
4847
left = left, right = right)
@@ -76,7 +75,7 @@ function SciMLBase.solve(prob::IntervalNonlinearProblem, alg::Ridder, args...;
7675
retcode = ReturnCode.FloatingPointLimit,
7776
left = left, right = right)
7877
fm = f(mid)
79-
if abs((right - left) / 2) < atol
78+
if abs((right - left) / 2) < abstol
8079
return SciMLBase.build_solution(prob, alg, mid, fm;
8180
retcode = ReturnCode.Success,
8281
left = left, right = right)

0 commit comments

Comments
 (0)