LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
MG1_EG.m
1function G=MG1_EG(A,optVerbose)
2%MG1_EG determines G directly if rank(A0)=1
3
4G=[];
5
6m=size(A,1);
7dega=size(A,2)/m-1;
8
9sumA=A(:,dega*m+1:end);
10beta=sum(sumA,2);
11% beta = (A_maxd)e + (A_maxd + A_maxd-1)e + ... + (Amaxd+...+A1)e
12for i=dega-1:-1:1
13 sumA=sumA+A(:,i*m+1:(i+1)*m);
14 beta=beta+sum(sumA,2);
15end
16sumA=sumA+A(:,1:m);
17theta=stat(sumA);
18drift=theta*beta;
19
20if (drift < 1) % pos recurrent case
21 if (rank(A(:,1:m))==1) % A0 = alpha * beta ?
22 temp=find(sum(A(:,1:m),2)>0,1,'first'); % index of first nonzero row
23 beta=A(temp,1:m)/sum(A(temp,1:m));
24 G=ones(m,1)*beta;
25 end
26elseif (drift > 1) % transient case
27 if (rank(A(:,1:m))==1) % A0 = alpha * beta ?
28 if (optVerbose==1)
29 Aold=A;
30 end
31 for i=0:dega
32 A(:,i*m+1:(i+1)*m)=diag(theta.^(-1))*A(:,i*m+1:(i+1)*m)'*diag(theta);
33 end
34 etahat=GIM1_Caudal(A);
35 temp=A(:,dega*m+1:end);
36 for i=dega-1:-1:1
37 temp=temp*etahat+A(:,i*m+1:(i+1)*m);
38 end
39 G=diag(theta.^(-1))*(A(:,1:m)*(eye(m)-temp)^(-1))'*...
40 diag(theta);
41 if (optVerbose==1)
42 A=Aold;
43 end
44 end
45end
46
47if (optVerbose==1)
48 if (~isempty(G))
49 Gcheck=A(:,dega*m+1:end);
50 for j=dega-1:-1:0
51 Gcheck=A(:,j*m+1:(j+1)*m)+Gcheck*G;
52 end
53 res_norm=norm(G-Gcheck,inf);
54 fprintf('Final Residual Error for G: %d\n',res_norm);
55 end
56end
57