function [x,se] = hatv(A,x0,N)
n=max(size(x0));
if x0 == zeros(n,1),  
      x0(1)=1; 
end;
x=x0/norm(x0);
for j=1:N, xs=A*x;
   if A == A',             
      se=(x'*xs)/(x'*x);
   else 
      [m,k]=max(abs(x));
      se=xs(k)/x(k);
   end;
   x=xs/norm(xs);
end;
