% Forward elimination part of the Scaled Partial Pivoting Gaussian
% elimination (only update of 'A', i.e. the LU factorization)

function [A]  = NaiveGauss(A)

% Given as input: 
%   a square coefficient matrix 'A'
% we will have as output:
%   the 'A=LU' factorization and the pivoting index vector 'l'

[m,n] = size(A);
if abs(m-n)>0
   error('The Matrix A is not square');
end

% start with index vector 'l' being l=[1,2,...,n]
% and generate a scale vector 's'
for i=1:n
    l(i) = i;
end    

for k=1:n-1
    rmax=0;

for i=k+1:n
        xmult=A(l(i),k)/A(l(k),k);
        A(l(i),k) = xmult;
        for j = k+1:n
            A(l(i),j) = A(l(i),j) - xmult*A(l(k),j);
        end
    end  
end 
