Skip to content

Commit

Permalink
remove - and * for Interval
Browse files Browse the repository at this point in the history
  • Loading branch information
schillic committed Aug 24, 2024
1 parent 6e1f954 commit b2a7faf
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 62 deletions.
2 changes: 0 additions & 2 deletions docs/src/lib/sets/Interval.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ minkowski_sum(::Interval, ::Interval)
plot_recipe(::Interval{N}, ::Any=zero(N)) where {N}
min(::Interval)
max(::Interval)
-(::Interval, ::Interval)
*(::Interval, ::Interval)
```

```@meta
Expand Down
40 changes: 1 addition & 39 deletions src/Sets/Interval/IntervalModule.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ using ReachabilityBase.Require: require
@reexport import ..LazySets: chebyshev_center_radius, isflat, ngens,
radius_hyperrectangle, split
import ..LazySets: plot_recipe
import Base: convert, -, *, min, max
import Base: convert, min, max
@reexport using ..API

export Interval
Expand Down Expand Up @@ -77,44 +77,6 @@ include("split.jl")

include("convert.jl")

"""
-(x::Interval, y::Interval)
Return the difference of two intervals (in the interval-arithmetic sense).
### Input
- `x` -- interval
- `y` -- interval
### Output
The difference of the intervals as a new `Interval` set.
"""
function -(x::Interval, y::Interval)
return Interval(x.dat - y.dat)
end

"""
```
*(x::Interval, y::Interval)
```
Return the product of two intervals (in the interval-arithmetic sense).
### Input
- `x` -- interval
- `y` -- interval
### Output
The product of the intervals as a new `Interval` set.
"""
function *(x::Interval, y::Interval)
return Interval(x.dat * y.dat)
end

"""
min(x::Interval)
Expand Down
21 changes: 0 additions & 21 deletions test/Sets/Interval.jl
Original file line number Diff line number Diff line change
Expand Up @@ -77,27 +77,6 @@ for N in [Float64, Float32, Rational{Int}]
# the concrete Minkowski sum of intervals returns an interval
@test minkowski_sum(x, y) == Interval(N(-2), N(1.5))

# subtraction
d = x - y
@test dim(d) == 1
@test σ(N[1], d) == N[3]
@test σ(N[-1], d) == N[-0.5]
@test min(d) == N(-0.5) && max(d) == N(3)
v = vertices_list(d)
@test N[-0.5] in v && N[3] in v

# product of intervals: use the * operator
p = x * y
@test dim(p) == 1
@test σ(N[1], p) == N[0.5]
@test σ(N[-1], p) == N[-2]
v = vertices_list(p)
@test N[0.5] in v && N[-2] in v

# test different arithmetic operations
r = minkowski_sum(x, y) - minkowski_sum(d, p)
@test min(r) == N(-5.5) && max(r) == N(4)

# ispolyhedral
@test ispolyhedral(x)

Expand Down

0 comments on commit b2a7faf

Please sign in to comment.