Matlab program for testing Cholesky.m

% Script to test function Cholesky.m for the
% Cholesky Factorization of symmetric positive definite matrix
% Algorithm 2.7 Heath, p.86
% Factorize A such that A = L*L',
% where L is a lower triangular matrix whose
% diagonal entries are not necessarily unity.
% Upper triangular part of the result is meaningless.
% K. Ming Leung, 01/25/03
clear all; format short;
% A=[ 3 -1 -1
% -1 3 -1
% -1 -1 3];
A=[ 1   4   5
       4 20 32
       5 32 64]; % Example from p.17 Fausett

L=Cholesky(A);
display(L);
b=[1;1;1];
xInv=inv(A)*b, % Find the solution for x using MATLAB

U=chol(A); % using MATLAB's Cholesky factorization
display(U'); % Note: U is returned, not L.

y=forwardSubstitution(L,b,3);
x=backSubstitution(L',y,3), % should be the same as xInv