Skip to content

Commit

Permalink
Merge pull request #216 from JuliaReach/sguadalupe/split
Browse files Browse the repository at this point in the history
Add split function for zonotopes
  • Loading branch information
mforets authored Jun 9, 2020
2 parents 0ee749c + 9682528 commit bbd5789
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/Flowpipes/setops.jl
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,24 @@ function _split(Z::Zonotope{N, SVector{n, N}, <:SMatrix{n, p, N}}, j::Int) where
return Z₁, Z₂
end

function split(Z::Zonotope, gens::AbstractVector, n::AbstractVector)
@assert length(gens) == length(n) "the number of generators doesn't match the" *
" number of indicated partitions ($(length(gens)) and $(length(n)))"
@assert length(gens) <= ngens(Z) "the number of generators to split is greater" *
" than the number of generators of the zonotope (($(length(gens)) and $(ngens(Z)))"
Zs = [Z]
for i = 1:length(gens)
for j = 1:n[i]
km = length(Zs)
for k = 1:km
append!(Zs, _split(Zs[k], gens[i]))
end
deleteat!(Zs, 1:km)
end
end
return Zs
end

# TODO in-place split for static arrays

# ==================================
Expand Down

0 comments on commit bbd5789

Please sign in to comment.