
function [P,L,U]=LU_2018(A)

n=size(A,1); L=eye(n); P=eye(n);

for k=1:n-1
    [M,i]=max(abs(A(k:n,k))); % Pivoting
    i=k+i-1; 
    A([k i],:)=A([i k],:);
    P1=eye(n); P1([i k],:)=P1([k i],:); P=P1*P;
    for r=k+1:n % Eliminazione.
       m_rk=A(r,k)/A(k,k); L(r,k)=m_rk;
       A(r,:)=A(r,:)-L(r,k)*A(k,:);
    end
end

U=A;
