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

#1061 - Add linear map of empty set #1062

Merged
merged 2 commits into from
Jan 25, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions docs/src/lib/representations.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ isempty(::EmptySet)
norm(::EmptySet, ::Real=Inf)
radius(::EmptySet, ::Real=Inf)
diameter(::EmptySet, ::Real=Inf)
linear_map(::AbstractMatrix{N}, ::EmptySet{N}) where {N}
```
Inherited from [`LazySet`](@ref):
* [`norm`](@ref norm(::LazySet, ::Real))
Expand Down
19 changes: 18 additions & 1 deletion src/EmptySet.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import Base: rand,
isempty

export EmptySet, ∅,
an_element
an_element,
linear_map

"""
EmptySet{N<:Real} <: LazySet{N}
Expand Down Expand Up @@ -225,3 +226,19 @@ An error.
function diameter(S::EmptySet, p::Real=Inf)
error("an empty set does not have a diameter")
end

"""
linear_map(M::AbstractMatrix{N}, ∅::EmptySet{N}) where {N}

Return the linear map of an empt set
mforets marked this conversation as resolved.
Show resolved Hide resolved

### Input

- `M` -- matrix
- `∅` -- empty set

### Output

The empty set.
"""
linear_map(M::AbstractMatrix{N}, ∅::EmptySet{N}) where {N} = ∅
3 changes: 3 additions & 0 deletions test/unit_EmptySet.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ for N in [Float64, Rational{Int}, Float32]
@test_throws ErrorException norm(E)
@test_throws ErrorException radius(E)
@test_throws ErrorException diameter(E)

# linear map of an empty set
linear_map(ones(N, 2, 2), E) == E
end

# default Float64 constructors
Expand Down