Skip to content

Commit

Permalink
EmptySet: redefine norm/radius/diameter
Browse files Browse the repository at this point in the history
  • Loading branch information
schillic committed Dec 13, 2024
1 parent 515118f commit 4be1942
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
5 changes: 3 additions & 2 deletions src/Sets/EmptySet/diameter.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
function diameter(::EmptySet, ::Real=Inf)
throw(ArgumentError("the diameter of an empty set is undefined"))
function diameter(∅::EmptySet, ::Real=Inf)
N = eltype(∅)
return zero(N)
end
5 changes: 3 additions & 2 deletions src/Sets/EmptySet/norm.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
function norm(::EmptySet, ::Real=Inf)
throw(ArgumentError("the norm of an empty set is undefined"))
function norm(∅::EmptySet, ::Real=Inf)
N = eltype(∅)
return zero(N)
end
5 changes: 3 additions & 2 deletions src/Sets/EmptySet/radius.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
function radius(::EmptySet, ::Real=Inf)
throw(ArgumentError("the radius of an empty set is undefined"))
function radius(∅::EmptySet, ::Real=Inf)
N = eltype(∅)
return zero(N)
end
6 changes: 3 additions & 3 deletions test/Sets/EmptySet.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ for N in [Float64, Rational{Int}, Float32]

# an_element/norm/radius/diameter functions
@test_throws ArgumentError an_element(E)
@test_throws ArgumentError norm(E)
@test_throws ArgumentError radius(E)
@test_throws ArgumentError diameter(E)
@test norm(E) == N(0)
@test radius(E) == N(0)
@test diameter(E) == N(0)

# vertices / vertices_list
@test collect(vertices(E)) == vertices_list(E) == Vector{Vector{N}}()
Expand Down

0 comments on commit 4be1942

Please sign in to comment.