[fontsize=\footnotesize,numbers=left,frame=single,commandchars=\\\{\},label=\verbtitle{Yule-Walker solver},
codes={\catcode`$=3\catcode`^=7}]
FUNCTION Y=YWSOLVERBANDHSS(U,V,A)
%--------PART 1: SOLVE THE SYSTEM----------------------------
% Initialisation:n=size,2l+1=bandwidth,p=semiseparability rank
[n,l]=size(A);l=l-1;
[n,p]=size(U);
% Initialisation of alpha and Q'Y
alpha(1,[1:p,p+l])=[-V(1,:),-1]./(U(1,:)*V(1,:)'+A(1,l+1));\flop{3p+1}
qy=[V(1,:),zeros(1,l-1),1]'*alpha(1,:); \flop{p(p+1)}
% The main loop in which we use always the previous solution
for k=2:n
% Initialisation of help variable c, product c*qy
c=[U(k,:),A(k,1:l)];cqy=c*qy; \flop{(p+l)(2(p+l)-1)}
% Calculate alpha
denominator=cqy*c'+U(k,:)*V(k,:)'+A(k,l+1); \flop{(2(p+l)-1)+2p}
alpha(k,:)=[-V(k,:)-cqy(1:p),-cqy(p+2:l+p),-1]/denominator; \flop{l+2p}
% Calculation of the new Product Q'*Y
qyc=qy([1:p,p+2:l+p],:)*c'; \flop{(p+l-1)(2(p+l)-1)}
qyc(1:p)=qyc(1:p)+V(k,:)'; \flop{p}
qy=[qy([1:p,p+2:l+p],[1:p,p+2:l+p])+qyc*alpha(k,1:l+p-1),qyc*alpha(k,l+p)];
\flop{2(p+l-1)^2+p+l-1}
qy=[qy;alpha(k,:)];
end
%--------PART 2: CALCULATE THE SOLUTION -----------------------
% Initialisation of Y and F
Y(n,:)=alpha(n,:);
F=eye(l+p);
% Construction of Y
for i=n-1:-1:1
F(1:p,:)=F(1:p,:)+U(i+1,:)'*Y(i+1,:); \flop{2p(l+p)}
F(p+2:l+p,:)=F(p+1:l+p-1,:)+A(i+1,2:l)'*Y(i+1,:); \flop{2(l-1)(l+p)}
F(p+1,:)=A(i+1,1)*Y(i+1,:); \flop{l+p}
Y(i,:)=alpha(i,:)*F; \flop{(2(l+p)-1)(l+p)}
end
Combining the operations, leads to a total of