diff --git a/src/Sets/Universe/UniverseModule.jl b/src/Sets/Universe/UniverseModule.jl index 04a5a0f26e..fce05bb7b4 100644 --- a/src/Sets/Universe/UniverseModule.jl +++ b/src/Sets/Universe/UniverseModule.jl @@ -15,6 +15,7 @@ using ReachabilityBase.Require: require translate, translate!, cartesian_product, intersection @reexport import ..LazySets: constrained_dimensions, linear_map_inverse, tosimplehrep +import Base: copy @reexport using ..API export Universe @@ -25,6 +26,7 @@ include("an_element.jl") include("complement.jl") include("constraints.jl") include("constraints_list.jl") +include("copy.jl") include("diameter.jl") include("dim.jl") include("isbounded.jl") diff --git a/src/Sets/Universe/copy.jl b/src/Sets/Universe/copy.jl new file mode 100644 index 0000000000..12d0005c25 --- /dev/null +++ b/src/Sets/Universe/copy.jl @@ -0,0 +1,4 @@ +# since there is only a single instance (per dimensionality), we do not copy +function copy(U::Universe) + return U +end diff --git a/src/Sets/ZeroSet/ZeroSetModule.jl b/src/Sets/ZeroSet/ZeroSetModule.jl index 159442f7d1..7a3133d947 100644 --- a/src/Sets/ZeroSet/ZeroSetModule.jl +++ b/src/Sets/ZeroSet/ZeroSetModule.jl @@ -10,12 +10,14 @@ using ReachabilityBase.Require: require @reexport import ..API: dim, isoperationtype, rand, rectify, reflect, ∈, linear_map, scale, scale!, ρ, translate, minkowski_sum @reexport import ..LazySets: element +import Base: copy @reexport using ..API export ZeroSet include("ZeroSet.jl") +include("copy.jl") include("dim.jl") include("isoperationtype.jl") include("rand.jl") diff --git a/src/Sets/ZeroSet/copy.jl b/src/Sets/ZeroSet/copy.jl new file mode 100644 index 0000000000..8570313cdc --- /dev/null +++ b/src/Sets/ZeroSet/copy.jl @@ -0,0 +1,4 @@ +# since there is only a single instance (per dimensionality), we do not copy +function copy(Z::ZeroSet) + return Z +end diff --git a/test/Sets/Universe.jl b/test/Sets/Universe.jl index 835a1a6272..a3ce44cc8b 100644 --- a/test/Sets/Universe.jl +++ b/test/Sets/Universe.jl @@ -30,6 +30,10 @@ for N in [Float64, Rational{Int}, Float32] # dim @test dim(U) == 2 + # copy + U2 = copy(U) + @test U2 isa Universe{N} && dim(U2) == 2 + # support function and support vector @test ρ(N[0, 1], U) == N(Inf) @test ρ(N[0, 0], U) == zero(N) diff --git a/test/Sets/ZeroSet.jl b/test/Sets/ZeroSet.jl index cf783a1cdb..9c04de7b0c 100644 --- a/test/Sets/ZeroSet.jl +++ b/test/Sets/ZeroSet.jl @@ -5,6 +5,10 @@ for N in [Float64, Rational{Int}, Float32] Z = ZeroSet{N}(2) B = BallInf(ones(N, 2), N(1)) + # copy + Z2 = copy(Z) + @test Z2 isa ZeroSet{N} && dim(Z2) == 2 + # isoperationtype @test !isoperationtype(ZeroSet)