function A = AnnGenerate(n)
%%  A = diag(4*ones(n^2,1)) -diag(ones(n^2-1,1),1) -diag(ones(n^2-1,1),-1)...
%%                      -diag(ones(n^2-n,1),n) -diag(ones(n^2-n,1),-n);
  A = diag(4*ones(n^2,1));
  for k = 1:(n^2-1)
    A(k,k+1) = -1;  A(k+1,k) = -1;
  end%for
  for k = 1:(n^2-n)
    A(k,k+n) = -1;  A(k+n,k) = -1;
  end%for

  for k = 1:n-1
    A(k*n,k*n+1) = 0;    A(k*n+1,k*n) = 0;
  end%for
  A = (n+1)^2*A;
end%function
