  function Feb11()
% Implementation of the Cholesky factorization...
clc
n = 6;
A = randn(n,n); A = A'*A;
G = MyChol(A)
fprintf('|| A - GG'' || = %10.3e\n',norm(A - G*G'))


  function G = MyChol(A)
% Cholesky factorization of a symmetric positive definite matrix
% A is nxn symmetric and positive definite.
% G is nxn lower triangular and A = GG'.
n = length(A);
v = zeros(n,1);
for j=1:n
    % This....
    v(j:n) = A(j:n,j);
    for k=1:j-1
        v(j:n) = v(j:n) - A(j:n,k)*A(j,k);
    end
    % Can be replaced by this
    % v(j:n) = A(j:n,j) - A(j:n,1:j-1)*A(j,1:j-1)';
    A(j:n,j) = v(j:n)/sqrt(v(j)); 
end
G = tril(A);