% classical Gram-Schmidt
function [u]=cgs(v)
   n = length(v);
   u = zeros(n,n)   
   u(:,1) = v(:,1)
   for k=2:n
       u(:,k)=v(:,k);
       for j=1:k-1  
           ujuj=u(:,j)'*u(:,j)
           u(:,k)=u(:,k)-((u(:,j)'*v(:,k))/ujuj)*u(:,j);
       end
   end 
   % normilization
   for k=1:n
       u(:,k)=u(:,k)/sqrt(u(:,k)'*u(:,k));
   end
   
   
end