Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/newton1d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Optional keyword arguments give the tolerances `reltol` and `abstol`.
`reltol` is the tolerance on the relative error whereas `abstol` is the tolerance on |f(X)|,
and a `debug` boolean argument that prints out diagnostic information."""

function newton1d{T}(f::Function, f′::Function, x::Interval{T};
reltol=eps(T), abstol=eps(T), debug=false, debugroot=false)
function newton1d(f::Function, f′::Function, x::Interval{T};
reltol=eps(T), abstol=eps(T), debug=false, debugroot=false) where T

L = Interval{T}[] # Array to hold the intervals still to be processed

Expand Down Expand Up @@ -202,5 +202,5 @@ Optional keyword arguments give the tolerances `reltol` and `abstol`.
`reltol` is the tolerance on the relative error whereas `abstol` is the tolerance on |f(X)|,
and a `debug` boolean argument that prints out diagnostic information."""

newton1d{T}(f::Function, x::Interval{T}; args...) =
newton1d(f::Function, x::Interval{T}; args...) where {T} =
newton1d(f, x->D(f,x), x; args...)
4 changes: 2 additions & 2 deletions src/quadratic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Helper function for quadratic_interval that computes roots of a
real quadratic using interval arithmetic to bound rounding errors.
"""
function quadratic_helper!{T}(a::Interval{T}, b::Interval{T}, c::Interval{T}, L::Array{Interval{T}})
function quadratic_helper!(a::Interval{T}, b::Interval{T}, c::Interval{T}, L::Array{Interval{T}}) where T

Δ = b^2 - 4*a*c

Expand Down Expand Up @@ -40,7 +40,7 @@ This algorithm finds the set of points where `F.lo(x) ≥ 0` and the set
of points where `F.hi(x) ≤ 0` and takes the intersection of these two sets.
Eldon Hansen and G. William Walster : Global Optimization Using Interval Analysis - Chapter 8
"""
function quadratic_roots{T}(a::Interval{T}, b::Interval{T}, c::Interval{T})
function quadratic_roots(a::Interval{T}, b::Interval{T}, c::Interval{T}) where T

L = Interval{T}[]
R = Interval{T}[]
Expand Down
2 changes: 1 addition & 1 deletion src/root_object.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ root_status(x::Root) = x.status

show(io::IO, root::Root) = print(io, "Root($(root.interval), :$(root.status))")

isunique{T}(root::Root{T}) = (root.status == :unique)
isunique(root::Root{T}) where {T} = (root.status == :unique)

⊆(a::Interval, b::Root) = a ⊆ b.interval # the Root object has the interval in the first entry
⊆(a::Root, b::Root) = a.interval ⊆ b.interval
Expand Down
6 changes: 3 additions & 3 deletions src/roots.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ struct RootSearchState{T <: Union{Interval,IntervalBox}}
working::Vector{T}
outputs::Vector{Root{T}}
end
RootSearchState{T<:Union{Interval,IntervalBox}}(region::T) =
RootSearchState(region::T) where {T<:Union{Interval,IntervalBox}} =
RootSearchState([region], Root{T}[])

copy(state::RootSearchState) =
Expand All @@ -31,8 +31,8 @@ struct RootSearch{R <: Union{Interval,IntervalBox}, S <: Contractor, T <: Real}
tolerance::T
end

eltype{R, T <: RootSearch{R}}(::Type{T}) = RootSearchState{R}
iteratorsize{T <: RootSearch}(::Type{T}) = Base.SizeUnknown()
eltype(::Type{T}) where {R, T <: RootSearch{R}} = RootSearchState{R}
iteratorsize(::Type{T}) where {T <: RootSearch} = Base.SizeUnknown()

function start(iter::RootSearch)
state = RootSearchState(iter.region)
Expand Down