The algorithm

In this section a Matlab implementation of the algorithm for solving the Yule-Walker-like problem for band matrices is given. The input of the algorithm is the matrix $ A$, which contains in fact the representation of the band matrix $ B$. The output Y is the solution matrix of the Yule-Walker-like equation. The number of flops corresponding to a particular equation are given at the end of every line.


[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 $ 6nl^2-2nl-6l^2+2l+1$, the number of operations needed to calculate the solution is $ 4nl^2-3nl-4l^2+3l$. The overall complexity is $ O(l^2n)$, more precisely $ 10nl^2-5nl-10l^2+5l+1$ flops are needed to compute the solution of the Yule-Walker-like equation for band matrices.



Raf Vandebril 2005-04-26