Utility functions
LazySets.sign_cadlag
— Function.sign_cadlag(x::N)::N where {N<:Real}
This function works like the sign function but is $1$ for input $0$.
Input
x
– real scalar
Output
$1$ if $x ≥ 0$, $-1$ otherwise.
Notes
This is the sign function right-continuous at zero (see càdlàg function). It can be used with vector-valued arguments via the dot operator.
Examples
julia> import LazySets.sign_cadlag
julia> sign_cadlag.([-0.6, 1.3, 0.0])
3-element Array{Float64,1}:
-1.0
1.0
1.0
LazySets.ispermutation
— Function.ispermutation(u::AbstractVector{T}, v::AbstractVector{T})::Bool where T
Check that two vectors contain the same elements up to reordering.
Input
u
– first vectorv
– second vector
Output
true
iff the vectors are identical up to reordering.
Examples
julia> LazySets.ispermutation([1, 2, 2], [2, 2, 1])
true
julia> LazySets.ispermutation([1, 2, 2], [1, 1, 2])
false
LazySets.@neutral
— Macro.@neutral(SET, NEUT)
Create functions to make a lazy set operation commutative with a given neutral element set type.
Input
SET
– lazy set operation typeNEUT
– set type for neutral element
Output
Nothing.
Notes
This macro generates four functions (possibly two more if @absorbing
has been used in advance) (possibly two or four more if @declare_array_version
has been used in advance).
Examples
@neutral(MinkowskiSum, N)
creates at least the following functions:
neutral(::MinkowskiSum) = N
MinkowskiSum(X, N) = X
MinkowskiSum(N, X) = X
MinkowskiSum(N, N) = N
LazySets.@absorbing
— Macro.@absorbing(SET, ABS)
Create functions to make a lazy set operation commutative with a given absorbing element set type.
Input
SET
– lazy set operation typeABS
– set type for absorbing element
Output
Nothing.
Notes
This macro generates four functions (possibly two more if @neutral
has been used in advance) (possibly two or four more if @declare_array_version
has been used in advance).
Examples
@absorbing(MinkowskiSum, A)
creates at least the following functions:
absorbing(::MinkowskiSum) = A
MinkowskiSum(X, A) = A
MinkowskiSum(A, X) = A
MinkowskiSum(A, A) = A
LazySets.@declare_array_version
— Macro.@declare_array_version(SET, SETARR)
Create functions to connect a lazy set operation with its array set type.
Input
SET
– lazy set operation typeSETARR
– array set type
Output
Nothing.
Notes
This macro generates eight functions (and possibly up to eight more if @neutral
/@absorbing
has been used in advance for the base and/or array set type).
Examples
@declare_array_version(MinkowskiSum, MinkowskiSumArray)
creates at least the following functions:
array_constructor(::MinkowskiSum) = MinkowskiSumArray
is_array_constructor(::MinkowskiSumArray) = true
MinkowskiSum!(X, Y)
MinkowskiSum!(X, arr)
MinkowskiSum!(arr, X)
MinkowskiSum!(arr1, arr2)
Helpers for internal use only
Functions and Macros
LazySets.@neutral_absorbing
— Macro.@neutral_absorbing(SET, NEUT, ABS)
Create two functions to avoid method ambiguties for a lazy set operation with respect to neutral and absorbing element set types.
Input
SET
– lazy set operation typeNEUT
– set type for neutral elementABS
– set type for absorbing element
Output
A quoted expression containing the function definitions.
Examples
@neutral_absorbing(MinkowskiSum, N, A)
creates the following functions as quoted expressions:
MinkowskiSum(N, A) = A
MinkowskiSum(A, N) = A
LazySets.@array_neutral
— Macro.@array_neutral(FUN, NEUT, SETARR)
Create two functions to avoid method ambiguities for a lazy set operation with respect to the neutral element set type and the array set type.
Input
FUN
– function nameNEUT
– set type for neutral elementSETARR
– array set type
Output
A quoted expression containing the function definitions.
Examples
@array_neutral(MinkowskiSum, N, ARR)
creates the following functions as quoted expressions:
MinkowskiSum(N, ARR) = ARR
MinkowskiSum(ARR, N) = ARR
LazySets.@array_absorbing
— Macro.@array_absorbing(FUN, ABS, SETARR)
Create two functions to avoid method ambiguities for a lazy set operation with respect to the absorbing element set type and the array set type.
Input
FUN
– function nameABS
– set type for absorbing elementSETARR
– array set type
Output
A quoted expression containing the function definitions.
Examples
@array_absorbing(MinkowskiSum, ABS, ARR)
creates the following functions as quoted expressions:
MinkowskiSum(ABS, ARR) = ABS
MinkowskiSum(ARR, ABS) = ABS
LazySets.get_radius!
— Function.get_radius!(sih::SymmetricIntervalHull{N},
i::Int,
n::Int=dim(sih))::N where {N<:Real}
Compute the radius of a symmetric interval hull of a convex set in a given dimension.
Input
sih
– symmetric interval hull of a convex seti
– dimension in which the radius should be computedn
– (optional, default:dim(sih)
) set dimension
Output
The radius of a symmetric interval hull of a convex set in a given dimension.
Algorithm
We ask for the support vector of the underlying set for both the positive and negative unit vector in the dimension i
.
LazySets.an_element_helper
— Function.an_element_helper(hp::Hyperplane{N},
[nonzero_entry_a]::Int)::Vector{N} where {N<:Real}
Helper function that computes an element on a hyperplane's hyperplane.
Input
hp
– hyperplanenonzero_entry_a
– (optional, default: computes the first index) indexi
such thathp.a[i]
is different from 0
Output
An element on a hyperplane.
Algorithm
We compute the point on the hyperplane as follows:
- We already found a nonzero entry of $a$ in dimension, say, $i$.
- We set $x[i] = b / a[i]$.
- We set $x[j] = 0$ for all $j ≠ i$.
LazySets.σ_helper
— Function. σ_helper(d::AbstractVector{N},
hp::Hyperplane{N},
[halfspace]::Bool=false) where {N<:Real}
Return the support vector of a hyperplane.
Input
d
– directionhp
– hyperplanehalfspace
– (optional, default: false)true
if the support vector should be computed for a half-space
Output
The support vector in the given direction, which is only defined in the following two cases:
- The direction has norm zero.
- The direction is the hyperplane's normal direction.
In both cases the result is any point on the hyperplane. Otherwise this function throws an error.
LazySets.binary_search_constraints
— Function.binary_search_constraints(d::AbstractVector{N},
constraints::Vector{LinearConstraint{N}},
n::Int,
k::Int;
[choose_lower]::Bool=false
)::Int where {N<:Real}
Performs a binary search in the constraints.
Input
d
– directionconstraints
– constraintsn
– number of constraintsk
– start indexchoose_lower
– (optional, default:false
) flag for choosing the lower index (see the 'Output' section)
Output
In the default setting, the result is the smallest index k
such that d <= constraints[k]
, or n+1
if no such k
exists. If the choose_lower
flag is set, the result is the largest index k
such that constraints[k] < d
, which is equivalent to being k-1
in the normal setting.
LazySets.nonzero_indices
— Function.nonzero_indices(v::AbstractVector{N})::Vector{Int} where N<:Real
Return the indices in which a vector is non-zero.
Input
v
– vector
Output
A vector of ascending indices i
such that the vector is non-zero in dimension i
.
LazySets.samedir
— Function.samedir(u::AbstractVector{N},
v::AbstractVector{N})::Tuple{Bool, Real} where N<:Real
Check whether two vectors point in the same direction.
Input
u
– first vectorv
– second vector
Output
(true, k)
iff the vectors are identical up to a positive scaling factor k
, and (false, 0)
otherwise.
Examples
julia> LazySets.samedir([1, 2, 3], [2, 4, 6])
(true, 0.5)
julia> LazySets.samedir([1, 2, 3], [3, 2, 1])
(false, 0)
julia> LazySets.samedir([1, 2, 3], [-1, -2, -3])
(false, 0)
Types
LazySets.CachedPair
— Type.CachedPair{N} where N
A mutable pair of an index and a vector.
Fields
idx
– indexvec
– vector
UnitVector{T} <: AbstractVector{T}
A lazy unit vector with arbitrary one-element.
Fields
i
– index of non-zero entryn
– vector lengthv
– non-zero entry