function p2test

% Check correctness of L and U factors
% (ensure no pivoting by diagonal dominance)

n = 100;
u = rand(n,1)/(n+1);
v = rand(n,1)/(n+1);
A = eye(n) + u*v';
[L1,U1] = lu(A);
[L2,U2] = p2lu(u,v);

fprintf('Residual for L: %g\n', norm(L2-L1,inf)/norm(L1,inf));
fprintf('Residual for U: %g\n', norm(U2-U1,inf)/norm(U1,inf));