Similar as in the previous algorithm the complexity is given after each operation and operations involving indices and sign changes are not counted.
[fontsize=\footnotesize,numbers=left,frame=single,commandchars=\\\{\},label=\verbtitle{Levinson solver for higher order semiseparable},codes={\catcode`$=3\catcode`^=7}]
FUNCTION x=LEVSOLVERHSS(U,V,b)
%--------PART 1: SOLVE THE SYSTEM----------------------------
% Initialisation:n=size,p=semiseparability rank
[n,p]=size(U);
% Initialising alpha and mu
denominator=U(1,:)*V(1,:)'; \flop{2p-1}
alpha(1,:)=-V(1,:)./denominator; \flop{p}
mu(1)=b(1)./denominator; \flop{1}
% Initialising the p x p matrix R'*Y and the 1 x p vector R'*X
ry=V(1,:)'*alpha; \flop{p^2}
rx=V(1,:)'*mu(1); \flop{p}
% The main loop in which we use always the previous solution
for k=2:n
% Initialising help variables which appear twice in the loop
ury=U(k,:)*ry; \flop{p(2p-1)}
ryu=ry*U(k,:)'; \flop{p(2p-1)}
% Calculate alpha and mu
denominator=ury*U(k,:)'+U(k,:)*V(k,:)'; \flop{4p-2}
mu(k)=(b(k)-U(k,:)*rx)/denominator; \flop{2p+1}
alpha(k,:)=(-1)*(V(k,:)+ury)/denominator; \flop{2p}
% Update the products R'*Y and R'*X
rx=rx+mu(k)*(ryu+V(k,:)'); \flop{3p}
ry=ry+(ryu+V(k,:)')*alpha(k,:); \flop{2p^2+p}
end
%--------PART 2: CALCULATE THE SOLUTION -----------------------
% Initialisation of x and auxiliary variable G
x(n)=mu(n);
G=mu(n)*U(n,:)'; \flop{p}
% Constructing the solution vector x
for i=n-1:-1:1
x(i)=mu(i)+alpha(i,:)*G; \flop{2p}
G=x(i)*U(i,:)'+G; \flop{2p}
end
end
The overall operation count leads to