LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
ctmc_stochcomp.m
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
4% All rights reserved.
5if nargin==1
6 I=1:ceil(length(Q)/2);
7end
8isSelected = false(1, length(Q));
9for idx = 1:length(I)
10 isSelected(I(idx)) = true;
11end
12Ic = zeros(1, length(Q) - length(I));
13icPos = 0;
14for idx = 1:length(Q)
15 if ~isSelected(idx)
16 icPos = icPos + 1;
17 Ic(icPos) = idx;
18 end
19end
20Q11 = Q(I,I);
21Q12 = Q(I,Ic);
22Q21 = Q(Ic,I);
23Q22 = Q(Ic,Ic);
24%I = eye(size(Q22));
25% Iterative path. The backslash below factorizes the whole complement block, so
26% its fill-in is what limits the model above the dispatch threshold rather than
27% the arithmetic. One ILUT factorization serves every column of Q21. The direct
28% solve stays the default and remains the fallback when a column fails.
29GMRES_MIN_STATES = 6000;
30T = [];
31if size(Q22,1) > GMRES_MIN_STATES
32 [T,gflag] = ctmc_gmres_multi(-Q22, Q21);
33 if gflag ~= 0
34 T = [];
35 end
36end
37if isempty(T)
38 T = (-Q22) \ Q21;
39end
40T = Q12*T;
41S = Q11+T;
42end
Definition Station.m:245