function [A, R] = myqrfact(A)
% MYQRFACT - reduced QR factorization of a matrix using
% Gramm-Schimdt process
    [~, n] = size(A);
    R = zeros(n, n);
    for k = 1:n
        R(k, k) = norm(A(:, k));
        A(:, k) = A(:, k)/R(k,k);
        for j = (k+1):n
            R(k, j) = A(:, k)' * A(:, j);
            A(:, j) = A(:, j) - R(k,j)* A(:, k);
        end
    end
end
