LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
MG1_Shifts.m
1function [hatA,drift,tau,v]=MG1_Shifts(A,ShiftType)
2% this function performs the shift operation for the MG1 case
3% input: A = [A0 A1 A2 ... A_maxd]
4% includes: one, tau and dbl
5
6m=size(A,1);
7v=zeros(m,1); % default value if redundant
8tau=1; % default value if redundant
9maxd=size(A,2)/m-1;
10sumA=A(:,maxd*m+1:end);
11beta=sum(sumA,2);
12% beta = (A_maxd)e + (A_maxd + A_maxd-1)e + ... + (Amaxd+...+A1)e
13for i=maxd-1:-1:1
14 sumA=sumA+A(:,i*m+1:(i+1)*m);
15 beta=beta+sum(sumA,2);
16end
17sumA=sumA+A(:,1:m);
18theta=stat(sumA);
19drift=theta*beta;
20
21% if drift < 1 : positive recurrent
22hatA=zeros(m,m*(maxd+1));
23if (drift < 1)
24 if (strcmp(ShiftType,'tau')|strcmp(ShiftType,'dbl')) % shift tau to infinity
25 [tau,uT]=MG1_Decay(A);
26 A(:,m+1:2*m)=A(:,m+1:2*m)-eye(m);
27 uT=uT/sum(uT);
28 rowhatA=zeros(1,m*(maxd+1));
29 rowhatA(1,maxd*i:end)=uT*A(:,maxd*i:end);
30 for i=maxd-1:-1:0
31 rowhatA(1,i*m+1:(i+1)*m)=tau*rowhatA(1,(i+1)*m+1:(i+2)*m)+...
32 uT*A(:,i*m+1:(i+1)*m);
33 end
34 hatA=A-ones(m,1)*rowhatA;
35 end
36 if (strcmp(ShiftType,'dbl')) % shift one to zero
37 A=hatA;
38 % e is also the right eigenvector of hatA(1)
39 % as the shift-tau does not influence G and Ge=e,
40 % implying that hatA(1)e = e as G=hatA(G)
41 end
42 if (strcmp(ShiftType,'one')) % shift one to zero
43 A(:,m+1:2*m)=A(:,m+1:2*m)-eye(m);
44 end
45 if (strcmp(ShiftType,'one')|strcmp(ShiftType,'dbl')) % shift one ot zero
46 colhatA=zeros(m,maxd+1);
47 colhatA(:,1)=sum(A(:,1:m),2); % colhatA(:,1) = (A0)e
48 for i=1:maxd
49 colhatA(:,i+1)=colhatA(:,i)+sum(A(:,i*m+1:(i+1)*m),2);
50 % colhatA(:,i+1) = (A0+A1+...+Ai)e
51 end
52 hatA=A-kron(colhatA,ones(1,m)/m); % hatAi = Ai - (A0+A1+...+Ai)e*uT
53 end
54else
55 if (strcmp(ShiftType,'one')|strcmp(ShiftType,'dbl')) % shift one to infinity
56 A(:,m+1:2*m)=A(:,m+1:2*m)-eye(m);
57 rowhatA=zeros(1,m*(maxd+1));
58 rowhatA(1,maxd*i:end)=theta*A(:,maxd*i:end);
59 for i=maxd-1:-1:0
60 rowhatA(1,i*m+1:(i+1)*m)=rowhatA(1,(i+1)*m+1:(i+2)*m)+...
61 theta*A(:,i*m+1:(i+1)*m); % rowhatAi = theta(Amaxd+...+Ai)
62 end
63 hatA=A-ones(m,1)*rowhatA;
64 end
65 if (strcmp(ShiftType,'dbl')) % shift one to infinity
66 A=hatA;
67 A(:,m+1:2*m)=A(:,m+1:2*m)+eye(m);
68 % v is also the right eigenvector of hatA(tau)
69 % as the shift-one does not influence G and Gv=tau*v,
70 % implying that hatA(tau)v = tau*v as G=hatA(G)
71 end
72 if (strcmp(ShiftType,'tau')|strcmp(ShiftType,'dbl')) % shift tau to zero
73 [tau,v]=GIM1_Caudal(A);
74 A(:,m+1:2*m)=A(:,m+1:2*m)-eye(m);
75 v=v/sum(v);
76 colhatA=zeros(m,maxd+1);
77 colhatA(:,1)=A(:,1:m)*v; % colhatA(:,1) = (A0)v
78 for i=1:maxd
79 colhatA(:,i+1)=colhatA(:,i)*tau^(-1)+A(:,i*m+1:(i+1)*m)*v;
80 end
81 hatA=A-kron(colhatA,ones(1,m));
82 end
83end
84hatA(:,m+1:2*m)=hatA(:,m+1:2*m)+eye(m);
85