Skip to content

Commit

Permalink
Merge pull request #126 from JuliaReach/schillic/125
Browse files Browse the repository at this point in the history
#125 - Fix get_rows for 1D block
  • Loading branch information
schillic authored Mar 27, 2018
2 parents 59f8fc2 + 12ab2a7 commit e8420e9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
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

0 comments on commit e8420e9

Please sign in to comment.