Skip to content

Commit

Permalink
Fix misc from rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
Kolaru committed Oct 26, 2020
1 parent 283f878 commit 337ce67
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/IntervalArithmetic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ const Region{T} = Union{Interval{T}, IntervalBox{T}}
# These definitions has been put there because generated functions must be
# defined after all methods they use.
@generated function Interval{T}(x::Irrational) where T
res = atomic(Interval{T}, x()) # Precompute the interval
res = Interval{T}(x(), x()) # Precompute the interval
return :(return $res) # Set body of the function to return the precomputed result
end

Expand Down
5 changes: 2 additions & 3 deletions src/intervals/intervals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ struct Interval{T<:Real} <: AbstractInterval{T}
end
end

eltype(::Interval{T}) where T = T

## Traits functions
can_bound_interval(::Type{T}) where {T} = false # Default case
can_bound_interval(::Type{T}) where {T <: IASupportedType} = true
Expand All @@ -50,15 +52,13 @@ Interval(a::T, b::S) where {T, S} = Interval(promote(a,b)...)
## Concrete constructors for Interval, to effectively deal only with Float64,
# BigFloat or Rational{Integer} intervals.
Interval(a::T, b::T) where {T <: Integer} = Interval(float(a), float(b))
Interval(a::T, b::T) where {T <: Irrational} = Interval(float(a), float(b))

# Constructors for Irrational
# Single argument Irrational constructor are in IntervalArithmetic.jl
# as generated functions need to be define last.
Interval{T}(a::Irrational, b::Irrational) where {T<:Real} = Interval{T}(T(a, RoundDown), T(b, RoundUp))
Interval{T}(a::Irrational, b::Real) where {T<:Real} = Interval{T}(T(a, RoundDown), b)
Interval{T}(a::Real, b::Irrational) where {T<:Real} = Interval{T}(a, T(b, RoundUp))
eltype(x::Interval{T}) where {T} = T

Interval(a::Irrational, b::Irrational) = Interval{Float64}(a, b)
Interval(a::Irrational, b::Real) = Interval{Float64}(a, b)
Expand Down Expand Up @@ -160,7 +160,6 @@ function ..(a::Irrational{T}, b::S) where {T, S}
end

function ..(a::Irrational{T}, b::Irrational{S}) where {T, S}
R = promote_type(Irrational{T}, Irrational{S})
return Interval(a, b)
end

Expand Down

0 comments on commit 337ce67

Please sign in to comment.