Hyperrectangle
LazySets.HyperrectangleModule.Hyperrectangle
— TypeHyperrectangle{N, VNC<:AbstractVector{N}, VNR<:AbstractVector{N}
} <: AbstractHyperrectangle{N}
Type that represents a hyperrectangle.
A hyperrectangle is the Cartesian product of one-dimensional intervals.
Fields
center
– center of the hyperrectangle as a real vectorradius
– radius of the hyperrectangle as a real vector, i.e., half of its width along each coordinate direction
Examples
The Hyperrectangle
type stores a vector representing the center and another vector representing the radius. The default constructor Hyperrectangle(c, r)
receives the center and radius, in that order. For instance,
julia> c = [-1.0, 1.0];
julia> r = [2.0, 1.0];
julia> H = Hyperrectangle(c, r)
Hyperrectangle{Float64, Vector{Float64}, Vector{Float64}}([-1.0, 1.0], [2.0, 1.0])
The above instance represents the hyperrectangle with the following vertices:
julia> vertices_list(H)
4-element Vector{Vector{Float64}}:
[1.0, 2.0]
[-3.0, 2.0]
[1.0, 0.0]
[-3.0, 0.0]
The getter functions for the center and the radius are center
and radius_hyperrectangle
(since radius
corresponds to the radius of the enclosing ball of minimal volume):
julia> center(H)
2-element Vector{Float64}:
-1.0
1.0
julia> radius_hyperrectangle(H)
2-element Vector{Float64}:
2.0
1.0
There is also a constructor from lower and upper bounds with keyword arguments high
and low
. The following construction results in the same hyperrectangle as in the previous paragraph:
julia> l = [-3.0, 0.0];
julia> h = [1.0, 2.0];
julia> Hyperrectangle(low=l, high=h)
Hyperrectangle{Float64, Vector{Float64}, Vector{Float64}}([-1.0, 1.0], [2.0, 1.0])
By default, the constructor checks that that radius of the hyperrectangle is nonnegative. To suppress this check, use the check_bounds
optional flag in the constructor. Note that if check_bounds
is set to false
, the behavior of a set with contradictory bounds is undefined.
Conversion
Base.convert
— Methodconvert(::Type{Hyperrectangle}, H::AbstractHyperrectangle)
Convert a hyperrectangular set to a hyperrectangle.
Input
Hyperrectangle
– hyperrectangle target typeH
– hyperrectangular set
Output
A hyperrectangle.
Examples
julia> convert(Hyperrectangle, Interval(0.0, 1.0))
Hyperrectangle{Float64, Vector{Float64}, Vector{Float64}}([0.5], [0.5])
Base.convert
— Methodconvert(::Type{Hyperrectangle}, IB::IntervalArithmetic.IntervalBox)
Convert an IntervalBox
from IntervalArithmetic
to a hyperrectangular set.
Input
Hyperrectangle
– target typeIB
– interval box
Output
A Hyperrectangle
.
Notes
IntervalArithmetic.IntervalBox
uses static vectors to store each component interval; hence the resulting Hyperrectangle
has its center and radius represented as a static vector (SArray
).
Base.convert
— Methodconvert(::Type{IntervalArithmetic.IntervalBox}, H::AbstractHyperrectangle)
Convert a hyperrectangular set to an IntervalBox
from IntervalArithmetic
.
Input
IntervalBox
– target typeH
– hyperrectangular set
Output
An IntervalBox
.
Operations
LazySets.API.center
— Methodcenter(H::Hyperrectangle)
Return the center of a hyperrectangle.
Input
H
– hyperrectangle
Output
The center of the hyperrectangle.
LazySets.radius_hyperrectangle
— Methodradius_hyperrectangle(H::Hyperrectangle)
Return the box radius of a hyperrectangle in every dimension.
Input
H
– hyperrectangle
Output
The box radius of the hyperrectangle.
LazySets.radius_hyperrectangle
— Methodradius_hyperrectangle(H::Hyperrectangle, i::Int)
Return the box radius of a hyperrectangle in a given dimension.
Input
H
– hyperrectanglei
– dimension of interest
Output
The box radius in the given dimension.
Base.rand
— Methodrand(::Type{Hyperrectangle}; [N]::Type{<:Real}=Float64, [dim]::Int=2,
[rng]::AbstractRNG=GLOBAL_RNG, [seed]::Union{Int, Nothing}=nothing)
Create a random hyperrectangle.
Input
Hyperrectangle
– type for dispatchN
– (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 hyperrectangle.
Algorithm
All numbers are normally distributed with mean 0 and standard deviation 1. Additionally, the radius is nonnegative.
SparseArrays.permute
— Methodpermute(H::Hyperrectangle, p::AbstractVector{Int})
Permute the dimensions according to a permutation vector.
Input
H
– hyperrectanglep
– permutation vector
Output
A permuted hyperrectangle.
LazySets.API.translate
— Methodtranslate(H::Hyperrectangle, v::AbstractVector; [share]::Bool=false)
Translate (i.e., shift) a hyperrectangle by a given vector.
Input
H
– hyperrectanglev
– translation vectorshare
– (optional, default:false
) flag for sharing unmodified parts of the original set representation
Output
A translated hyperrectangle.
Notes
The radius vector is shared with the original hyperrectangle if share == true
.
Algorithm
We add the vector to the center of the hyperrectangle.
Inherited from LazySet
:
Inherited from AbstractPolytope
:
Inherited from AbstractCentrallySymmetricPolytope
:
Inherited from AbstractZonotope
:
Inherited from AbstractHyperrectangle
: