% P1 
% Tests ProdTriSol

clc
randn('seed',0)

% Example 1.
n = 20;
S = triu(randn(n,n)); T = triu(randn(n,n));
lambda = randn(1); b = randn(n,1);
x0 = (S*T - lambda*eye(n,n))\b;
x = ProdTriSol(S,T,lambda,b);
disp('Example 1.')
TheTwoSolutions = [x0 x]

% Example 2.
n = 100;
S = triu(randn(n,n)); T = triu(randn(n,n));
lambda = randn(1); b = randn(n,1);
x0 = (S*T - lambda*eye(n,n))\b;
x = ProdTriSol(S,T,lambda,b);
fprintf('\nExample 2.\n\nRelErr = %10.3e\n',norm(x - x0)/norm(x0))
