% CHOLT   Computes the cholesky factorization of a tridiagonal matrix
%       
%
%       [d,sd]=cholt(dT,sdT)
%       Computes the cholesky factorization of the positive definite
%       tridiagonal matrix with dT as diagonal and sdT as subdiagonal
%
%       
%       The output are de diagonal and subdiagonal of the matrix L
%       such that LL* is the Cholesky decomposition of the tridiagonal
%       matrix.
%
%       Software of the MaSe - Group
%       mase-at-cs.kuleuven.ac.be
%       Revision Date: 29/09/2006


function [dT,sdT]=CHOLT(dT,sdT)

  % Initialize the length of the variables
  n=length(dT);
  
  % Compute the diagonal elements
 
  if (n==1)
    dT=sqrt(dT);
    sdT=[];
  else
    for j=2:n
      dT(j)=dT(j)-sdT(j-1)*(sdT(j-1)/dT(j-1));
      % 3 Operations * n-1
    end
  
    % Assign and scale the output
    sqdT=sqrt(dT);
    dT=dT./sqdT;
    sdT=sdT./sqdT(1:n-1);
  end
  
  