function [flops] = hw1afn(n, A, B, x)

   flops = 0;

   for i = 1:n
      y(i,1) = 0;
      for j = 1:n
         y(i,1) = y(i,1)+B(i,j)*x(j,1);
         flops = flops+2;
      end
   end

   for i = 1:n
      z(i,1) = 0;
      for j = 1:n
         z(i,1) = z(i,1)+A(i,j)*y(j,1);
         flops = flops+2;
      end
   end

%   for i = 1:n
%      y(i,1) = B(i,1)*x(1,1);
%      flops = flops+1;
%      for j = 2:n
%         y(i,1) = y(i,1)+B(i,j)*x(j,1);
%         flops = flops+2;
%      end
%   end
%
%   for i = 1:n
%      z(i,1) = A(i,1)*y(1,1);
%      flops = flops+1;
%      for j = 2:n
%         z(i,1) = z(i,1)+A(i,j)*y(j,1);
%         flops = flops+2;
%      end
%   end

end
