% Script P2: Checks BlockJac
 
  randn('seed',0)
  k = 7;
  n = 2^k;
  A = randn(n,n); A = A + A';
  clc
  fprintf('n = %1d\n\n',n)
  disp('      tol        m    Sweeps        off         errD         errQ')
  disp('--------------------------------------------------------------------')

  for tol = [.001 .000001 .000000001 .000000000001]
     for m = 2.^(0:k-2)
         [Q,D,sweeps] = BlockJac(A,tol,m);
         errD = norm(Q'*A*Q - D,'fro')/norm(A,'fro');
         errQ = norm(Q'*Q - eye(n,n),'fro');
         off  = norm(D - diag(diag(D)),'fro')/norm(A,'fro');
         fprintf('%10.1e    %4d    %4d     %10.1e   %10.1e   %10.1e  \n',tol,m,sweeps,off,errD,errQ)
     end
  end

 