1function [S,Q11,Q12,Q21,Q22,T]=ctmc_stochcomp(Q,I)
2% [S,Q11,Q12,Q21,Q22,T] = CTMC_STOCHCOMP(Q,I)
3% Copyright (c) 2012-2026, Imperial College London
8isSelected =
false(1, length(Q));
10 isSelected(I(idx)) =
true;
12Ic = zeros(1, length(Q) - length(I));
24% see _kb/03-api-layer.md (mc/ additions)
for the ILUT/fill-in rationale
25GMRES_MIN_STATES = 6000;
27if size(Q22,1) > GMRES_MIN_STATES
28 [T,gflag] = ctmc_gmres_multi(-Q22, Q21);
35 if ~all(isfinite(T(:)))
36 % Backslash returns NaN on a rank-deficient complement, which then
37 % contaminates every downstream metric. Fall back to the minimum-norm
38 % least-squares solution, as the Java and Python kernels do.
39 T = lsqminnorm(full(-Q22), full(Q21));