 function [x] = gaussp (A, b)
%  function x = guass(A, b)
%  solves A x  = b by Gaussian elimination with
%  partial pivoting/ 
%-----------------------------------------------
 n = size(A,1) ;
 A = [A,b] ;
 disp(A);
 for k=1:n-1 
   [t, ip] = max(abs(A(k:n,k))); 
   ip = ip+k-1 ;
%%-------------------- swap 
    if (ip ~= k) 
     fprintf(1,'swap rows k=%d & ip=%d\n',k,ip);
     temp = A(k,k:n+1) ;
     A(k,k:n+1) =  A(ip,k:n+1); 
     A(ip,k:n+1) = temp;
     disp(A);
     disp('--------------')

    end
%%-------------------- eliminate
    for i=k+1:n
    piv = A(i,k) / A(k,k) ;
 %% A(i,k+1:n+1)=A(i,k+1:n+1)-piv*A(k,k+1:n+1);
    A(i,k:n+1) = A(i,k:n+1) - piv*A(k,k:n+1);
   end
 disp(A)
 pause 
 end 
 x = backsolv(A,A(:,n+1)); 
