function Mar11()
% Tridiagonalizing a low rank matrix symmetric matrix C*C'.
% Generate C...
m = 1000; n = 5; C = randn(m,n);
[Q,R] = qr(C);
R1 = R(1:n,1:n);
% Note that Q'*(C*C')Q = [R1*R1' zeros(n,m-n);zeros(m-n,n) zeros(m-n,m-n)]
[U,T] = hess(R1*R1');
% Note that if Utilde = [U zeros(n,m-n) ; zeros(m-n,n) eye(m-n,m-n)
% then Utilde is orthogonal and 
% Utilde'(Q'*C*C'*Q)*Utilde = [T zeros(n,m-n) ; zeros(m-n,n) zeros(m-n,m-n)]
Q(:,1:n) = Q(:,1:n)*U;
T = [T zeros(n,m-n);zeros(m-n,n) zeros(m-n,m-n)];
% Check:
clc
errQ = norm(Q'*Q - eye(m,m))
errT = norm(Q'*(C*C')*Q - T)
errTridiag = norm(T - tril(triu(T,-1),1))
