Skip to content

Resolves Issue #213 #215

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
16 changes: 8 additions & 8 deletions src/jointoperators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
jointoperator_bc(operators, Q::Array)

Returns a discretized operator that solves systems of differential equations defined by
`operators` with transitions by `Q` where `operators` is an N-length collection of
`operators` with transitions by `Q` where `operators` is an N-length collection of
discretized operators with boundary conditions applied and `Q` is N by N intensity matrix.

# Examples
Expand Down Expand Up @@ -47,23 +47,23 @@ function jointoperator_bc(operators, Q::Array)
N = length(operators)

# check if all operators are square
@assert all(operator->(size(operator,1) == size(operator,2)),
@assert all(operator->(size(operator,1) == size(operator,2)),
operators)

# check if all operators have same size
@assert all(operator->(size(operator) == size(operators[1])),
@assert all(operator->(size(operator) == size(operators[1])),
operators)

# check if the size of transition matrix is
# same as the number of operators
# check if the size of transition matrix is
# same as the number of operators
@assert size(Q,1) == size(Q,2) == N

# extract operators and append them to form a diagonal block tridiagonal
# extract operators and append them to form a diagonal block tridiagonal
Ls = blockdiag(sparse.(operators)...)
Ls = BandedBlockBandedMatrix(Ls, (M*ones(Int64, N), M*ones(Int64, N)), (0,0), (1,1))
Ls = BandedBlockBandedMatrix(Ls, M*ones(Int64, N), M*ones(Int64, N), (0,0), (1,1))

# construct a kronecker product of Q times I_M
Qs = BandedBlockBandedMatrix(Kron(Q, Eye(M)))
Qs = BandedBlockBandedMatrix(Kron(Q, Eye(M)), M*ones(Int64, N), M*ones(Int64, N), (1,1), (0,0))

return (Ls + Qs)
end