Matrix Conversions

FiniteStateProjection.jl provides functionality for building the right-hand side of the CME as a (sparse) matrix. This provides another way to solve the CME in time:

...

A = convert(SparseMatrixCSC, sys, dims, p, 0)

prob = ODEProblem((du,u,p,t) -> mul!(du, p, u), u0, tt, A)

...

This can also be done for steady-state problems:

...

A = convert(SparseMatrixCSC, sys, dims, p, SteadyState())

prob = SteadyStateProblem((du,u,p,t) -> mul!(vec(du), p, vec(u)), u0, A)

...

Note that the matrix A has to be rebuilt for every truncation size and every set of parameters, a restriction not shared by the ODEFunction API.

Base.convertMethod
Base.convert(::Type{SparseMatrixCSC}, sys::FSPSystem, dims::NTuple, ps, t::Real)

Convert the reaction system into a sparse matrix defining the right-hand side of the Chemical Master Equation. dims is a tuple denoting the dimensions of the FSP and ps is the tuple of parameters. The sparse matrix works on the flattened version of the state obtained using vec.

Base.convertMethod
Base.convert(::Type{SparseMatrixCSC}, sys::FSPSystem, dims::NTuple, ps, ::SteadyState)

Convert the reaction system into a sparse matrix defining the right-hand side of the Chemical Master Equation, steady-state version.

Base.vecFunction
vec(idxhandler::AbstractIndexHandler, arr)

Converts the right-hand side defining the solution of the CME into a one-dimensional vector to which a matrix can be applied.

See also: LinearIndices