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 = 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 = 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.

SparseArrays.SparseMatrixCSC — Method
SparseArrays.SparseMatrixCSC(sys::FSPSystem, dims::NTuple, ps, t::Real)

Converts an FSP system into a sparse matrix defining the time-dependent Chemical Master Equation.

Arguments

  • sys: FSP system to convert.
  • dims: Dimensions of the truncated FSP state array.
  • pmap: Iterable of parameter-value pairs, or SciMLBase.NullParameters().
  • t: Time at which to evaluate a time-dependent rate law.

Returns

  • A sparse matrix acting on the state vector produced by vec.
source
SparseArrays.SparseMatrixCSC — Method
SparseArrays.SparseMatrixCSC(sys::FSPSystem, dims::NTuple, ps, ::SteadyState)

Converts an FSP system into the sparse matrix for its steady-state Chemical Master Equation formulation.

Arguments

  • sys: FSP system to convert.
  • dims: Dimensions of the truncated FSP state array.
  • pmap: Iterable of parameter-value pairs, or SciMLBase.NullParameters().
  • SteadyState(): Dispatch marker selecting the formulation that drops transitions leaving the truncated state space.

Returns

  • A sparse matrix acting on the state vector produced by vec.
source
Base.vec — Function
vec(idxhandler::AbstractIndexHandler, arr)

Converts the CME state array into the vector ordering used by sparse-matrix representations.

Arguments

  • idxhandler: The index handler that defines the vector ordering.
  • arr: State array to flatten.

Returns

Extension Rules

Custom index handlers that support matrix conversions must import and extend this Base function.

See also: LinearIndices

source