Skip to content

Commit

Permalink
Fix mid and isnan
Browse files Browse the repository at this point in the history
  • Loading branch information
Kolaru committed Jan 5, 2024
1 parent 776e848 commit 09c0160
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/contractors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ struct Newton{F, FP} <: AbstractContractor{F}
end

function (N::Newton)(X::Interval ; α=where_bisect)
m = interval(scaled_mid.(X, α))
m = interval(mid(X, α))
return m - (N.f(m) / N.f′(X))
end

Expand Down Expand Up @@ -79,7 +79,7 @@ struct Krawczyk{F, FP} <: AbstractContractor{F}
end

function (K::Krawczyk)(X::Interval ; α=where_bisect)
m = interval(scaled_mid(X, α))
m = interval(mid(X, α))
Y = 1 / K.f′(m)

return m - Y*K.f(m) + (1 - Y*K.f′(X)) * (X - m)
Expand Down
6 changes: 3 additions & 3 deletions src/roots.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@

import IntervalArithmetic: diam, bisect, isnan
import IntervalArithmetic: diam, bisect, isnai

export branch_and_prune, Bisection, Newton

diam(r::Root) = diam(interval(r))
isnan(r::Root) = isnan(interval(r))
isnai(r::Root) = isnai(interval(r))

struct RootProblem{T}
abstol::T
Expand All @@ -26,7 +26,7 @@ function process(contractor, root_problem, r::Root)

if status == :unknown
# Avoid infinite division of intervals with singularity
isnan(refined_root) && diam(r) < root_problem.abstol && return :store, r
isnai(refined_root) && diam(r) < root_problem.abstol && return :store, r
diam(refined_root) < root_problem.abstol && return :store, refined_root

return :branch, r
Expand Down

0 comments on commit 09c0160

Please sign in to comment.