diff --git a/docs/src/lib/interfaces/AbstractCentrallySymmetric.md b/docs/src/lib/interfaces/AbstractCentrallySymmetric.md index 1a1201eee8..7454835444 100644 --- a/docs/src/lib/interfaces/AbstractCentrallySymmetric.md +++ b/docs/src/lib/interfaces/AbstractCentrallySymmetric.md @@ -41,7 +41,7 @@ extrema(::AbstractCentrallySymmetric) extrema(::AbstractCentrallySymmetric, ::Int) isbounded(::AbstractCentrallySymmetric) isempty(::AbstractCentrallySymmetric) -isuniversal(::AbstractCentrallySymmetric{N}, ::Bool=false) where {N} +isuniversal(::AbstractCentrallySymmetric, ::Bool=false) ``` ## Implementations diff --git a/docs/src/lib/interfaces/AbstractHyperrectangle.md b/docs/src/lib/interfaces/AbstractHyperrectangle.md index 25728331d5..aaaca3863e 100644 --- a/docs/src/lib/interfaces/AbstractHyperrectangle.md +++ b/docs/src/lib/interfaces/AbstractHyperrectangle.md @@ -26,7 +26,7 @@ This interface defines the following functions: ```@docs □(c, r) -constraints_list(::AbstractHyperrectangle{N}) where {N} +constraints_list(::AbstractHyperrectangle) extrema(::AbstractHyperrectangle) extrema(::AbstractHyperrectangle, ::Int) generators(::AbstractHyperrectangle) diff --git a/docs/src/lib/interfaces/AbstractPolytope.md b/docs/src/lib/interfaces/AbstractPolytope.md index 2cc8ab49ae..757bea1fee 100644 --- a/docs/src/lib/interfaces/AbstractPolytope.md +++ b/docs/src/lib/interfaces/AbstractPolytope.md @@ -35,7 +35,7 @@ This interface defines the following functions: ```@docs isbounded(::AbstractPolytope) isempty(::AbstractPolytope) -isuniversal(::AbstractPolytope{N}, ::Bool=false) where {N} +isuniversal(::AbstractPolytope, ::Bool=false) volume(::AbstractPolytope) ``` diff --git a/docs/src/lib/interfaces/AbstractSingleton.md b/docs/src/lib/interfaces/AbstractSingleton.md index a62c538811..90187a9c63 100644 --- a/docs/src/lib/interfaces/AbstractSingleton.md +++ b/docs/src/lib/interfaces/AbstractSingleton.md @@ -27,17 +27,17 @@ This interface defines the following functions: center(::AbstractSingleton) center(::AbstractSingleton, ::Int) element(::AbstractSingleton, ::Int) -generators(::AbstractSingleton{N}) where {N} -genmat(::AbstractSingleton{N}) where {N} +generators(::AbstractSingleton) +genmat(::AbstractSingleton) high(::AbstractSingleton) high(::AbstractSingleton, ::Int) low(::AbstractSingleton) low(::AbstractSingleton, ::Int) ngens(::AbstractSingleton) -radius_hyperrectangle(::AbstractSingleton{N}) where {N} -radius_hyperrectangle(::AbstractSingleton{N}, ::Int) where {N} +radius_hyperrectangle(::AbstractSingleton) +radius_hyperrectangle(::AbstractSingleton, ::Int) reflect(::AbstractSingleton) -vertices(::AbstractSingleton{N}) where {N} +vertices(::AbstractSingleton) vertices_list(::AbstractSingleton) ∈(::AbstractVector, ::AbstractSingleton) ρ(::AbstractVector, ::AbstractSingleton) diff --git a/docs/src/lib/sets/Ball2.md b/docs/src/lib/sets/Ball2.md index a8572432ee..d0df9c32ee 100644 --- a/docs/src/lib/sets/Ball2.md +++ b/docs/src/lib/sets/Ball2.md @@ -71,7 +71,7 @@ sample(::LazySet, ::Int) CurrentModule = LazySets.Ball2Module ``` ```@docs -sample(::Ball2{N}, ::Int) where {N} +sample(::Ball2, ::Int) ``` ```@meta CurrentModule = LazySets.API @@ -187,7 +187,7 @@ CurrentModule = LazySets.API CurrentModule = LazySets ``` * [`isempty`](@ref isempty(::AbstractCentrallySymmetric)) -* [`isuniversal`](@ref isuniversal(::AbstractCentrallySymmetric{N}, ::Bool=false) where {N}) +* [`isuniversal`](@ref isuniversal(::AbstractCentrallySymmetric, ::Bool=false)) Inherited from [`AbstractBallp`](@ref): * [`high`](@ref high(::AbstractBallp, ::Int)) diff --git a/docs/src/lib/sets/BallInf.md b/docs/src/lib/sets/BallInf.md index 03cbae9300..a9b74d725e 100644 --- a/docs/src/lib/sets/BallInf.md +++ b/docs/src/lib/sets/BallInf.md @@ -148,7 +148,7 @@ Inherited from [`AbstractCentrallySymmetricPolytope`](@ref): * [`center`](@ref center(::LazySet, ::Int)) * [`dim`](@ref dim(::AbstractCentrallySymmetricPolytope)) * [`isempty`](@ref isempty(::AbstractCentrallySymmetricPolytope)) -* [`isuniversal`](@ref isuniversal(::AbstractPolytope{N}, ::Bool=false) where {N}) +* [`isuniversal`](@ref isuniversal(::AbstractPolytope, ::Bool=false)) Inherited from [`AbstractZonotope`](@ref): * [`order`](@ref order(::AbstractZonotope)) @@ -163,7 +163,7 @@ CurrentModule = LazySets.API ```@meta CurrentModule = LazySets ``` -* [`constraints_list`](@ref constraints_list(::AbstractHyperrectangle{N}) where {N}) +* [`constraints_list`](@ref constraints_list(::AbstractHyperrectangle)) * [`extrema`](@ref extrema(::AbstractHyperrectangle)) * [`extrema`](@ref extrema(::AbstractHyperrectangle, ::Int)) * [`generators`](@ref generators(::AbstractHyperrectangle)) diff --git a/docs/src/lib/sets/Ballp.md b/docs/src/lib/sets/Ballp.md index 26e52df37a..3a5d1a9d3e 100644 --- a/docs/src/lib/sets/Ballp.md +++ b/docs/src/lib/sets/Ballp.md @@ -91,7 +91,7 @@ Inherited from [`AbstractCentrallySymmetric`](@ref): * [`isboundedtype`](@ref isboundedtype(::Type{AbstractCentrallySymmetric})) * [`isconvextype`](@ref isconvextype(::Type{AbstractCentrallySymmetric})) * [`isempty`](@ref isempty(::AbstractCentrallySymmetric)) -* [`isuniversal`](@ref isuniversal(::AbstractCentrallySymmetric{N}, ::Bool=false) where {N}) +* [`isuniversal`](@ref isuniversal(::AbstractCentrallySymmetric, ::Bool=false)) Inherited from [`AbstractBallp`](@ref): * [`low`](@ref low(::AbstractBallp, ::Int)) diff --git a/docs/src/lib/sets/Ellipsoid.md b/docs/src/lib/sets/Ellipsoid.md index 3936cf1bd9..45e4cba05f 100644 --- a/docs/src/lib/sets/Ellipsoid.md +++ b/docs/src/lib/sets/Ellipsoid.md @@ -126,4 +126,4 @@ CurrentModule = LazySets.API CurrentModule = LazySets ``` * [`isempty`](@ref isempty(::AbstractCentrallySymmetric)) -* [`isuniversal`](@ref isuniversal(::AbstractCentrallySymmetric{N}, ::Bool=false) where {N}) +* [`isuniversal`](@ref isuniversal(::AbstractCentrallySymmetric, ::Bool=false)) diff --git a/docs/src/lib/sets/HParallelotope.md b/docs/src/lib/sets/HParallelotope.md index a31dca5437..bcf8e86a4d 100644 --- a/docs/src/lib/sets/HParallelotope.md +++ b/docs/src/lib/sets/HParallelotope.md @@ -50,7 +50,7 @@ Inherited from [`AbstractCentrallySymmetricPolytope`](@ref): * [`an_element`](@ref an_element(::AbstractCentrallySymmetricPolytope)) * [`extrema`](@ref extrema(::AbstractCentrallySymmetricPolytope)) * [`extrema`](@ref extrema(::AbstractCentrallySymmetricPolytope, ::Int)) -* [`isuniversal`](@ref isuniversal(::AbstractCentrallySymmetricPolytope, ::Bool=false)) +* [`isuniversal`](@ref isuniversal(::AbstractPolytope, ::Bool=false)) Inherited from [`AbstractZonotope`](@ref): * [`isempty`](@ref isempty(::AbstractZonotope)) diff --git a/docs/src/lib/sets/HPolygon.md b/docs/src/lib/sets/HPolygon.md index 71a432ea1c..2afa3f31ff 100644 --- a/docs/src/lib/sets/HPolygon.md +++ b/docs/src/lib/sets/HPolygon.md @@ -29,7 +29,7 @@ Inherited from [`LazySet`](@ref): Inherited from [`AbstractPolytope`](@ref): * [`isempty`](@ref isempty(::AbstractPolytope)) -* [`isuniversal`](@ref isuniversal(::AbstractPolytope{N}, ::Bool=false) where {N}) +* [`isuniversal`](@ref isuniversal(::AbstractPolytope, ::Bool=false)) Inherited from [`AbstractPolygon`](@ref): * [`dim`](@ref dim(::AbstractPolygon)) diff --git a/docs/src/lib/sets/HPolygonOpt.md b/docs/src/lib/sets/HPolygonOpt.md index dc5219938c..265846f225 100644 --- a/docs/src/lib/sets/HPolygonOpt.md +++ b/docs/src/lib/sets/HPolygonOpt.md @@ -18,7 +18,7 @@ Inherited from [`LazySet`](@ref): Inherited from [`AbstractPolytope`](@ref): * [`isempty`](@ref isempty(::AbstractPolytope)) -* [`isuniversal`](@ref isuniversal(::AbstractPolytope{N}, ::Bool=false) where {N}) +* [`isuniversal`](@ref isuniversal(::AbstractPolytope, ::Bool=false)) Inherited from [`AbstractPolygon`](@ref): * [`dim`](@ref dim(::AbstractPolygon)) diff --git a/docs/src/lib/sets/HPolytope.md b/docs/src/lib/sets/HPolytope.md index 91bbd12dff..f23a12f88e 100644 --- a/docs/src/lib/sets/HPolytope.md +++ b/docs/src/lib/sets/HPolytope.md @@ -47,5 +47,5 @@ CurrentModule = LazySets ``` Inherited from [`AbstractPolytope`](@ref): -* [`isuniversal`](@ref isuniversal(::AbstractPolytope{N}, ::Bool=false) where {N}) +* [`isuniversal`](@ref isuniversal(::AbstractPolytope, ::Bool=false)) * [`volume`](@ref volume(::AbstractPolytope)) diff --git a/docs/src/lib/sets/Hyperrectangle.md b/docs/src/lib/sets/Hyperrectangle.md index 7b701235ca..66a01d97fa 100644 --- a/docs/src/lib/sets/Hyperrectangle.md +++ b/docs/src/lib/sets/Hyperrectangle.md @@ -50,7 +50,7 @@ Inherited from [`AbstractZonotope`](@ref): * [`linear_map`](@ref linear_map(::AbstractMatrix, ::AbstractZonotope)) Inherited from [`AbstractHyperrectangle`](@ref): -* [`constraints_list`](@ref constraints_list(::AbstractHyperrectangle{N}) where {N}) +* [`constraints_list`](@ref constraints_list(::AbstractHyperrectangle)) * [`extrema`](@ref extrema(::AbstractHyperrectangle)) * [`extrema`](@ref extrema(::AbstractHyperrectangle, ::Int)) * [`generators`](@ref generators(::AbstractHyperrectangle)) diff --git a/docs/src/lib/sets/Singleton.md b/docs/src/lib/sets/Singleton.md index 2f2d52d598..1a9f0b604f 100644 --- a/docs/src/lib/sets/Singleton.md +++ b/docs/src/lib/sets/Singleton.md @@ -120,18 +120,18 @@ Inherited from [`AbstractSingleton`](@ref): * [`center`](@ref center(::AbstractSingleton)) * [`center`](@ref center(::AbstractSingleton, ::Int)) * [`constraints_list`](@ref constraints_list(::AbstractSingleton)) -* [`generators`](@ref generators(::AbstractSingleton{N}) where {N}) -* [`genmat`](@ref genmat(::AbstractSingleton{N}) where {N}) +* [`generators`](@ref generators(::AbstractSingleton)) +* [`genmat`](@ref genmat(::AbstractSingleton)) * [`high`](@ref high(::AbstractSingleton)) * [`high`](@ref high(::AbstractSingleton, ::Int)) * [`isboundedtype`](@ref isboundedtype(::Type{AbstractSingleton})) * [`low`](@ref low(::AbstractSingleton)) * [`low`](@ref low(::AbstractSingleton, ::Int)) * [`ngens`](@ref ngens(::AbstractSingleton)) -* [`radius_hyperrectangle`](@ref radius_hyperrectangle(::AbstractSingleton{N}) where {N}) -* [`radius_hyperrectangle`](@ref radius_hyperrectangle(::AbstractSingleton{N}, ::Int) where {N}) +* [`radius_hyperrectangle`](@ref radius_hyperrectangle(::AbstractSingleton)) +* [`radius_hyperrectangle`](@ref radius_hyperrectangle(::AbstractSingleton, ::Int)) * [`reflect`](@ref reflect(::AbstractSingleton)) -* [`vertices`](@ref vertices(::AbstractSingleton{N}) where {N}) +* [`vertices`](@ref vertices(::AbstractSingleton)) * [`vertices_list`](@ref vertices_list(::AbstractSingleton)) * [`∈`](@ref ∈(::AbstractVector, ::AbstractSingleton)) * [`ρ`](@ref σ(::AbstractVector, ::AbstractSingleton)) diff --git a/docs/src/lib/sets/Universe.md b/docs/src/lib/sets/Universe.md index e976a32174..9a20ed4843 100644 --- a/docs/src/lib/sets/Universe.md +++ b/docs/src/lib/sets/Universe.md @@ -20,7 +20,7 @@ an_element(::LazySet) CurrentModule = LazySets.UniverseModule ``` ```@docs -an_element(::Universe{N}) where {N} +an_element(::Universe) constrained_dimensions(::Universe) ``` ```@meta diff --git a/docs/src/lib/sets/VPolygon.md b/docs/src/lib/sets/VPolygon.md index 4526834f16..43f298a195 100644 --- a/docs/src/lib/sets/VPolygon.md +++ b/docs/src/lib/sets/VPolygon.md @@ -52,7 +52,7 @@ Inherited from [`LazySet`](@ref): Inherited from [`AbstractPolytope`](@ref): * [`isbounded`](@ref isbounded(::AbstractPolytope)) * [`isempty`](@ref isempty(::AbstractPolytope)) -* [`isuniversal`](@ref isuniversal(::AbstractPolytope{N}, ::Bool=false) where {N}) +* [`isuniversal`](@ref isuniversal(::AbstractPolytope, ::Bool=false)) Inherited from [`AbstractPolygon`](@ref): * [`dim`](@ref dim(::AbstractPolygon)) diff --git a/docs/src/lib/sets/VPolytope.md b/docs/src/lib/sets/VPolytope.md index 0456160783..7b096b3072 100644 --- a/docs/src/lib/sets/VPolytope.md +++ b/docs/src/lib/sets/VPolytope.md @@ -55,5 +55,5 @@ Inherited from [`AbstractPolyhedron`](@ref): Inherited from [`AbstractPolytope`](@ref): * [`isbounded`](@ref isbounded(::AbstractPolytope)) * [`isempty`](@ref isempty(::AbstractPolytope)) -* [`isuniversal`](@ref isuniversal(::AbstractPolytope{N}, ::Bool=false) where {N}) +* [`isuniversal`](@ref isuniversal(::AbstractPolytope, ::Bool=false)) * [`volume`](@ref volume(::AbstractPolytope)) diff --git a/docs/src/lib/sets/ZeroSet.md b/docs/src/lib/sets/ZeroSet.md index accea5c888..d4613c0657 100644 --- a/docs/src/lib/sets/ZeroSet.md +++ b/docs/src/lib/sets/ZeroSet.md @@ -11,8 +11,8 @@ ZeroSet ## Operations ```@docs -element(::ZeroSet{N}) where {N} -element(::ZeroSet{N}, ::Int) where {N} +element(::ZeroSet) +element(::ZeroSet, ::Int) ``` ```@meta CurrentModule = LazySets.API @@ -99,17 +99,17 @@ Inherited from [`AbstractSingleton`](@ref): * [`center`](@ref center(::AbstractSingleton)) * [`center`](@ref center(::AbstractSingleton, ::Int)) * [`constraints_list`](@ref constraints_list(::AbstractSingleton)) -* [`generators`](@ref generators(::AbstractSingleton{N}) where {N}) -* [`genmat`](@ref genmat(::AbstractSingleton{N}) where {N}) +* [`generators`](@ref generators(::AbstractSingleton)) +* [`genmat`](@ref genmat(::AbstractSingleton)) * [`high`](@ref high(::AbstractSingleton)) * [`high`](@ref high(::AbstractSingleton, ::Int)) * [`isconvextype`](@ref isconvextype(::Type{AbstractSingleton})) * [`low`](@ref low(::AbstractSingleton)) * [`low`](@ref low(::AbstractSingleton, ::Int)) * [`ngens`](@ref ngens(::AbstractSingleton)) -* [`radius_hyperrectangle`](@ref radius_hyperrectangle(::AbstractSingleton{N}) where {N}) -* [`radius_hyperrectangle`](@ref radius_hyperrectangle(::AbstractSingleton{N}, ::Int) where {N}) -* [`vertices`](@ref vertices(::AbstractSingleton{N}) where {N}) +* [`radius_hyperrectangle`](@ref radius_hyperrectangle(::AbstractSingleton)) +* [`radius_hyperrectangle`](@ref radius_hyperrectangle(::AbstractSingleton, ::Int)) +* [`vertices`](@ref vertices(::AbstractSingleton)) * [`vertices`](@ref vertices(::AbstractSingleton)) * [`vertices_list`](@ref vertices_list(::AbstractSingleton)) * [`σ`](@ref σ(::AbstractVector, ::AbstractSingleton)) diff --git a/docs/src/lib/sets/Zonotope.md b/docs/src/lib/sets/Zonotope.md index 083b59d409..bab5339380 100644 --- a/docs/src/lib/sets/Zonotope.md +++ b/docs/src/lib/sets/Zonotope.md @@ -47,7 +47,7 @@ Inherited from [`LazySet`](@ref): Inherited from [`AbstractPolytope`](@ref): * [`isbounded`](@ref isbounded(::AbstractPolytope)) -* [`isuniversal`](@ref isuniversal(::AbstractPolytope{N}, ::Bool=false) where {N}) +* [`isuniversal`](@ref isuniversal(::AbstractPolytope, ::Bool=false)) * [`volume`](@ref volume(::AbstractPolytope)) Inherited from [`AbstractCentrallySymmetricPolytope`](@ref): diff --git a/src/Interfaces/AbstractCentrallySymmetric.jl b/src/Interfaces/AbstractCentrallySymmetric.jl index 171f27d94d..ae250904ef 100644 --- a/src/Interfaces/AbstractCentrallySymmetric.jl +++ b/src/Interfaces/AbstractCentrallySymmetric.jl @@ -99,8 +99,7 @@ function isempty(::AbstractCentrallySymmetric) end """ - isuniversal(S::AbstractCentrallySymmetric{N}, - [witness]::Bool=false) where {N} + isuniversal(S::AbstractCentrallySymmetric, [witness]::Bool=false) Check whether a centrally symmetric set is universal. @@ -120,9 +119,9 @@ Centrally symmetric sets are bounded. A witness is obtained by computing the support vector in direction `d = [1, 0, …, 0]` and adding `d` on top. """ -function isuniversal(S::AbstractCentrallySymmetric{N}, - witness::Bool=false) where {N} +function isuniversal(S::AbstractCentrallySymmetric, witness::Bool=false) if witness + N = eltype(S) d = SingleEntryVector{N}(1, dim(S)) w = σ(d, S) + d return (false, w) diff --git a/src/Interfaces/AbstractHyperrectangle.jl b/src/Interfaces/AbstractHyperrectangle.jl index 2774ee799d..c9369bff7e 100644 --- a/src/Interfaces/AbstractHyperrectangle.jl +++ b/src/Interfaces/AbstractHyperrectangle.jl @@ -283,7 +283,7 @@ function vertices_list(H::AbstractHyperrectangle; kwargs...) end """ - constraints_list(H::AbstractHyperrectangle{N}) where {N} + constraints_list(H::AbstractHyperrectangle) Return the list of constraints of a hyperrectangular set. @@ -295,7 +295,7 @@ Return the list of constraints of a hyperrectangular set. A list of ``2n`` linear constraints, where ``n`` is the dimension of `H`. """ -function constraints_list(H::AbstractHyperrectangle{N}) where {N} +function constraints_list(H::AbstractHyperrectangle) return _constraints_list_hyperrectangle(H) end diff --git a/src/Interfaces/AbstractPolytope.jl b/src/Interfaces/AbstractPolytope.jl index b47464f890..310d179273 100644 --- a/src/Interfaces/AbstractPolytope.jl +++ b/src/Interfaces/AbstractPolytope.jl @@ -76,7 +76,7 @@ function isempty(P::AbstractPolytope) end """ - isuniversal(P::AbstractPolytope{N}, [witness]::Bool=false) where {N} + isuniversal(P::AbstractPolytope, [witness]::Bool=false) Check whether a polytopic set is universal. @@ -96,10 +96,11 @@ Check whether a polytopic set is universal. A witness is produced using `isuniversal(H)` where `H` is the first linear constraint of `P`. """ -function isuniversal(P::AbstractPolytope{N}, witness::Bool=false) where {N} +function isuniversal(P::AbstractPolytope, witness::Bool=false) if witness constraints = constraints_list(P) if isempty(constraints) + N = eltype(P) return (true, N[]) # special case for polytopes without constraints end return isuniversal(constraints[1], true) diff --git a/src/Interfaces/AbstractSingleton.jl b/src/Interfaces/AbstractSingleton.jl index a1c7ff8747..6d244374bf 100644 --- a/src/Interfaces/AbstractSingleton.jl +++ b/src/Interfaces/AbstractSingleton.jl @@ -63,7 +63,7 @@ function element(S::AbstractSingleton, i::Int) end """ - radius_hyperrectangle(S::AbstractSingleton{N}, i::Int) where {N} + radius_hyperrectangle(S::AbstractSingleton, i::Int) Return the box radius of a set with a single value in a given dimension. @@ -76,13 +76,14 @@ Return the box radius of a set with a single value in a given dimension. Zero. """ -function radius_hyperrectangle(S::AbstractSingleton{N}, i::Int) where {N} +function radius_hyperrectangle(S::AbstractSingleton, i::Int) @boundscheck _check_bounds(S, i) + N = eltype(S) return zero(N) end """ - radius_hyperrectangle(S::AbstractSingleton{N}) where {N} + radius_hyperrectangle(S::AbstractSingleton) Return the box radius of a set with a single value in every dimension. @@ -94,7 +95,8 @@ Return the box radius of a set with a single value in every dimension. The zero vector. """ -function radius_hyperrectangle(S::AbstractSingleton{N}) where {N} +function radius_hyperrectangle(S::AbstractSingleton) + N = eltype(S) return zeros(N, dim(S)) end @@ -173,7 +175,7 @@ function low(S::AbstractSingleton, i::Int) end """ - genmat(S::AbstractSingleton{N}) where {N} + genmat(S::AbstractSingleton) Return the (empty) generator matrix of a set with a single value. @@ -185,12 +187,13 @@ Return the (empty) generator matrix of a set with a single value. A matrix with no columns representing the generators of `S`. """ -function genmat(S::AbstractSingleton{N}) where {N} +function genmat(S::AbstractSingleton) + N = eltype(S) return Matrix{N}(undef, dim(S), 0) end """ - generators(S::AbstractSingleton{N}) where {N} + generators(S::AbstractSingleton) Return an (empty) iterator over the generators of a set with a single value. @@ -202,7 +205,8 @@ Return an (empty) iterator over the generators of a set with a single value. An empty iterator. """ -function generators(S::AbstractSingleton{N}) where {N} +function generators(S::AbstractSingleton) + N = eltype(S) return EmptyIterator{Vector{N}}() end @@ -260,7 +264,7 @@ function center(S::AbstractSingleton, i::Int) end """ - vertices(S::AbstractSingleton{N}) where {N} + vertices(S::AbstractSingleton) Construct an iterator over the vertices of a set with a single value. @@ -272,7 +276,7 @@ Construct an iterator over the vertices of a set with a single value. An iterator with a single value. """ -function vertices(S::AbstractSingleton{N}) where {N} +function vertices(S::AbstractSingleton) return SingletonIterator(element(S)) end diff --git a/src/Sets/Ball2/sample.jl b/src/Sets/Ball2/sample.jl index 8bbb82fa0d..ac5d3a1af2 100644 --- a/src/Sets/Ball2/sample.jl +++ b/src/Sets/Ball2/sample.jl @@ -1,9 +1,9 @@ """ # Extended help - sample(B::Ball2{N}, [nsamples]::Int; + sample(B::Ball2, [nsamples]::Int; [rng]::AbstractRNG=GLOBAL_RNG, - [seed]::Union{Int, Nothing}=nothing) where {N} + [seed]::Union{Int, Nothing}=nothing) ### Algorithm @@ -11,11 +11,12 @@ Random sampling with uniform distribution in `B` is computed using Muller's meth of normalized Gaussians. This method requires the package `Distributions`. See [`_sample_unit_nball_muller!`](@ref) for implementation details. """ -function sample(B::Ball2{N}, nsamples::Int; +function sample(B::Ball2, nsamples::Int; rng::AbstractRNG=GLOBAL_RNG, - seed::Union{Int,Nothing}=nothing) where {N} + seed::Union{Int,Nothing}=nothing) require(@__MODULE__, :Distributions; fun_name="sample") n = dim(B) + N = eltype(B) D = Vector{Vector{N}}(undef, nsamples) # preallocate output _sample_unit_nball_muller!(D, n, nsamples; rng=rng, seed=seed) @@ -28,9 +29,9 @@ function sample(B::Ball2{N}, nsamples::Int; end """ - _sample_unit_nball_muller!(D::Vector{Vector{N}}, n::Int, p::Int; + _sample_unit_nball_muller!(D::Vector{<:Vector}, n::Int, p::Int; [rng]::AbstractRNG=GLOBAL_RNG, - [seed]::Union{Int, Nothing}=nothing) where {N} + [seed]::Union{Int, Nothing}=nothing) Draw samples from a uniform distribution on an ``n``-dimensional unit ball using Muller's method. @@ -65,9 +66,9 @@ where ``α := \\sqrt{z₁² + z₂² + … + z_n²}``, is uniform over the [1] Muller, Mervin E. *A note on a method for generating points uniformly on n-dimensional spheres.* Communications of the ACM 2.4 (1959): 19-20. """ -function _sample_unit_nball_muller!(D::Vector{Vector{N}}, n::Int, p::Int; +function _sample_unit_nball_muller!(D::Vector{<:Vector}, n::Int, p::Int; rng::AbstractRNG=GLOBAL_RNG, - seed::Union{Int,Nothing}=nothing) where {N} + seed::Union{Int,Nothing}=nothing) return _sample_unit_nball_muller_distributions!(D, n, p; rng=rng, seed=seed) end diff --git a/src/Sets/Universe/an_element.jl b/src/Sets/Universe/an_element.jl index 64898b0eeb..7c0438fd4d 100644 --- a/src/Sets/Universe/an_element.jl +++ b/src/Sets/Universe/an_element.jl @@ -1,12 +1,13 @@ """ # Extended help - an_element(U::Universe{N}) where {N} + an_element(U::Universe) ### Algorithm The output is the origin. """ -function an_element(U::Universe{N}) where {N} +function an_element(U::Universe) + N = eltype(U) return zeros(N, dim(U)) end diff --git a/src/Sets/ZeroSet/element.jl b/src/Sets/ZeroSet/element.jl index 1c6fa6085d..b60562eab5 100644 --- a/src/Sets/ZeroSet/element.jl +++ b/src/Sets/ZeroSet/element.jl @@ -1,5 +1,5 @@ """ - element(Z::ZeroSet{N}) where {N} + element(Z::ZeroSet) Return the element of a zero set. @@ -11,12 +11,13 @@ Return the element of a zero set. The element of the zero set, i.e., a zero vector. """ -function element(Z::ZeroSet{N}) where {N} +function element(Z::ZeroSet) + N = eltype(Z) return zeros(N, Z.dim) end """ - element(Z::ZeroSet{N}, ::Int) where {N} + element(Z::ZeroSet, i::Int) Return the i-th entry of the element of a zero set. @@ -29,6 +30,7 @@ Return the i-th entry of the element of a zero set. The i-th entry of the element of the zero set, i.e., 0. """ -function element(Z::ZeroSet{N}, ::Int) where {N} +function element(::ZeroSet, ::Int) + N = eltype(Z) return zero(N) end