[fontsize=\footnotesize,numbers=left,frame=single,commandchars=\\\{\},label=\verbtitle{Levinson solver},
codes={\catcode`$=3\catcode`^=7}]
FUNCTION x=LEVSOLVERBANDHSS(U,V,A,b)
%--------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 mu
alpha(1,[1:p,p+l])=[-V(1,:),-1]./(U(1,:)*V(1,:)'+A(1,l+1)); \flop{3p+1}
mu(1)=b(1)/(A(1,l+1)+U(1,:)*V(1,:)');
% initialisation of the product Q'*Y and Q'*x
qy=[V(1,:),zeros(1,l-1),1]'*alpha(1,:); \flop{p(p+1)}
qx=[V(1,:),zeros(1,l-1),1]'*mu(1); \flop{p+1}
% the main loop in which we use always the previous solution
for k=2:n
% Initialisation of help variable c and two products
c=[U(k,:),A(k,1:l)];cqy=c*qy; \flop{(p+l)(2(p+l)-1)}
qyc=qy([1:p,p+2:l+p],:)*c'; \flop{(2(p+l)-1)(p+l-1)}
qyc(1:p)=qyc(1:p)+V(k,:)'; \flop{p}
% Calculate alpha and mu
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}
mu(k)=(b(k)-c*qx)/denominator; \flop{2(p+l)+1}
% Calculation of the new Product Q'*x and Q'*y
qx=[qx([1:p,p+2:l+p])+qyc*mu(k);mu(k)]; \flop{2(l+p-1)}
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 x
x(n)=mu(n);
% Constructing x
for i=n-1:-1:1
M(1:p,1)=M(1:p)+U(i+1,:)'*x(i+1); \flop{2p}
M(p+2:l+p,1)=M(p+1:l+p-1)+A(i+1,2:l)'*x(i+1); \flop{2(l-1)}
M(p+1,1)=A(i+1,1)*x(i+1); \flop{1}
x(i)=mu(i)+alpha(i,:)*M; \flop{2(l+p)}
end
The first part of the method performs