1function [G,R,U]=QBD_EG(A0,A1,A2,optVerbose,nargout_caller)
2%QBD_EG determines G directly
if rank(A0)=1 or rank(A2)=1
10drift=theta*sum(A0,2)-theta*sum(A2,2);
11if (drift > 0) % pos recurrent
case
12 if (rank(A0)==1) % A0 = alpha * beta ?
13 temp=min(find(sum(A0,2)>0)); % find index of first nonzero row
14 beta=A0(temp,:)/sum(A0(temp,:));
16 if (nargout_caller > 1)
17 R=A2*(eye(m)-(A1+A2*G))^(-1);
19 elseif (rank(A2)==1) % A2 = alpha * beta ?
20 eta=QBD_Caudal(A0,A1,A2);
21 R=A2*(eye(m)-A1-eta*A0)^(-1);
22 G=(eye(m)-(A1+R*A0))^(-1)*A0;
24elseif (drift < 0) % transient
case
25 if (rank(A2)==1) % A2 = alpha * beta ?
27 R=alpha*theta/(theta*alpha);
28 G=(eye(m)-(A1+R*A0))^(-1)*A0;
29 elseif (rank(A0)==1) % A0 = alpha * beta ?
30 A0hat=diag(theta.^(-1))*A2
'*diag(theta);
31 A1hat=diag(theta.^(-1))*A1'*diag(theta);
32 A2hat=diag(theta.^(-1))*A0
'*diag(theta);
33 etahat=QBD_Caudal(A0hat,A1hat,A2hat);
34 G=diag(theta.^(-1))*(A2hat*(eye(m)-A1hat-etahat*A0hat)^(-1))'*...
36 if (nargout_caller > 1)
37 R=A2*(eye(m)-(A1+A2*G))^(-1);
42if (~isempty(R) & nargout_caller > 2)
48 res_norm=norm(G-A0-(A1+A2*G)*G,inf);
49 fprintf(
'Final Residual Error for G: %d\n',res_norm);
51 if (~isempty(R) & nargout_caller > 1)
52 res_norm=norm(R-A2-R*(A1+R*A0),inf);
53 fprintf(
'Final Residual Error for R: %d\n',res_norm);
56 res_norm=norm(U-A1-A2*(eye(m)-U)^(-1)*A0,inf);
57 fprintf(
'Final Residual Error for U: %d\n',res_norm);