function [QC,RC] = clgs(A)

[m,n] = size(A);

RC = zeros(n,n);
QC = zeros(m,n);

for j=1:n
    
   v = A(:,j);
   
   for i=1:j-1
       RC(i,j) = QC(:,i)'*A(:,j);
       v = v - RC(i,j)*QC(:,i);
   end
   RC(j,j) = norm(v);
   QC(:,j) = v/RC(j,j);
    
end
