disp(' ');
disp(' Cholesky.m   ver 1.1  February 7, 2011 ');
disp(' ');
disp('  Cholesky Decomposition:  A=LLT   ');
disp(' ');
disp('  The input matrix must be symmetric and positive definite. ');
disp(' ');
%
clear A;
clear L;
clear sum;
%
A = input('  Enter the matrix name ');
%
n=rank(A);
%
L=zeros(n,n);
D=zeros(n,n);
L(1,1)=sqrt(A(1,1));
%
for i=1:n
    for k=i:n
        if(i==k)
            sum=0.;
            for j=1:i-1
                sum=sum+L(i,j)^2;
            end
            L(i,i)=sqrt( A(i,i)-sum);   
        else
            sum=0.;
            for j=1:i-1
                sum=sum+L(i,j)*L(k,j);
            end
            L(k,i)=( A(i,k)-sum)/L(i,i);          
        end
    end
end
L