%gram.m
function [W]=gram(W)
for i=1:1:size(W,2)
W(:,i)=W(:,i)/sqrt(sum(W(:,i).^2));
end
for i=1:1:size(W,2)-1
s=W(:,i+1);
for j=1:1:i
s=s-(W(:,i+1)'*W(:,j))*W(:,j);
end
s=s/sqrt(sum(s.^2));
W(:,i+1)=s;
end