function l = t_cholesky_lower ( n, t )

%*****************************************************************************80
%
%% T_CHOLESKY_LOWER: lower Cholesky factor of a compressed Toeplitz matrix.
%
%  Discussion:
%
%    The first row of the Toeplitz matrix A is supplied in T.
%
%    The Toeplitz matrix must be positive semi-definite.
%
%    After factorization, A = L * L'.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    27 January 2017
%
%  Author:
%
%    Michael Stewart
%
%  Reference:
%
%    Michael Stewart,
%    Cholesky factorization of semi-definite Toeplitz matrices.
%    Linear Algebra and its Applications,
%    Volume 254, pages 497-525, 1997.
%
%  Parameters:
%
%    Input, integer N, the order of the matrix.
%
%    Input, real T(N), the first row of the Toeplitz matrix.
%
%    Output, real L(N,N), the lower Cholesky factor.
%
  t = t(:);
  g = zeros ( 2, n );
  g(1,1:n) = t(1:n)';
  g(2,2:n) = t(2:n)';

  l = zeros ( n, n );
  l(1:n,1) = g(1,1:n)';
  g(1,2:n) = g(1,1:n-1);
  g(1,1) = 0.0;
  for i = 2 : n
    rho = - g(2,i) / g(1,i);
    g(:,i:n) = ( [ 1.0 rho; rho 1.0 ] * g(:,i:n) ) ...
      / sqrt ( ( 1.0 - rho ) * ( 1.0 + rho ) );
    l(i:n,i) = g(1,i:n)';
    g(1,i+1:n) = g(1,i:n-1);
    g(1,i) = 0.0;
  end

  return
end

