Skip to content

Commit

Permalink
implement AbstractZonotope methods for AbstractSingleton
Browse files Browse the repository at this point in the history
  • Loading branch information
schillic committed Jun 17, 2019
1 parent 665aba6 commit 2eb6329
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions src/AbstractSingleton.jl
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,55 @@ function low(S::AbstractSingleton{N}, i::Int)::N where {N<:Real}
end


# --- AbstractZonotope interface functions ---


"""
genmat(S::AbstractSingleton)
Return the (empty) generator matrix of a set with a single value.
### Input
- `S` -- set with a single value
### Output
A matrix with no columns representing the generators of `S`.
"""
function genmat(S::AbstractSingleton{N}) where {N<:Real}
return Matrix{N}(undef, dim(S), 0)
end

# iterator that wraps the generator matrix
struct EmptyGeneratorIterator{N<:Real}
end

Base.length(::EmptyGeneratorIterator) = 0

Base.eltype(::Type{EmptyGeneratorIterator{N}}) where {N} = Vector{N}

function Base.iterate(::EmptyGeneratorIterator, state=nothing)
return nothing
end

"""
generators(S::AbstractSingleton)
Return an (empty) iterator over the generators of a set with a single value.
### Input
- `S` -- set with a single value
### Output
An empty iterator.
"""
function generators(S::AbstractSingleton{N}) where {N<:Real}
return EmptyGeneratorIterator{N}()
end


# --- AbstractCentrallySymmetric interface functions ---

Expand Down

0 comments on commit 2eb6329

Please sign in to comment.