diff --git a/docs/src/lib/sets/EmptySet.md b/docs/src/lib/sets/EmptySet.md index 92c784e062..31f6a9246f 100644 --- a/docs/src/lib/sets/EmptySet.md +++ b/docs/src/lib/sets/EmptySet.md @@ -12,32 +12,9 @@ EmptySet ## Operations ```@docs -an_element(::EmptySet) -area(::EmptySet) chebyshev_center_radius(::EmptySet; kwargs...) complement(::EmptySet{N}) where {N} -diameter(::EmptySet, ::Real=Inf) -dim(::EmptySet) -high(::EmptySet) -high(::EmptySet, ::Int) -isbounded(::EmptySet) -isempty(::EmptySet) -isuniversal(::EmptySet{N}, ::Bool=false) where {N} -low(::EmptySet) -low(::EmptySet, ::Int) -norm(::EmptySet, ::Real=Inf) -radius(::EmptySet, ::Real=Inf) rand(::Type{EmptySet}) -rectify(::EmptySet) -reflect(::EmptySet) -vertices_list(::EmptySet) -vertices(::EmptySet) -volume(::EmptySet{N}) where {N} -∈(::AbstractVector, ::EmptySet) -linear_map(::AbstractMatrix, ::EmptySet) -ρ(::AbstractVector, ::EmptySet) -σ(::AbstractVector, ::EmptySet) -translate(::EmptySet, ::AbstractVector) plot_recipe(::EmptySet{N}, ::Any=zero(N)) where {N} ``` @@ -46,15 +23,36 @@ CurrentModule = LazySets.API ``` Undocumented implementations: + +* [`an_element`](@ref an_element(::LazySet)) +* [`area`](@ref area(::LazySet)) * [`convex_hull`](@ref convex_hull(::LazySet)) +* [`diameter`](@ref diameter(::LazySet, ::Real=Inf)) +* [`dim`](@ref dim(::LazySet)) +* [`high`](@ref high(::LazySet)) +* [`high`](@ref high(::LazySet, ::Int)) +* [`isbounded`](@ref isbounded(::LazySet)) * [`isboundedtype`](@ref isboundedtype(::Type{LazySet})) * [`isconvextype`](@ref isconvextype(::Type{LazySet})) +* [`isempty`](@ref isempty(::LazySet)) * [`isoperationtype`](@ref isoperationtype(::Type{LazySet})) -* [`affine_map`](@ref affine_map(::AbstractMatrix, ::LazySet, ::AbstractVector)) -* [`exponential_map`](@ref exponential_map(::AbstractMatrix, ::LazySet)) -* [`is_interior_point`](@ref is_interior_point(::AbstractVector, ::LazySet)) +* [`isuniversal`](@ref isuniversal(::LazySet, ::Bool=false)) +* [`low`](@ref low(::LazySet)) +* [`low`](@ref low(::LazySet, ::Int)) +* [`norm`](@ref norm(::LazySet, ::Real=Inf)) +* [`radius`](@ref radius(::LazySet, ::Real=Inf)) +* [`rectify`](@ref rectify(::LazySet)) +* [`reflect`](@ref reflect(::LazySet)) +* [`vertices_list`](@ref vertices_list(::LazySet)) +* [`vertices`](@ref vertices(::LazySet)) +* [`volume`](@ref volume(::LazySet)) +* [`∈`](@ref ∈(::AbstractVector, ::LazySet)) +* [`linear_map`](@ref linear_map(::AbstractMatrix, ::LazySet)) +* [`ρ`](@ref ρ(::AbstractVector, ::LazySet)) +* [`σ`](@ref σ(::AbstractVector, ::LazySet)) * [`scale`](@ref scale(::Real, ::LazySet)) * [`scale!`](@ref scale!(::Real, ::LazySet)) +* [`translate`](@ref translate(::LazySet, ::AbstractVector)) * [`translate!`](@ref translate!(::LazySet, ::AbstractVector)) * [`convex_hull`](@ref convex_hull(::LazySet, ::LazySet)) * [`intersection`](@ref isequivalent(::LazySet, ::LazySet)) @@ -75,6 +73,9 @@ Inherited from [`LazySet`](@ref): * [`ispolyhedral`](@ref ispolyhedral(::LazySet)) * [`singleton_list`](@ref singleton_list(::LazySet)) * [`surface`](@ref surface(::LazySet)) +* [`affine_map`](@ref affine_map(::AbstractMatrix, ::LazySet, ::AbstractVector)) +* [`exponential_map`](@ref exponential_map(::AbstractMatrix, ::LazySet)) +* [`is_interior_point`](@ref is_interior_point(::AbstractVector, ::LazySet)) * [`cartesian_product`](@ref cartesian_product(::LazySet, ::LazySet)) * [`≈`](@ref ≈(::LazySet, ::LazySet)) * [`==`](@ref ==(::LazySet, ::LazySet)) diff --git a/src/Sets/EmptySet/an_element.jl b/src/Sets/EmptySet/an_element.jl index b6b84b1602..a2094b587e 100644 --- a/src/Sets/EmptySet/an_element.jl +++ b/src/Sets/EmptySet/an_element.jl @@ -1,16 +1,3 @@ -""" - an_element(∅::EmptySet) - -Return some element of an empty set. - -### Input - -- `∅` -- empty set - -### Output - -An error. -""" function an_element(::EmptySet) - return error("an empty set does not contain any element") + throw(ArgumentError("an empty set does not contain any element")) end diff --git a/src/Sets/EmptySet/area.jl b/src/Sets/EmptySet/area.jl index ff33f3d676..e9e89399d5 100644 --- a/src/Sets/EmptySet/area.jl +++ b/src/Sets/EmptySet/area.jl @@ -1,16 +1,3 @@ -""" - area(∅::EmptySet) - -Return the area of an empty set. - -### Input - -- `∅` -- empty set - -### Output - -``0``. -""" function area(∅::EmptySet) N = eltype(∅) return zero(N) diff --git a/src/Sets/EmptySet/chebyshev_center_radius.jl b/src/Sets/EmptySet/chebyshev_center_radius.jl index d68a4a97b4..2682f57a1e 100644 --- a/src/Sets/EmptySet/chebyshev_center_radius.jl +++ b/src/Sets/EmptySet/chebyshev_center_radius.jl @@ -14,5 +14,5 @@ and the corresponding radius of an empty set. An error. """ function chebyshev_center_radius(∅::EmptySet; kwargs...) - return error("the Chebyshev center and radius of an empty set are undefined") + throw(ArgumentError("the Chebyshev center and radius of an empty set are undefined")) end diff --git a/src/Sets/EmptySet/complement.jl b/src/Sets/EmptySet/complement.jl index 321f3ce1b7..73eff228fb 100644 --- a/src/Sets/EmptySet/complement.jl +++ b/src/Sets/EmptySet/complement.jl @@ -1,15 +1,11 @@ """ - complement(∅::EmptySet{N}) where {N} - -Return the complement of an empty set. +# Extended help -### Input - -- `∅` -- empty set + complement(∅::EmptySet{N}) where {N} ### Output -The universe of the same dimension. +The [`Universe`](@ref) of the same dimension. """ function complement(∅::EmptySet{N}) where {N} require(@__MODULE__, :LazySets; fun_name="complement") diff --git a/src/Sets/EmptySet/convex_hull.jl b/src/Sets/EmptySet/convex_hull.jl index f3e34187d5..c1a986e5d8 100644 --- a/src/Sets/EmptySet/convex_hull.jl +++ b/src/Sets/EmptySet/convex_hull.jl @@ -1 +1,9 @@ -convex_hull(∅::EmptySet, ::EmptySet) = ∅ +function convex_hull(∅::EmptySet) + return ∅ +end + +function convex_hull(∅₁::EmptySet, ∅₂::EmptySet) + @assert dim(∅₁) == dim(∅₂) "cannot take the convex hull between two " * + "empty sets of dimensions $(dim(∅₁)) and $(dim(∅₂))" + return ∅₁ +end diff --git a/src/Sets/EmptySet/diameter.jl b/src/Sets/EmptySet/diameter.jl index 772eae8d1c..1e57ef52bd 100644 --- a/src/Sets/EmptySet/diameter.jl +++ b/src/Sets/EmptySet/diameter.jl @@ -1,20 +1,3 @@ -""" - diameter(∅::EmptySet, [p]::Real=Inf) - -Return the diameter of an empty set. -It is the maximum distance between any two elements of the set or, equivalently, -the diameter of the enclosing ball (of the given ``p``-norm) of minimal volume -with the same center. - -### Input - -- `∅` -- empty set -- `p` -- (optional, default: `Inf`) norm - -### Output - -An error. -""" function diameter(::EmptySet, ::Real=Inf) - return error("the diameter of an empty set is undefined") + throw(ArgumentError("the diameter of an empty set is undefined")) end diff --git a/src/Sets/EmptySet/dim.jl b/src/Sets/EmptySet/dim.jl index 900e6b19d4..5d404009ff 100644 --- a/src/Sets/EmptySet/dim.jl +++ b/src/Sets/EmptySet/dim.jl @@ -1,16 +1,3 @@ -""" - dim(∅::EmptySet) - -Return the dimension of an empty set. - -### Input - -- `∅` -- an empty set - -### Output - -The dimension of the empty set. -""" function dim(∅::EmptySet) return ∅.dim end diff --git a/src/Sets/EmptySet/high.jl b/src/Sets/EmptySet/high.jl index 3032a53f40..a85e8ac7a4 100644 --- a/src/Sets/EmptySet/high.jl +++ b/src/Sets/EmptySet/high.jl @@ -1,39 +1,7 @@ -""" - high(∅::EmptySet) - -Return a vector with the highest coordinates of an empty set in each canonical -direction. - -### Input - -- `∅` -- empty set - -### Output - -An error. - -### Notes - -See also [`high(∅::EmptySet, i::Int)`](@ref). -""" function high(::EmptySet) - return error("the upper bound of an empty set is undefined") + throw(ArgumentError("the upper bound of an empty set is undefined")) end -""" - high(∅::EmptySet, i::Int) - -Return the highest coordinate of an empty set in the given direction. - -### Input - -- `∅` -- empty set -- `i` -- dimension of interest - -### Output - -An error. -""" function high(::EmptySet, ::Int) - return error("the upper bound of an empty set is undefined") + throw(ArgumentError("the upper bound of an empty set is undefined")) end diff --git a/src/Sets/EmptySet/in.jl b/src/Sets/EmptySet/in.jl index ffa7918bc8..63ef72d48c 100644 --- a/src/Sets/EmptySet/in.jl +++ b/src/Sets/EmptySet/in.jl @@ -1,24 +1,3 @@ -""" - ∈(x::AbstractVector, ∅::EmptySet) - -Check whether a given point is contained in an empty set. - -### Input - -- `x` -- point/vector -- `∅` -- empty set - -### Output - -`false`. - -### Examples - -```jldoctest -julia> [1.0, 0.0] ∈ ∅(2) -false -``` -""" function ∈(::AbstractVector, ::EmptySet) return false end diff --git a/src/Sets/EmptySet/isbounded.jl b/src/Sets/EmptySet/isbounded.jl index d39b35237d..6e3cacd2f4 100644 --- a/src/Sets/EmptySet/isbounded.jl +++ b/src/Sets/EmptySet/isbounded.jl @@ -1,16 +1,3 @@ -""" - isbounded(∅::EmptySet) - -Check whether an empty set is bounded. - -### Input - -- `∅` -- empty set - -### Output - -`true`. -""" function isbounded(::EmptySet) return true end diff --git a/src/Sets/EmptySet/isempty.jl b/src/Sets/EmptySet/isempty.jl index 15510cf918..3c3c29cce8 100644 --- a/src/Sets/EmptySet/isempty.jl +++ b/src/Sets/EmptySet/isempty.jl @@ -1,16 +1,3 @@ -""" - isempty(∅::EmptySet) - -Check if the empty set is empty. - -### Input - -- `∅` -- empty set - -### Output - -`true`. -""" function isempty(::EmptySet) return true end diff --git a/src/Sets/EmptySet/isuniversal.jl b/src/Sets/EmptySet/isuniversal.jl index d6536da26f..22544ed02b 100644 --- a/src/Sets/EmptySet/isuniversal.jl +++ b/src/Sets/EmptySet/isuniversal.jl @@ -1,18 +1,3 @@ -""" - isuniversal(∅::EmptySet{N}, [witness]::Bool=false) where {N} - -Check whether an empty set is universal. - -### Input - -- `∅` -- empty set -- `witness` -- (optional, default: `false`) compute a witness if activated - -### Output - -* If `witness` option is deactivated: `false` -* If `witness` option is activated: `(false, v)` where ``v ∉ S`` -""" function isuniversal(∅::EmptySet{N}, witness::Bool=false) where {N} if witness return (false, zeros(N, dim(∅))) diff --git a/src/Sets/EmptySet/linear_map.jl b/src/Sets/EmptySet/linear_map.jl index 83d1395e77..3980b2cc19 100644 --- a/src/Sets/EmptySet/linear_map.jl +++ b/src/Sets/EmptySet/linear_map.jl @@ -1,21 +1,7 @@ -""" - linear_map(M::AbstractMatrix{N}, ∅::EmptySet{N}) where {N} - -Return the linear map of an empty set. - -### Input - -- `M` -- matrix -- `∅` -- empty set - -### Output - -An empty set. -""" function linear_map(M::AbstractMatrix, ∅::EmptySet) - N = eltype(∅) @assert size(M, 2) == dim(∅) "cannot apply a $(size(M))-dimensional " * "matrix to a $(dim(∅))-dimensional set" + N = eltype(∅) return EmptySet{N}(size(M, 1)) end diff --git a/src/Sets/EmptySet/low.jl b/src/Sets/EmptySet/low.jl index 5ea5a5cbeb..1d4a59c745 100644 --- a/src/Sets/EmptySet/low.jl +++ b/src/Sets/EmptySet/low.jl @@ -1,39 +1,7 @@ -""" - low(∅::EmptySet) - -Return a vector with the lowest coordinates of an empty set in each canonical -direction. - -### Input - -- `∅` -- empty set - -### Output - -An error. - -### Notes - -See also [`low(∅::EmptySet, i::Int)`](@ref). -""" function low(::EmptySet) - return error("the lower bound of an empty set is undefined") + throw(ArgumentError("the lower bound of an empty set is undefined")) end -""" - low(∅::EmptySet, i::Int) - -Return the lowest coordinate of an empty set in the given direction. - -### Input - -- `∅` -- empty set -- `i` -- dimension of interest - -### Output - -An error. -""" function low(::EmptySet, ::Int) - return error("the lower bound of an empty set is undefined") + throw(ArgumentError("the lower bound of an empty set is undefined")) end diff --git a/src/Sets/EmptySet/norm.jl b/src/Sets/EmptySet/norm.jl index d28534c461..53765124de 100644 --- a/src/Sets/EmptySet/norm.jl +++ b/src/Sets/EmptySet/norm.jl @@ -1,19 +1,3 @@ -""" - norm(∅::EmptySet, [p]::Real=Inf) - -Return the norm of an empty set. -It is the norm of the enclosing ball (of the given ``p``-norm) of minimal volume -that is centered in the origin. - -### Input - -- `∅` -- empty set -- `p` -- (optional, default: `Inf`) norm - -### Output - -An error. -""" function norm(::EmptySet, ::Real=Inf) - return error("the norm of an empty set is undefined") + throw(ArgumentError("the norm of an empty set is undefined")) end diff --git a/src/Sets/EmptySet/radius.jl b/src/Sets/EmptySet/radius.jl index 1fa7684402..6727e5e370 100644 --- a/src/Sets/EmptySet/radius.jl +++ b/src/Sets/EmptySet/radius.jl @@ -1,19 +1,3 @@ -""" - radius(∅::EmptySet, [p]::Real=Inf) - -Return the radius of an empty set. -It is the radius of the enclosing ball (of the given ``p``-norm) of minimal -volume with the same center. - -### Input - -- `∅` -- empty set -- `p` -- (optional, default: `Inf`) norm - -### Output - -An error. -""" function radius(::EmptySet, ::Real=Inf) - return error("the radius of an empty set is undefined") + throw(ArgumentError("the radius of an empty set is undefined")) end diff --git a/src/Sets/EmptySet/rand.jl b/src/Sets/EmptySet/rand.jl index d66012e270..d02b67224e 100644 --- a/src/Sets/EmptySet/rand.jl +++ b/src/Sets/EmptySet/rand.jl @@ -1,20 +1,12 @@ """ +# Extended help + rand(::Type{EmptySet}; [N]::Type{<:Real}=Float64, [dim]::Int=2, [rng]::AbstractRNG=GLOBAL_RNG, [seed]::Union{Int, Nothing}=nothing) -Create an empty set (note that there is nothing to randomize). - -### Input - -- `EmptySet` -- type for dispatch -- `N` -- (optional, default: `Float64`) numeric type -- `dim` -- (optional, default: 2) dimension -- `rng` -- (optional, default: `GLOBAL_RNG`) random number generator -- `seed` -- (optional, default: `nothing`) seed for reseeding - ### Output -The (only) empty set of the given numeric type and dimension. +The (unique) empty set of the given numeric type and dimension. """ function rand(::Type{EmptySet}; N::Type{<:Real}=Float64, diff --git a/src/Sets/EmptySet/rectify.jl b/src/Sets/EmptySet/rectify.jl index 08482a7e20..ac6783aaad 100644 --- a/src/Sets/EmptySet/rectify.jl +++ b/src/Sets/EmptySet/rectify.jl @@ -1,16 +1,3 @@ -""" - rectify(∅::EmptySet) - -Concrete rectification of an empty set. - -### Input - -- `∅` -- empty set - -### Output - -The empty set. -""" function rectify(∅::EmptySet) return ∅ end diff --git a/src/Sets/EmptySet/reflect.jl b/src/Sets/EmptySet/reflect.jl index 48fff31488..e5e5108a2b 100644 --- a/src/Sets/EmptySet/reflect.jl +++ b/src/Sets/EmptySet/reflect.jl @@ -1,16 +1,3 @@ -""" - reflect(∅::EmptySet) - -Concrete reflection of an empty set. - -### Input - -- `∅` -- empty set - -### Output - -The same empty set. -""" function reflect(∅::EmptySet) return ∅ end diff --git a/src/Sets/EmptySet/support_function.jl b/src/Sets/EmptySet/support_function.jl index 3f201c81a3..4ec4bab7cb 100644 --- a/src/Sets/EmptySet/support_function.jl +++ b/src/Sets/EmptySet/support_function.jl @@ -1,17 +1,3 @@ -""" - ρ(d::AbstractVector, ∅::EmptySet) - -Evaluate the support function of an empty set in a given direction. - -### Input - -- `d` -- direction -- `∅` -- empty set - -### Output - -An error. -""" function ρ(::AbstractVector, ::EmptySet) - return error("the support function of an empty set is undefined") + throw(ArgumentError("the support function of an empty set is undefined")) end diff --git a/src/Sets/EmptySet/support_vector.jl b/src/Sets/EmptySet/support_vector.jl index 0f6c8d16d7..cf7542b9c2 100644 --- a/src/Sets/EmptySet/support_vector.jl +++ b/src/Sets/EmptySet/support_vector.jl @@ -1,17 +1,3 @@ -""" - σ(d::AbstractVector, ∅::EmptySet) - -Return the support vector of an empty set. - -### Input - -- `d` -- direction -- `∅` -- empty set - -### Output - -An error. -""" function σ(::AbstractVector, ::EmptySet) - return error("the support vector of an empty set is undefined") + throw(ArgumentError("the support vector of an empty set is undefined")) end diff --git a/src/Sets/EmptySet/translate.jl b/src/Sets/EmptySet/translate.jl index eda2777b77..d2cbc8a39a 100644 --- a/src/Sets/EmptySet/translate.jl +++ b/src/Sets/EmptySet/translate.jl @@ -1,17 +1,3 @@ -""" - translate(∅::EmptySet, v::AbstractVector) - -Translate (i.e., shift) an empty set by a given vector. - -### Input - -- `∅` -- empty set -- `v` -- translation vector - -### Output - -The empty set. -""" function translate(∅::EmptySet, v::AbstractVector) return translate!(∅, v) # no need to copy end diff --git a/src/Sets/EmptySet/vertices.jl b/src/Sets/EmptySet/vertices.jl index d8b214ca02..11866e918a 100644 --- a/src/Sets/EmptySet/vertices.jl +++ b/src/Sets/EmptySet/vertices.jl @@ -1,16 +1,3 @@ -""" - vertices(∅::EmptySet) - -Construct an iterator over the vertices of an empty set. - -### Input - -- `∅` -- empty set - -### Output - -The empty iterator, as the empty set does not contain any vertices. -""" function vertices(∅::EmptySet) N = eltype(∅) return EmptyIterator{Vector{N}}() diff --git a/src/Sets/EmptySet/vertices_list.jl b/src/Sets/EmptySet/vertices_list.jl index dffbf08197..e2d15c7b40 100644 --- a/src/Sets/EmptySet/vertices_list.jl +++ b/src/Sets/EmptySet/vertices_list.jl @@ -1,16 +1,3 @@ -""" - vertices_list(∅::EmptySet) - -Return the list of vertices of an empty set. - -### Input - -- `∅` -- empty set - -### Output - -The empty list of vertices, as the empty set does not contain any vertices. -""" function vertices_list(∅::EmptySet) N = eltype(∅) return Vector{Vector{N}}() diff --git a/src/Sets/EmptySet/volume.jl b/src/Sets/EmptySet/volume.jl index aba8129fe1..3b27bdce06 100644 --- a/src/Sets/EmptySet/volume.jl +++ b/src/Sets/EmptySet/volume.jl @@ -1,16 +1,3 @@ -""" - volume(∅::EmptySet{N}) where {N} - -Return the volume of an empty set. - -### Input - -- `∅` -- empty set - -### Output - -``0``. -""" function volume(::EmptySet{N}) where {N} return zero(N) end diff --git a/test/Sets/EmptySet.jl b/test/Sets/EmptySet.jl index 41f6ae7d07..0892a36a25 100644 --- a/test/Sets/EmptySet.jl +++ b/test/Sets/EmptySet.jl @@ -9,8 +9,8 @@ for N in [Float64, Rational{Int}, Float32] @test dim(E) == 2 # support function & support vector - @test_throws ErrorException ρ(N[0], E) - @test_throws ErrorException σ(N[0], E) + @test_throws ArgumentError ρ(N[0], E) + @test_throws ArgumentError σ(N[0], E) # boundedness @test isbounded(E) && isboundedtype(typeof(E)) @@ -36,10 +36,10 @@ for N in [Float64, Rational{Int}, Float32] @test isempty(E) # an_element/norm/radius/diameter functions - @test_throws ErrorException an_element(E) - @test_throws ErrorException norm(E) - @test_throws ErrorException radius(E) - @test_throws ErrorException diameter(E) + @test_throws ArgumentError an_element(E) + @test_throws ArgumentError norm(E) + @test_throws ArgumentError radius(E) + @test_throws ArgumentError diameter(E) # vertices / vertices_list @test collect(vertices(E)) == vertices_list(E) == Vector{Vector{N}}() @@ -84,13 +84,13 @@ for N in [Float64, Rational{Int}, Float32] @test area(E) == N(0) # chebyshev_center_radius - @test_throws ErrorException chebyshev_center_radius(E) + @test_throws ArgumentError chebyshev_center_radius(E) # low/high - @test_throws ErrorException low(E) - @test_throws ErrorException low(E, 1) - @test_throws ErrorException high(E) - @test_throws ErrorException high(E, 1) + @test_throws ArgumentError low(E) + @test_throws ArgumentError low(E, 1) + @test_throws ArgumentError high(E) + @test_throws ArgumentError high(E, 1) # isdisjoint @test isdisjoint(E, B) && isdisjoint(B, E) && isdisjoint(E, E)