function C=Covariance(R)
% COVARIANCE computes the covariance matrix
%   C=Covariance(R) computes the upper triangle of the covariance
%   matrix from the R factor of the QR-decomposition [Q,R]=qr(A)

n=min(size(R)); U=[];                      % U is R^(-1)
for i=1:n,
  u=ui(i,R); U=[U; u];
end;
for i=1:n,                                 % compute C=inv(R)*inv(R')
  for j=i:n,
    C(i,j)=U(i,j:n)*U(j,j:n)';
  end
end
