function basis=B_orthog(base)
global bbar bl
[i,j]=size(base);
basis=zeros(i,j);
basis(:,1)=base(:,1);
s=0;
for i=2:j
    d=basis(:,i-1);
    Bd=bbar*(bbar'*d)+bl^2*d;
    s=s+((base(:,i)'*Bd)/(d'*Bd))*d;
    basis(:,i)=base(:,i)-s;
end
for i=1:j
    d=basis(:,i);
    Bd=d'*(bbar*(bbar'*d)+bl^2*d);
    basis(:,i)=d/sqrt(Bd);
end
    
    
    