function hw01_p2

%%% Set random number generator, and various problem parameters.
rng(0)
m     = 20; % Size of the matrix.
ell   = 5;  % Block size in block power iteration.
nstep = 12; % Number of steps of power iteration.

%%% Generate a test matrix.
dd = 2.^(-linspace(0,m-1,m))';  % The vector of eigenvalues.
V  = randn(m) + eye(m);
A  = V*diag(dd)*inv(V);

%%% Execute the power iteration
Y     = randn(m,ell);
ERR   = NaN*ones(20,ell);
for i = 1:nstep
  Y        = A*Y;
  [Q,~]    = qr(Y,0);
  ee       = eig(Q'*A*Q);
  ERR(i,:) = min(abs(dd*ones(1,ell) - ones(m,1)*ee'));
end

semilogy(ERR,'LineWidth',2)

    keyboard
return


