1function G=NSF_GHT(A,N,varargin)
2%NSF_GHT Gail, Hantler, Taylor algorithm
for Non-Skip-Free Type Markov Chains
4% G=NSF_GHT(A,N) computes the minimal nonnegative solution to the
5% matrix equation G = C0 + C1 G + C2 G^2 + C3 G^3 + ... + C_max G^max,
6% of the reblocked Non-Skip-Free Markov chain.
7% A = [A0 A1 A2 A3 ... A_max] has m rows and m*(max+1) columns and
is
8% a nonnegative matrix, with (A0+A1+A2+...+A_max) irreducible and
9% stochastic. The parameter N identifies the number of non-zero blocks
10% below the main diagonal, the matrices Ci are of dimension mN.
14% MaxNumIt: Maximum number of iterations (
default: 10000)
15% Verbose: When set to k, the residual error
is printed every
17% FirstBlockRow: When set to one, only the first block row of G
18%
is returned, which fully characterizes G (default:0)
20OptionNames=[
'MaxNumIt ';
23OptionTypes=[
'numeric';
29for i=1:size(OptionNames,1)
30 options.(deblank(OptionNames(i,:)))=[];
34options.MaxNumIt=10000;
36options.FirstBlockRow=0;
38% Parse Optional Parameters
39options=ParseOptPara(options,OptionNames,OptionTypes,OptionValues,varargin);
42K=size(A,2)/m-1; % degree of A(z)
47while(check > 10^(-14) && numit < options.MaxNumIt)
51 G=A(:,1:m*N)+A(:,m*N+1:m*(N+1))*G;
53 temp=[zeros(m) temp(:,1:(N-1)*m)]+temp(:,(N-1)*m+1:end)*Gold;
54 G=G+A(:,j*m+1:(j+1)*m)*temp;
56 check=norm(G-Gold,inf);
57 if (~mod(numit,options.Verbose))
58 fprintf('Check after %d iterations: %d\n',numit,check);
63if (numit == options.MaxNumIt && check > 10^(-14))
64 warning('Maximum Number of Iterations %d reached',numit);
67if ( ~options.FirstBlockRow )
68 % compute remaining blockrows of G
69 G(m+1:N*m,1:N*m)=zeros(m*(N-1),m*N);
71 G((j-1)*m+1:j*m,:)=[zeros(m) G((j-2)*m+1:(j-1)*m,1:(N-1)*m)]+...
72 G((j-2)*m+1:(j-1)*m,(N-1)*m+1:end)*G(1:m,:);
77 % we compute the residual error of first blockrow
78 if (~options.FirstBlockRow)
79 A=[A zeros(m,(N-1-mod(K,N))*m)];
81 Gcheck=A(:,Nb*N*m+1:end);
83 Gcheck=A(:,j*N*m+1:(j+1)*N*m)+Gcheck*G;
85 res_norm=norm(G(1:m,:)-Gcheck,inf);
86 fprintf('Final Residual Error for G: %d\n',res_norm);