p-norm ball (Ballp)
LazySets.BallpModule.Ballp
— TypeBallp{N<:AbstractFloat, VN<:AbstractVector{N}} <: AbstractBallp{N}
Type that represents a ball in the p-norm, for $1 ≤ p ≤ ∞$.
It is defined as the set
\[\mathcal{B}_p^n(c, r) = \{ x ∈ ℝ^n : ‖ x - c ‖_p ≤ r \},\]
where $c ∈ ℝ^n$ is its center and $r ∈ ℝ_+$ its radius. Here $‖ ⋅ ‖_p$ for $1 ≤ p ≤ ∞$ denotes the vector $p$-norm, defined as $‖ x ‖_p = \left( ∑\limits_{i=1}^n |x_i|^p \right)^{1/p}$ for any $x ∈ ℝ^n$.
Fields
p
– norm as a real scalarcenter
– center of the ball as a real vectorradius
– radius of the ball as a scalar ($≥ 0$)
Notes
The special cases $p=1$, $p=2$ and $p=∞$ fall back to the specialized types Ball1
, Ball2
and BallInf
, respectively.
Examples
A five-dimensional ball in the $p=3/2$ norm centered at the origin of radius 0.5:
julia> B = Ballp(3/2, zeros(5), 0.5)
Ballp{Float64, Vector{Float64}}(1.5, [0.0, 0.0, 0.0, 0.0, 0.0], 0.5)
julia> dim(B)
5
We evaluate the support vector in direction $[1,2,…,5]$:
julia> σ([1.0, 2, 3, 4, 5], B)
5-element Vector{Float64}:
0.013516004434607558
0.05406401773843023
0.12164403991146802
0.21625607095372093
0.33790011086518895
Operations
Base.rand
— Methodrand(T::Type{<:LazySet}; [N]::Type{<:Real}=Float64, [dim]::Int=2,
[rng]::AbstractRNG=GLOBAL_RNG, [seed]::Union{Int, Nothing}=nothing
)
Create a random set of the given set type.
Input
T
– set typeN
– (optional, default:Float64
) numeric typedim
– (optional, default: 2) dimensionrng
– (optional, default:GLOBAL_RNG
) random number generatorseed
– (optional, default:nothing
) seed for reseeding
Output
A random set of the given set type.
Base.rand
— MethodExtended help
rand(::Type{Ballp}; [N]::Type{<:Real}=Float64, [dim]::Int=2,
[rng]::AbstractRNG=GLOBAL_RNG, [seed]::Union{Int, Nothing}=nothing)
Algorithm
The center and radius are normally distributed with mean 0 and standard deviation 1. Additionally, the radius is nonnegative. The p-norm is a normally distributed number ≥ 1 with mean 1 and standard deviation 1.
LazySets.API.reflect
— Methodreflect(X::LazySet)
Compute the reflection of a set in the origin.
Input
X
– set
Output
A set representing the reflection $-X$.
LazySets.API.reflect
— MethodExtended help
reflect(B::Ballp)
Algorithm
If $B$ has center $c$ and radius $r$, then $-B$ has center $-c$ and radius $r$. The norm remains the same.
LazySets.API.translate!
— Methodtranslate!(X::LazySet, v::AbstractVector)
Translate a set with a vector by modifying it.
Input
X
– setv
– vector
Output
The translated set representing $X + \{v\}$.
LazySets.API.translate!
— MethodExtended help
translate!(B::Ballp, v::AbstractVector)
Algorithm
We add the vector to the center of the ball.
Undocumented implementations:
Inherited from LazySet
:
concretize
convex_hull
copy(::Type{LazySet})
diameter
eltype
eltype
high
low
ispolyhedral
isoperation
norm
radius
rectify
is_interior_point
sample
translate
≈
==
isequivalent
Inherited from AbstractCentrallySymmetric
:
Inherited from AbstractBallp
: