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

Add low and high method for AbstractHyperrectangles #618

Closed
mforets opened this issue Sep 11, 2018 · 3 comments
Closed

Add low and high method for AbstractHyperrectangles #618

mforets opened this issue Sep 11, 2018 · 3 comments
Assignees
Labels
feature ➕ A new feature

Comments

@mforets
Copy link
Member

mforets commented Sep 11, 2018

julia> using LazySets

julia> B = BallInf(ones(2), 1.0)
LazySets.BallInf{Float64}([1.0, 1.0], 1.0)

julia> low(B)
ERROR: MethodError: no method matching low(::LazySets.BallInf{Float64})
Closest candidates are:
  low(::LazySets.Hyperrectangle{N<:Real}) where N<:Real at /Users/forets/.julia/v0.6/LazySets/src/Hyperrectangle.jl:187
  low(::LazySets.Interval) at /Users/forets/.julia/v0.6/LazySets/src/Interval.jl:258

julia> high(B)
ERROR: MethodError: no method matching high(::LazySets.BallInf{Float64})
Closest candidates are:
  high(::LazySets.Hyperrectangle{N<:Real}) where N<:Real at /Users/forets/.julia/v0.6/LazySets/src/Hyperrectangle.jl:169
  high(::LazySets.Interval) at /Users/forets/.julia/v0.6/LazySets/src/Interval.jl:273
@schillic schillic added the feature ➕ A new feature label Sep 11, 2018
@schillic
Copy link
Member

Should they be general methods for AbstractHyperrectangles? Then we also need them for AbstractSingleton, but there it is just a call to element(S).

@mforets
Copy link
Member Author

mforets commented Sep 11, 2018

Hmm the AbstractHyperrectangle interface already requires that the radius of the hyperrectangle (as a vector, the radius_hyperrectangle) is implemented.

If we also require that each concrete subtype defines the center, then we can define in the interface the fallback functions

function high(H::AbstractHyperrectangle{N})::Vector{N} where {N<:Real}
    return center(H) .+ radius_hyperrectangle(H)
end

function low(H::AbstractHyperrectangle{N})::Vector{N} where {N<:Real}
    return center(H) .- radius_hyperrectangle(H)
end

do you agree?

@schillic
Copy link
Member

👍, then we can remove the implementation in Hyperrectangle.jl which is doing exactly that.

@schillic schillic self-assigned this Sep 17, 2018
@schillic schillic changed the title Add low and high method for BallInf Add low and high method for AbstractHyperrectangles Sep 17, 2018
schillic added a commit that referenced this issue Sep 17, 2018
#618 - Add low and high method for AbstractHyperrectangles
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature ➕ A new feature
Projects
None yet
Development

No branches or pull requests

2 participants