Skip to content

Commit 046a8b9

Browse files
committed
simplify interval
1 parent 8a64563 commit 046a8b9

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

src/intervals.jl

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -66,28 +66,31 @@ function Base.iszero(a::Interval)
6666
return iszero(a.hi) && iszero(a.lo)
6767
end
6868

69-
Base.:+(a::Interval) = a
70-
Base.:-(a::Interval) = Interval(-a.hi, -a.lo)
69+
# this code is only used for interval += scalar_coef * interval
70+
# so only bivariate + and * are needes
7171

72-
function Base.:+(a::Interval{T}, b::T) where {T<:Real}
73-
return Interval(a.lo + b, a.hi + b)
74-
end
75-
Base.:+(b::T, a::Interval{T}) where {T<:Real} = a + b
72+
# Base.:+(a::Interval) = a
73+
# Base.:-(a::Interval) = Interval(-a.hi, -a.lo)
7674

77-
function Base.:-(a::Interval{T}, b::T) where {T<:Real}
78-
return Interval(a.lo - b, a.hi - b)
79-
end
80-
function Base.:-(b::T, a::Interval{T}) where {T<:Real}
81-
return Interval(b - a.hi, b - a.lo)
82-
end
75+
# function Base.:+(a::Interval{T}, b::T) where {T<:Real}
76+
# return Interval(a.lo + b, a.hi + b)
77+
# end
78+
# Base.:+(b::T, a::Interval{T}) where {T<:Real} = a + b
79+
80+
# function Base.:-(a::Interval{T}, b::T) where {T<:Real}
81+
# return Interval(a.lo - b, a.hi - b)
82+
# end
83+
# function Base.:-(b::T, a::Interval{T}) where {T<:Real}
84+
# return Interval(b - a.hi, b - a.lo)
85+
# end
8386

8487
function Base.:+(a::Interval{T}, b::Interval{T}) where {T<:Real}
8588
return Interval(a.lo + b.lo, a.hi + b.hi)
8689
end
8790

88-
function Base.:-(a::Interval{T}, b::Interval{T}) where {T<:Real}
89-
return Interval(a.lo - b.hi, a.hi - b.lo)
90-
end
91+
# function Base.:-(a::Interval{T}, b::Interval{T}) where {T<:Real}
92+
# return Interval(a.lo - b.hi, a.hi - b.lo)
93+
# end
9194

9295
## Multiplication
9396
function Base.:*(x::T, a::Interval{T}) where {T<:Real}
@@ -99,6 +102,6 @@ function Base.:*(x::T, a::Interval{T}) where {T<:Real}
99102
end
100103
end
101104

102-
Base.:*(a::Interval{T}, x::T) where {T<:Real} = x * a
105+
# Base.:*(a::Interval{T}, x::T) where {T<:Real} = x * a
103106

104107
Base.convert(::Type{Interval{T}}, x::T) where {T<:Real} = Interval(x, x)

0 commit comments

Comments
 (0)