diff --git a/src/newton1d.jl b/src/newton1d.jl index 98d22cee..6b0b01e9 100644 --- a/src/newton1d.jl +++ b/src/newton1d.jl @@ -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 @@ -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...) diff --git a/src/quadratic.jl b/src/quadratic.jl index 4d1f517d..0abecff7 100644 --- a/src/quadratic.jl +++ b/src/quadratic.jl @@ -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 @@ -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}[] diff --git a/src/root_object.jl b/src/root_object.jl index cd684401..fec0374c 100644 --- a/src/root_object.jl +++ b/src/root_object.jl @@ -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 diff --git a/src/roots.jl b/src/roots.jl index 9a8830c7..8585a93e 100644 --- a/src/roots.jl +++ b/src/roots.jl @@ -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) = @@ -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)