Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revise documentation of Interval operations #3551

Merged
merged 4 commits into from
Nov 20, 2024
Merged
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
125 changes: 111 additions & 14 deletions docs/src/lib/sets/Interval.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,43 +10,127 @@ Interval

## Conversion

```@docs
```julia
convert(::Type{Interval}, ::LazySet)
convert(::Type{IA.Interval}, ::LazySet)
convert(::Type{Interval}, ::IA.Interval)
```

## Operations

```@meta
CurrentModule = LazySets.API
```
```@docs; canonical=false
an_element(::LazySet)
```
```@meta
CurrentModule = LazySets.IntervalModule
```
```@docs
an_element(::Interval)
center(::Interval)
center(::Interval, ::Int)
chebyshev_center_radius(::Interval)
constraints_list(::Interval)
diameter(::Interval, ::Real=Inf)
dim(::Interval)
isflat(::Interval)
ngens(::Interval)
radius_hyperrectangle(::Interval)
radius_hyperrectangle(::Interval{N}, ::Int) where {N}
```
```@meta
CurrentModule = LazySets.API
```
```@docs; canonical=false
rand(::Type{<:LazySet})
```
```@meta
CurrentModule = LazySets.IntervalModule
```
```@docs
rand(::Type{Interval})
```
```@meta
CurrentModule = LazySets.API
```
```@docs; canonical=false
rectify(::LazySet)
```
```@meta
CurrentModule = LazySets.IntervalModule
```
```@docs
rectify(::Interval{N}) where {N}
reflect(::Interval)
```
```@meta
CurrentModule = LazySets.API
```
```@docs; canonical=false
vertices_list(::LazySet)
```
```@meta
CurrentModule = LazySets.IntervalModule
```
```@docs
vertices_list(::Interval)
∈(::AbstractVector, ::Interval)
```
```@meta
CurrentModule = LazySets.API
```
```@docs; canonical=false
linear_map(::AbstractMatrix, ::LazySet)
```
```@meta
CurrentModule = LazySets.IntervalModule
```
```@docs
linear_map(::AbstractMatrix, ::Interval)
scale(::Real, ::Interval)
split(::Interval, ::AbstractVector{Int})
ρ(::AbstractVector, ::Interval)
σ(::AbstractVector, ::Interval)
```
```@meta
CurrentModule = LazySets.API
```
```@docs; canonical=false
translate(::LazySet, ::AbstractVector)
```
```@meta
CurrentModule = LazySets.IntervalModule
```
```@docs
translate(::Interval, ::AbstractVector)
```
```@meta
CurrentModule = LazySets.API
```
```@docs; canonical=false
difference(::LazySet, ::LazySet)
```
```@meta
CurrentModule = LazySets.IntervalModule
```
```@docs
difference(::Interval{N}, ::Interval) where {N}
intersection(::Interval, ::Interval)
```
```@meta
CurrentModule = LazySets.API
```
```@docs; canonical=false
isdisjoint(::LazySet, ::LazySet, ::Bool=false)
```
```@meta
CurrentModule = LazySets.IntervalModule
```
```@docs
isdisjoint(::Interval, ::Interval, ::Bool=false)
⊆(::Interval, ::Interval, ::Bool=false)
```
```@meta
CurrentModule = LazySets.API
```
```@docs; canonical=false
minkowski_difference(::LazySet, ::LazySet)
```
```@meta
CurrentModule = LazySets.IntervalModule
```
```@docs
minkowski_difference(::Interval, ::Interval)
minkowski_sum(::Interval, ::Interval)
plot_recipe(::Interval{N}, ::Any=zero(N)) where {N}
min(::Interval)
max(::Interval)
Expand All @@ -59,7 +143,12 @@ CurrentModule = LazySets.API
```

Undocumented implementations:
* [`center`](@ref center(::LazySet))
* [`center`](@ref center(::LazySet, ::Int))
* [`complement`](@ref complement(::LazySet))
* [`constraints_list`](@ref constraints_list(::LazySet))
* [`diameter`](@ref diameter(::LazySet, ::Real=Inf))
* [`dim`](@ref dim(::LazySet))
* [`extrema`](@ref extrema(::LazySet))
* [`extrema`](@ref extrema(::LazySet, ::Int))
* [`high`](@ref high(::LazySet, ::Int))
Expand All @@ -69,16 +158,24 @@ Undocumented implementations:
* [`low`](@ref low(::LazySet))
* [`norm`](@ref norm(::LazySet, ::Real))
* [`radius`](@ref radius(::LazySet, ::Real))
* [`reflect`](@ref reflect(::LazySet))
* [`volume`](@ref volume(::LazySet))
* [`affine_map`](@ref affine_map(::AbstractMatrix, ::LazySet, ::AbstractVector))
* [`exponential_map`](@ref exponential_map(::AbstractMatrix, ::LazySet))
* [`∈`](@ref ∈(::AbstractVector, ::LazySet))
* [`permute`](@ref permute(::LazySet, ::AbstractVector{Int}))
* [`project`](@ref project(::LazySet, ::AbstractVector{Int}))
* [`scale`](@ref scale(::Real, ::LazySet))
* [`ρ`](@ref ρ(::AbstractVector, ::LazySet))
* [`σ`](@ref σ(::AbstractVector, ::LazySet))
* [`convex_hull`](@ref convex_hull(::LazySet, ::LazySet))
* [`distance`](@ref distance(::LazySet, ::LazySet))
* [`intersection`](@ref intersection(::LazySet, ::LazySet))
* [`≈`](@ref ≈(::LazySet, ::LazySet))
* [`isequivalent`](@ref isequivalent(::LazySet, ::LazySet))
* [`⊂`](@ref ⊂(::LazySet, ::LazySet))
* [`⊆`](@ref ⊆(::LazySet, ::LazySet, ::Bool=false))
* [`minkowski_sum`](@ref minkowski_sum(::LazySet, ::LazySet))

```@meta
CurrentModule = LazySets
Expand Down
12 changes: 4 additions & 8 deletions src/Sets/Interval/an_element.jl
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
"""
an_element(x::Interval)

Return some element of an interval.
# Extended help

### Input

- `x` -- interval
an_element(x::Interval)

### Output
### Algorithm

The left border (`low(x)`) of the interval.
Return the left border (`low(x)`) of the interval.
"""
function an_element(x::Interval)
return low(x)
Expand Down
27 changes: 0 additions & 27 deletions src/Sets/Interval/center.jl
Original file line number Diff line number Diff line change
@@ -1,34 +1,7 @@
"""
center(x::Interval)

Return the center of an interval.

### Input

- `x` -- interval

### Output

The center, or midpoint, of `x`.
"""
function center(x::Interval)
return [_center(x)]
end

"""
center(H::Interval, i::Int)

Return the center along a given dimension of a interval.

### Input

- `x` -- interval
- `i` -- dimension of interest

### Output

The center along a given dimension of the interval.
"""
@inline function center(x::Interval, i::Int)
@assert i == 1 "an interval has dimension 1, but the index is $i"
return _center(x)
Expand Down
14 changes: 0 additions & 14 deletions src/Sets/Interval/constraints_list.jl
Original file line number Diff line number Diff line change
@@ -1,17 +1,3 @@
"""
constraints_list(x::Interval)

Return the list of constraints of an interval.

### Input

- `x` -- interval

### Output

The list of constraints of the interval represented as two one-dimensional
half-spaces.
"""
function constraints_list(x::Interval)
N = eltype(x)
constraints = Vector{HalfSpace{N,SingleEntryVector{N}}}(undef, 2)
Expand Down
49 changes: 0 additions & 49 deletions src/Sets/Interval/convert.jl
Original file line number Diff line number Diff line change
@@ -1,42 +1,7 @@
"""
convert(::Type{Interval}, X::LazySet)

Convert a one-dimensional convex set to an interval.

### Input

- `Interval` -- interval target type
- `X` -- one-dimensional convex set

### Output

An interval.

### Examples

```jldoctest
julia> convert(Interval, Hyperrectangle([0.5], [0.5]))
Interval{Float64}([0, 1])
```
"""
function convert(::Type{Interval}, X::LazySet)
return Interval(convert(IA.Interval, X))
end

"""
convert(::Type{IntervalArithmetic.Interval}, X::LazySet)

Convert a convex set to an `Interval` from `IntervalArithmetic`.

### Input

- `Interval` -- target type, from `IntervalArithmetic`
- `X` -- convex set

### Output

An `IntervalArithmetic.Interval`.
"""
function convert(::Type{IA.Interval}, X::LazySet)
@assert dim(X) == 1 "cannot convert a $(dim(X))-dimensional set to an `Interval`"
@assert isconvextype(typeof(X)) "cannot convert a non-convex set to an `Interval`"
Expand All @@ -45,20 +10,6 @@ function convert(::Type{IA.Interval}, X::LazySet)
return IA.interval(l, h)
end

"""
convert(::Type{Interval}, x::IntervalArithmetic.Interval)

Convert an `Interval` from `IntervalArithmetic` to an `Interval` in `LazySets`.

### Input

- `Interval` -- target type
- `x` -- interval (`IntervalArithmetic.Interval`)

### Output

A `LazySets.Interval`.
"""
function convert(::Type{Interval}, x::IA.Interval)
return Interval(x)
end
21 changes: 1 addition & 20 deletions src/Sets/Interval/diameter.jl
Original file line number Diff line number Diff line change
@@ -1,23 +1,4 @@
"""
diameter(x::Interval, [p]::Real=Inf)

Compute the diameter of an interval, defined as ``‖b - a‖`` in the
``p`-norm, where ``a`` (resp. ``b``) are the minimum (resp. maximum) value of
the interval.

### Input

- `x` -- interval
- `p` -- (optional, default: `Inf`) norm (ignored)

### Output

A real number representing the diameter.

### Notes

In one dimension, all p-norms are identical.
"""
# in one dimension, all p-norms are identical
function diameter(x::Interval, ::Real=Inf)
return max(x) - min(x)
end
17 changes: 9 additions & 8 deletions src/Sets/Interval/difference.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
"""
difference(X::Interval{N}, Y::Interval) where {N}

Compute the set difference between two intervals.

### Input
# Extended help

- `X` -- first interval
- `Y` -- second interval
difference(X::Interval{N}, Y::Interval) where {N}

### Output

Expand Down Expand Up @@ -42,10 +37,16 @@ flat. Three cases may arise:
### Examples

```jldoctest
julia> X = Interval(0, 2); Y = Interval(1, 4);
julia> X = Interval(0, 2); Y = Interval(1, 4); Z = Interval(2, 3);

julia> difference(X, X)
∅(1)

julia> difference(X, Y)
Interval{Float64}([0, 1])

julia> difference(Y, Z)
UnionSet{Float64, Interval{Float64}, Interval{Float64}}(Interval{Float64}([1, 2]), Interval{Float64}([3, 4]))
```
"""
function difference(X::Interval{N}, Y::Interval) where {N}
Expand Down
13 changes: 0 additions & 13 deletions src/Sets/Interval/dim.jl
Original file line number Diff line number Diff line change
@@ -1,14 +1 @@
"""
dim(x::Interval)

Return the ambient dimension of an interval.

### Input

- `x` -- interval

### Output

``1``.
"""
dim(x::Interval) = 1
Loading
Loading