Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#125 - Fix get_rows for 1D block #126

Merged
merged 2 commits into from
Mar 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/Properties/check_blocks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@ The first time index where the property is violated, and 0 if the property is sa
@inline proj(bi::Int, n::Int) = sparse([1], [bi], ones(1), 1, n)
@inline row(ϕpowerk::AbstractMatrix, bi::UnitRange{Int}) = ϕpowerk[bi, :]
@inline row(ϕpowerk::AbstractMatrix, bi::Int) = ϕpowerk[[bi], :]
@inline block(ϕpowerk_πbi::SparseMatrixCSC, bj::UnitRange{Int}) =
@inline row(ϕpowerk::SparseMatrixExp, bi::UnitRange{Int}) =
get_rows(ϕpowerk, bi)
@inline row(ϕpowerk::SparseMatrixExp, bi::Int) = get_row(ϕpowerk, bi)
@inline block(ϕpowerk_πbi::AbstractMatrix, bj::UnitRange{Int}) =
ϕpowerk_πbi[:, bj]
@inline block(ϕpowerk_πbi::SparseMatrixCSC, bj::Int) = ϕpowerk_πbi[:, [bj]]
@inline block(ϕpowerk_πbi::AbstractMatrix, bj::Int) = ϕpowerk_πbi[:, [bj]]

# sparse
function check_blocks!(ϕ::SparseMatrixCSC{NUM, Int},
Expand Down Expand Up @@ -208,7 +211,7 @@ function check_blocks!(ϕ::SparseMatrixExp{NUM},
for i in 1:b
bi = partition[blocks[i]]
arr = Vector{LazySet{NUM}}(arr_length)
ϕpowerk_πbi = get_rows(ϕpowerk, bi)
ϕpowerk_πbi = row(ϕpowerk, bi)
for (j, bj) in enumerate(partition)
arr[j] = block(ϕpowerk_πbi, bj) * Xhat0[j]
end
Expand All @@ -227,7 +230,7 @@ function check_blocks!(ϕ::SparseMatrixExp{NUM},
if U != nothing
for i in 1:b
bi = partition[blocks[i]]
ϕpowerk_πbi = get_rows(ϕpowerk, bi)
ϕpowerk_πbi = row(ϕpowerk, bi)
Whatk[i] =
overapproximate(blocks[i], Whatk[i] + ϕpowerk_πbi * inputs)
end
Expand Down
9 changes: 6 additions & 3 deletions src/ReachSets/reach_blocks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,12 @@ nondeterministic inputs.
@inline proj(bi::Int, n::Int) = sparse([1], [bi], ones(1), 1, n)
@inline row(ϕpowerk::AbstractMatrix, bi::UnitRange{Int}) = ϕpowerk[bi, :]
@inline row(ϕpowerk::AbstractMatrix, bi::Int) = ϕpowerk[[bi], :]
@inline block(ϕpowerk_πbi::SparseMatrixCSC, bj::UnitRange{Int}) =
@inline row(ϕpowerk::SparseMatrixExp, bi::UnitRange{Int}) =
get_rows(ϕpowerk, bi)
@inline row(ϕpowerk::SparseMatrixExp, bi::Int) = get_row(ϕpowerk, bi)
@inline block(ϕpowerk_πbi::AbstractMatrix, bj::UnitRange{Int}) =
ϕpowerk_πbi[:, bj]
@inline block(ϕpowerk_πbi::SparseMatrixCSC, bj::Int) = ϕpowerk_πbi[:, [bj]]
@inline block(ϕpowerk_πbi::AbstractMatrix, bj::Int) = ϕpowerk_πbi[:, [bj]]

# sparse
function reach_blocks!(ϕ::SparseMatrixCSC{NUM, Int},
Expand Down Expand Up @@ -206,7 +209,7 @@ function reach_blocks!(ϕ::SparseMatrixExp{NUM},
update!(p, k)
for i in 1:b
bi = partition[blocks[i]]
ϕpowerk_πbi = get_rows(ϕpowerk, bi)
ϕpowerk_πbi = row(ϕpowerk, bi)
Xhatk_bi = ZeroSet(length(bi))
for (j, bj) in enumerate(partition)
πbi = block(ϕpowerk_πbi, bj)
Expand Down