[fontsize=\footnotesize,numbers=left,
frame=single,commandchars=\\\{\},label=\verbtitle{Yule-Walker solver
for band matrices},codes={\catcode`$=3\catcode`^=7}]
FUNCTION Y=YWSOLVERBAND(A)
%--------PART 1: SOLVE THE SYSTEM----------------------------
% Initialisation:n=size,2l+1=bandwidth
[n,l]=size(A);l=l-1;
% Initialising alpha, l x l matrix T'*Y
alpha(1,l)=-1/A(1,l+1);ty(l,l)=alpha(1,l); \flop{1}
% The main loop in which we use always the previous solution
for k=2:n
% Because the inner-product A(k,1:l)* ty appears twice
bty=A(k,1:l)*ty; \flop{2l^2 - l}
% Calculate alpha
denominator=(bty*B(k,1:l)'+A(k,l+1)); \flop{3l -1}
alpha(k,:)=[-bty(:,2:l),-1]/denominator; \flop{l}
% Calculation of the T'*Y for the next loop
tyb=ty(2:l,:)*A(k,1:l)'; \flop{(l-1)(2l-1)}
ty(1:l-1,1:l)=[ty(2:l,2:l)+tyb*alpha(k,1:l-1),tyb*alpha(k,l)];
\flop{2(l-1)^2+l-1}
ty(l,:)=alpha(k,:);
end
%--------PART 2: CALCULATE THE SOLUTION -----------------------
% Initialisation of Y and F
Y(n,:)=alpha(n,:);
F=eye(l);
% Construction of the n x l matrix Y
for i=n-1:-1:1
F=[A(i+1,1)*Y(i+1,:);F(1:l-1,:)+A(i+1,2:l)'* Y(i+1,:)]; \flop{2l(l-1)+l}
Y(i,:)=alpha(i,:)*F; \flop{l(2l-1)}
end
end
The number of operations for the first part in the algorithm is