-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
71 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
export RotatedHyperrectangle | ||
|
||
struct RotatedHyperrectangle{N, MN<:AbstractMatrix{N}, | ||
HT<:AbstractHyperrectangle{N}} <: AbstractZonotope{N} | ||
M::MN | ||
box::HT | ||
|
||
function RotatedHyperrectangle(M::MN, box::HT) where {N, | ||
MN<:AbstractMatrix{N}, HT<:AbstractHyperrectangle{N}} | ||
@assert dim(box) == checksquare(M) "a rotated hyperrectangle " * | ||
"of dimension $(dim(box)) requires a square matrix of the same " * | ||
"dimension" | ||
return new{N, MN, HT}(M, box) | ||
end | ||
end | ||
|
||
isoperationtype(::Type{RotatedHyperrectangle}) = false | ||
isconvextype(::Type{RotatedHyperrectangle}) = true | ||
|
||
function dim(R::RotatedHyperrectangle) | ||
return size(R.M, 1) | ||
end | ||
|
||
function ρ(d::AbstractVector, R::RotatedHyperrectangle) | ||
return _ρ_linear_map(d, R) | ||
end | ||
|
||
function σ(d::AbstractVector, R::RotatedHyperrectangle) | ||
return _σ_linear_map(d, R) | ||
end | ||
|
||
function center(R::RotatedHyperrectangle) | ||
return R.M * center(R.box) | ||
end | ||
|
||
function generators(R::RotatedHyperrectangle) | ||
return generators_fallback(R) | ||
end | ||
|
||
function genmat(R::RotatedHyperrectangle) | ||
return R.M * genmat(R.box) | ||
end | ||
|
||
function linear_map(M::AbstractMatrix, R::RotatedHyperrectangle) | ||
@assert size(M, 2) == dim(R) "a linear map of size $(size(M)) is " * | ||
"incompatible with a set of dimension $(dim(R))" | ||
if size(M, 1) != size(M, 2) # TODO generalize | ||
throw(ArgumentError("non-square linear maps for rotated " * | ||
"hyperrectangles are not supported yet")) | ||
end | ||
|
||
return RotatedHyperrectangle(M * R.M, R.box) | ||
end | ||
|
||
function vertices_list(R::RotatedHyperrectangle) | ||
return broadcast(v -> R.M * v, vertices_list(R.box)) | ||
end | ||
|
||
function constraints_list(R::RotatedHyperrectangle) | ||
return constraints_list(convert(VPolytope, R)) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters