% CS 4220 (Spring 2010) Assignment 2
% Test Script P3. Checks out HessLU and HessSolve.

clc
randn('seed',0)

disp('Small example to check HessLU...')
format short
n = 5; A = triu(randn(n,n),-1); b = randn(n,1);
[alpha,piv,U] = HessLU(A)
fprintf('\n\n\n')

disp('Larger example to check HessSolve...')
disp(' ')
n = 20; A = triu(randn(n,n),-1); b = randn(n,1);
% Solve Ax = b via \ ...
x0 = A\b;
% Solve via HessLU and HessSolve...
[alpha,piv,U] = HessLU(A);
x = HessSolve(alpha,piv,U,b);
% Display results
disp('     Backslash Solve               HessLU Solve ')
disp('---------------------------------------------------')
for k=1:n
  fprintf('%23.16f   %23.16f\n',x0(k),x(k))
end