JuliaReach / LazySets.jl

Scalable symbolic-numeric set computations in Julia
https://juliareach.github.io/LazySets.jl/
Other
226 stars 32 forks source link

Convert m-sum of m-array to m-sum array #1678

Closed mforets closed 4 years ago

mforets commented 5 years ago

... by one MinkowskiSumArray.

e.g the result in the second line could be automatically simplified to a MinkowskiSumArray{Float64,Zonotope{Float64}}:

julia> z = rand(Zonotope);

julia> typeof(z ⊕ MinkowskiSumArray([z, z]))
MinkowskiSum{Float64,Zonotope{Float64},MinkowskiSumArray{Float64,Zonotope{Float64}}}
schillic commented 5 years ago

related: #269, #614

mforets commented 4 years ago

I'm not sure if the library should do this automatic conversion on the creation of the object. Perhaps not. However, we can easily offer the conversion, adding a method for:

julia> convert(MinkowskiSumArray, z ⊕ MinkowskiSumArray([z, z]))
ERROR: MethodError: Cannot `convert` an object of type MinkowskiSum{Float64,Zonotope{Float64},MinkowskiSumArray{Float64,Zonotope{Float64}}} to an object of type MinkowskiSumArray
Closest candidates are:
  convert(::Type{MinkowskiSumArray}, ::MinkowskiSumArray) at /home/mforets/.julia/dev/LazySets/src/convert.jl:8
  convert(::Type{T}, ::T) where T at essentials.jl:167
  MinkowskiSumArray(::LazySet{N<:Real}, ::ZeroSet{N<:Real}) where N<:Real at /home/mforets/.julia/dev/LazySets/src/Utils/macros.jl:39
  ...
Stacktrace:
 [1] top-level scope at REPL[8]:1