  function x = gaussj (A, b)
%--------------------------------------------
% function x = guass(A, b)
% solves A x  = b by Gauss-Jordan elimination
% this version scales rows. 
%--------------------------------------------
n = size(A,1) ;
A = [A,b] 
for k=1:n
    A(k,k:n+1) = A(k,k:n+1)/A(k,k);
    for i=1:n
        if (i ~= k) 
            piv = A(i,k) ;
            A(i,k:n+1)=A(i,k:n+1)-piv*A(k,k:n+1);
        end 
    end
    A 
    pause
end 
x = A(:,n+1);

