function [x,flag,k]=GSnew(A,b,toll)
n=length(A);
xold=b;
x=zeros(n,1);
flag=0;
for k=1:1000
 %   x=P\(b+N*xold);  
    for i=1:n
        x(i)=(b(i)-A(i,1:i-1)*x(1:i-1)-A(i,i+1:n)*xold(i+1:n))/A(i,i);
    end
    inc=norm(x-xold);
    if inc<toll
        return
    end
    xold=x;
end
flag=1;