
function P1()
% Generate a random nxn tridiagonal hermitian positive definite matrix A
% and represent it with three real vectors
n = 5;
A = randn(n,n) + sqrt(-1)*randn(n,n);
A = triu(tril(A),-1);
A = A'*A;
a = diag(A);           % The diagonal of A
g = real(diag(A,-1));  % The real part of A's subdiagonal
h = imag(diag(A,-1));  % The imaginary part of A's subdiagonal

%[d,c,e] = HermFactor(a,g,h);


  function [d,c,e] = HermFactor(a,g,h)
% a is a real column n-vector.
% g and h are real column (n-1)-vectors.
% Let A be the n-by-n Hermitian tridiagonal matrix with diagonal a and subdiagonal 
% c + i*e,  where i^2 = -1. Assume that A is positive definite so that it has
% the factorization A = L*D*L' where D is diagonal and L is unit lower bidiagonal.
   % 
   % d is a real column n-vector so D = diag(d).
   % c and e are real column (n-1)-vectors so that the subdiagonal
   % of L is  c + i*e.