function [Q,R] = class_grams(A)
[m,n]=size(A);
Q=zeros(m,n); Q=A; R=zeros(n);
for j = 1:n
    for k=1:j-1
        R(k,j) = Q(1:m,k)'*Q(1:m,j);
        Q(1:m,j) = Q(1:m,j) - Q(1:m,k)*R(k,j);
    end
    R(j,j) = norm (Q(1:m,j));
    Q(1:m,j) = Q(1:m,j)/R(j,j);
end
